ExoIris 0.16.0__py3-none-any.whl → 0.17.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: ExoIris
3
- Version: 0.16.0
3
+ Version: 0.17.0
4
4
  Summary: Easy and robust exoplanet transmission spectroscopy.
5
5
  Author-email: Hannu Parviainen <hannu@iac.es>
6
6
  License: GPLv3
@@ -1,15 +1,15 @@
1
1
  exoiris/__init__.py,sha256=gaNfxNKXH41yRK35JghqackXpENyB-NOg-JlciqO1YU,1145
2
2
  exoiris/binning.py,sha256=-Y9hdK0jZj8DOS82keaprneid2lZ4rCx-keWlKi0LP8,6455
3
3
  exoiris/ephemeris.py,sha256=dthBkJztT5yAP6VnnO7jGvxikboFUQBUGPUfBCFrA3w,1316
4
- exoiris/exoiris.py,sha256=QR6c-4M_koYm8YA6gZst5jWiSfG57ciOTqR9foX0AgI,48315
4
+ exoiris/exoiris.py,sha256=_qQNSiv9r189rnGdKW7WInZhPzW4k0BdwL-Yg0HR9U8,48774
5
5
  exoiris/ldtkld.py,sha256=u4c5Yh6JlG0Zfec7-nOCQGXxIt1VVp9mniFMM7h-L6s,3489
6
6
  exoiris/tsdata.py,sha256=uIHml2RKRS6eAF9O0pkdvVj7xL7RqTHfHXQlCUhgtOc,31506
7
- exoiris/tslpf.py,sha256=gQJpLoz8WWmS6buAupDxFJnenUjXYQe_ZWcq_UZ2kls,27717
7
+ exoiris/tslpf.py,sha256=qZLQw2okT3j66ObFiJsboUC_Ay4w6xdyyIUI-NTMKaY,27902
8
8
  exoiris/tsmodel.py,sha256=6NaGY48fWHUT_7ti6Ao618PN-LgyoIhfQd8lZQqZ7hU,5160
9
9
  exoiris/util.py,sha256=5PynwYYHRrzyXJHskBtp2J-pcM59zsA1_VtDxencQm4,4630
10
- exoiris/wlpf.py,sha256=un-aEevAhqDfCocnP3I5lTdQDkLdmUBEbtvORRVR5LM,4370
11
- ExoIris-0.16.0.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
12
- ExoIris-0.16.0.dist-info/METADATA,sha256=9_-HWCcU8GrM0a_k2PS_JD22bkmPf7Mi4BxrG0DBuXg,4189
13
- ExoIris-0.16.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
14
- ExoIris-0.16.0.dist-info/top_level.txt,sha256=EoNxT6c5mQDcM0f_LUQB-ETsYg03lNaV3o2L_Yc6-aE,8
15
- ExoIris-0.16.0.dist-info/RECORD,,
10
+ exoiris/wlpf.py,sha256=Xelg7pRamgG9TRreXnphJo5w_qK7VwXbUJxnI_lphpU,4512
11
+ ExoIris-0.17.0.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
12
+ ExoIris-0.17.0.dist-info/METADATA,sha256=VwkZypbMCrzKvc_xcmN8nOo8THiu0KGpGGAuKBhE820,4189
13
+ ExoIris-0.17.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
14
+ ExoIris-0.17.0.dist-info/top_level.txt,sha256=EoNxT6c5mQDcM0f_LUQB-ETsYg03lNaV3o2L_Yc6-aE,8
15
+ ExoIris-0.17.0.dist-info/RECORD,,
exoiris/exoiris.py CHANGED
@@ -94,7 +94,7 @@ def load_model(fname: Path | str, name: str | None = None):
94
94
  a.period = hdul[0].header['P']
95
95
  a.zero_epoch = hdul[0].header['T0']
96
96
  a.transit_duration = hdul[0].header['T14']
97
- [d.calculate_ootmask(a.zero_epoch, a.period, a.transit_duration) for d in a.data]
97
+ [d.mask_transit(a.zero_epoch, a.period, a.transit_duration) for d in a.data]
98
98
  except KeyError:
