mimical 0.0.4__tar.gz → 0.0.6__tar.gz
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.
- {mimical-0.0.4 → mimical-0.0.6}/PKG-INFO +1 -1
- {mimical-0.0.4 → mimical-0.0.6}/mimical/fitting/fitter.py +14 -11
- {mimical-0.0.4 → mimical-0.0.6}/mimical.egg-info/PKG-INFO +1 -1
- {mimical-0.0.4 → mimical-0.0.6}/setup.py +1 -1
- {mimical-0.0.4 → mimical-0.0.6}/README.md +0 -0
- {mimical-0.0.4 → mimical-0.0.6}/mimical/__init__.py +0 -0
- {mimical-0.0.4 → mimical-0.0.6}/mimical/fitting/__init__.py +0 -0
- {mimical-0.0.4 → mimical-0.0.6}/mimical/fitting/prior_handler.py +0 -0
- {mimical-0.0.4 → mimical-0.0.6}/mimical/plotting/__init__.py +0 -0
- {mimical-0.0.4 → mimical-0.0.6}/mimical/plotting/plotting.py +0 -0
- {mimical-0.0.4 → mimical-0.0.6}/mimical/utils/__init__.py +0 -0
- {mimical-0.0.4 → mimical-0.0.6}/mimical/utils/filter_set.py +0 -0
- {mimical-0.0.4 → mimical-0.0.6}/mimical.egg-info/SOURCES.txt +0 -0
- {mimical-0.0.4 → mimical-0.0.6}/mimical.egg-info/dependency_links.txt +0 -0
- {mimical-0.0.4 → mimical-0.0.6}/mimical.egg-info/requires.txt +0 -0
- {mimical-0.0.4 → mimical-0.0.6}/mimical.egg-info/top_level.txt +0 -0
- {mimical-0.0.4 → mimical-0.0.6}/setup.cfg +0 -0
|
@@ -58,7 +58,7 @@ class mimical(object):
|
|
|
58
58
|
"""
|
|
59
59
|
|
|
60
60
|
|
|
61
|
-
def __init__(self, id, images, filt_list, psfs, user_prior, astropy_model=models.Sersic2D(), pool=None):
|
|
61
|
+
def __init__(self, id, images, filt_list, psfs, user_prior, astropy_model=models.Sersic2D(), pool=None, timeout=3600):
|
|
62
62
|
|
|
63
63
|
self.id = id
|
|
64
64
|
|
|
@@ -82,6 +82,7 @@ class mimical(object):
|
|
|
82
82
|
self.t0 = time.time()
|
|
83
83
|
self.calls = 0
|
|
84
84
|
|
|
85
|
+
self.timeout=timeout
|
|
85
86
|
self.pool = pool
|
|
86
87
|
|
|
87
88
|
|
|
@@ -148,14 +149,14 @@ class mimical(object):
|
|
|
148
149
|
|
|
149
150
|
|
|
150
151
|
if os.path.isfile(dir_path+'/mimical/posteriors' + f'/{self.id}.txt'):
|
|
151
|
-
samples = pd.read_csv(dir_path+'/mimical/posteriors' + f'/{self.id}.txt', delimiter=' ').to_numpy()
|
|
152
|
+
self.samples = pd.read_csv(dir_path+'/mimical/posteriors' + f'/{self.id}.txt', delimiter=' ').to_numpy()
|
|
152
153
|
|
|
153
154
|
else:
|
|
154
155
|
# Run sampler
|
|
155
156
|
t0 = time.time()
|
|
156
157
|
#sampler = Sampler(self.fitter_prior, self.lnlike, n_live=400, filepath= dir_path+'/bogout'+f'/{self.id}.hdf5', resume=True, pool=self.pool)
|
|
157
158
|
sampler = Sampler(self.fitter_prior, self.lnlike, n_live=400, pool=self.pool)
|
|
158
|
-
sampler.run(verbose=True, timeout=
|
|
159
|
+
sampler.run(verbose=True, timeout=self.timeout)
|
|
159
160
|
print(f"Sampling time (minutes): {(time.time()-t0)/60}")
|
|
160
161
|
|
|
161
162
|
# Sample the posterior information
|
|
@@ -168,20 +169,22 @@ class mimical(object):
|
|
|
168
169
|
# Sample an appropriately weighted posterior for representative samples.
|
|
169
170
|
n_post = 10000
|
|
170
171
|
indices = np.random.choice(np.arange(points.shape[0]), size = n_post, p=np.exp(log_w))
|
|
171
|
-
samples = points[indices]
|
|
172
|
-
samples_df = pd.DataFrame(data=samples, columns=self.fitter_prior.keys)
|
|
172
|
+
self.samples = points[indices]
|
|
173
|
+
samples_df = pd.DataFrame(data=self.samples, columns=self.fitter_prior.keys)
|
|
173
174
|
samples_df.to_csv(dir_path+'/mimical/posteriors' + f'/{self.id}.txt', sep=' ', index=False)
|
|
174
175
|
|
|
175
|
-
|
|
176
|
-
# Plot and save the median-parameter fit
|
|
177
|
-
Plotter().plot_median(self.images, self.wavs, self.convolved_models, samples, list(self.fitter_prior.keys), self.prior_handler)
|
|
178
|
-
plt.savefig(dir_path+'/mimical/plots' + f'/{self.id}_best_model.pdf', bbox_inches='tight')
|
|
179
|
-
|
|
180
176
|
# Return the median-parameter model
|
|
181
|
-
fit_dic = dict(zip((np.array((list(self.fitter_prior.keys)))+"_50").tolist(), np.median(samples, axis=0).tolist()))
|
|
177
|
+
fit_dic = dict(zip((np.array((list(self.fitter_prior.keys)))+"_50").tolist(), np.median(self.samples, axis=0).tolist()))
|
|
182
178
|
|
|
183
179
|
print("Finished.")
|
|
184
180
|
print(" ")
|
|
185
181
|
|
|
186
182
|
return fit_dic
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def plot_model(self):
|
|
186
|
+
# Plot and save the median-parameter fit
|
|
187
|
+
Plotter().plot_median(self.images, self.wavs, self.convolved_models, self.samples, list(self.fitter_prior.keys), self.prior_handler)
|
|
188
|
+
plt.savefig(dir_path+'/mimical/plots' + f'/{self.id}_best_model.pdf', bbox_inches='tight')
|
|
189
|
+
|
|
187
190
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|