Skip to content

Commit

Permalink
set wave_log=False by default to avoid issues with extrapolation
Browse files Browse the repository at this point in the history
  • Loading branch information
temuller committed Jun 18, 2024
1 parent de8a523 commit f1d25fe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/piscola/gaussian_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def prepare_gp_inputs(times, wavelengths, fluxes, flux_errors, fit_log, wave_log

return X, y, yerr, y_norm

def fit_gp_model(times, wavelengths, fluxes, flux_errors, k1='Matern52', fit_mean=False, fit_log=False, wave_log=True):
def fit_gp_model(times, wavelengths, fluxes, flux_errors, k1='Matern52', fit_mean=False, fit_log=False, wave_log=False):
"""Fits a Gaussian Process model to a SN multi-colour light curve.
All input arrays MUST have the same length.
Expand All @@ -81,7 +81,7 @@ def fit_gp_model(times, wavelengths, fluxes, flux_errors, k1='Matern52', fit_mea
``Matern32`` or ``ExpSquared``.
fit_log: bool, default ``False``.
Whether to fit the light curves in logarithmic (base 10) scale.
wave_log: bool, default ``True``.
wave_log: bool, default ``False``.
Whether to use logarithmic (base 10) scale for the
wavelength axis.
Expand Down
12 changes: 8 additions & 4 deletions src/piscola/sn_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,24 +275,28 @@ def init_gp_predict(self, times_pred, wavelengths_pred, return_cov=True):
mu, cov = self.init_gp_model.predict(y, X_test=X_test, return_cov=True)
# renormalise outputs
if self.init_fit_log is False:
# flux space
mu *= y_norm
cov *= y_norm ** 2
else:
# convert logarithmic to flux space
mu = 10 ** (mu - y_norm)
cov *= np.abs(np.outer(mu, mu)) * np.log(10) ** 2
return mu, cov
else:
mu, var = self.init_gp_model.predict(y, X_test=X_test, return_var=True)
# renormalise outputs
if self.init_fit_log is False:
# flux space
mu *= y_norm
var *= y_norm ** 2
else:
# convert logarithmic to flux space
mu = 10 ** (mu - y_norm)
var *= np.abs(mu) ** 2 * np.log(10) ** 2
return mu, var

def fit_lcs(self, bands=None, k1='Matern52', fit_log=False, wave_log=True):
def fit_lcs(self, bands=None, k1='Matern52', fit_log=False, wave_log=False):
"""Fits the multi-colour observed light-curve data with Gaussian Process.
The time of rest-frame B-band peak luminosity is estimated by finding where the derivative is equal to zero.
Expand All @@ -306,7 +310,7 @@ def fit_lcs(self, bands=None, k1='Matern52', fit_log=False, wave_log=True):
``Matern32`` or ``ExpSquared``.
fit_log: bool, default ``False``.
Whether to fit the light curves in logarithmic (base 10) scale.
wave_log: bool, default ``True``.
wave_log: bool, default ``False``.
Whether to use logarithmic (base 10) scale for the
wavelength axis.
"""
Expand Down Expand Up @@ -542,7 +546,7 @@ def gp_predict(self, times_pred, wavelengths_pred, return_cov=True):
var *= y_norm ** 2
return mu, var

def fit(self, bands=None, k1='Matern52', fit_log=False, wave_log=True, skip_lcs_fit=False):
def fit(self, bands=None, k1='Matern52', fit_log=False, wave_log=False, skip_lcs_fit=False):
"""Fits and corrects the multi-colour light curves with an SED template.
The corrections include Milky-Way dust extinction and mangling of the SED
Expand All @@ -558,7 +562,7 @@ def fit(self, bands=None, k1='Matern52', fit_log=False, wave_log=True, skip_lcs_
fit_log: bool, default ``False``.
Whether to initiallly fit the light curves in logarithmic (base 10) scale.
The mangling is always done in flux space.
wave_log: bool, default ``True``.
wave_log: bool, default ``False``.
Whether to use logarithmic (base 10) scale for the
wavelength axis.
skip_lcs_fit: bool, default ``False``.
Expand Down

0 comments on commit f1d25fe

Please sign in to comment.