opticam.differential_photometer

Classes

DifferentialPhotometer

Helper class for creating relative light curves.

Functions

filter_dataframes_to_common_time_column(target_df, ...)

Get the matching times between a target data frame (light curve) and a list of comparison data frames (light

compute_relative_flux(time, target_df, comp_dfs)

Compute the relative flux between a target source and one or more comparison sources.

transform_IDs(out_directory, ref_coords, ...)

Transform some source IDs from one camera to another.

Module Contents

class opticam.differential_photometer.DifferentialPhotometer(out_directory, show_plots=True)

Helper class for creating relative light curves.

Parameters:
  • out_directory (pathlib.Path)

  • show_plots (bool)

out_directory
show_plots = True
keys
time_key = 'BMJD'
time_scale = 'tdb'
t_ref
catalogs
get_relative_light_curve(key, target, comparisons, phot_label, prefix=None, match_other_cameras=False, show_diagnostics=True)

Compute the relative light curve for a target source with respect to one or more comparison sources. By default, the relative light curve is computed for a single filter. The relative light curve is saved to out_directory/relative_light_curves. To automatically match the target and comparison sources across the other two filters, set match_other_cameras to True. Note that this can incorrectly match sources, so it is recommended to manually check the results.

Parameters

keystr

The camera:filter key for which the relative light curve will be computed.

targetint

The catalog ID of the target source.

comparisonsint | List[int]

The catalog ID(s) of the comparison source(s).

phot_labelstr

The photometry label, used for file reading and labelling.

prefixstr, optional

The prefix to use when saving the relative light curve (e.g., the target star’s name), by default None.

match_other_camerasbool, optional

Whether to match the target and comparison(s) IDs to the remaining catalog filters, by default False. If True, astroalign must be installed.

show_diagnosticsbool, optional

Whether to show diagnostic plots, by default True.

Returns

Analyzer

An Analyzer object containing the relative light curve(s).

Parameters:
  • key (str)

  • target (int)

  • comparisons (int | List[int])

  • phot_label (str)

  • prefix (str | None)

  • match_other_cameras (bool)

  • show_diagnostics (bool)

Return type:

opticam.analyzer.Analyzer

_compute_relative_light_curve(key, target, comparisons, prefix, phot_label, show_diagnostics)

Compute the relative light curve for a target source with respect to one or more comparison sources for a given filter.

Parameters

keystr

The camera:filter key.

targetint

The catalog ID of the target source.

comparisonsList[int]

The catalog ID(s) of the comparison source(s).

prefixstr | None

The prefix to use when saving the relative light curve (e.g., the target star’s name), by default None.

phot_labelstr

The photometry label, used for file reading and labelling.

show_diagnosticsbool

Whether to show diagnostic plots, by default True.

Returns

TimeSeries | None

The relative light curve for the target source with respect to the comparison sources, or None if the light curve could not be computed.

Parameters:
  • key (str)

  • target (int)

  • comparisons (List[int])

  • prefix (str | None)

  • phot_label (str)

  • show_diagnostics (bool)

Return type:

astropy.timeseries.TimeSeries | None

_match_other_cameras(input_key, input_target, input_comparisons, prefix, phot_label, show_diagnostics)

Compute the relative light curves for all available filters.

Parameters

input_keystr

The input filter.

input_targetint

The target ID in the input filter’s catalog.

input_comparisonsList[int]

The comparison ID(s) in the input filter’s catalog.

prefixstr | None

The prefix to use when saving the relative light curve (e.g., the target source’s name).

phot_labelstr

The photometry label.

show_diagnosticsbool

Whether to show the diagnostic plots.

Returns

Tuple[TimeSeries, List[str]]

The light curves for all available filters and the list of filters that were successfully matched.

Parameters:
  • input_key (str)

  • input_target (int)

  • input_comparisons (List[int])

  • prefix (str | None)

  • phot_label (str)

  • show_diagnostics (bool)

Return type:

Tuple[astropy.timeseries.TimeSeries, List[str]]

_plot_diags(key, target, comparisons, target_df, comp_dfs, phot_label, show)

Plot a combination of diagnostic plots for the specified target and comparison sources.

Parameters

keystr

The image filter.

targetint

The target ID.

comparisonsList[int]

The comparison ID(s).

target_dfDataFrame

The target light curve.

comp_dfsList[DataFrame]

The comparison light curve(s).

phot_labelstr

The photometry label.

showbool

Whether to show the plots.

Parameters:
  • key (str)

  • target (int)

  • comparisons (List[int])

  • target_df (pandas.DataFrame)

  • comp_dfs (List[pandas.DataFrame])

  • phot_label (str)

  • show (bool)

Return type:

None

_plot_diag(key, comparison1, comparison2, comparison1_df, comparison2_df, phot_label, show)

Plot the relative diagnostic light curve for two comparison sources for a given filter.

Parameters

keystr

The filter to compute the relative light curve.

comparison1int

The catalog ID of the first comparison source.

comparison2int

The catalog ID of the second comparison source.

comparison1_dfDataFrame

The data frame of the first comparison source.

comparison2_dfDataFrame

The data frame of the second comparison source.

phot_labelstr

The photometry label.

showbool

Whether to show the diagnostic plot.

Parameters:
  • key (str)

  • comparison1 (int)

  • comparison2 (int)

  • comparison1_df (pandas.DataFrame)

  • comparison2_df (pandas.DataFrame)

  • phot_label (str)

  • show (bool)

Return type:

None

opticam.differential_photometer.filter_dataframes_to_common_time_column(target_df, comp_dfs, time_key)

Get the matching times between a target data frame (light curve) and a list of comparison data frames (light curves).

Parameters

target_dfDataFrame

The data frame of the target source.

comp_dfsList[DataFrame]

The list of data frames of the comparison sources.

time_keystr,

The time key (either BMJD or MJD depending on whether Barycentric corrections were applied).

Returns

Tuple[DataFrame, List[DataFrame]]

The filtered target data frame and the list of filtered comparison data frames.

Parameters:
  • target_df (pandas.DataFrame)

  • comp_dfs (List[pandas.DataFrame])

  • time_key (str)

Return type:

Tuple[pandas.DataFrame, List[pandas.DataFrame]]

opticam.differential_photometer.compute_relative_flux(time, target_df, comp_dfs)

Compute the relative flux between a target source and one or more comparison sources.

Parameters

timeNDArray[np.float64]

The time column.

target_dfDataFrame

The light curve of the target source.

comp_dfsList[DataFrame]

The light curves of the comparison sources.

Returns

Tuple[NDArray[np.float64], NDArray[np.float64], NDArray[np.float64]]

The time, relative flux, and relative flux error.

Parameters:
  • time (numpy.typing.NDArray[numpy.float64])

  • target_df (pandas.DataFrame)

  • comp_dfs (List[pandas.DataFrame])

Return type:

Tuple[numpy.typing.NDArray[numpy.float64], numpy.typing.NDArray[numpy.float64], numpy.typing.NDArray[numpy.float64]]

opticam.differential_photometer.transform_IDs(out_directory, ref_coords, ref_target_coords, ref_comparison_coords, key)

Transform some source IDs from one camera to another.

Parameters

out_directoryPath

The output directory.

ref_coordsNDArray

The coordinates of all sources in the current (reference) catalogue.

ref_target_coordsNDArray

The coordinates of the sources being transformed in the current (reference) catalogue.

ref_comparison_coordsList[NDArray]

The coordiantes of all sources in the new (comparison) catalogue.

keystr

The current filter.

Returns

Tuple[int, List[int]]

The transformed target and comparison source IDs.

Parameters:
  • out_directory (pathlib.Path)

  • ref_coords (numpy.typing.NDArray)

  • ref_target_coords (numpy.typing.NDArray)

  • ref_comparison_coords (List[numpy.typing.NDArray])

  • key (str)

Return type:

Tuple[int, List[int]]