Skip to content

Commit

Permalink
Store priors from FitModel in the database results
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasstolker committed Feb 14, 2024
1 parent 6e60fea commit 57d7eca
Show file tree
Hide file tree
Showing 5 changed files with 230 additions and 109 deletions.
143 changes: 102 additions & 41 deletions docs/tutorials/fitting_model_spectra.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,23 @@
"\n",
"Working folder: /Users/tomasstolker/applications/species/docs/tutorials\n",
"Creating species_config.ini... [DONE]\n",
"\n",
"Configuration settings:\n",
" - Database: /Users/tomasstolker/applications/species/docs/tutorials/species_database.hdf5\n",
" - Data folder: /Users/tomasstolker/applications/species/docs/tutorials/data\n",
" - Interpolation method: linear\n",
" - Magnitude of Vega: 0.03\n",
"Creating species_database.hdf5... [DONE]\n",
"Creating data folder... [DONE]\n"
"Creating data folder... [DONE]\n",
"\n",
"Multiprocessing: mpi4py installed\n",
"Process number 1 out of 1...\n"
]
},
{
"data": {
"text/plain": [
"<species.core.species_init.SpeciesInit at 0x10d202990>"
"<species.core.species_init.SpeciesInit at 0x10ebfaa50>"
]
},
"execution_count": 3,
Expand All @@ -124,7 +128,7 @@
{
"data": {
"text/plain": [
"('betapicb_gpi_h.dat', <http.client.HTTPMessage at 0x18fe8c8d0>)"
"('betapicb_gpi_h.dat', <http.client.HTTPMessage at 0x194ca0fd0>)"
]
},
"execution_count": 4,
Expand Down Expand Up @@ -182,8 +186,26 @@
"name": "stderr",
"output_type": "stream",
"text": [
"Downloading data from 'https://home.strw.leidenuniv.nl/~stolker/species/drift-phoenix.tgz' to file '/Users/tomasstolker/applications/species/docs/tutorials/data/drift-phoenix.tgz'.\n",
"100%|████████████████████████████████████████| 240M/240M [00:00<00:00, 111GB/s]\n",
"Downloading data from 'https://home.strw.leidenuniv.nl/~stolker/species/drift-phoenix.tgz' to file '/Users/tomasstolker/applications/species/docs/tutorials/data/drift-phoenix.tgz'.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"-------------------------\n",
"Add grid of model spectra\n",
"-------------------------\n",
"\n",
"Model name: drift-phoenix\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"100%|████████████████████████████████████████| 240M/240M [00:00<00:00, 142GB/s]\n",
"SHA256 hash of downloaded file: ba71a5e4d3d399a6f8ae249590c2e174e90ec2b55e712d350dad8ca1ae83a907\n",
"Use this value as the 'known_hash' argument of 'pooch.retrieve' to ensure that the file hasn't changed if it is downloaded again in the future.\n"
]
Expand All @@ -195,23 +217,28 @@
"Unpacking 140/496 model spectra from DRIFT-PHOENIX (229 MB)... [DONE]\n",
"Please cite Helling et al. (2008) when using DRIFT-PHOENIX in a publication\n",
"Reference URL: https://ui.adsabs.harvard.edu/abs/2008ApJ...675L.105H\n",
"\n",
"Wavelength range (um) = 0.1 - 50\n",
"Spectral resolution = 4000\n",
"Teff range (K) = 1500.0 - 2000.0\n",
"Adding DRIFT-PHOENIX model spectra... [DONE] \n",
"\n",
" \n",
"Grid points stored in the database:\n",
" - Teff = [1500. 1600. 1700. 1800. 1900. 2000.]\n",
" - log(g) = [3. 3.5 4. 4.5 5. 5.5]\n",
" - [Fe/H] = [-0.6 -0.3 -0. 0.3]\n",
"\n",
"Number of grid points per parameter:\n",
" - teff: 6\n",
" - logg: 6\n",
" - feh: 4\n",
"\n",
"Fix missing grid points with a linear interpolation:\n",
" - teff = 1600.0, logg = 3.0, feh = 0.3\n",
" - teff = 1600.0, logg = 5.5, feh = 0.3\n",
" - teff = 1900.0, logg = 4.5, feh = 0.3\n",
" - teff = 1900.0, logg = 5.5, feh = 0.3\n",
"\n",
"Number of stored grid points: 144\n",
"Number of interpolated grid points: 4\n",
"Number of missing grid points: 0\n"
Expand Down Expand Up @@ -261,27 +288,30 @@
"output_type": "stream",
"text": [
"\n",
"------------------\n",
"Add companion data\n",
"------------------\n",
"---------------------\n",
"Get companion spectra\n",
"---------------------\n",
"\n",
"Getting GPI_YJHK spectrum of beta Pic b... [DONE]\n",
"Please cite Chilcote et al. 2017, AJ, 153, 182 when making use of this spectrum in a publication\n",
"Getting GRAVITY spectrum of beta Pic b... [DONE]\n",
"Please cite Gravity Collaboration et al. 2020, A&A, 633, 110 when making use of this spectrum in a publication\n",
"\n",
"---------------\n",
"Add object data\n",
"---------------\n",
"\n"
"----------\n",
"Add object\n",
"----------\n",
"\n",
"Object name: beta Pic b\n",
"Units: None\n",
"Deredden: None\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"Downloading data from 'https://archive.stsci.edu/hlsps/reference-atlases/cdbs/current_calspec/alpha_lyr_stis_011.fits' to file '/Users/tomasstolker/applications/species/docs/tutorials/data/alpha_lyr_stis_011.fits'.\n",
"100%|███████████████████████████████████████| 288k/288k [00:00<00:00, 180MB/s]"
"100%|███████████████████████████████████████| 288k/288k [00:00<00:00, 92.5MB/s]"
]
},
{
Expand All @@ -305,8 +335,9 @@
" [DONE]\n",
"Reference: Bohlin et al. 2014, PASP, 126\n",
"URL: https://ui.adsabs.harvard.edu/abs/2014PASP..126..711B/abstract\n",
"Adding object: beta Pic b\n",
" - Parallax (mas) = 50.93 +/- 0.15\n",
"Parallax (mas) = 50.93 +/- 0.15\n",
"\n",
"Magnitudes:\n",
" - Magellan/VisAO.Ys:\n",
" - Mean wavelength (um) = 4.7810e+00\n",
" - Apparent magnitude = 15.53 +/- 0.34\n",
Expand Down Expand Up @@ -343,6 +374,8 @@
" - Mean wavelength (um) = 4.7810e+00\n",
" - Apparent magnitude = 11.10 +/- 0.12\n",
" - Flux (W m-2 um-1) = 7.70e-16 +/- 8.52e-17\n",
"\n",
"Spectra:\n",
" - Spectrum:\n",
" - Database tag: GPI_YJHK\n",
" - Filename: ./data/companion_data/betapicb_gpi_yjhk.dat\n",
Expand Down Expand Up @@ -372,7 +405,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/tomasstolker/applications/species/species/data/database.py:1379: UserWarning: Found 33 fluxes with NaN in the data of GPI_YJHK. Removing the spectral fluxes that contain a NaN.\n",
"/Users/tomasstolker/applications/species/species/data/database.py:1355: UserWarning: Found 33 fluxes with NaN in the data of GPI_YJHK. Removing the spectral fluxes that contain a NaN.\n",
" warnings.warn(\n"
]
}
Expand Down Expand Up @@ -412,11 +445,15 @@
"output_type": "stream",
"text": [
"\n",
"---------------\n",
"Add object data\n",
"---------------\n",
"----------\n",
"Add object\n",
"----------\n",
"\n",
"Adding object: beta Pic b\n",
"Object name: beta Pic b\n",
"Units: None\n",
"Deredden: None\n",
"\n",
"Spectra:\n",
" - GRAVITY spectrum:\n",
" - Object: Unknown\n",
" - Database tag: GRAVITY\n",
Expand Down Expand Up @@ -509,7 +546,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -525,13 +562,18 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"-----------------\n",
"Fit model spectra\n",
"-----------------\n",
"\n",
"Interpolating Paranal/NACO.Lp... [DONE]\n",
"Interpolating Paranal/NACO.NB374... [DONE]\n",
"Interpolating Paranal/NACO.NB405... [DONE]\n",
Expand All @@ -541,22 +583,26 @@
"Interpolating GPI_Y... [DONE]\n",
"Interpolating GPI_YJHK... [DONE]\n",
"Interpolating GRAVITY... [DONE]\n",
"\n",
"Fitting 6 parameters:\n",
" - teff\n",
" - logg\n",
" - feh\n",
" - radius\n",
" - parallax\n",
" - scaling_GPI_H\n",
"\n",
"Uniform priors (min, max):\n",
" - teff = (1500.0, 2000.0)\n",
" - radius = (0.5, 2.0)\n",
" - logg = (3.0, 5.5)\n",
" - feh = (-0.6, 0.3)\n",
" - scaling_GPI_H = (0.5, 1.5)\n",
"\n",
"Normal priors (mean, sigma):\n",
" - mass = (9.0, 1.6)\n",
" - parallax = (50.9307, 0.1482)\n",
"\n",
"Weights for the log-likelihood function:\n",
" - GPI_H = 1.00\n",
" - GPI_J = 1.00\n",
Expand Down Expand Up @@ -606,14 +652,18 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Running nested sampling with MultiNest...\n",
"\n",
"------------------------------\n",
"Nested sampling with MultiNest\n",
"------------------------------\n",
"\n",
" *****************************************************\n",
" MultiNest v3.10\n",
" Copyright Farhan Feroz & Mike Hobson\n",
Expand All @@ -622,27 +672,38 @@
" no. of live points = 500\n",
" dimensionality = 6\n",
" *****************************************************\n",
" analysing data from multinest/.txt ln(ev)= 16477.900315547453 +/- 0.19296347197000588 \n",
" Total Likelihood Evaluations: 42441\n",
" ln(ev)= 16478.369649839929 +/- 0.19072622217532367 \n",
" analysing data from multinest/.txt\n",
" Total Likelihood Evaluations: 49040\n",
" Sampling finished. Exiting MultiNest\n",
"\n",
"Nested sampling global log-evidence: 16477.90 +/- 0.19\n",
"Nested importance sampling global log-evidence: 16476.64 +/- 0.14\n",
"Sample with the highest likelihood:\n",
" - Log-likelihood = 16499.13\n",
" - teff = 1708.78\n",
" - logg = 3.83\n",
"Nested sampling global log-evidence: 16478.37 +/- 0.19\n",
"Nested importance sampling global log-evidence: 16476.34 +/- 0.01\n",
"\n",
"Sample with the highest probability:\n",
" - Log-likelihood = 16499.09\n",
" - teff = 1710.52\n",
" - logg = 3.85\n",
" - feh = 0.12\n",
" - radius = 1.49\n",
" - parallax = 50.93\n",
" - radius = 1.48\n",
" - parallax = 50.97\n",
" - scaling_GPI_H = 1.11\n",
"\n",
"---------------------\n",
"Add posterior samples\n",
"---------------------\n",
"\n",
"Database tag: betapic\n",
"Sampler: multinest\n",
"Array shape: (2757, 6)\n",
"\n",
"Integrated autocorrelation time:\n",
" - teff: 1.41\n",
" - logg: 1.20\n",
" - feh: 1.27\n",
" - radius: 1.51\n",
" - parallax: 1.33\n",
" - scaling_GPI_H: 1.25\n"
" - teff: 1.05\n",
" - logg: 1.30\n",
" - feh: 1.24\n",
" - radius: 1.13\n",
" - parallax: 1.34\n",
" - scaling_GPI_H: 1.20\n"
]
}
],
Expand Down
Loading

0 comments on commit 57d7eca

Please sign in to comment.