Reference / API

Models

Loading/saving a model

ParsnipModel(path, bands[, device, threads, ...])

Generative model of transient light curves

load_model([path, device, threads])

Load a ParSNIP model.

ParsnipModel.save()

Save the model

ParsnipModel.to(device[, force])

Send the model to the specified device

Interacting with a dataset

ParsnipModel.preprocess(dataset[, ...])

Preprocess an lcdata dataset

ParsnipModel.augment_light_curves(light_curves)

Augment a set of light curves

ParsnipModel.get_data_loader(dataset[, augment])

Get a PyTorch DataLoader for an lcdata Dataset

ParsnipModel.fit(dataset[, max_epochs, ...])

Fit the model to a dataset

ParsnipModel.score(dataset[, rounds, ...])

Evaluate the loss function on a given dataset.

Generating model predictions

ParsnipModel.predict(light_curves[, augment])

Generate predictions for a light curve or set of light curves.

ParsnipModel.predict_dataset(dataset[, augment])

Generate predictions for a dataset

ParsnipModel.predict_dataset_augmented(dataset)

Generate predictions for a dataset with augmentation

ParsnipModel.predict_light_curve(light_curve)

Predict the flux of a light curve on a grid

ParsnipModel.predict_spectrum(light_curve, time)

Predict the spectrum of a light curve at a given time

ParsnipModel.predict_sncosmo(light_curve[, ...])

Package the predictions for a light curve as an sncosmo model

Individual parts of the model

ParsnipModel.forward(light_curves[, sample, ...])

Run a set of light curves through the full ParSNIP model

ParsnipModel.encode(input_data)

Predict the latent variables for a set of light curves

ParsnipModel.decode(encoding, ref_times, ...)

Predict the light curves for a given set of latent variables

ParsnipModel.decode_spectra(encoding, ...[, ...])

Predict the spectra at a given set of latent variables

ParsnipModel.loss_function(result[, ...])

Compute the loss function for a set of light curves

Datasets

Loading datasets

load_dataset(path[, kind, in_memory, ...])

Load a dataset using the lcdata package.

load_datasets(dataset_paths[, kind, ...])

Load a list of datasets and merge them

parse_dataset(dataset[, path_or_name, kind, ...])

Parse a dataset from the lcdata package.

Parsers for specific instruments

parse_plasticc(dataset[, reject_invalid, ...])

Parse a PLAsTiCC dataset

parse_ps1(dataset[, reject_invalid, ...])

Parse a PanSTARRS-1 dataset

parse_ztf(dataset[, reject_invalid, ...])

Parse a ZTF dataset

Tools for manipulating datasets

split_train_test(dataset)

Split a dataset into training and testing parts.

get_bands(dataset)

Retrieve a list of bands in a dataset

Plotting

plot_light_curve(light_curve[, model, ...])

Plot a light curve

plot_representation(predictions, plot_labels)

Plot the representation of a ParSNIP model

plot_spectrum(light_curve, model, time[, ...])

Plot the spectrum of a light curve predicted by a ParSNIP model

plot_spectra(light_curve, model[, times, ...])

Plot the spectral time series of a light curve predicted by a ParSNIP model

plot_sne_space(light_curve, model, name[, ...])

Compare a ParSNIP spectrum prediction to a real spectrum from sne.space

plot_confusion_matrix(predictions, ...[, ...])

Plot a confusion matrix

get_band_plot_color(band)

Return the plot color for a given band.

get_band_plot_marker(band)

Return the plot marker for a given band.

Classification

Classifier()

LightGBM classifier that operates on ParSNIP predictions

extract_top_classifications(classifications)

Extract the top classification for each row a classifications Table.

weighted_multi_logloss(true_types, ...)

Calculate a weighted log loss metric.

SNCosmo Interface

ParsnipSncosmoSource([model])

SNCosmo interface for a ParSNIP model

ParsnipModel.predict_sncosmo(light_curve[, ...])

Package the predictions for a light curve as an sncosmo model

Custom Neural Network Layers

ResidualBlock(in_channels, out_channels, ...)

1D residual convolutional neural network block

Conv1dBlock(in_channels, out_channels, dilation)

1D convolutional neural network block

GlobalMaxPoolingTime(*args, **kwargs)

Time max pooling layer for 1D sequences

Settings

parse_settings(bands[, settings, ...])

Parse the settings for a ParSNIP model

parse_int_list(text)

Parse a string into a list of integers

build_default_argparse(description)

Build an argparse object that can handle all of the ParSNIP model settings.

update_derived_settings(settings)

Update the derived settings for a model

update_settings_version(settings)

Update settings to a new version

Light curve utilities

preprocess_light_curve(light_curve, settings)

Preprocess a light curve for the ParSNIP model

time_to_grid(time, reference_time)

Convert a time in the original units to one on the internal ParSNIP grid

grid_to_time(grid_time, reference_time)

Convert a time on the internal grid to a time in the original units

get_band_effective_wavelength(band)

Calculate the effective wavelength of a band

calculate_band_mw_extinctions(bands)

Calculate the Milky Way extinction corrections for a set of bands

should_correct_background(bands)

Determine if we should correct the background levels for a set of bands

General utilities

nmad(x)

Calculate the normalize median absolute deviation (NMAD)

frac_to_mag(fractional_difference)

Convert a fractional difference to a difference in magnitude.

parse_device(device)

Figure out which PyTorch device to use