Obtaining and pre-processing data#
Obtaining archival light curves#
This module contains functions to obtain light curve data and transit information from the NASA Exoplanet Archive.
- democratic_detrender.get_lc.get_light_curve(object_id, flux_type, TESS=False, Kepler=False, user_period=None, user_t0=None, user_duration=None, planet_number=1, mask_width=1.3, remove_PDCSAP_blend=True)[source]#
Obtains light curve data based on the object ID, flux type, and optional user-provided transit parameters.
- Parameters:
object_id (str) – Object ID for which the light curve needs to be obtained.
flux_type (str) – Type of flux data to retrieve (e.g., ‘sap_flux’, ‘pdcsap_flux’).
TESS (bool, optional) – Whether the object is observed by TESS. Defaults to False.
Kepler (bool, optional) – Whether the object is observed by Kepler. Defaults to False.
user_period (float, optional) – User-provided period for the transit. Defaults to None.
user_t0 (float, optional) – User-provided transit midpoint. Defaults to None.
user_duration (float, optional) – User-provided transit duration. Defaults to None.
planet_number (int, optional) – Number of the planet in the system. Defaults to 1.
mask_width (float, optional) – Width multiplier for creating transit masks. Defaults to 1.3.
remove_PDCSAP_blend (bool, optional)
- Returns:
- A tuple containing the light curve data:
np.array: Time values (xs). np.array: Flux values (ys). np.array: Flux error values (ys_err). np.array: Transit mask (mask). np.array: Fitted planet mask (mask_fitted_planet). np.array: Transit midpoints (t0s_in_data). np.array: Transit periods (period). np.array: Transit durations (duration). list: Quarters of observation (quarters). list: Crowding information (crowding). list: Flux fraction information (flux_fraction).
- Return type:
tuple
- democratic_detrender.get_lc.get_transit_info(object_id)[source]#
Takes an object ID, queries Simbad to get the matching TIC ID, then queries the Exoplanet Archive to extract transit information including t0, period, and duration.
if no Simbad match found, then returns None and prints error message if no exoplanet archive match found, then returns None and prints error message
- Parameters:
object_id (str) – Object ID for which transit information needs to be obtained.
- Returns:
Returns a DataFrame containing transit information if found. Returns the TIC ID as a string if no transit information is found but a TIC ID is retrieved. Returns None if neither a TIC ID nor transit information is found.
- Return type:
pandas.DataFrame or str or None
- democratic_detrender.get_lc.tic_id_from_exoplanet_archive(other_id)[source]#
- Parameters:
other_id (str) – Identifier for which the TIC ID needs to be obtained.
- Returns:
TIC ID obtained from the Exoplanet Archive. Returns None if no TIC ID is found.
- Return type:
str
- democratic_detrender.get_lc.tic_id_from_simbad(other_id)[source]#
Queries Simbad to obtain the TIC ID corresponding to the given identifier.
Note: This function requires the astroquery and astropy packages to be installed.
- Parameters:
other_id (str) – Identifier for which TIC ID needs to be obtained.
- Returns:
TIC ID obtained from Simbad. Returns None if no TIC ID is found.
- Return type:
str
Examples
>>> tic_id = tic_id_from_simbad('HD 12345') >>> print(tic_id)
- democratic_detrender.get_lc.transit_info_from_exoplanet_archive(tic_id)[source]#
Queries the Exoplanet Archive to obtain transit information (t0, period, and duration) for a given TIC ID.
- Parameters:
tic_id (str) – TIC ID for which transit information needs to be obtained.
- Returns:
DataFrame containing transit information (t0, period, and duration) for the specified TIC ID. Returns an empty DataFrame if no information is found.
- Return type:
result
Rejecting outliers#
This module contains functions to perform outlier rejection on light curve data.
- democratic_detrender.outlier_rejection.reject_outliers_everywhere(time, flux, flux_err, time_window, npoints_window, sigma_window)[source]#
rejects outliers via moving median and sigma clipping outside of transit mask
input: time = array of time values flux = array of flux values flux_err = array of flux error values time_window = float, much time before and after data gaps (of length >time_window) for which we don’t do outlier rejection npoints_window = int, how points around which to determine median on sigma_window = int, how many sigmas to clip
returns: time_out = array of time values with outliers removed flux_out = array of flux values with outliers removed
- democratic_detrender.outlier_rejection.reject_outliers_out_of_transit(time, flux, flux_err, mask, mask_fitted_planet, time_window, sigma_window)[source]#
rejects outliers via moving median and sigma clipping outside of transit mask
input: time = array of time values flux = array of flux values flux_err = array of flux error values mask = array of all mask values mask = array of mask values only for the planet we are fitting time_window = int, how much time around which to determine median on sigma_window = int, how many sigmas to clip
returns: flux_out = array of flux values with outliers value changed to np.nan flux_err_out = array of flux error values with outliers value changed to np.nan
Identifying flux jumps#
This module contains functions to identify flux jumps in light curves and return the necessary data for further analysis.
- democratic_detrender.find_flux_jumps.find_flux_jumps(star_id, flux_type, save_to_directory, show_plots, TESS=False, Kepler=False, user_periods=None, user_t0s=None, user_durations=None, planet_number=1, mask_width=1.3, no_pdc_problem_times=True, dont_bin=False, data_name=None, problem_times_default=None, user_light_curve=None, remove_PDCSAP_blend=True)[source]#
Allows the user to label discontinuities (ie flux jumps or problem times) in a light curve and return the necessary data for further analysis.
- Parameters:
star_id (str) – Identifier for the star.
flux_type (str) – Type of flux data (e.g., ‘pdcsap_flux’ or ‘sap_flux’).
save_to_directory (str) – Directory path to save plots.
show_plots (bool) – Whether to display plots.
TESS (bool, optional, default=False) – Flag indicating whether TESS data is used.
Kepler (bool, optional, default=False) – Flag indicating whether Kepler data is used.
user_periods (list, optional) – List of user-defined planet periods.
user_t0s (list, optional) – List of user-defined midtransit times.
user_durations (list, optional) – List of user-defined transit durations.
planet_number (int, optional, default=1) – Number of the planet being analyzed.
mask_width (float, optional, default=1.3) – Width of the transit mask.
no_pdc_problem_times (bool, optional, default=True) – Flag indicating whether PDC flux has no problem times.
dont_bin (bool, optional, default=False) – Flag indicating whether to skip binning.
data_name (str, optional) – Name of the data source.
problem_times_default (str, optional) – Default problem times source.
user_light_curve (string, optional) – path to folder with user light curve. Default: NO.
remove_PDCSAP_blend (bool, optional)
- Returns:
x_epochs (array): Array of time values for each epoch. y_epochs (array): Array of flux values for each epoch. yerr_epochs (array): Array of flux error values for each epoch. mask_epochs (array): Array of mask values for each epoch. mask_fitted_planet_epochs (array): Array of mask values for each fitted planet epoch. problem_times (list): List of jump times to trim structured noise. t0s (list): List of midtransit times. period (float): Planet period. duration (float): Transit duration. cadence (float): Cadence of observations.
- Return type:
Tuple containing the necessary data for further analysis
- democratic_detrender.find_flux_jumps.find_sap_and_pdc_flux_jumps(star_id, save_to_directory, show_plots, TESS=False, Kepler=False, user_periods=None, user_t0s=None, user_durations=None, planet_number=1, mask_width=1.3, dont_bin=False, data_name=None, problem_times_default=None, no_pdc_problem_times=True, user_light_curve=None)[source]#
Wrapper to identify flux jumps in both SAP and PDC flux data and return the necessary data for further analysis.
- Parameters:
star_id (str) – Identifier for the star.
save_to_directory (str) – Directory path to save plots.
show_plots (bool) – Whether to display plots.
TESS (bool, optional, default=False) – Flag indicating whether TESS data is used.
Kepler (bool, optional, default=False) – Flag indicating whether Kepler data is used.
user_periods (list, optional) – List of user-defined planet periods.
user_t0s (list, optional) – List of user-defined midtransit times.
user_durations (list, optional) – List of user-defined transit durations.
planet_number (int, optional, default=1) – Number of the planet being analyzed.
mask_width (float, optional, default=1.3) – Width of the mask.
dont_bin (bool, optional, default=False) – Flag indicating whether to skip binning.
data_name (str, optional) – Name of the data source.
problem_times_default (str, optional) – Default problem times source.
no_pdc_problem_times (bool, optional, default=True) – Flag indicating whether PDC flux has no problem times.
user_light_curve (string, optional) – path to folder with user light curve. Default: NO.
- Returns:
- x_epochs_sap (array): Array of time values for each SAP epoch.
y_epochs_sap (array): Array of flux values for each SAP epoch. yerr_epochs_sap (array): Array of flux error values for each SAP epoch. mask_epochs_sap (array): Array of mask values for each SAP epoch. mask_fitted_planet_epochs_sap (array): Array of mask values for each fitted planet epoch in SAP flux.
- Tuple containing the necessary data for further analysis for PDC flux:
x_epochs_pdc (array): Array of time values for each PDC epoch. y_epochs_pdc (array): Array of flux values for each PDC epoch. yerr_epochs_pdc (array): Array of flux error values for each PDC epoch. mask_epochs_pdc (array): Array of mask values for each PDC epoch. mask_fitted_planet_epochs_pdc (array): Array of mask values for each fitted planet epoch in PDC flux.
- Return type:
Tuple containing the necessary data for further analysis for SAP flux
Manipulating light curve data#
This module contains functions to split, join and mask light curve data.
- democratic_detrender.manipulate_data.add_nans_for_missing_data(sap_x_local, sap_detrended_lcs, sap_yerr_local, sap_mask_local, sap_mask_fitted_planet_local, pdc_x_local, pdc_detrended_lcs, pdc_yerr_local, pdc_mask_local, pdc_mask_fitted_planet_local)[source]#
- democratic_detrender.manipulate_data.find_quarters_with_transits(x_quarters, y_quarters, yerr_quarters, mask_quarters, mask_fitted_planet_quarters, t0s)[source]#