mimical 0.0.6__tar.gz → 0.0.7__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mimical
3
- Version: 0.0.6
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
@@ -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
+ self.success = True
152
153
  self.samples = pd.read_csv(dir_path+'/mimical/posteriors' + f'/{self.id}.txt', delimiter=' ').to_numpy()
153
-
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
 
@@ -173,18 +184,21 @@ class mimical(object):
173
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
 
176
- # Return the median-parameter model
177
- fit_dic = dict(zip((np.array((list(self.fitter_prior.keys)))+"_50").tolist(), np.median(self.samples, axis=0).tolist()))
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()))
178
189
 
179
- print("Finished.")
180
- print(" ")
190
+ print("Finished.")
191
+ print(" ")
181
192
 
182
- return fit_dic
193
+ return fit_dic
183
194
 
184
195
 
185
196
  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')
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')
189
203
 
190
204
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mimical
3
- Version: 0.0.6
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
@@ -8,7 +8,7 @@ long_description = (this_directory / "README.md").read_text()
8
8
  setup(
9
9
  name='mimical',
10
10
 
11
- version='0.0.6',
11
+ version='0.0.7',
12
12
 
13
13
  description='Intesity modelling of multiply-imaged objects',
14
14
 
File without changes
File without changes
File without changes