Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modified CDIPS output to present flux values and BTJD time #1335

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 28 additions & 6 deletions src/lightkurve/io/cdips.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
log = logging.getLogger(__name__)

def read_cdips_lightcurve(filename,
flux_column="IRM1",
include_inst_errs=False,
flux_column="IFL1",
include_inst_errs=True,
quality_bitmask=None):
"""Returns a TESS CDIPS `~lightkurve.lightcurve.LightCurve`.

Expand All @@ -25,6 +25,11 @@ def read_cdips_lightcurve(filename,
is allowed. The `quality_bitmask` parameter is ignored but accepted for
compatibility with other data format readers.

There are several kinds of flux and magnitudes provided. For consistancy
we have chosen to display as default 'IFL1', the flux in aperture 1.
This is given in ADU.
The flux_err is also provided as 'IFE1' in ADU

More information: https://archive.stsci.edu/hlsp/cdips

Parameters
Expand All @@ -40,9 +45,10 @@ def read_cdips_lightcurve(filename,
"""
ap = flux_column[-1]

# Only the instrumental magnitudes are provided, and are not provided for
# trend-filtered light curves. User should select whether to include the
# instrumental errors or ignore them
# A user can chose to dipsplay the magnitudes or any of the other flux values,
# They can do this by using the flux_column key
# By default the flux_err for the given flux specified is returned

if include_inst_errs:
# If fluxes are requested, return flux errors
if flux_column[:-1].lower()=="ifl":
Expand All @@ -63,6 +69,11 @@ def read_cdips_lightcurve(filename,
quality_column=quality_column,
time_format='btjd')

#The time displayed is in BJD not BTJD. We can fix this by subtracting
# 2457000
lc["time"] = lc["time"]-2457000
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be taken care of with the time_format argument by setting it to jd

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has now been adjusted. Thank you.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note however that the time is given in BJD, but this does not seem to be an option.



# Filter out poor-quality data
# NOTE: Unfortunately Astropy Table masking does not yet work for columns
# that are Quantity objects, so for now we remove poor-quality data instead
Expand All @@ -74,8 +85,19 @@ def read_cdips_lightcurve(filename,
quality_mask = (lc['quality']=="G") | (lc['quality']=="0")
lc = lc[quality_mask]


#This makes sure that the TIC ID is obtained and returned as the plot label
tic = lc.meta.get('TICID')
if tic is not None:
# compatibility with SPOC, QLP, etc.
lc.meta["TARGETID"] = tic
lc.meta["TICID"] = tic
lc.meta["OBJECT"] = f"TIC {tic}"
# for Lightkurve's plotting methods
lc.meta["LABEL"] = f"TIC {tic}"


lc.meta["AUTHOR"] = "CDIPS"
lc.meta['TARGETID'] = lc.meta.get('TICID')
lc.meta['QUALITY_BITMASK'] = 36
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bitmask needs to be updated

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the point here to change the quality bitmask to the TESS default i.e., 175?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally CDIPS light curves have already had quality filtering applied, and do not provide the bitflags necessary for a user to apply a new bitmask.

lc.meta['QUALITY_MASK'] = quality_mask

Expand Down
3 changes: 2 additions & 1 deletion tests/io/test_cdips.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ def test_read_cdips():
assert type(lc).__name__ == "TessLightCurve"
assert lc.meta["FLUX_ORIGIN"] == ext.lower()
# Are `time` and `flux` consistent with the FITS file?
assert_array_equal(f[1].data['TMID_BJD'][lc.meta['QUALITY_MASK']],
# Removed 2457000 days from the TMID_BJD values
assert_array_equal(f[1].data['TMID_BJD'][lc.meta['QUALITY_MASK']]-2457000,
lc.time.value)
assert_array_equal(f[1].data[ext][lc.meta['QUALITY_MASK']],
lc.flux.value)
Expand Down