-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Prior to v0.10, the degradation function accepted a calibration_version kwarg,
Lines 161 to 166 in a4ad94d
| def degradation( | |
| channel: u.angstrom, | |
| obstime, | |
| *, | |
| correction_table=None, | |
| calibration_version=None, |
Line 137 in a4ad94d
| table = table[table["VER_NUM"] == version] |
However, this has the unintended consequence of allowing the use of tables which contain multiple calibration versions. For some observation times, there is only one calibration version and so this does not have much of an effect. For some dates, there are multiple valid versions which means that multiple calibration versions might be mixed together or a version of the calibration is used unintentionally.
This is especially problematic now as we are by default using the JSOC correction table, which contains multiple versions, but not selecting the latest (or even a single) version. For the SSW case, this isn't a problem because there is only one version of the correction in these files.
MWE
Thanks to @ianan for pointing this out
import astropy.units as u
import astropy.time
import aiapy.calibrate
import aiapy.calibrate.util
channels = [94,131,171,193,211,335] * u.angstrom
time = astropy.time.Time('2010-11-03T12:15:00')
jsoc_table = aiapy.calibrate.util.get_correction_table('jsoc')
ssw_table = aiapy.calibrate.util.get_correction_table('ssw')
for chan in channels:
d_jsoc = aiapy.calibrate.degradation(chan, time, correction_table=jsoc_table)
d_ssw = aiapy.calibrate.degradation(chan, time, correction_table=ssw_table)
print(chan, f'JSOC: {d_jsoc[0]:.06f}, SSW: {d_ssw[0]:.06f}')gives
94.0 Angstrom JSOC: 1.091806, SSW: 1.142789
131.0 Angstrom JSOC: 0.954178, SSW: 0.914013
171.0 Angstrom JSOC: 0.963809, SSW: 0.995510
193.0 Angstrom JSOC: 1.189416, SSW: 0.986529
211.0 Angstrom JSOC: 1.051417, SSW: 0.970365
335.0 Angstrom JSOC: 1.049593, SSW: 0.830944
Adding the line jsoc_table=jsoc_table[jsoc_table['VER_NUM']==10] gives
94.0 Angstrom JSOC: 1.142789, SSW: 1.142789
131.0 Angstrom JSOC: 0.914013, SSW: 0.914013
171.0 Angstrom JSOC: 0.995510, SSW: 0.995510
193.0 Angstrom JSOC: 0.986529, SSW: 0.986529
211.0 Angstrom JSOC: 0.970365, SSW: 0.970365
335.0 Angstrom JSOC: 0.830944, SSW: 0.830944
Proposed Solution
Rather than return to the old API, I would suggest we do two things:
- In cases where the default correction table is used, i.e. it is not supplied by the user, the latest calibration version should be selected. This can go inside this conditional here:
Line 209 in 1c43246
correction_table = get_correction_table() - When selecting the relevant epoch in the correction table for the supplied obstime, check if there are multiple calibration versions present and if there are, throw an exception. This logic should go in this function
aiapy/aiapy/calibrate/utils.py
Line 143 in 1c43246
def _select_epoch_from_correction_table(channel: u.angstrom, obstime, correction_table):