Skip to content

Commit

Permalink
Fix some bugs in GP fitting
Browse files Browse the repository at this point in the history
  • Loading branch information
kboone committed May 14, 2019
1 parent e5c3974 commit c319b92
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions avocado/astronomical_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from scipy.optimize import minimize

from .instruments import band_central_wavelengths, band_plot_colors
from .utils import logger

class AstronomicalObject():
"""Class representing an astronomical object.
Expand Down Expand Up @@ -137,7 +138,7 @@ def fit_gaussian_process(self, fix_scale=False, verbose=False,
(default), the scale is a free fit parameter.
verbose : bool (optional)
If True, output additional debugging information.
start_length_scale : float (optional)
guess_length_scale : float (optional)
The initial length scale to use for the fit. The default is 20
days.
preprocessing_kwargs : kwargs (optional)
Expand Down Expand Up @@ -174,7 +175,7 @@ def fit_gaussian_process(self, fix_scale=False, verbose=False,
scale = np.abs(fluxes[signal_to_noises.idxmax()])

kernel = (
(0.2 * scale)**2 *
(0.5 * scale)**2 *
kernels.Matern32Kernel([guess_length_scale**2, 6000**2], ndim=2)
)

Expand Down Expand Up @@ -218,7 +219,8 @@ def grad_neg_ln_like(p):
# Fit failed. Print out a warning, and use the initial guesses for
# fit parameters. This only really seems to happen for objects
# where the lightcurve is almost entirely noise.
logger.warn("GP fit failed for %s! Using guessed GP parameters.")
logger.warn("GP fit failed for %s! Using guessed GP parameters." %
self)
gp.set_parameter_vector(guess_parameters)

if verbose:
Expand Down

0 comments on commit c319b92

Please sign in to comment.