lightcurvelynx.utils.post_process_results

Utility functions for post processing the results data by adding statistics columns and filtering on those columns.

Functions

concat_results(results_list)

Concatenate a list of results into a single NestedFrame,

results_drop_empty(results)

Drop empty lightcurves from the results DataFrame.

results_append_param_as_col(results, param_name)

Append a simulation parameter as a new column to the results DataFrame.

results_append_obstable_data(results, column_name, ...)

Append the ObsTable entries for each observation as a new column in the

lightcurve_compute_snr(flux, fluxerr)

Compute the signal-to-noise ratio (SNR) for given flux and flux error arrays.

lightcurve_compute_mag(flux, fluxerr)

Compute the AB magnitude and magnitude error for given flux and flux error arrays.

augment_single_lightcurve(results, *[, min_snr, t0])

Add columns to a single lightcurve DataFrame with additional information

results_augment_lightcurves(results, *[, min_snr])

Add columns to the results DataFrame with additional information

results_use_full_filter_names(results, passbands)

Modifies the 'filter' column in the results DataFrame to include

Module Contents

concat_results(results_list)[source]

Concatenate a list of results into a single NestedFrame, updating the ID column to be unique across all results.

Parameters:

results_list (list of nested_pandas.NestedFrame) – The list of DataFrames to concatenate.

Returns:

The concatenated DataFrame.

Return type:

nested_pandas.NestedFrame

results_drop_empty(results)[source]

Drop empty lightcurves from the results DataFrame.

Parameters:

results (nested_pandas.NestedFrame) – The DataFrame containing lightcurve data.

Returns:

The DataFrame with empty lightcurves removed.

Return type:

nested_pandas.NestedFrame

results_append_param_as_col(results, param_name)[source]

Append a simulation parameter as a new column to the results DataFrame.

Parameters:
  • results (nested_pandas.NestedFrame) – The DataFrame containing lightcurve data. This is modified in place.

  • param_name (str) – The name of the parameter to append in the form <node_label>.<param_name>.

Returns:

The DataFrame with the new parameter column added.

Return type:

nested_pandas.NestedFrame

results_append_obstable_data(results, column_name, obstables)[source]

Append the ObsTable entries for each observation as a new column in the lightcurves nested DataFrame.

Parameters:
  • results (nested_pandas.NestedFrame) – The DataFrame containing lightcurve data. This is modified in place.

  • column_name (str) – The name of the column to append from the ObsTable entries.

  • obstables (ObsTable or list of ObsTable) – The ObsTable(s) containing the data to append. These should be in the same order as where used in the simulation.

Returns:

The DataFrame with the new parameter column added.

Return type:

nested_pandas.NestedFrame

lightcurve_compute_snr(flux, fluxerr)[source]

Compute the signal-to-noise ratio (SNR) for given flux and flux error arrays.

Parameters:
  • flux (array-like) – The flux values.

  • fluxerr (array-like) – The flux error values.

Returns:

result – The SNR values, with None for invalid entries (e.g., zero or negative flux error).

Return type:

np.ndarray

lightcurve_compute_mag(flux, fluxerr)[source]

Compute the AB magnitude and magnitude error for given flux and flux error arrays.

Parameters:
  • flux (array-like) – The flux values.

  • fluxerr (array-like) – The flux error values.

Returns:

The magnitude and magnitude error values, with None for invalid entries (e.g., non-positive flux).

Return type:

tuple of np.ndarray

augment_single_lightcurve(results, *, min_snr=0.0, t0=None)[source]

Add columns to a single lightcurve DataFrame with additional information about the light curve, including:

  • SNR = flux / fluxerr

  • detection flag (True if SNR >= min_snr, False otherwise)

  • AB magnitude

  • AB magnitude error = (2.5 / ln(10)) * (fluxerr / flux)

  • relative time = mjd - t0 (if t0 is provided)

None is used for invalid entries, e.g. negative flux or zero flux error.

Parameters:
  • results (pandas.DataFrame) – The DataFrame containing lightcurve data. Modified in place.

  • min_snr (float, optional) – Minimum SNR required to mark an entry as a detection. Default is 0.0.

  • t0 (float or None, optional) – Reference time for the lightcurve.

Returns:

results – The modified DataFrame (to enable chaining).

Return type:

pandas.DataFrame

results_augment_lightcurves(results, *, min_snr=0.0)[source]

Add columns to the results DataFrame with additional information about each light curve, including:

  • SNR = flux / fluxerr

  • detection flag (True if SNR >= min_snr, False otherwise)

  • AB magnitude

  • AB magnitude error = (2.5 / ln(10)) * (fluxerr / flux)

  • relative time = mjd - t0 (if t0 in the results table)

None is used for invalid entries, e.g. negative flux or zero flux error.

The input data frame can either be a single light curve (pandas.DataFrame) with columns “flux” and “fluxerr”, or a NestedFrame (nested_pandas.NestedFrame) with a nested DataFrame column “lightcurve” that contains the “flux” and “fluxerr” columns.

Parameters:
  • results (pandas.DataFrame or nested_pandas.NestedFrame) – The DataFrame containing lightcurve data. Modified in place.

  • min_snr (float, optional) – Minimum SNR required to mark an entry as a detection. Default is 0.0.

Returns:

results – The modified DataFrame (to enable chaining).

Return type:

pandas.DataFrame or nested_pandas.NestedFrame

results_use_full_filter_names(results, passbands)[source]

Modifies the ‘filter’ column in the results DataFrame to include the survey name as a prefix, e.g. ‘LSST_g’.

Parameters:
  • results (pandas.DataFrame or nested_pandas.NestedFrame) – The DataFrame containing lightcurve data. Modified in place.

  • passbands (list of PassbandGroup) – The list of PassbandGroups used in the simulation, in the same order as in the simulation.

Returns:

results – The modified DataFrame (to enable chaining).

Return type:

pandas.DataFrame or nested_pandas.NestedFrame