Small caveat in TESS/Kepler magnitude conversion

American Association of Variable Star Observers (AAVSO)
Mon, 01/02/2023 - 21:12

This note is about a small caveat in magnitudes shown for TESS / Kepler data. Empirically, the possible difference is tiny (< 0.0001 magnitude) in SAP_FLUX, so it's likely to be a non issue for most, if not all, cases. I'm posting this note in case the caveat is an issue for some people.


Background: I predominantly use Python / Lightkurve for analyzing TESS data, and notice some small discrepancy in the magnitude I got from my Lightkurve workflow and VStar results. In the handful of samples I looked into, the largest difference is 0.000099 magnitude.

Both VStar and my Lightkurve workflow derive magnitude by converting normalized flux to magnitude, assuming the median flux is the reference TESS magnitude. The discrepancy turns out to be due to the flux included to calculate median:

  • VStar: get the median of all  flux values in the FITS file.
  • My Lightkurve workflow: instead of using all flux values, it ignores the fluxes of possibly unreliable cadences based on the quality flags in the FITS file.
    • For Lightkurve users, ignoring possibly unreliable cadence is the default behavior when reading TESS FITS file (that one can override).


As a result, the derived magnitude is slightly different. The max is 0.000099 mag in the handful of samples (all based on SAP_FLUX).

  • 298734307, sector 57:  0.000022
  • 441794509, sector 57:  0.000003
  • 261136679, sector 1:  0.000015
  • 198537349, sector 23:  0.000055
  • 323968843, sector 39:  0.000019
  • 77209028, sector 4:  0.000099


PDCSAP_FLUX in practice would have no difference most of the time, because most, if not all, likely unreliable cadences have no values in PDCSAP_FLUX to begin with.


For reference: the cadences Lightkurve ignored by default based on quality flag are those with:  Attitude Tweak, Safe Mode, Spacecraft is in Coarse Point, Spacecraft is in Earth Point, Reaction Wheel Desaturation Event, Manual Exclude due to an anomaly.


- sam


Astronomical Society of South Australia (ASSAU)

In the VStar plugin we could add a checkbox to say whether to ignore such values in the median calculation. Feel free to create an issue for this in GitHub.

I momentarily thought about use of a VeLa filter in the generic file load dialog but that is only useful for filtering observations out of the final set of rather than out of a step in the retrieval such as the median calculation here. 

Note that there's the Kepler/TESS plugin and Lightkurve plugin variant.


American Association of Variable Star Observers (AAVSO)
I've logged it as an issue…

I've logged it as an issue at: .

On how to address the issue, I wonder if it might be better to provide an option post load to recalculate median (and thus magnitude). 

In the context of TESS SAP_FLUX lightcurves, it is not unusual to have cadences that are still problematic even after a (default) filtering by quality flags is applied, especially for the cadences near the beginning or the end of a TESS orbit. So users might want to further filter out cadences after the observation is loaded.

I have not used VStar much myself. It might be better to solicit feedback from VStar users who deal with TESS data a lot.