Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update reduction API to fully suppress logging #1224

Merged
merged 8 commits into from
Sep 4, 2023
21 changes: 11 additions & 10 deletions exotic/api/elca.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,14 @@
# Fit an exoplanet transit model to time series data.
# ########################################################################### #

from astropy.time import Time
import copy
import numpy as np
from itertools import cycle
import matplotlib.pyplot as plt
import numpy as np
from scipy import spatial
from scipy.optimize import least_squares
from scipy.signal import savgol_filter
from scipy import spatial

try:
from ultranest import ReactiveNestedSampler
Expand Down Expand Up @@ -168,6 +169,7 @@ def __init__(self, time, data, dataerr, airmass, prior, bounds, neighbors=200, m
self.verbose = verbose
self.mode = mode
self.neighbors = neighbors
self.results = None
if self.mode == "lm":
self.fit_LM()
elif self.mode == "ns":
Expand Down Expand Up @@ -322,12 +324,10 @@ def prior_transform(upars):
self.results['posterior']['errup'][i]]
except NameError:
self.ns_type = 'dynesty'
dsampler = dynesty.DynamicNestedSampler(loglike, prior_transform,
ndim=len(freekeys), bound='multi', sample='unif'
)
dsampler = dynesty.DynamicNestedSampler(loglike, prior_transform, ndim=len(freekeys),
bound='multi', sample='unif')
dsampler.run_nested(maxcall=int(1e5), dlogz_init=0.05,
maxbatch=10, nlive_batch=100
)
maxbatch=10, nlive_batch=100, print_progressbool=self.verbose)
self.results = dsampler.results

tests = [copy.deepcopy(self.prior) for i in range(5)]
Expand Down Expand Up @@ -558,7 +558,7 @@ def __init__(self, input_data, global_bounds, local_bounds, individual_fit=False
self.individual_fit = individual_fit
self.stdev_cutoff = stdev_cutoff
self.verbose = verbose

self.results = None
self.fit_nested()

def fit_nested(self):
Expand Down Expand Up @@ -680,10 +680,11 @@ def loglike(pars):
#clean_name = self.lc_data[n].get('name', n).replace(' ','_').replace('(','').replace(')','').replace('[','').replace(']','').replace('-','_').split('-')[0]
freekeys.append(f"local_{k}_{n}")

noop = lambda *args, **kwargs: None
if self.verbose:
self.results = ReactiveNestedSampler(freekeys, loglike, prior_transform).run(max_ncalls=1e6)
self.results = ReactiveNestedSampler(freekeys, loglike, prior_transform).run(max_ncalls=1e6, show_status=True)
else:
self.results = ReactiveNestedSampler(freekeys, loglike, prior_transform).run(max_ncalls=1e6, show_status=self.verbose, viz_callback=self.verbose)
self.results = ReactiveNestedSampler(freekeys, loglike, prior_transform).run(max_ncalls=1e6, show_status=False, viz_callback=noop)

self.quantiles = {}
self.errors = {}
Expand Down
Loading