99
99
  pass
100
100
 
@@ -164,13 +164,13 @@ class ExoIris:
164
164
  """
165
165
  return squeeze(self._tsa.lnposterior(pvp))
166
166
 
167
- def set_noise_model(self, noise_model: str) -> None:
167
+ def set_noise_model(self, noise_model: Literal['white', 'fixed_gp', 'free_gp']) -> None:
168
168
  """Set the noise model for the analysis.
169
169
 
170
170
  Parameters
171
171
  ----------
172
172
  noise_model
173
- The noise model to be used. Must be one of the following: white, fixed_gp, free_gp.
173
+ The noise model to be used.
174
174
 
175
175
  Raises
176
176
  ------
@@ -374,6 +374,26 @@ class ExoIris:
374
374
  """Posterior samples from the MCMC sampler."""
375
375
  return pd.DataFrame(self._tsa._mc_chains.reshape([-1, self.ndim]), columns=self.ps.names)
376
376
 
377
+ @property
378
+ def white_times(self) -> list[ndarray]:
379
+ """White light curve time arrays."""
380
+ return self._wa.times
381
+
382
+ @property
383
+ def white_fluxes(self) -> list[ndarray]:
384
+ """White light curve flux arrays."""
385
+ return self._wa.fluxes
386
+
387
+ @property
388
+ def white_models(self) -> list[ndarray]:
389
+ fm = self._wa.flux_model(self._wa._local_minimization.x)
390
+ return [fm[sl] for sl in self._wa.lcslices]
391
+
392
+ @property
393
+ def white_errors(self) -> list[ndarray]:
394
+ """White light curve flux error arrays."""
395
+ return self._wa.std_errors
396
+
377
397
  def add_radius_ratio_knots(self, knot_wavelengths: Sequence) -> None:
378
398
  """Add radius ratio (k) knots.
379
399
 
@@ -915,9 +935,6 @@ class ExoIris:
915
935
  pp = nanpercentile(residuals, [pmin, pmax])
916
936
  data.plot(ax=ax, data=residuals, vmin=pp[0], vmax=pp[1], cmap=cmap)
917
937
 
918
- tc = pv[1] + pv[2]*epoch(data.time.mean(), pv[1], pv[2])
919
- td = self.transit_duration
920
-
921
938
  if not show_names:
922
939
  ax.set_title("")
923
940
 
exoiris/tslpf.py CHANGED
@@ -240,23 +240,26 @@ class TSLPF(LogPosteriorFunction):
240
240
  self._gp_ferr = []
241
241
  self._gp = []
242
242
  for d in self.data:
243
- self._gp_time.append((tile(d.time[newaxis, :], (d.nwl, 1)) + arange(d.nwl)[:, newaxis]).ravel())
244
- self._gp_flux.append(d.fluxes.ravel())
245
- self._gp_ferr.append(d.errors.ravel())
243
+ self._gp_time.append((tile(d.time[newaxis, :], (d.nwl, 1)) + arange(d.nwl)[:, newaxis])[d.mask])
244
+ self._gp_flux.append(d.fluxes[d.mask])
245
+ self._gp_ferr.append(d.errors[d.mask])
246
246
  self._gp.append(GP(terms.Matern32Term(sigma=self._gp_flux[-1].std(), rho=0.1)))
247
247
  self._gp[-1].compute(self._gp_time[-1], yerr=self._gp_ferr[-1], quiet=True)
248
248
 
249
- def set_gp_hyperparameters(self, sigma: float, rho: float) -> None:
249
+ def set_gp_hyperparameters(self, sigma: float, rho: float, idata: int | None = None) -> None:
250
250
  """Sets the Gaussian Process hyperparameters assuming a Matern32 kernel.
251
251
 
252
252
  Parameters
253
253
  ----------
254
- sigma : float
254
+ sigma
255
255
  The kernel amplitude parameter.
256
256
 
257
- rho : float
257
+ rho
258
258
  The length scale parameter.
