opticam.differential_photometer =============================== .. py:module:: opticam.differential_photometer Classes ------- .. autoapisummary:: opticam.differential_photometer.DifferentialPhotometer Functions --------- .. autoapisummary:: opticam.differential_photometer.filter_dataframes_to_common_time_column opticam.differential_photometer.compute_relative_flux opticam.differential_photometer.transform_IDs Module Contents --------------- .. py:class:: DifferentialPhotometer(out_directory, show_plots = True) Helper class for creating relative light curves. .. py:attribute:: out_directory .. py:attribute:: show_plots :value: True .. py:attribute:: keys .. py:attribute:: time_key :value: 'BMJD' .. py:attribute:: time_scale :value: 'tdb' .. py:attribute:: t_ref .. py:attribute:: catalogs .. py:method:: 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 ---------- key : str The camera:filter key for which the relative light curve will be computed. target : int The catalog ID of the target source. comparisons : int | List[int] The catalog ID(s) of the comparison source(s). phot_label : str The photometry label, used for file reading and labelling. prefix : str, optional The prefix to use when saving the relative light curve (e.g., the target star's name), by default None. match_other_cameras : bool, 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_diagnostics : bool, optional Whether to show diagnostic plots, by default True. Returns ------- Analyzer An Analyzer object containing the relative light curve(s). .. py:method:: _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 ---------- key : str The camera:filter key. target : int The catalog ID of the target source. comparisons : List[int] The catalog ID(s) of the comparison source(s). prefix : str | None The prefix to use when saving the relative light curve (e.g., the target star's name), by default None. phot_label : str The photometry label, used for file reading and labelling. show_diagnostics : bool 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. .. py:method:: _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_key : str The input filter. input_target : int The target ID in the input filter's catalog. input_comparisons : List[int] The comparison ID(s) in the input filter's catalog. prefix : str | None The prefix to use when saving the relative light curve (e.g., the target source's name). phot_label : str The photometry label. show_diagnostics : bool 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. .. py:method:: _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 ---------- key : str The image filter. target : int The target ID. comparisons : List[int] The comparison ID(s). target_df : DataFrame The target light curve. comp_dfs : List[DataFrame] The comparison light curve(s). phot_label : str The photometry label. show : bool Whether to show the plots. .. py:method:: _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 ---------- key : str The filter to compute the relative light curve. comparison1 : int The catalog ID of the first comparison source. comparison2 : int The catalog ID of the second comparison source. comparison1_df : DataFrame The data frame of the first comparison source. comparison2_df : DataFrame The data frame of the second comparison source. phot_label : str The photometry label. show : bool Whether to show the diagnostic plot. .. py:function:: 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_df : DataFrame The data frame of the target source. comp_dfs : List[DataFrame] The list of data frames of the comparison sources. time_key : str, 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. .. py:function:: compute_relative_flux(time, target_df, comp_dfs) Compute the relative flux between a target source and one or more comparison sources. Parameters ---------- time : NDArray[np.float64] The time column. target_df : DataFrame The light curve of the target source. comp_dfs : List[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. .. py:function:: transform_IDs(out_directory, ref_coords, ref_target_coords, ref_comparison_coords, key) Transform some source IDs from one camera to another. Parameters ---------- out_directory : Path The output directory. ref_coords : NDArray The coordinates of all sources in the current (reference) catalogue. ref_target_coords : NDArray The coordinates of the sources being transformed in the current (reference) catalogue. ref_comparison_coords : List[NDArray] The coordiantes of all sources in the new (comparison) catalogue. key : str The current filter. Returns ------- Tuple[int, List[int]] The transformed target and comparison source IDs.