Skip to content

Commit fcffaa9

Browse files
committed
Added support for a free GP noise model.
1 parent a2f0fd4 commit fcffaa9

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

exoiris/exoiris.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,12 @@ def load_model(fname: Path | str, name: str | None = None):
8686
except KeyError:
8787
ip = 'bspline'
8888

89-
#TODO: save and load the noise model information
90-
a = ExoIris(name or hdul[0].header['NAME'], ldmodel=ldm, data=data, interpolation=ip)
89+
try:
90+
noise_model = hdul[0].header['NOISE']
91+
except KeyError:
92+
noise_model = "white"
93+
94+
a = ExoIris(name or hdul[0].header['NAME'], ldmodel=ldm, data=data, noise_model=noise_model, interpolation=ip)
9195
a.set_radius_ratio_knots(hdul['K_KNOTS'].data.astype('d'))
9296
a.set_limb_darkening_knots(hdul['LD_KNOTS'].data.astype('d'))
9397

@@ -117,7 +121,7 @@ class ExoIris:
117121
"""
118122

119123
def __init__(self, name: str, ldmodel, data: TSDataSet | TSData, nk: int = 50, nldc: int = 10, nthreads: int = 1,
120-
tmpars: dict | None = None, noise_model: str = 'white',
124+
tmpars: dict | None = None, noise_model: Literal["white", "fixed_gp", "free_gp"] = 'white',
121125
interpolation: Literal['bspline', 'pchip', 'makima'] = 'bspline'):
122126
"""
123127
Parameters
@@ -1062,6 +1066,7 @@ def save(self, overwrite: bool = False) -> None:
10621066
pri.header['t14'] = self.transit_duration
10631067
pri.header['ndgroups'] = self.data.size
10641068
pri.header['interp'] = self._tsa.interpolation
1069+
pri.header['noise'] = self._tsa.noise_model
10651070

10661071
pr = pf.ImageHDU(name='priors')
10671072
priors = [pickle.dumps(p) for p in self.ps]
@@ -1160,8 +1165,8 @@ def optimize_gp_hyperparameters(self,
11601165
log10_rho_bounds: float | tuple[float, float] = (-5, 0),
11611166
log10_sigma_prior=None, log10_rho_prior=None,
11621167
npop: int = 10, niter: int = 100):
1163-
if self._tsa.noise_model != 'fixed_gp':
1164-
raise ValueError("The noise model must be set to 'fixed_gp' before the hyperparameter optimization.")
1168+
if self._tsa.noise_model not in ('fixed_gp', 'free_gp'):
1169+
raise ValueError("The noise model must be set to 'fixed_gp' or 'free_gp' before the hyperparameter optimization.")
11651170

11661171
if self._wa is None:
11671172
raise ValueError("The white light curves must be fit using 'fit_white()' before the hyperparameter optimization.")

0 commit comments

Comments
 (0)