quasarnp.model

A module defining the QuasarNP model object.

QuasarNP is a pure numpy implementation of the original TensorFlow QuasarNet. This module only defines the QuasarNP model object and provides no other functionality on its own.

class quasarnp.model.QuasarNP(weights, nlines=7, rescale=False, nlayers=4, config_dict=None)[source]

Bases: object

A QuasarNP model object. The model holds all of the relevant layer information, including layer names, weights and definitions.

Parameters:
  • weights (dict) – Dictionary that maps layer names to layer weights.

  • nlines (int, optional) – Number of lines this model was trained for. Defaults to 7.

  • rescale (bool, optional) – Whether or not to rescale the output of the box layers. Defaults to False.

conv_layer(x, name)[source]
predict(x_input)[source]

Run a set of spectra and generate predictions.

Parameters:

x_input (numpy.ndarray) – Input array of spectra, with shape (nspectra, nbins, 1)

Returns:

Moodel predicted values per trained line, with length nlines.

Return type:

list of numpy.ndarray

Notes

In order to mimic QuasarNet behaviour in QuasarNP, predict does not directly take as input the output of load_desi_exposure or load_desi_daily. You must first expand the dimensions of the loaded data before loading. For example:

>>> data, w = load_desi_daily("20210107", "00071246", 1)
>>> data = data[:, :, None]
>>> model.predict(data)
rescale(x)[source]