259
259
 
260
+ idata
261
+ The data set for which to set the hyperparameters. If None, the hyperparameters are set for all data sets.
262
+
260
263
  Raises
261
264
  ------
262
265
  RuntimeError
@@ -264,9 +267,10 @@ class TSLPF(LogPosteriorFunction):
264
267
  """
265
268
  if self._gp is None:
266
269
  raise RuntimeError('The GP needs to be initialized before setting hyperparameters.')
267
- for i, gp in enumerate(self._gp):
268
- gp.kernel = terms.Matern32Term(sigma=sigma, rho=rho)
269
- gp.compute(self._gp_time[i], yerr=self._gp_ferr[i], quiet=True)
270
+
271
+ for i in ([idata] or range(self.data.size)):
272
+ self._gp[i].kernel = terms.Matern32Term(sigma=sigma, rho=rho)
273
+ self._gp[i].compute(self._gp_time[i], yerr=self._gp_ferr[i], quiet=True)
270
274
 
271
275
  def set_gp_kernel(self, kernel: terms.Term) -> None:
272
276
  """Sets the kernel for the Gaussian Process (GP) model and recomputes the GP.
@@ -646,7 +650,7 @@ class TSLPF(LogPosteriorFunction):
646
650
  elif self._nm == NM_GP_FIXED:
647
651
  for j in range(npv):
648
652
  for i in range(self.data.size):
649
- lnl[j] += self._gp[i].log_likelihood(self._gp_flux[i] - fmod[i][j].ravel())
653
+ lnl[j] += self._gp[i].log_likelihood(self._gp_flux[i] - fmod[i][j][self.data[i].mask])
650
654
  else:
651
655
  raise NotImplementedError("The free GP noise model hasn't been implemented yet.")
652
656
  return lnl if npv > 1 else lnl[0]
exoiris/wlpf.py CHANGED
@@ -15,7 +15,7 @@
15
15
  # along with this program. If not, see <https://www.gnu.org/licenses/>.
16
16
  from matplotlib.figure import Figure
17
17
  from matplotlib.pyplot import subplots, setp
18
- from numpy import log10, diff, sqrt, floor, ceil, arange, newaxis, nanmean, isfinite
18
+ from numpy import log10, diff, sqrt, floor, ceil, arange, newaxis, nanmean, isfinite, nan, where, nanstd
19
19
  from scipy.optimize import minimize
20
20
 
21
21
  from pytransit import BaseLPF, LinearModelBaseline
@@ -26,16 +26,18 @@ from .tslpf import TSLPF
26
26
  class WhiteLPF(BaseLPF):
27
27
  def __init__(self, tsa: TSLPF):
28
28
  self.tsa = tsa
29
- fluxes, times = [], []
29
+ fluxes, times, errors = [], [], []
30
30
  for t, f in zip(tsa.data.times, tsa.data.fluxes):
31
- f = nanmean(f, 0)
32
- m = isfinite(f)
31
+ mf = nanmean(f, 0)
32
+ m = isfinite(mf)
33
33
  times.append(t[m])
34
- fluxes.append(f[m])
34
+ fluxes.append(mf[m])
35
+ errors.append(nanstd(where(m, f, nan), 0) / sqrt(f.shape[0]))
35
36
  covs = [(t-t.mean())[:, newaxis] for t in times]
37
+ self.std_errors = errors
36
38
 
37
- super().__init__('white', tsa.data.unique_noise_groups, times, fluxes, covariates=covs, wnids=tsa.data.ngids,
38
- pbids=tsa.data.ngids)
39
+ super().__init__('white', tsa.data.unique_noise_groups, times, fluxes,
40
+ covariates=covs, wnids=tsa.data.ngids, pbids=tsa.data.ngids)
39
41
  self.set_prior('tc', tsa.ps[tsa.ps.find_pid('tc')].prior)
40
42
  self.set_prior('p', tsa.ps[tsa.ps.find_pid('p')].prior)
41
43
  self.set_prior('rho', tsa.ps[tsa.ps.find_pid('rho')].prior)