fiesta#

Top-level utility modules.

class fiesta.filters.Filter(name, nus=None, trans=None)[source]#

Bases: object

get_mags(fluxes, nus)[source]#
Return type:

Array, 'n_samples n_times']

class fiesta.scalers.DataScaler(scalers)[source]#

Bases: Scaler

fit(x)[source]#
Return type:

None

inverse_transform(x)[source]#
Return type:

Array

transform(x)[source]#
Return type:

Array

class fiesta.scalers.ImageScaler(downscale, upscale)[source]#

Bases: Scaler

Scaler that down samples 2D arrays of shape upscale to downscale and the inverse. Note that the methods always assume that the input array x is flattened along the last axis, i.e. it will reshape the input x.reshape(-1, *upscale). The down sampled image is scaled once more with a scaler object. Attention, this object has no proper fit method, because of its application in FluxTrainerCVAE and the way the data is loaded there to avoid memory issues.

fit(x)[source]#
static fix_edges(yp)[source]#

Vectorized version of fix_edges. Takes similar arguments as fix_edges but with additional array axes over which fix_edges is mapped.

Original documentation:

Extrapolate at early and late times from the reconstructed array to avoid artefacts at the edges from jax.image.resize.

Return type:

Array

class fiesta.scalers.MinMaxScalerJax(min_val=1.0, max_val=0.0)[source]#

Bases: Scaler

JAX compatible MinMaxScaler. API inspired by sklearn.

fit(x)[source]#
Return type:

None

inverse_transform(x)[source]#
Return type:

Array

transform(x)[source]#
Return type:

Array

class fiesta.scalers.PCADecomposer(n_components, solver='randomized')[source]#

Bases: Scaler

JAX compatible PCA decomposition. API inspired by sklearn. Based on alonfnt/pcax.

fit(x)[source]#
Return type:

None

inverse_transform(x)[source]#
Return type:

Array

transform(x)[source]#
Return type:

Array

class fiesta.scalers.ParameterScaler(scaler, parameter_names, conversion)[source]#

Bases: Scaler

fit(x)[source]#
Return type:

None

transform(x)[source]#
Return type:

Array

class fiesta.scalers.SVDDecomposer(svd_ncoeff)[source]#

Bases: Scaler

JAX compatible SVD Decomposition. Based on the old NMMA approach to decompose lightcurves into SVD coefficients.

fit(x)[source]#
inverse_transform(x)[source]#
Return type:

Array

transform(x)[source]#
Return type:

Array

class fiesta.scalers.Scaler[source]#

Bases: object

Base class for all the scalers that depend on some analytic algorithm to transform data.

fit(x)[source]#
Return type:

None

fit_transform(x)[source]#
Return type:

Array

inverse_transform(x)[source]#
Return type:

Array

transform(x)[source]#
Return type:

Array

class fiesta.scalers.StandardScalerJax(mu=0.0, sigma=1.0)[source]#

Bases: Scaler

JAX compatible StandardScaler. API inspired by sklearn.

fit(x)[source]#
Return type:

None

inverse_transform(x)[source]#
Return type:

Array

transform(x)[source]#
Return type:

Array

fiesta.scalers.identity(x)[source]#
fiesta.scalers.thetaCore_inclination(x)[source]#
fiesta.scalers.thetaWing_inclination(x)[source]#
fiesta.conversions.Flambda_to_Fnu(F_lambda, lambdas)[source]#

JAX-compatible conversion of wavelength flux in erg cm^{-2} s^{-1} Angström^{-1} to spectral flux density in mJys.

Parameters:
  • flux_lambda (Float[Array]) – 2D flux density array in erg cm^{-2} s^{-1} Angström^{-1}. The rows correspond to the wavelengths provided in lambdas.

  • lambdas (Float[Array]) – 1D wavelength array in Angström.

Returns:

2D spectral flux density array in mJys nus (Float[Array]): 1D frequency array in Hz

Return type:

mJys (Float[Array])

fiesta.conversions.Fnu_to_Flambda(F_nu, nus)[source]#

JAX-compatible conversion of spectral flux density in mJys to wavelength flux in erg cm^{-2} s^{-1}.

Parameters:
  • flux_nu (Float[Array]) – 2D flux density array in mJys. The rows correspond to the frequencies provided in nus.

  • nus (Float[Array]) – 1D frequency array in Hz.

Returns:

2D wavelength flux density array in erg cm^{-2} s^{-1} Angström^{-1}. lambdas (Float[Array]): 1D wavelength array in Angström.

Return type:

flux_lambda (Float[Array])

fiesta.conversions.Mpc_to_cm(d)[source]#
fiesta.conversions.apply_redshift(F_nu, times, nus, z)[source]#

Transforms a 2D flux density array from source frame in observer frame, as well as the associated time and frequency array. Does not account for the distance factor, so cosmological energy loss and time elongation are taken into account by the luminosity distance.

Parameters:
  • F_nu (Float[Array]) – 2D flux density array in mJy in source frame. The rows correspond to the frequencies provided in nus, the columns to times.

  • times (Float[Array]) – 1D time array in source frame.

  • nus (Float[Array]) – 1D frequency array in source frame

Returns:

times (Float[Array]): 1D time array in observer frame. nus (Float[Array]): 1D frequency array in source frame. F_nu (Float[Array]): 2D flux density redshifted to observer frame.

Return type:

tuple

fiesta.conversions.bandpass_AB_mag(flux, nus, nus_filt, trans_filt, ref_flux)[source]#

This is a JAX-compatile equivalent of sncosmo.TimeSeriesSource.bandmag(). Unlike sncosmo, we use the frequency flux and not wavelength flux, but this function is tested to yield the same results as the sncosmo version.

Parameters:
  • flux (Float[Array, "n_nus n_times"]) – Spectral flux density as a 2D array in mJys.

  • nus (Float[Array, "n_nus"]) – Associated frequencies in Hz

  • nus_filt (Float[Array, "n_nus_filt"]) – frequency array of the filter in Hz

  • trans_filt (Float[Array, "n_nus_filt"]) – transmissivity array of the filter in transmitted photons / incoming photons

  • ref_flux (Float) – flux in mJy for which the filter is 0 mag

Return type:

Array, 'n_times']

fiesta.conversions.integrated_AB_mag(flux, nus, nus_filt, trans_filt)[source]#
Return type:

Array, 'n_times']

fiesta.conversions.luminosity_distance_to_redshift(dL)[source]#
fiesta.conversions.mJys_to_mag_jnp(mJys)[source]#
fiesta.conversions.mJys_to_mag_np(mJys)[source]#
fiesta.conversions.mag_app_from_mag_abs(mag_abs, luminosity_distance)[source]#
Return type:

Array

fiesta.conversions.monochromatic_AB_mag(flux, nus, nus_filt, trans_filt, ref_flux)[source]#
Return type:

Array, 'n_times']

fiesta.conversions.redshift_to_luminosity_distance(z, H0=67660.0, Omega_m=0.30966)[source]#
fiesta.utils.append_training_data_file(outfile, train_X, train_y, val_X, val_y, test_X, test_y)[source]#
fiesta.utils.convert_POSSIS_outputs_to_h5(possis_dirs, outfile, parameter_names=['log10_mej_dyn', 'v_ej_dyn', 'Ye_dyn', 'log10_mej_wind', 'v_ej_wind', 'Ye_wind', 'inclination_EM'], clip=6.5144, log_arguments=[0, 3])[source]#
fiesta.utils.convert_gwemopt_to_h5(dirs, outfile, parameter_names=['dens_slope', 'log10_X_lan', 'vkin', 'log10_mej'], clip=6.5144, log_arguments=[1, 3])[source]#
fiesta.utils.interpolate_nans(data, times, output_times=None)[source]#

Interpolate NaNs and infs in the raw light curve data.

Parameters:
  • data (dict[str, Float[Array, 'n_files n_times']]) – The raw light curve data

  • diagnose (bool) – If True, print out the number of NaNs and infs in the data etc to inform about quality of the grid.

Returns:

Raw light curve data but with NaNs and infs interpolated

Return type:

dict[str, Float[Array, ‘n_files n_times’]]

fiesta.utils.load_event_data(filename)[source]#

Takes a file and outputs a magnitude dict with filters as keys.

Parameters:

filename (str) – path to file to be read in

Returns:

Data dictionary with filters as keys. The array has the structure [[mjd, mag, err]].

Return type:

data (dict[str, Array])

fiesta.utils.read_POSSIS_file(filename)[source]#
fiesta.utils.read_gwemopt_file(filename)[source]#
fiesta.utils.read_gwemopt_parameters(filename)[source]#
fiesta.utils.read_parameters_POSSIS(filename)[source]#
fiesta.utils.train_test_split(X, y, train_size)[source]#
fiesta.utils.truncated_gaussian(mag_det, mag_err, mag_est, lim=inf)[source]#

Evaluate log PDF of a truncated Gaussian with loc at mag_est and scale mag_err, truncated at lim above.

Returns:

_description_

Return type:

_type_

fiesta.utils.write_event_data(filename, data)[source]#

Takes a magnitude dict and writes it to filename. The magnitude dict should have filters as keys, the arrays should have the structure [[mjd, mag, err]].

fiesta.utils.write_training_data(outfile, train_X, train_y, val_X, val_y, test_X, test_y, times, nus, parameter_names, parameter_distributions)[source]#

Constants and simple conversions

fiesta.extinction.extinctionFactorP92SMC(nu, Ebv, redshift)[source]#

Subpackages#