Skip to content

Commit

Permalink
Allow residuals to be calculated for soltabs of same type
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Nov 6, 2024
1 parent 06877e8 commit 0a67206
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions losoto/operations/residuals.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# Residual operation for LoSoTo

# This operation subtract a clock and/or tec from a phase
# This operation subtracts/divides two tables or a clock/tec/tec3rd/rm from a phase
# Operation is flag-only capable

from losoto.lib_operations import *
Expand Down Expand Up @@ -39,9 +39,11 @@ def run( soltab, soltabsToSub, ratio=False ):
for soltabToSub in soltabsToSub:
soltabsub = solset.getSoltab(soltabToSub)

if soltab.getType() != 'phase' and (soltabsub.getType() == 'tec' or soltabsub.getType() == 'clock' or soltabsub.getType() == 'rotationmeasure' or soltabsub.getType() == 'tec3rd'):
logging.warning(soltabToSub+' is of type clock/tec/rm and should be subtracted from a phase. Skipping it.')
return 1
# If the two soltabs have different types, check that they are compatible
if soltab.getType() != soltabsub.getType():
if soltab.getType() != 'phase' and (soltabsub.getType() == 'tec' or soltabsub.getType() == 'clock' or soltabsub.getType() == 'rotationmeasure' or soltabsub.getType() == 'tec3rd'):
logging.warning(soltabToSub+' is of type clock/tec/rm and should be subtracted from a phase. Skipping it.')
return 1
logging.info('Subtracting table: '+soltabToSub)

# a major speed up if tables are assumed with same axes, check that (should be the case in almost any case)
Expand Down Expand Up @@ -89,16 +91,16 @@ def run( soltab, soltabsToSub, ratio=False ):
#print 'vals reshaped', valsSub.shape

# a multiplication will go along the last axis of the array
if soltabsub.getType() == 'clock':
if soltabsub.getType() == 'clock' and soltab.getType() == 'phase':
vals -= 2. * np.pi * valsSub * freq

elif soltabsub.getType() == 'tec':
elif soltabsub.getType() == 'tec' and soltab.getType() == 'phase':
vals -= -8.44797245e9 * valsSub / freq

elif soltabsub.getType() == 'tec3rd':
elif soltabsub.getType() == 'tec3rd' and soltab.getType() == 'phase':
vals -= - 1.e21 * valsSub / np.power(freq,3)

elif soltabsub.getType() == 'rotationmeasure':
elif soltabsub.getType() == 'rotationmeasure' and soltab.getType() == 'phase':
# put pol axis at the beginning
idxPol = soltab.getAxesNames().index('pol')
if idxPol == len(vals.shape)-1: idxPol = idxFreq # maybe freq swapped with pol
Expand Down

0 comments on commit 0a67206

Please sign in to comment.