diff --git a/losoto/operations/residuals.py b/losoto/operations/residuals.py index 6bd363c..ae23e51 100644 --- a/losoto/operations/residuals.py +++ b/losoto/operations/residuals.py @@ -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 * @@ -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) @@ -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