Skip to content

Commit 96657c2

Browse files
committed
Enhanced white light curve handling
- Improved reading and storing of white light curve data, including time, flux, errors, and models. - Updated white light curve properties for more flexible access. - Enhanced FITS export to include refined white curve data structure.
1 parent ad03bfe commit 96657c2

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

exoiris/exoiris.py

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,12 @@ def load_model(fname: Path | str, name: str | None = None):
9696
try:
9797
tb = Table.read(hdul['WHITE_DATA'])
9898
white_ids = tb['id'].data
99-
model_flux = tb['mod_flux'].data
10099
uids = unique(white_ids)
101-
a._white_models = [model_flux[white_ids == i] for i in uids]
100+
a._white_times = [tb['time'].data[white_ids == i] for i in uids]
101+
a._white_fluxes = [tb['flux_obs'].data[white_ids == i] for i in uids]
102+
a._white_errors = [tb['flux_obs_err'].data[white_ids == i] for i in uids]
103+
a._white_models = [tb['flux_mod'].data[white_ids == i] for i in uids]
104+
102105
except KeyError:
103106
pass
104107

@@ -181,6 +184,10 @@ def __init__(self, name: str, ldmodel, data: TSDataGroup | TSData, nk: int = 50,
181184
self.zero_epoch: float | None = None
182185
self.transit_duration: float | None= None
183186
self._tref = floor(self.data.tmin)
187+
188+
self._white_times: None | list[ndarray] = None
189+
self._white_fluxes: None | list[ndarray] = None
190+
self._white_errors: None | list[ndarray] = None
184191
self._white_models: None | list[ndarray] = None
185192

186193
def lnposterior(self, pvp: ndarray) -> ndarray:
@@ -413,26 +420,35 @@ def posterior_samples(self) -> pd.DataFrame:
413420
@property
414421
def white_times(self) -> list[ndarray]:
415422
"""White light curve time arrays."""
416-
return self._wa.times
423+
if self._wa is None:
424+
return self._white_times
425+
else:
426+
return self._wa.times
417427

418428
@property
419429
def white_fluxes(self) -> list[ndarray]:
420430
"""White light curve flux arrays."""
421-
return self._wa.fluxes
431+
if self._wa is None:
432+
return self._white_fluxes
433+
else:
434+
return self._wa.fluxes
422435

423436
@property
424437
def white_models(self) -> list[ndarray]:
425438
"""Fitted white light curve flux model arrays."""
426-
if self._wa._local_minimization is not None:
439+
if self._wa is None:
440+
return self._white_models
441+
else:
427442
fm = self._wa.flux_model(self._wa._local_minimization.x)
428443
return [fm[sl] for sl in self._wa.lcslices]
429-
else:
430-
return self._white_models
431444

432445
@property
433446
def white_errors(self) -> list[ndarray]:
434447
"""White light curve flux error arrays."""
435-
return self._wa.std_errors
448+
if self._wa is None:
449+
return self._white_errors
450+
else:
451+
return self._wa.std_errors
436452

437453
def add_radius_ratio_knots(self, knot_wavelengths: Sequence) -> None:
438454
"""Add radius ratio (k) knots.
@@ -1096,7 +1112,7 @@ def save(self, overwrite: bool = False) -> None:
10961112
hdul = pf.HDUList([pri, k_knots, ld_knots, pr])
10971113
hdul += self.data.export_fits()
10981114

1099-
if self._wa._local_minimization is not None:
1115+
if self._wa is not None and self._wa._local_minimization is not None:
11001116
wa_data = pf.BinTableHDU(
11011117
Table(
11021118
[
@@ -1106,7 +1122,7 @@ def save(self, overwrite: bool = False) -> None:
11061122
self._wa.ofluxa,
11071123
concatenate(self._wa.std_errors),
11081124
],
1109-
names="id time mod_flux obs_flux obs_error".split(),
1125+
names="id time flux_mod flux_obs flux_obs_err".split(),
11101126
), name='white_data'
11111127
)
11121128
hdul.append(wa_data)

0 commit comments

Comments
 (0)