src.superphot_plus.format_data_ztf

This script provides functions for importing, preprocessing, and manipulating data related to ZTF lightcurves.

Module Contents

Functions

import_labels_only(input_csvs, allowed_types[, ...])

Filters CSVs for rows where label is in allowed_types and returns

tally_each_class(labels)

Prints the number of samples with each class label.

retrieve_posterior_set(lc_names, fits_dir[, sampler, ...])

Retrieve all sets of posterior samples, excluding

normalize_features(features[, mean, std])

Normalizes the features for feeding into the neural network.

import_labels_only(input_csvs, allowed_types, fits_dir=None, needs_posteriors=True, sampler=None)[source]

Filters CSVs for rows where label is in allowed_types and returns names, labels.

Parameters:
  • input_csvs (list of str) – List of input CSV file paths.

  • allowed_types (list) – List of allowed types for labels.

  • fits_dir (str, optional) – Directory path for FITS files. Defaults to None.

  • needs_posteriors (boolean, optional) – Indicates whether to load posterior samples.

  • sampler (str, optional) – The sampler to get posteriors from.

Returns:

Tuple of names, labels and redshifts.

Return type:

tuple of np.ndarray

Notes

Maps groups of similar labels to a single representative label name (eg, “SN Ic”, “SNIc-BL”, and “21” all become “SN Ibc”).

tally_each_class(labels)[source]

Prints the number of samples with each class label.

Parameters:

labels (list) – Input labels.

retrieve_posterior_set(lc_names, fits_dir, sampler=None, redshifts=None, labels=None, chisq_cutoff=np.inf)[source]

Retrieve all sets of posterior samples, excluding poor median fits and invalid redshift values.

Parameters:
  • lc_names (str) – Lightcurve names.

  • fits_dir (str) – Where fit parameters are stored.

  • sampler (str, optional) – The name of the sampler to use.

  • redshifts (list, optional) – List of redshift values.

  • chisq_cutoff (float, optional) – Ignore all fit sets with median chisq above this value.

normalize_features(features, mean=None, std=None)[source]

Normalizes the features for feeding into the neural network.

Parameters:
  • features (numpy array) – Input features. Must be a 2-d array where each row corresponds to a data point and each entry to a feature.

  • mean (ndarray, optional) – Mean values for normalization. Defaults to None.

  • std (ndarray, optional) – Standard deviation values for normalization. Defaults to None.

Returns:

Tuple containing normalized features, mean values, and standard deviation values.

Return type:

tuple of np.ndarray