mimical 0.0.5__py3-none-any.whl → 0.0.7__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.
mimical/fitting/fitter.py CHANGED
@@ -149,16 +149,27 @@ class mimical(object):
149
149
 
150
150
 
151
151
  if os.path.isfile(dir_path+'/mimical/posteriors' + f'/{self.id}.txt'):
152
- samples = pd.read_csv(dir_path+'/mimical/posteriors' + f'/{self.id}.txt', delimiter=' ').to_numpy()
153
-
152
+ self.success = True
153
+ self.samples = pd.read_csv(dir_path+'/mimical/posteriors' + f'/{self.id}.txt', delimiter=' ').to_numpy()
154
+ fit_dic = dict(zip((np.array((list(self.fitter_prior.keys)))+"_50").tolist(), np.median(self.samples, axis=0).tolist()))
155
+ print("Finished.")
156
+ print(" ")
157
+ return fit_dic
158
+
159
+ # Run sampler
160
+ t0 = time.time()
161
+ #sampler = Sampler(self.fitter_prior, self.lnlike, n_live=400, filepath= dir_path+'/bogout'+f'/{self.id}.hdf5', resume=True, pool=self.pool)
162
+ sampler = Sampler(self.fitter_prior, self.lnlike, n_live=400, pool=self.pool)
163
+ self.success = sampler.run(verbose=True, timeout=self.timeout)
164
+ print(f"Sampling time (minutes): {(time.time()-t0)/60}")
165
+
166
+ if self.success != True:
167
+
168
+ print("Sampling failed (timout).")
169
+ print(" ")
170
+ return {}
171
+
154
172
  else:
155
- # Run sampler
156
- t0 = time.time()
157
- #sampler = Sampler(self.fitter_prior, self.lnlike, n_live=400, filepath= dir_path+'/bogout'+f'/{self.id}.hdf5', resume=True, pool=self.pool)
158
- sampler = Sampler(self.fitter_prior, self.lnlike, n_live=400, pool=self.pool)
159
- sampler.run(verbose=True, timeout=self.timeout)
160
- print(f"Sampling time (minutes): {(time.time()-t0)/60}")
161
-
162
173
  # Sample the posterior information
163
174
  points, log_w, log_l = sampler.posterior()
164
175
 
@@ -169,20 +180,25 @@ class mimical(object):
169
180
  # Sample an appropriately weighted posterior for representative samples.
170
181
  n_post = 10000
171
182
  indices = np.random.choice(np.arange(points.shape[0]), size = n_post, p=np.exp(log_w))
172
- samples = points[indices]
173
- samples_df = pd.DataFrame(data=samples, columns=self.fitter_prior.keys)
183
+ self.samples = points[indices]
184
+ samples_df = pd.DataFrame(data=self.samples, columns=self.fitter_prior.keys)
174
185
  samples_df.to_csv(dir_path+'/mimical/posteriors' + f'/{self.id}.txt', sep=' ', index=False)
175
186
 
187
+ # Return the median-parameter model
188
+ fit_dic = dict(zip((np.array((list(self.fitter_prior.keys)))+"_50").tolist(), np.median(self.samples, axis=0).tolist()))
176
189
 
177
- # Plot and save the median-parameter fit
178
- Plotter().plot_median(self.images, self.wavs, self.convolved_models, samples, list(self.fitter_prior.keys), self.prior_handler)
179
- plt.savefig(dir_path+'/mimical/plots' + f'/{self.id}_best_model.pdf', bbox_inches='tight')
190
+ print("Finished.")
191
+ print(" ")
180
192
 
181
- # Return the median-parameter model
182
- fit_dic = dict(zip((np.array((list(self.fitter_prior.keys)))+"_50").tolist(), np.median(samples, axis=0).tolist()))
193
+ return fit_dic
194
+
183
195
 
184
- print("Finished.")
185
- print(" ")
196
+ def plot_model(self):
197
+ if self.success != True:
198
+ print(f'Failed sampling - cannot plot model for {self.id}.')
199
+ else:
200
+ # Plot and save the median-parameter fit
201
+ Plotter().plot_median(self.images, self.wavs, self.convolved_models, self.samples, list(self.fitter_prior.keys), self.prior_handler)
202
+ plt.savefig(dir_path+'/mimical/plots' + f'/{self.id}_best_model.pdf', bbox_inches='tight')
186
203
 
187
- return fit_dic
188
204
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mimical
3
- Version: 0.0.5
3
+ Version: 0.0.7
4
4
  Summary: Intesity modelling of multiply-imaged objects
5
5
  Author: Struan Stevenson
6
6
  Author-email: struan.stevenson@ed.ac.uk
@@ -1,12 +1,12 @@
1
1
  mimical/__init__.py,sha256=cBuyDtPwn6KcIkjlT7oct36jigvYDJmbZNmnt1I1QJU,75
2
2
  mimical/fitting/__init__.py,sha256=xcnLoeBDtt4Le5NhD6GhJe2ZRPNSsEySRHFYNuJyNEQ,69
3
- mimical/fitting/fitter.py,sha256=dzPbsJ6DkllZHFil-rZNFXzFKsEX_3kyVGjyt6_nm2M,7741
3
+ mimical/fitting/fitter.py,sha256=snF9OS6enzjBvcmFPyS5NmVljRRL54So4JN9QfE-SQY,8309
4
4
  mimical/fitting/prior_handler.py,sha256=yXvxbohS6f94CMRyeIViFc83hRYAj82IZNA5mzhMSRw,4193
5
5
  mimical/plotting/__init__.py,sha256=I1ZpQA48g-YPkqwrDGgTrqaTxDUgR8n0mbBX0MdbZtU,30
6
6
  mimical/plotting/plotting.py,sha256=OWTR-uOT4UpBw0XcKpl_uFSODuEdcfw7nIk3Sf1cOGY,2646
7
7
  mimical/utils/__init__.py,sha256=yolMgYFpvXoHuyV-ijGo26SQ0_niw0gz__iAFgdiQiY,35
8
8
  mimical/utils/filter_set.py,sha256=EITLa2c3FG3n1-v7KatKRwHCRyfZ4TTjsi_WM7Bz64k,6819
9
- mimical-0.0.5.dist-info/METADATA,sha256=7urHqR68dVp4-X8i-DOj5BRjoQ7apWHVytNwm99yen8,831
10
- mimical-0.0.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
11
- mimical-0.0.5.dist-info/top_level.txt,sha256=z6HTYpsoNjLUFayXjn8WyjX8C1mIbZw8Arb334cUbwc,8
12
- mimical-0.0.5.dist-info/RECORD,,
9
+ mimical-0.0.7.dist-info/METADATA,sha256=KMd6HC02m-F7FQ64pHZi_aHBjyOG__rL-Lpc-mUwUvk,831
10
+ mimical-0.0.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
11
+ mimical-0.0.7.dist-info/top_level.txt,sha256=z6HTYpsoNjLUFayXjn8WyjX8C1mIbZw8Arb334cUbwc,8
12
+ mimical-0.0.7.dist-info/RECORD,,