ACID-code-v2 0.2.2a2__tar.gz → 0.2.2a4__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.
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/PKG-INFO +1 -1
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/src/ACID_code_v2/ACID.py +88 -14
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/src/ACID_code_v2.egg-info/PKG-INFO +1 -1
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/src/ACID_code_v2.egg-info/SOURCES.txt +0 -1
- acid_code_v2-0.2.2a2/src/ACID_code_v2/mcmc_utils.py +0 -90
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/.gitattributes +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/.github/workflows/publish.yml +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/.gitignore +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/.other_scripts/5_residual_profiles.py +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/.other_scripts/8_master_out_profiles.py +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/.readthedocs.yaml +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/.vscode/launch.json +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/LICENSE +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/README.md +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/acid.yml +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/docs/ACID.rst +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/docs/conf.py +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/docs/index.rst +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/docs/installation.rst +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/docs/make.bat +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/docs/requirements.txt +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/docs/using_ACID.rst +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/example/.make_syn_dat.py +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/example/example_linelist.txt +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/example/sample_spec_1.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/example/sample_spec_2.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/example/sample_spec_3.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/example/tutorial_code.py +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/pyproject.toml +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/setup.cfg +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/src/ACID_code_v2/LSD.py +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/src/ACID_code_v2/__init__.py +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/src/ACID_code_v2/utils.py +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/src/ACID_code_v2.egg-info/dependency_links.txt +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/src/ACID_code_v2.egg-info/requires.txt +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/src/ACID_code_v2.egg-info/top_level.txt +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/.DS_Store +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-28T21:11:56.678_blaze_B.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-28T21:11:56.678_flat_A.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-28T21:11:56.678_flat_B.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-28T21:11:56.678_lamp_A.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-28T21:11:56.678_lamp_B.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-28T21:11:56.678_order_profile.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:02:50.897_bis_G2_A.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:02:50.897_bis_G2_B.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:02:50.897_bis_K5_A.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:02:50.897_ccf_G2_A.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:02:50.897_ccf_G2_B.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:02:50.897_ccf_K5_A.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:02:50.897_e2ds_A.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:02:50.897_e2ds_B.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:02:50.897_s1d_A.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:02:50.897_s1d_B.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:08:22.216_bis_G2_A.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:08:22.216_bis_G2_B.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:08:22.216_bis_K5_A.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:08:22.216_ccf_G2_A.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:08:22.216_ccf_G2_B.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:08:22.216_ccf_K5_A.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:08:22.216_e2ds_A.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:08:22.216_e2ds_B.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:08:22.216_s1d_A.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:08:22.216_s1d_B.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:13:54.107_bis_G2_A.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:13:54.107_bis_G2_B.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:13:54.107_bis_K5_A.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:13:54.107_ccf_G2_A.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:13:54.107_ccf_G2_B.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:13:54.107_ccf_K5_A.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:13:54.107_e2ds_A.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:13:54.107_e2ds_B.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:13:54.107_s1d_A.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:13:54.107_s1d_B.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:19:25.377_bis_G2_A.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:19:25.377_bis_G2_B.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:19:25.377_bis_K5_A.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:19:25.377_ccf_G2_A.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:19:25.377_ccf_G2_B.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:19:25.377_ccf_K5_A.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:19:25.377_e2ds_A.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:19:25.377_e2ds_B.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:19:25.377_s1d_A.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:19:25.377_s1d_B.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:24:57.238_bis_G2_A.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:24:57.238_bis_G2_B.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:24:57.238_bis_K5_A.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:24:57.238_ccf_G2_A.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:24:57.238_ccf_G2_B.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:24:57.238_ccf_K5_A.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:24:57.238_e2ds_A.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:24:57.238_e2ds_B.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:24:57.238_s1d_A.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:24:57.238_s1d_B.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:30:28.617_bis_G2_A.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:30:28.617_bis_G2_B.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:30:28.617_bis_K5_A.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:30:28.617_ccf_G2_A.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:30:28.617_ccf_G2_B.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:30:28.617_ccf_K5_A.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:30:28.617_e2ds_A.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:30:28.617_e2ds_B.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:30:28.617_s1d_A.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:30:28.617_s1d_B.fits +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/tests.py +0 -0
- {acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/tutorial_test.py +0 -0
|
@@ -8,7 +8,6 @@ from functools import partial
|
|
|
8
8
|
from multiprocessing import Pool
|
|
9
9
|
from . import utils
|
|
10
10
|
from . import LSD
|
|
11
|
-
from . import mcmc_utils
|
|
12
11
|
|
|
13
12
|
warnings.filterwarnings("ignore")
|
|
14
13
|
importlib.reload(LSD)
|
|
@@ -201,14 +200,92 @@ def combine_spec(wavelengths_f, spectra_f, errors_f, sns_f):
|
|
|
201
200
|
|
|
202
201
|
return reference_wave, spectrum_f, spec_errors_f, sn_f
|
|
203
202
|
|
|
203
|
+
def model_func(inputs, x):
|
|
204
|
+
## model for the mcmc - takes the profile(z) and the continuum coefficents(inputs[k_max:]) to create a model spectrum.
|
|
205
|
+
z = inputs[:k_max]
|
|
206
|
+
|
|
207
|
+
mdl = np.dot(alpha, z) ##alpha has been declared a global variable after LSD is run.
|
|
208
|
+
|
|
209
|
+
#converting model from optical depth to flux
|
|
210
|
+
mdl = np.exp(mdl)
|
|
211
|
+
|
|
212
|
+
## these are used to adjust the wavelengths to between -1 and 1 - makes the continuum coefficents smaller and easier for emcee to handle.
|
|
213
|
+
a = 2/(np.max(x)-np.min(x))
|
|
214
|
+
b = 1 - a*np.max(x)
|
|
215
|
+
|
|
216
|
+
mdl1 = 0
|
|
217
|
+
for i in range(k_max, len(inputs) - 1):
|
|
218
|
+
mdl1 = mdl1 + (inputs[i] * ((x * a) + b) ** (i - k_max))
|
|
219
|
+
|
|
220
|
+
# coefs = np.asarray(inputs[k_max:-1], dtype=float) # Potential improvement - Ben
|
|
221
|
+
# X = (a * x) + b
|
|
222
|
+
# if coefs.size:
|
|
223
|
+
# powers = np.arange(coefs.size)
|
|
224
|
+
# # X[:, None] ** powers -> shape (len(x), coefs.size); dot with coefs -> (len(x),)
|
|
225
|
+
# mdl1 = np.dot(X[:, None] ** powers[None, :], coefs)
|
|
226
|
+
# else:
|
|
227
|
+
# mdl1 = 0.0
|
|
228
|
+
|
|
229
|
+
mdl1 = mdl1 * inputs[-1]
|
|
230
|
+
|
|
231
|
+
mdl = mdl * mdl1
|
|
232
|
+
|
|
233
|
+
return mdl
|
|
234
|
+
|
|
235
|
+
def log_likelihood(theta, x, y, yerr):
|
|
236
|
+
## maximum likelihood estimation for the mcmc model.
|
|
237
|
+
model = model_func(theta, x)
|
|
238
|
+
|
|
239
|
+
lnlike = -0.5 * np.sum(((y) - (model)) ** 2 / yerr**2 + np.log(yerr**2)+ np.log(2*np.pi))
|
|
240
|
+
|
|
241
|
+
return lnlike
|
|
242
|
+
|
|
243
|
+
def log_prior(theta):
|
|
244
|
+
## imposes the prior restrictions on the inputs - rejects if profile point is less than -10 or greater than 0.5.
|
|
245
|
+
check = 0
|
|
246
|
+
z = theta[:k_max]
|
|
247
|
+
|
|
248
|
+
for i in range(len(theta)):
|
|
249
|
+
if i < k_max: ## must lie in z
|
|
250
|
+
if -10 <= theta[i] <= 0.5:
|
|
251
|
+
pass
|
|
252
|
+
else:
|
|
253
|
+
check = 1
|
|
254
|
+
|
|
255
|
+
if check == 0:
|
|
256
|
+
|
|
257
|
+
# excluding the continuum points in the profile (in flux)
|
|
258
|
+
z_cont = []
|
|
259
|
+
v_cont = []
|
|
260
|
+
for i in range(0, 5):
|
|
261
|
+
z_cont.append(np.exp(z[len(z)-i-1])-1)
|
|
262
|
+
v_cont.append(velocities[len(velocities)-i-1])
|
|
263
|
+
z_cont.append(np.exp(z[i])-1)
|
|
264
|
+
v_cont.append(velocities[i])
|
|
265
|
+
|
|
266
|
+
z_cont = np.array(z_cont)
|
|
267
|
+
v_cont = np.array(v_cont)
|
|
268
|
+
|
|
269
|
+
p_pent = np.sum((np.log((1/np.sqrt(2*np.pi*0.01**2)))-0.5*(z_cont/0.01)**2))
|
|
270
|
+
|
|
271
|
+
return p_pent
|
|
272
|
+
|
|
273
|
+
return -np.inf
|
|
274
|
+
|
|
275
|
+
def log_probability(theta):
|
|
276
|
+
## calculates log probability - used for mcmc
|
|
277
|
+
lp = log_prior(theta)
|
|
278
|
+
if not np.isfinite(lp):
|
|
279
|
+
return -np.inf
|
|
280
|
+
final = lp + log_likelihood(theta, x, y, yerr)
|
|
281
|
+
return final
|
|
282
|
+
|
|
204
283
|
def residual_mask(wavelengths, data_spec_in, data_err, initial_inputs, poly_ord, linelist,
|
|
205
284
|
velocities=np.arange(-25, 25, 0.82), pix_chunk=20, dev_perc=25,
|
|
206
|
-
tell_lines=
|
|
207
|
-
4861.34, 5183.62, 5270.39, 5889.95, 5895.92, 6562.81,
|
|
208
|
-
7593.70, 8226.96], n_sig=1):
|
|
285
|
+
tell_lines=None, n_sig=1, alpha=None):
|
|
209
286
|
## iterative residual masking - mask continuous areas first - then possibly progress to masking the narrow lines
|
|
210
287
|
|
|
211
|
-
forward =
|
|
288
|
+
forward = model_func(initial_inputs, wavelengths)
|
|
212
289
|
|
|
213
290
|
a = 2 / (np.max(wavelengths) - np.min(wavelengths))
|
|
214
291
|
b = 1 - a * np.max(wavelengths)
|
|
@@ -536,7 +613,7 @@ def ACID(input_wavelengths, input_spectra, input_spectral_errors, line, frame_sn
|
|
|
536
613
|
yerr, model_inputs_resi, mask_idx = residual_mask(x, y, yerr, model_inputs, poly_ord,
|
|
537
614
|
linelist, pix_chunk=pix_chunk,
|
|
538
615
|
dev_perc=dev_perc, tell_lines=telluric_lines,
|
|
539
|
-
n_sig=n_sig)
|
|
616
|
+
n_sig=n_sig, alpha=alpha)
|
|
540
617
|
|
|
541
618
|
# if verbose:
|
|
542
619
|
# t4 = time.time()
|
|
@@ -561,9 +638,6 @@ def ACID(input_wavelengths, input_spectra, input_spectral_errors, line, frame_sn
|
|
|
561
638
|
pos = np.array(pos)
|
|
562
639
|
pos = np.transpose(pos)
|
|
563
640
|
|
|
564
|
-
# Initialise MCMC class:
|
|
565
|
-
mcmc_class = mcmc_utils.Model(x, y, yerr, velocities, k_max, alpha)
|
|
566
|
-
|
|
567
641
|
if verbose:
|
|
568
642
|
t5 = time.time()
|
|
569
643
|
# print('MCMC set up takes: %s'%(t5-t4))
|
|
@@ -587,7 +661,7 @@ def ACID(input_wavelengths, input_spectra, input_spectral_errors, line, frame_sn
|
|
|
587
661
|
if sys.platform != "win32":
|
|
588
662
|
ctx = mp.get_context("fork")
|
|
589
663
|
with ctx.Pool(processes = cores) as pool:
|
|
590
|
-
sampler = emcee.EnsembleSampler(nwalkers, ndim,
|
|
664
|
+
sampler = emcee.EnsembleSampler(nwalkers, ndim, log_probability, pool=pool)
|
|
591
665
|
sampler.run_mcmc(pos, nsteps, progress=True, store=True)
|
|
592
666
|
|
|
593
667
|
# with Pool() as pool: # Original code
|
|
@@ -601,7 +675,7 @@ def ACID(input_wavelengths, input_spectra, input_spectral_errors, line, frame_sn
|
|
|
601
675
|
|
|
602
676
|
|
|
603
677
|
else:
|
|
604
|
-
sampler = emcee.EnsembleSampler(nwalkers, ndim,
|
|
678
|
+
sampler = emcee.EnsembleSampler(nwalkers, ndim, log_probability)
|
|
605
679
|
sampler.run_mcmc(pos, nsteps, progress=True)
|
|
606
680
|
|
|
607
681
|
print('MCMC run takes: %s'%(time.time()-t5))
|
|
@@ -643,7 +717,7 @@ def ACID(input_wavelengths, input_spectra, input_spectral_errors, line, frame_sn
|
|
|
643
717
|
inds = np.random.randint(len(flat_samples), size=100)
|
|
644
718
|
for ind in inds:
|
|
645
719
|
sample = flat_samples[ind]
|
|
646
|
-
mdl =
|
|
720
|
+
mdl = model_func(sample, x)
|
|
647
721
|
mdl1 = 0
|
|
648
722
|
for i in np.arange(k_max, len(sample)-1):
|
|
649
723
|
mdl1 = mdl1+sample[i]*((a*x)+b)**(i-k_max)
|
|
@@ -697,7 +771,7 @@ def ACID(input_wavelengths, input_spectra, input_spectral_errors, line, frame_sn
|
|
|
697
771
|
plt.savefig('figures/cont_%s'%(run_name))
|
|
698
772
|
|
|
699
773
|
mcmc_inputs = np.concatenate((profile, poly_cos))
|
|
700
|
-
mcmc_mdl =
|
|
774
|
+
mcmc_mdl = model_func(mcmc_inputs, x)
|
|
701
775
|
|
|
702
776
|
residuals_2 = (y+1) - (mcmc_mdl+1)
|
|
703
777
|
|
|
@@ -741,7 +815,7 @@ def ACID(input_wavelengths, input_spectra, input_spectral_errors, line, frame_sn
|
|
|
741
815
|
conts = []
|
|
742
816
|
for ind in inds:
|
|
743
817
|
sample = flat_samples[ind]
|
|
744
|
-
mdl =
|
|
818
|
+
mdl = model_func(sample, wavelengths)
|
|
745
819
|
#mdl = model_func(sample, x)
|
|
746
820
|
#mdl = mdl[idx]
|
|
747
821
|
mdl1_temp = 0
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import numpy as np
|
|
2
|
-
|
|
3
|
-
def model_func(inputs, x, k_max, alpha):
|
|
4
|
-
## model for the mcmc - takes the profile(z) and the continuum coefficents(inputs[k_max:]) to create a model spectrum.
|
|
5
|
-
z = inputs[:k_max]
|
|
6
|
-
|
|
7
|
-
mdl = np.dot(alpha, z) ##alpha has been declared a global variable after LSD is run.
|
|
8
|
-
|
|
9
|
-
#converting model from optical depth to flux
|
|
10
|
-
mdl = np.exp(mdl)
|
|
11
|
-
|
|
12
|
-
## these are used to adjust the wavelengths to between -1 and 1 - makes the continuum coefficents smaller and easier for emcee to handle.
|
|
13
|
-
a = 2/(np.max(x)-np.min(x))
|
|
14
|
-
b = 1 - a*np.max(x)
|
|
15
|
-
|
|
16
|
-
mdl1 = 0
|
|
17
|
-
for i in range(k_max, len(inputs) - 1):
|
|
18
|
-
mdl1 = mdl1 + (inputs[i] * ((x * a) + b) ** (i - k_max))
|
|
19
|
-
|
|
20
|
-
# coefs = np.asarray(inputs[k_max:-1], dtype=float) # Potential improvement - Ben
|
|
21
|
-
# X = (a * x) + b
|
|
22
|
-
# if coefs.size:
|
|
23
|
-
# powers = np.arange(coefs.size)
|
|
24
|
-
# # X[:, None] ** powers -> shape (len(x), coefs.size); dot with coefs -> (len(x),)
|
|
25
|
-
# mdl1 = np.dot(X[:, None] ** powers[None, :], coefs)
|
|
26
|
-
# else:
|
|
27
|
-
# mdl1 = 0.0
|
|
28
|
-
|
|
29
|
-
mdl1 = mdl1 * inputs[-1]
|
|
30
|
-
|
|
31
|
-
mdl = mdl * mdl1
|
|
32
|
-
|
|
33
|
-
return mdl
|
|
34
|
-
|
|
35
|
-
class Model:
|
|
36
|
-
def __init__(self, x, y, yerr, velocities, k_max, alpha):
|
|
37
|
-
self.x = x
|
|
38
|
-
self.y = y
|
|
39
|
-
self.yerr = yerr
|
|
40
|
-
self.velocities = velocities
|
|
41
|
-
self.k_max = k_max
|
|
42
|
-
self.alpha = alpha
|
|
43
|
-
|
|
44
|
-
def log_likelihood(self, theta, x, y, yerr):
|
|
45
|
-
## maximum likelihood estimation for the mcmc model.
|
|
46
|
-
model = model_func(theta, x, k_max=self.k_max, alpha=self.alpha)
|
|
47
|
-
|
|
48
|
-
lnlike = -0.5 * np.sum(((y) - (model)) ** 2 / yerr**2 + np.log(yerr**2)+ np.log(2*np.pi))
|
|
49
|
-
|
|
50
|
-
return lnlike
|
|
51
|
-
|
|
52
|
-
def log_prior(self, theta):
|
|
53
|
-
## imposes the prior restrictions on the inputs - rejects if profile point is less than -10 or greater than 0.5.
|
|
54
|
-
check = 0
|
|
55
|
-
z = theta[:self.k_max]
|
|
56
|
-
|
|
57
|
-
for i in range(len(theta)):
|
|
58
|
-
if i < self.k_max: ## must lie in z
|
|
59
|
-
if -10 <= theta[i] <= 0.5:
|
|
60
|
-
pass
|
|
61
|
-
else:
|
|
62
|
-
check = 1
|
|
63
|
-
|
|
64
|
-
if check == 0:
|
|
65
|
-
|
|
66
|
-
# excluding the continuum points in the profile (in flux)
|
|
67
|
-
z_cont = []
|
|
68
|
-
v_cont = []
|
|
69
|
-
for i in range(0, 5):
|
|
70
|
-
z_cont.append(np.exp(z[len(z)-i-1])-1)
|
|
71
|
-
v_cont.append(self.velocities[len(self.velocities)-i-1])
|
|
72
|
-
z_cont.append(np.exp(z[i])-1)
|
|
73
|
-
v_cont.append(self.velocities[i])
|
|
74
|
-
|
|
75
|
-
z_cont = np.array(z_cont)
|
|
76
|
-
v_cont = np.array(v_cont)
|
|
77
|
-
|
|
78
|
-
p_pent = np.sum((np.log((1/np.sqrt(2*np.pi*0.01**2)))-0.5*(z_cont/0.01)**2))
|
|
79
|
-
|
|
80
|
-
return p_pent
|
|
81
|
-
|
|
82
|
-
return -np.inf
|
|
83
|
-
|
|
84
|
-
def log_probability(self, theta):
|
|
85
|
-
## calculates log probability - used for mcmc
|
|
86
|
-
lp = self.log_prior(theta)
|
|
87
|
-
if not np.isfinite(lp):
|
|
88
|
-
return -np.inf
|
|
89
|
-
final = lp + self.log_likelihood(theta, self.x, self.y, self.yerr)
|
|
90
|
-
return final
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/src/ACID_code_v2.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-28T21:11:56.678_blaze_B.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-28T21:11:56.678_flat_A.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-28T21:11:56.678_flat_B.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-28T21:11:56.678_lamp_A.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-28T21:11:56.678_lamp_B.fits
RENAMED
|
File without changes
|
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:02:50.897_bis_G2_A.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:02:50.897_bis_G2_B.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:02:50.897_bis_K5_A.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:02:50.897_ccf_G2_A.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:02:50.897_ccf_G2_B.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:02:50.897_ccf_K5_A.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:02:50.897_e2ds_A.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:02:50.897_e2ds_B.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:02:50.897_s1d_A.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:02:50.897_s1d_B.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:08:22.216_bis_G2_A.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:08:22.216_bis_G2_B.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:08:22.216_bis_K5_A.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:08:22.216_ccf_G2_A.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:08:22.216_ccf_G2_B.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:08:22.216_ccf_K5_A.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:08:22.216_e2ds_A.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:08:22.216_e2ds_B.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:08:22.216_s1d_A.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:08:22.216_s1d_B.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:13:54.107_bis_G2_A.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:13:54.107_bis_G2_B.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:13:54.107_bis_K5_A.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:13:54.107_ccf_G2_A.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:13:54.107_ccf_G2_B.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:13:54.107_ccf_K5_A.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:13:54.107_e2ds_A.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:13:54.107_e2ds_B.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:13:54.107_s1d_A.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:13:54.107_s1d_B.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:19:25.377_bis_G2_A.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:19:25.377_bis_G2_B.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:19:25.377_bis_K5_A.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:19:25.377_ccf_G2_A.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:19:25.377_ccf_G2_B.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:19:25.377_ccf_K5_A.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:19:25.377_e2ds_A.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:19:25.377_e2ds_B.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:19:25.377_s1d_A.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:19:25.377_s1d_B.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:24:57.238_bis_G2_A.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:24:57.238_bis_G2_B.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:24:57.238_bis_K5_A.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:24:57.238_ccf_G2_A.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:24:57.238_ccf_G2_B.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:24:57.238_ccf_K5_A.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:24:57.238_e2ds_A.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:24:57.238_e2ds_B.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:24:57.238_s1d_A.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:24:57.238_s1d_B.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:30:28.617_bis_G2_A.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:30:28.617_bis_G2_B.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:30:28.617_bis_K5_A.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:30:28.617_ccf_G2_A.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:30:28.617_ccf_G2_B.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:30:28.617_ccf_K5_A.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:30:28.617_e2ds_A.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:30:28.617_e2ds_B.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:30:28.617_s1d_A.fits
RENAMED
|
File without changes
|
{acid_code_v2-0.2.2a2 → acid_code_v2-0.2.2a4}/tests/data/HARPS.2007-08-29T00:30:28.617_s1d_B.fits
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|