mimical 0.0.8__tar.gz → 0.1.0__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.8 → mimical-0.1.0}/PKG-INFO +1 -1
- {mimical-0.0.8 → mimical-0.1.0}/mimical/fitting/fitter.py +15 -5
- {mimical-0.0.8 → mimical-0.1.0}/mimical/plotting/plotting.py +23 -8
- {mimical-0.0.8 → mimical-0.1.0}/mimical.egg-info/PKG-INFO +1 -1
- {mimical-0.0.8 → mimical-0.1.0}/setup.py +1 -1
- {mimical-0.0.8 → mimical-0.1.0}/README.md +0 -0
- {mimical-0.0.8 → mimical-0.1.0}/mimical/__init__.py +0 -0
- {mimical-0.0.8 → mimical-0.1.0}/mimical/fitting/__init__.py +0 -0
- {mimical-0.0.8 → mimical-0.1.0}/mimical/fitting/prior_handler.py +0 -0
- {mimical-0.0.8 → mimical-0.1.0}/mimical/plotting/__init__.py +0 -0
- {mimical-0.0.8 → mimical-0.1.0}/mimical/utils/__init__.py +0 -0
- {mimical-0.0.8 → mimical-0.1.0}/mimical/utils/filter_set.py +0 -0
- {mimical-0.0.8 → mimical-0.1.0}/mimical.egg-info/SOURCES.txt +0 -0
- {mimical-0.0.8 → mimical-0.1.0}/mimical.egg-info/dependency_links.txt +0 -0
- {mimical-0.0.8 → mimical-0.1.0}/mimical.egg-info/requires.txt +0 -0
- {mimical-0.0.8 → mimical-0.1.0}/mimical.egg-info/top_level.txt +0 -0
- {mimical-0.0.8 → mimical-0.1.0}/setup.cfg +0 -0
|
@@ -39,7 +39,7 @@ class mimical(object):
|
|
|
39
39
|
A 3D array of image data with slices for each filter. Each image
|
|
40
40
|
must be the same shape.
|
|
41
41
|
|
|
42
|
-
filt_list :
|
|
42
|
+
filt_list : str or list
|
|
43
43
|
A list of path strings to the filter transmission curve files, relative
|
|
44
44
|
to the current working directory. Must be in ascending order with effective wavelength.
|
|
45
45
|
|
|
@@ -60,6 +60,14 @@ class mimical(object):
|
|
|
60
60
|
|
|
61
61
|
def __init__(self, id, images, filt_list, psfs, user_prior, astropy_model=models.Sersic2D(), pool=None, timeout=3600):
|
|
62
62
|
|
|
63
|
+
# Helper when only one image is passed
|
|
64
|
+
if len(images.shape)==2:
|
|
65
|
+
images = np.array(([images]))
|
|
66
|
+
if (type(filt_list).__name__=='str') | (type(filt_list).__name__=='str_'):
|
|
67
|
+
filt_list = [filt_list]
|
|
68
|
+
if len(psfs.shape)==2:
|
|
69
|
+
psfs = np.array(([psfs]))
|
|
70
|
+
|
|
63
71
|
self.id = id
|
|
64
72
|
|
|
65
73
|
print(f"Fitting object {id}")
|
|
@@ -88,6 +96,7 @@ class mimical(object):
|
|
|
88
96
|
|
|
89
97
|
|
|
90
98
|
|
|
99
|
+
|
|
91
100
|
def lnlike(self, param_dict):
|
|
92
101
|
""" Returns the log-likelihood for a given parameter vector. """
|
|
93
102
|
|
|
@@ -152,10 +161,11 @@ class mimical(object):
|
|
|
152
161
|
self.success = True
|
|
153
162
|
self.samples = pd.read_csv(dir_path+'/mimical/posteriors' + f'/{self.id}.txt', delimiter=' ').to_numpy()
|
|
154
163
|
fit_dic = dict(zip((np.array((list(self.fitter_prior.keys)))+"_50").tolist(), np.median(self.samples, axis=0).tolist()))
|
|
155
|
-
print("
|
|
164
|
+
print(f"Loading existing posterior at " + dir_path + '/mimical/posteriors' + f'/{self.id}.txt')
|
|
156
165
|
print(" ")
|
|
157
166
|
return fit_dic
|
|
158
167
|
|
|
168
|
+
|
|
159
169
|
# Run sampler
|
|
160
170
|
t0 = time.time()
|
|
161
171
|
#sampler = Sampler(self.fitter_prior, self.lnlike, n_live=400, filepath= dir_path+'/bogout'+f'/{self.id}.hdf5', resume=True, pool=self.pool)
|
|
@@ -165,7 +175,7 @@ class mimical(object):
|
|
|
165
175
|
|
|
166
176
|
if self.success != True:
|
|
167
177
|
|
|
168
|
-
print("Sampling failed (timeout
|
|
178
|
+
print("Sampling failed (timeout).")
|
|
169
179
|
print(" ")
|
|
170
180
|
return {}
|
|
171
181
|
|
|
@@ -187,7 +197,7 @@ class mimical(object):
|
|
|
187
197
|
# Return the median-parameter model
|
|
188
198
|
fit_dic = dict(zip((np.array((list(self.fitter_prior.keys)))+"_50").tolist(), np.median(self.samples, axis=0).tolist()))
|
|
189
199
|
|
|
190
|
-
print("
|
|
200
|
+
print("Sampling finished successfully.")
|
|
191
201
|
print(" ")
|
|
192
202
|
|
|
193
203
|
return fit_dic
|
|
@@ -195,7 +205,7 @@ class mimical(object):
|
|
|
195
205
|
|
|
196
206
|
def plot_model(self):
|
|
197
207
|
if self.success != True:
|
|
198
|
-
print(f'
|
|
208
|
+
print(f'Sampling failed, cannot plot model for {self.id}.')
|
|
199
209
|
else:
|
|
200
210
|
# Plot and save the median-parameter fit
|
|
201
211
|
Plotter().plot_median(self.images, self.wavs, self.convolved_models, self.samples, list(self.fitter_prior.keys), self.prior_handler)
|
|
@@ -57,16 +57,31 @@ class Plotter(object):
|
|
|
57
57
|
|
|
58
58
|
median_models = np.median(models, axis=0)
|
|
59
59
|
|
|
60
|
-
for i in range(len(wavs)):
|
|
61
60
|
|
|
62
|
-
|
|
61
|
+
if len(wavs)==1:
|
|
62
|
+
for i in range(len(wavs)):
|
|
63
|
+
v = np.percentile(images[-1], 99.9)
|
|
63
64
|
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
axes[0].imshow(images[i], vmax=v, vmin=-v)
|
|
66
|
+
axes[0].set_axis_off()
|
|
66
67
|
|
|
67
|
-
|
|
68
|
-
|
|
68
|
+
axes[1].imshow(median_models[i], vmax=v, vmin=-v)
|
|
69
|
+
axes[1].set_axis_off()
|
|
69
70
|
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
axes[2].imshow(images[i]-median_models[i], vmax=v, vmin=-v)
|
|
72
|
+
axes[2].set_axis_off()
|
|
73
|
+
|
|
74
|
+
else:
|
|
75
|
+
for i in range(len(wavs)):
|
|
76
|
+
|
|
77
|
+
v = np.percentile(images[-1], 99.9)
|
|
78
|
+
|
|
79
|
+
axes[0,i].imshow(images[i], vmax=v, vmin=-v)
|
|
80
|
+
axes[0,i].set_axis_off()
|
|
81
|
+
|
|
82
|
+
axes[1,i].imshow(median_models[i], vmax=v, vmin=-v)
|
|
83
|
+
axes[1,i].set_axis_off()
|
|
84
|
+
|
|
85
|
+
axes[2,i].imshow(images[i]-median_models[i], vmax=v, vmin=-v)
|
|
86
|
+
axes[2,i].set_axis_off()
|
|
72
87
|
|
|
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
|