Skip to content

degradation no longer accounts for possibility of multiple calibration versions in correction table. #375

@wtbarnes

Description

@wtbarnes

Prior to v0.10, the degradation function accepted a calibration_version kwarg,

def degradation(
channel: u.angstrom,
obstime,
*,
correction_table=None,
calibration_version=None,
This was then used to select the correct calibration version from the correction table
table = table[table["VER_NUM"] == version]
However, this logic was removed in #346. Presumably the logic here was reduce the API surface of these various top-level functions and only rely on a table as input.

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:

  1. 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:
    correction_table = get_correction_table()
  2. 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
    def _select_epoch_from_correction_table(channel: u.angstrom, obstime, correction_table):

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugProbably a bug.Priority HighRapid action required.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions