analysis.regression

The regression module fits light curves using a gaussian regression and compares the fitted colors with modeled color values.

Usage Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from sndata.csp import dr3

from analysis import regression

# Load demo data as an astropy table
dr3.download_module_data()
demo_id = dr3.get_available_ids()[0]
demo_data = dr3.get_data_for_id(demo_id)
print(demo_data)

# Fit a Gaussian process to the data
gp = lc_colors.fit_gaussian_process(demo_data)
gp_flux, gp_unc = regression.predict_light_curve(gp, bands, time)

# Pick the bands and time values to evaluate the Gaussian process at
all_bands = list(set(demo_data['band']))
time = np.arange(min(demo_data['time']) - 1, max(demo_data['time']) + 1)

# Interpolate flux in a single band
band_flux, band_err = regression.predict_band_flux(gp, all_bands[0], time)

# Interpolate flux in multiple bands
lc_flux, lc_err = regression.predict_light_curve(gp, all_bands, time)

# Predict the color at various time values
band1 = all_bands[0]
band2 = all_bands[1]
color, color_err = predict_color(gp, time, band1, band2)

Function Documentation

analysis.regression.predict_band_flux(gp, band_name, times)[source]

Return the flux modeled by a gaussian regression in a single band

Parameters:
  • gp (GP) – A fitted gaussian process
  • band_name (str) – Name of band pass to return flux for
  • times (list) – Times to predict flux for
Returns:

An array of flux values for the given times The errors in each flux value

analysis.regression.predict_c_15(gp, band1, band2, t0=0)[source]

Return the change in color over 15 days

Parameters:
  • gp (GP) – A fitted gaussian process
  • band1 (str) – Name of the first band in the magnitude difference
  • band2 (str) – Name of the second band in the magnitude difference
  • t0 (float) – Time of maximum (Default: 0)
Returns:

The change in color over 15 days The error in the change in color

analysis.regression.predict_color(gp, time, band1, band2)[source]

Return the color value modeled by a gaussian regression

Returns the band1 - band2 color. Assumes fluxes returned by the Gaussian regression are measured relative to the same zero point.

Parameters:
  • gp (GP) – A fitted gaussian process
  • time (list) – A 2d array of times for each band combination
  • band1 (str) – Name of the first band in the magnitude difference
  • band2 (str) – Name of the second band in the magnitude difference
Returns:

The predicted color The error in the predicted color

analysis.regression.predict_light_curve(gp, bands, times)[source]

Return the flux modeled by a gaussian regression in multiple bands

Times can either be a one dimensional list of times to be used for all bands or a two dimensional list specifying different times per band.

Parameters:
  • gp (GP) – A fitted gaussian process
  • bands (list[str]) – Name of band passes to return flux for
  • times (list) – Times to predict flux for
Returns:

A 2d array of flux values for each band A 2d array of errors for the predicted fluxes

analysis.regression.fit_gaussian_process(data, fix_scale=True, length_scale=20.0)[source]

Fit photometric observations with a gaussian regression

Parameters:
  • data (Table) – Data table from sndata (format_sncosmo=True)
  • fix_scale (bool) – Whether to fix the scale while fitting
  • length_scale (float) – The initial length scale to use for the fit.
Returns:

A Gaussian process conditioned on the object’s light-curve.