chanter 0.0.9__py3-none-any.whl → 0.1.2__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.
chanter/galaxy_fitter.py CHANGED
@@ -18,8 +18,10 @@ class galaxyfitter(object):
18
18
  Free parameters.
19
19
  """
20
20
  model = modelgalaxy(fit_instruc)
21
- wavs, flux = model.get_spectrum()
22
- effwavs, phot = model.get_photometry(wavs, flux, filt_files)
21
+ self.wavs, flux = model.get_spectrum()
22
+ self.spectrum_samples.append(flux)
23
+ effwavs, phot = model.get_photometry(self.wavs, flux, filt_files)
24
+ self.photometry_samples.append(phot)
23
25
 
24
26
  return phot
25
27
 
@@ -68,6 +70,7 @@ class galaxyfitter(object):
68
70
  # Fit an array of photometry, output the best galaxy parameters
69
71
  def fit(self, photdata, prior, filt_files):
70
72
 
73
+
71
74
  filt = filter_set(filt_files)
72
75
  effwavs = filt.eff_wavs
73
76
 
@@ -79,9 +82,13 @@ class galaxyfitter(object):
79
82
  dat[0] = 2.99792458E-05 * ((1e-6 * dat[0]) / ((effwavs)**2))
80
83
  dat[1] = 2.99792458E-05 * ((1e-6 * dat[1]) / ((effwavs)**2))
81
84
 
85
+
82
86
  # Run the nested sampler over the likelihood function
87
+ self.spectrum_samples=[]
88
+ self.photometry_samples=[]
83
89
  sampler = Sampler(prior, lambda param_dict: self.log_likelihood(dat, self.gen_phot, filt_files, param_dict), n_live=500)
84
- success = sampler.run(verbose=True, discard_exploration=True, timeout=1800)
90
+ success = sampler.run(verbose=True, discard_exploration=False, timeout=1800)
91
+
85
92
 
86
93
  # Plot results
87
94
  points, log_w, log_l = sampler.posterior()
@@ -94,6 +101,11 @@ class galaxyfitter(object):
94
101
  samples = np.random.choice(points_i, size = points_i.shape[0], p=np.exp(log_w))
95
102
  dic[key + "_50"] = np.percentile(samples, 50)
96
103
 
104
+
105
+ choicer = np.random.choice(np.arange(len(self.spectrum_samples)), size = len(self.spectrum_samples), p=np.exp(log_w))
106
+ self.spectrum_samples = np.take(np.array((self.spectrum_samples)), choicer, axis=0)
107
+ self.photometry_samples = np.take(np.array((self.photometry_samples)), choicer, axis=0)
108
+
97
109
  exp = {}
98
110
  exp["age"] = dic['age_50']
99
111
  exp["tau"] = dic['tau_50']
@@ -106,10 +118,12 @@ class galaxyfitter(object):
106
118
  fit_instructions["exponential"] = exp
107
119
  fit_instructions["dust"] = dust
108
120
 
121
+
109
122
  print('Finished in ' + str(time.time() - t0)+ ' seconds.')
110
123
  print(' ')
111
124
 
112
- return fit_instructions
125
+
126
+ return fit_instructions, self.wavs, self.spectrum_samples, self.photometry_samples
113
127
 
114
128
 
115
129
 
Binary file
@@ -0,0 +1,40 @@
1
+ # N lambdaj A_LAF_J_1 A_LAF_J_2 A_LAF_J_3 A_DLA_J_1 A_DLA_J_2
2
+ 2 1215.67 1.690e-02 2.354e-03 1.026e-04 1.617e-04 5.390e-05
3
+ 3 1025.72 4.692e-03 6.536e-04 2.849e-05 1.545e-04 5.151e-05
4
+ 4 972.537 2.239e-03 3.119e-04 1.360e-05 1.498e-04 4.992e-05
5
+ 5 949.743 1.319e-03 1.837e-04 8.010e-06 1.460e-04 4.868e-05
6
+ 6 937.803 8.707e-04 1.213e-04 5.287e-06 1.429e-04 4.763e-05
7
+ 7 930.748 6.178e-04 8.606e-05 3.752e-06 1.402e-04 4.672e-05
8
+ 8 926.226 4.609e-04 6.421e-05 2.799e-06 1.377e-04 4.590e-05
9
+ 9 923.150 3.569e-04 4.971e-05 2.167e-06 1.355e-04 4.516e-05
10
+ 10 920.963 2.843e-04 3.960e-05 1.726e-06 1.335e-04 4.448e-05
11
+ 11 919.352 2.318e-04 3.229e-05 1.407e-06 1.316e-04 4.385e-05
12
+ 12 918.129 1.923e-04 2.679e-05 1.168e-06 1.298e-04 4.326e-05
13
+ 13 917.181 1.622e-04 2.259e-05 9.847e-07 1.281e-04 4.271e-05
14
+ 14 916.429 1.385e-04 1.929e-05 8.410e-07 1.265e-04 4.218e-05
15
+ 15 915.824 1.196e-04 1.666e-05 7.263e-07 1.250e-04 4.168e-05
16
+ 16 915.329 1.043e-04 1.453e-05 6.334e-07 1.236e-04 4.120e-05
17
+ 17 914.919 9.174e-05 1.278e-05 5.571e-07 1.222e-04 4.075e-05
18
+ 18 914.576 8.128e-05 1.132e-05 4.936e-07 1.209e-04 4.031e-05
19
+ 19 914.286 7.251e-05 1.010e-05 4.403e-07 1.197e-04 3.989e-05
20
+ 20 914.039 6.505e-05 9.062e-06 3.950e-07 1.185e-04 3.949e-05
21
+ 21 913.826 5.868e-05 8.174e-06 3.563e-07 1.173e-04 3.910e-05
22
+ 22 913.641 5.319e-05 7.409e-06 3.230e-07 1.162e-04 3.872e-05
23
+ 23 913.480 4.843e-05 6.746e-06 2.941e-07 1.151e-04 3.836e-05
24
+ 24 913.339 4.427e-05 6.167e-06 2.689e-07 1.140e-04 3.800e-05
25
+ 25 913.215 4.063e-05 5.660e-06 2.467e-07 1.130e-04 3.766e-05
26
+ 26 913.104 3.738e-05 5.207e-06 2.270e-07 1.120e-04 3.732e-05
27
+ 27 913.006 3.454e-05 4.811e-06 2.097e-07 1.110e-04 3.700e-05
28
+ 28 912.918 3.199e-05 4.456e-06 1.943e-07 1.101e-04 3.668e-05
29
+ 29 912.839 2.971e-05 4.139e-06 1.804e-07 1.091e-04 3.637e-05
30
+ 30 912.768 2.766e-05 3.853e-06 1.680e-07 1.082e-04 3.607e-05
31
+ 31 912.703 2.582e-05 3.596e-06 1.568e-07 1.073e-04 3.578e-05
32
+ 32 912.645 2.415e-05 3.364e-06 1.466e-07 1.065e-04 3.549e-05
33
+ 33 912.592 2.263e-05 3.153e-06 1.375e-07 1.056e-04 3.521e-05
34
+ 34 912.543 2.126e-05 2.961e-06 1.291e-07 1.048e-04 3.493e-05
35
+ 35 912.499 2.000e-05 2.785e-06 1.214e-07 1.040e-04 3.466e-05
36
+ 36 912.458 1.885e-05 2.625e-06 1.145e-07 1.032e-04 3.440e-05
37
+ 37 912.420 1.779e-05 2.479e-06 1.080e-07 1.024e-04 3.414e-05
38
+ 38 912.385 1.682e-05 2.343e-06 1.022e-07 1.017e-04 3.389e-05
39
+ 39 912.353 1.593e-05 2.219e-06 9.673e-08 1.009e-04 3.364e-05
40
+ 40 912.324 1.510e-05 2.103e-06 9.169e-08 1.002e-04 3.339e-05
Binary file
chanter/model_galaxy.py CHANGED
@@ -47,8 +47,19 @@ def resample_igm_grid(wavs):
47
47
  return grid
48
48
 
49
49
 
50
- hdul = fits.open(os.path.dirname(os.path.realpath(__file__)) + '/grids/ssps.fits')
51
- master_base = np.array((hdul[1].data, hdul[2].data, hdul[3].data, hdul[4].data, hdul[5].data, hdul[6].data, hdul[7].data))
50
+ '''
51
+ ######
52
+ # Due to PyPi file size limits, I only include solar metallicity SSPs here.
53
+ ######
54
+ '''
55
+ #hdul_1 = fits.open(os.path.dirname(os.path.realpath(__file__)) + '/grids/ssps_1.fits')
56
+ #hdul_2 = fits.open(os.path.dirname(os.path.realpath(__file__)) + '/grids/ssps_2.fits')
57
+ #hdul_3 = fits.open(os.path.dirname(os.path.realpath(__file__)) + '/grids/ssps_3.fits')
58
+ #hdul_4 = fits.open(os.path.dirname(os.path.realpath(__file__)) + '/grids/ssps_4.fits')
59
+ hdul_5 = fits.open(os.path.dirname(os.path.realpath(__file__)) + '/grids/ssps_5.fits')
60
+ #hdul_6 = fits.open(os.path.dirname(os.path.realpath(__file__)) + '/grids/ssps_6.fits')
61
+ #hdul_7 = fits.open(os.path.dirname(os.path.realpath(__file__)) + '/grids/ssps_7.fits')
62
+ master_base = np.array((hdul_5[1].data, hdul_5[1].data, hdul_5[1].data, hdul_5[1].data, hdul_5[1].data, hdul_5[1].data, hdul_5[1].data))
52
63
 
53
64
  rest_target_wavs = np.arange(100., 50000., 25.)
54
65
  grid = resample_ssp_wavs(rest_target_wavs)
@@ -56,7 +67,10 @@ igm_grid = resample_igm_grid(rest_target_wavs)
56
67
 
57
68
 
58
69
  '''
59
- # !!AGE RESAMPLING NOT WORKING!!
70
+ ######
71
+ # Age resampling currently produces strange results. This is hence deactivated for now, which only serves to slow the code down and does
72
+ # not affect accuracy of results.
73
+ ######
60
74
 
61
75
  def resample_ssp_ages(grid_raw_ages, target_ages):
62
76
 
@@ -0,0 +1,23 @@
1
+ Metadata-Version: 2.4
2
+ Name: chanter
3
+ Version: 0.1.2
4
+ Summary: Simple quiescent galaxy spectral modelling and fitting
5
+ Author: Struan Stevenson
6
+ Author-email: struan.stevenson@ed.ac.uk
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: numpy
9
+ Requires-Dist: astropy
10
+ Requires-Dist: matplotlib
11
+ Requires-Dist: spectres
12
+ Requires-Dist: nautilus-sampler
13
+ Dynamic: author
14
+ Dynamic: author-email
15
+ Dynamic: description
16
+ Dynamic: description-content-type
17
+ Dynamic: requires-dist
18
+ Dynamic: summary
19
+
20
+ # CHANTER
21
+
22
+ #### CHANTER is a simple quiecent galaxy spectral energy distribution (SED) modelling/fitting code, based on the larger BAGPIPES code, of astronomical literary fame. CHANTER provides the barebones of Stellar Population Synthesis (SPS), as well as redshift and dust/IGM attenuation effects, and is written in a simple and digestible format, ideal for learning the theory behind larger spectral fitting software codes. CHANTER does not yet include nebular attenuation, and therefore only models the SED of quiescent galaxies.
23
+
@@ -0,0 +1,14 @@
1
+ chanter/__init__.py,sha256=bubSIcCkkzRcatq5ry6iSidWzj4YK8HqTvelHLunHJs,119
2
+ chanter/galaxy_fitter.py,sha256=g_66TJC2TpNudVz6qHOtwDADISWhhFs1v5g3oObNCcA,4201
3
+ chanter/model_galaxy.py,sha256=o_A_hqcIVUPphhQYDIk0fpCCArZZkOHbf3IDtQBCDN4,8789
4
+ chanter/grids/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ chanter/grids/d_igm_grid_inoue14.fits,sha256=T5Fb71OZjOqY9YkdZaEe3zPt1lOQZNoFXTZ-N_Y_Cnc,9843840
6
+ chanter/grids/lyman_series_coefs_inoue_2014_table2.txt,sha256=xFZsQQ8aV27G--iK0WJgBY0idFnNirWduCswT8TJ8y8,2721
7
+ chanter/grids/ssps_5.fits,sha256=Vfr_8DMIoY-IZYTxVhiqP8nFeypVOEJ6FasBUNp52NQ,23480640
8
+ chanter/utils/__init__.py,sha256=hn-ho-lJeT0evKXL1tV5jX0cR4meSlJmPcdxC49cLok,34
9
+ chanter/utils/filter_set.py,sha256=EITLa2c3FG3n1-v7KatKRwHCRyfZ4TTjsi_WM7Bz64k,6819
10
+ chanter/utils/make_igm_grid.py,sha256=nO3NvO-l15oG65mgf48FH3QdatxCfgPT_kqwZzO14CA,10280
11
+ chanter-0.1.2.dist-info/METADATA,sha256=40T32lxTtN-G6-hQVvKSoXqTfN3RQ8niOF8FiCVhyCU,1016
12
+ chanter-0.1.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
13
+ chanter-0.1.2.dist-info/top_level.txt,sha256=Q23dLK1syz0D-XIZ6zeY6TOZ7BQsC-BLqRiVQE7_udk,8
14
+ chanter-0.1.2.dist-info/RECORD,,
@@ -1,24 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: chanter
3
- Version: 0.0.9
4
- Summary: Simple galaxy spectral modelling and fitting
5
- Author: Struan Stevenson
6
- Author-email: struan.stevenson@ed.ac.uk
7
- Description-Content-Type: text/markdown
8
- Requires-Dist: numpy
9
- Requires-Dist: astropy
10
- Requires-Dist: matplotlib
11
- Requires-Dist: spectres
12
- Requires-Dist: nautilus-sampler
13
- Dynamic: author
14
- Dynamic: author-email
15
- Dynamic: description
16
- Dynamic: description-content-type
17
- Dynamic: requires-dist
18
- Dynamic: summary
19
-
20
- # CHANTER
21
-
22
- #### CHANTER is a simple galaxy spectral energy distribution (SED) modelling/fitting code, based on the larger BAGPIPES code, of astronomical literary fame. CHANTER provides the barebones of Stellar Population Synthesis (SPS), as well as redshift and dust/IGM attenuation effects, and is written in a simple and digestible format, ideal for learning the theory behind larger spectral fitting software codes.
23
-
24
- Currently, I cannot include the SSP/IGM grids in the package due to PyPi size limitations, but this is being appealed.
@@ -1,11 +0,0 @@
1
- chanter/__init__.py,sha256=bubSIcCkkzRcatq5ry6iSidWzj4YK8HqTvelHLunHJs,119
2
- chanter/galaxy_fitter.py,sha256=HhZ3cawiDMSaDI2EBkza9lWWtE83vIh3bkQCgV77J0g,3654
3
- chanter/model_galaxy.py,sha256=kYkuEO0VTyr9S84efzHYOoWXaYAp8VYXid6y4QZePaI,7993
4
- chanter/grids/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- chanter/utils/__init__.py,sha256=hn-ho-lJeT0evKXL1tV5jX0cR4meSlJmPcdxC49cLok,34
6
- chanter/utils/filter_set.py,sha256=EITLa2c3FG3n1-v7KatKRwHCRyfZ4TTjsi_WM7Bz64k,6819
7
- chanter/utils/make_igm_grid.py,sha256=nO3NvO-l15oG65mgf48FH3QdatxCfgPT_kqwZzO14CA,10280
8
- chanter-0.0.9.dist-info/METADATA,sha256=wPWHN-9ieNFxGqqynqReHkxQnOwQfV7bumVi1gWQ5zo,1009
9
- chanter-0.0.9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
10
- chanter-0.0.9.dist-info/top_level.txt,sha256=Q23dLK1syz0D-XIZ6zeY6TOZ7BQsC-BLqRiVQE7_udk,8
11
- chanter-0.0.9.dist-info/RECORD,,