From ec8f9c4aafbdec07552d9a4893e02cdb60b1bccf Mon Sep 17 00:00:00 2001 From: Tomas Stolker Date: Fri, 13 Sep 2024 11:42:45 +0200 Subject: [PATCH] Removed dependency versions from requirements.txt apart from NumPy, add AF Lep b and HD 206893 c to companion_data, added some ages and updated semi-major axis to companion_data, changed scipy.integrate.simps to simpson, removed Exo-Rem warning --- docs/tutorials/companion_data.ipynb | 14 +- requirements.txt | 54 ++-- .../data/companion_data/companion_data.json | 240 ++++++++++++++++-- species/data/database.py | 8 +- species/data/model_data/model_spectra.py | 9 - species/fit/retrieval.py | 4 +- species/read/read_model.py | 17 +- species/util/model_util.py | 2 +- 8 files changed, 265 insertions(+), 83 deletions(-) diff --git a/docs/tutorials/companion_data.ipynb b/docs/tutorials/companion_data.ipynb index fe0a1b5..2dcc535 100644 --- a/docs/tutorials/companion_data.ipynb +++ b/docs/tutorials/companion_data.ipynb @@ -63,7 +63,7 @@ "output_type": "stream", "text": [ "==============\n", - "species v0.8.3\n", + "species v0.8.4\n", "==============\n", "\n", "Working folder: /Users/tomasstolker/applications/species/docs/tutorials\n", @@ -83,7 +83,7 @@ { "data": { "text/plain": [ - "" + "" ] }, "execution_count": 2, @@ -141,7 +141,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "Add companion: ['beta Pic b', 'beta Pic c', 'HIP 65426 b', '51 Eri b', 'HR 8799 b', 'HR 8799 c', 'HR 8799 d', 'HR 8799 e', 'HD 95086 b', 'PDS 70 b', 'PDS 70 c', '2M 1207 B', 'AB Pic B', 'HD 206893 B', 'RZ Psc B', 'GQ Lup B', 'PZ Tel B', 'kappa And b', 'HD 1160 B', 'ROXs 12 B', 'ROXs 42 Bb', 'GJ 504 b', 'GJ 758 B', 'GU Psc b', '2M0103 ABb', '1RXS 1609 B', 'GSC 06214 B', 'HD 72946 B', 'HIP 64892 B', 'HD 13724 B', 'YSES 1 b', 'YSES 1 c', 'YSES 2 b', 'HD 142527 B', 'CS Cha B', 'CT Cha B', 'SR 12 C', 'DH Tau B', 'HD 4747 B', 'HR 3549 B', 'CHXR 73 B', 'HD 19467 B', 'b Cen (AB)b', 'VHS 1256 B']\n" + "Add companion: ['AF Lep b', 'beta Pic b', 'beta Pic c', 'HIP 65426 b', '51 Eri b', 'HR 8799 b', 'HR 8799 c', 'HR 8799 d', 'HR 8799 e', 'HD 95086 b', 'PDS 70 b', 'PDS 70 c', '2M 1207 B', 'AB Pic B', 'HD 206893 B', 'RZ Psc B', 'GQ Lup B', 'PZ Tel B', 'kappa And b', 'HD 1160 B', 'ROXs 12 B', 'ROXs 42 Bb', 'GJ 504 b', 'GJ 758 B', 'GU Psc b', '2M0103 ABb', '1RXS 1609 B', 'GSC 06214 B', 'HD 72946 B', 'HIP 64892 B', 'HD 13724 B', 'YSES 1 b', 'YSES 1 c', 'YSES 2 b', 'HD 142527 B', 'CS Cha B', 'CT Cha B', 'SR 12 C', 'DH Tau B', 'HD 4747 B', 'HR 3549 B', 'CHXR 73 B', 'HD 19467 B', 'b Cen (AB)b', 'VHS 1256 B']\n" ] }, { @@ -162,7 +162,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "100%|████████████████████████████████████████| 288k/288k [00:00<00:00, 160MB/s]" + "100%|████████████████████████████████████████| 288k/288k [00:00<00:00, 120MB/s]" ] }, { @@ -177,9 +177,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "\n", - "/Users/tomasstolker/applications/species/species/data/database.py:1420: UserWarning: Found 33 fluxes with NaN in the data of GPI_YJHK. Removing the spectral fluxes that contain a NaN.\n", - " warnings.warn(\n" + "\n" ] }, { @@ -195,6 +193,8 @@ "name": "stderr", "output_type": "stream", "text": [ + "/Users/tomasstolker/applications/species/species/data/database.py:1421: UserWarning: Found 33 fluxes with NaN in the data of GPI_YJHK. Removing the spectral fluxes that contain a NaN.\n", + " warnings.warn(\n", "/Users/tomasstolker/applications/species/species/data/filter_data/filter_data.py:227: UserWarning: The minimum transmission value of Subaru/CIAO.z is smaller than zero (-1.80e-03). Wavelengths with negative transmission values will be removed.\n", " warnings.warn(\n" ] diff --git a/requirements.txt b/requirements.txt index f2c4d2b..bf2c25b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,27 +1,27 @@ -astrodbkit2 ~= 0.5.0 -astropy ~= 6.0.0 -astroquery ~= 0.4.0 -corner ~= 2.2.0 -dynesty ~= 2.1.0 -emcee ~= 3.1.0 -h5py ~= 3.11.0 -matplotlib ~= 3.8.0 -molmass ~= 2023.8.0 -numba ~= 0.59.0 -numpy ~= 1.26.0 -pandas ~= 2.2.0 -pooch ~= 1.8.0 -PyAstronomy ~= 0.21.0 -PyMieScatt ~= 1.8.0 -pymultinest ~= 2.12.0 -requests ~= 2.32.0 -schwimmbad ~= 0.4.0 -scipy ~= 1.13.0 -shapely ~= 2.0.0 -spectres ~= 2.2.0 -specutils ~= 1.15.0 -SQLAlchemy ~= 2.0.0 -tqdm ~= 4.66.0 -typeguard ~= 4.3.0 -ultranest ~= 4.3.0 -xlrd ~= 2.0.0 +astrodbkit2 +astropy +astroquery +corner +dynesty +emcee +h5py +matplotlib +molmass +numba +numpy < 2.0.0 +pandas +pooch +PyAstronomy +PyMieScatt +pymultinest +requests +schwimmbad +scipy +shapely +spectres +specutils +SQLAlchemy +tqdm +typeguard +ultranest +xlrd diff --git a/species/data/companion_data/companion_data.json b/species/data/companion_data/companion_data.json index b94cbbc..47d49df 100644 --- a/species/data/companion_data/companion_data.json +++ b/species/data/companion_data/companion_data.json @@ -1,4 +1,49 @@ { + "AF Lep b": { + "simbad": "V* AF Lep", + "parallax": [ + 37.2539, + 0.0195 + ], + "app_mag": { + "Paranal/SPHERE.IRDIS_D_H23_2": [ + 17.50, + 0.13 + ], + "Paranal/SPHERE.IRDIS_D_K12_1": [ + 16.70, + 0.09 + ], + "Paranal/SPHERE.IRDIS_D_K12_2": [ + 16.85, + 0.12 + ] + }, + "semi_major": [ + 9.3, + -2.4, + 2.4 + ], + "mass_star": [ + 1.29, + 0.20 + ], + "mass_companion": [ + 4.3, + 2.9 + ], + "accretion": false, + "age": [ + 24.0, + -3.0, + 3.0 + ], + "references": [ + "Bell et al. 2015", + "De Rose et al. 2023", + "Gaia Early Data Release 3" + ] + }, "beta Pic b": { "simbad": "beta Pic", "parallax": [ @@ -44,8 +89,9 @@ ] }, "semi_major": [ - 10.31, - 0.11 + 9.90, + -0.05, + 0.05 ], "mass_star": [ 1.83, @@ -56,12 +102,19 @@ 2.7 ], "accretion": false, + "age": [ + 18.5, + -2.4, + 2.0 + ], "references": [ "Bonnefoy et al. 2011", "Currie et al. 2013", "Gaia Early Data Release 3", "Males et al. 2014", "Mirek Brandt et al. 2021", + "Miret-Roig et al. 2020", + "Nowak et al. 2020", "Stolker et al. 2019", "Stolker et al. 2020a" ] @@ -79,8 +132,9 @@ ] }, "semi_major": [ - 2.75, - 0.04 + 2.72, + -0.02, + 0.02 ], "mass_star": [ 1.83, @@ -91,9 +145,15 @@ 1.1 ], "accretion": false, + "age": [ + 18.5, + -2.4, + 2.0 + ], "references": [ "Gaia Early Data Release 3", "Mirek Brandt et al. 2021", + "Miret-Roig et al. 2020", "Nowak et al. 2020" ] }, @@ -134,8 +194,9 @@ ] }, "semi_major": [ - 110.0, - 45.0 + 62.2, + -7.2, + 14.7 ], "mass_star": [ 1.96, @@ -146,7 +207,13 @@ 1.8 ], "accretion": false, + "age": [ + 14.0, + 4.0, + 4.0 + ], "references": [ + "Blunt et al. 2023", "Chauvin et al. 2017", "Cheetham et al. 2019", "Gaia Early Data Release 3", @@ -195,8 +262,9 @@ ] }, "semi_major": [ - 12.0, - 4.0 + 10.4, + -1.1, + 0.8 ], "mass_star": [ 1.75, @@ -207,9 +275,16 @@ 4.9 ], "accretion": false, + "age": [ + 20.0, + 6.0, + 6.0 + ], "references": [ + "Dupuy et al. 2022", "Gaia Early Data Release 3", "Maire et al. 2019", + "Macintosh et al. 2015", "Rajan et al. 2017", "Samland et al. 2017", "Simon & Schaefer 2011" @@ -268,8 +343,9 @@ ] }, "semi_major": [ - 69.5, - 9.3 + 71.3, + -0.2, + 0.2 ], "mass_star": [ 1.52, @@ -280,6 +356,11 @@ 0.5 ], "accretion": false, + "age": [ + 42.0, + -16.0, + 14.0 + ], "references": [ "Baines et al. 2012", "Currie et al. 2011", @@ -288,6 +369,7 @@ "Gaia Early Data Release 3", "Galicher et al. 2011", "Marois et al. 2010", + "Mirek Brandt et al. 2021", "Wang et al. 2018", "Zurlo et al. 2016" ] @@ -341,8 +423,9 @@ ] }, "semi_major": [ - 37.6, - 2.2 + 41.0, + -0.15, + 0.15 ], "mass_star": [ 1.52, @@ -353,6 +436,11 @@ 0.7 ], "accretion": false, + "age": [ + 42.0, + -16.0, + 14.0 + ], "references": [ "Baines et al. 2012", "Currie et al. 2012", @@ -360,6 +448,7 @@ "Gaia Early Data Release 3", "Galicher et al. 2011", "Marois et al. 2010", + "Mirek Brandt et al. 2021", "Wang et al. 2018", "Zurlo et al. 2016" ] @@ -413,8 +502,9 @@ ] }, "semi_major": [ - 27.7, - 2.2 + 26.55, + -0.12, + 0.12 ], "mass_star": [ 1.52, @@ -425,6 +515,11 @@ 0.7 ], "accretion": false, + "age": [ + 42.0, + -16.0, + 14.0 + ], "references": [ "Baines et al. 2012", "Currie et al. 2012", @@ -432,6 +527,7 @@ "Gaia Early Data Release 3", "Galicher et al. 2011", "Marois et al. 2010", + "Mirek Brandt et al. 2021", "Wang et al. 2018", "Zurlo et al. 2016" ] @@ -477,8 +573,9 @@ ] }, "semi_major": [ - 15.3, - 1.4 + 16.0, + -0.1, + 0.1 ], "mass_star": [ 1.52, @@ -489,11 +586,17 @@ 0.7 ], "accretion": false, + "age": [ + 42.0, + -16.0, + 14.0 + ], "references": [ "Baines et al. 2012", "Currie et al. 2014", "Gaia Early Data Release 3", "Marois et al. 2010", + "Mirek Brandt et al. 2021", "Wang et al. 2018", "Zurlo et al. 2016" ] @@ -519,8 +622,9 @@ ] }, "semi_major": [ - 52.0, - 24.0 + 72, + -21.0, + 1.0 ], "mass_star": [ 1.6, @@ -531,9 +635,15 @@ 2.0 ], "accretion": false, + "age": [ + 17.0, + 2.0, + 2.0 + ], "references": [ "Chauvin et al. 2018", "De Rosa et al. 2016", + "Desgrange et al. 2022", "Gaia Early Data Release 3", "Rameau et al. 2013" ] @@ -588,6 +698,7 @@ }, "semi_major": [ 20.8, + -0.7, 0.7 ], "mass_star": [ @@ -636,6 +747,7 @@ }, "semi_major": [ 34.3, + -2.2, 2.2 ], "mass_star": [ @@ -697,6 +809,7 @@ }, "semi_major": [ 46.0, + -46.0, 46.0 ], "mass_star": [ @@ -738,6 +851,7 @@ }, "semi_major": [ 260.0, + -260.0, 260.0 ], "mass_star": [ @@ -788,8 +902,9 @@ ] }, "semi_major": [ - 11.0, - 11.0 + 9.6, + -0.3, + 0.4 ], "mass_star": [ 1.31, @@ -800,15 +915,53 @@ 20.0 ], "accretion": false, + "age": [ + 155.0, + -15.0, + 15.0 + ], "references": [ "Delorme et al. 2017", "Gaia Early Data Release 3", "Grandjean et al. 2019", + "Hinkley et al. 2023", + "Kammerer et al. 2021", "Milli et al. 2017", "Stolker et al. 2020a", "Ward-Duong et al. 2020" ] }, + "HD 206893 c": { + "simbad": "HD 206893", + "parallax": [ + 24.5275, + 0.0354 + ], + "semi_major": [ + 3.53, + -0.06, + 0.08 + ], + "mass_star": [ + 1.31, + 0.03 + ], + "mass_companion": [ + 20.0, + 20.0 + ], + "accretion": false, + "age": [ + 155.0, + -15.0, + 15.0 + ], + "references": [ + "Gaia Early Data Release 3", + "Hinkley et al. 2023", + "Ward-Duong et al. 2020" + ] + }, "RZ Psc B": { "simbad": "RZ Psc", "parallax": [ @@ -833,6 +986,7 @@ }, "semi_major": [ 23.0, + -23.0, 23.0 ], "mass_star": [ @@ -933,6 +1087,7 @@ }, "semi_major": [ 150.0, + -50.0, 50.0 ], "mass_star": [ @@ -1039,6 +1194,7 @@ }, "semi_major": [ 25.0, + -25.0, 25.0 ], "mass_star": [ @@ -1100,6 +1256,7 @@ }, "semi_major": [ 55.0, + -55.0, 55.0 ], "mass_star": [ @@ -1148,6 +1305,7 @@ }, "semi_major": [ 81.0, + -81.0, 81.0 ], "mass_star": [ @@ -1188,6 +1346,7 @@ }, "semi_major": [ 210.0, + -210.0, 210.0 ], "mass_star": [ @@ -1239,6 +1398,7 @@ }, "semi_major": [ 157.0, + -157.0, 157.0 ], "mass_star": [ @@ -1313,6 +1473,7 @@ }, "semi_major": [ 43.5, + -43.5, 43.5 ], "mass_star": [ @@ -1353,7 +1514,11 @@ }, "mass_star": [0.96, 0.03], "mass_companion": [38.0, 0.8], - "semi_major": [29.7, 5.3], + "semi_major": [ + 29.7, + -5.3, + 5.3 + ], "accretion": false, "references": [ "Gaia Early Data Release 3", @@ -1400,6 +1565,7 @@ }, "semi_major": [ 2000.0, + -2000.0, 2000.0 ], "mass_star": [ @@ -1442,6 +1608,7 @@ }, "semi_major": [ 84.0, + -84.0, 84.0 ], "mass_star": [ @@ -1495,6 +1662,7 @@ }, "semi_major": [ 330.0, + -320.0, 320.0 ], "mass_star": [ @@ -1544,6 +1712,7 @@ }, "semi_major": [ 320.0, + -320.0, 320.0 ], "mass_star": [ @@ -1591,6 +1760,7 @@ }, "semi_major": [ 6.45, + -0.08, 0.08 ], "mass_star": [ @@ -1637,6 +1807,7 @@ }, "semi_major": [ 159.0, + -159.0, 159.0 ], "mass_star": [ @@ -1687,6 +1858,7 @@ }, "semi_major": [ 26.3, + -5.6, 5.6 ], "mass_star": [ @@ -1765,6 +1937,7 @@ }, "semi_major": [ 162.0, + -162.0, 162.0 ], "mass_star": [ @@ -1828,6 +2001,7 @@ }, "semi_major": [ 320.0, + -320.0, 320.0 ], "mass_star": [ @@ -1863,6 +2037,7 @@ }, "semi_major": [ 115.0, + -115.0, 115.0 ], "mass_star": [ @@ -1963,6 +2138,7 @@ }, "semi_major": [ 38.0, + -20.0, 20.0 ], "mass_star": [ @@ -2019,7 +2195,8 @@ }, "semi_major": [ 214.0, - 0.0 + -214.0, + 214.0 ], "mass_star": [ 1.0, @@ -2066,7 +2243,8 @@ }, "semi_major": [ 430.0, - 0.0 + -430.0, + 430.0 ], "mass_star": [ 0.55, @@ -2111,7 +2289,8 @@ }, "semi_major": [ 1100.0, - 0.0 + -1100.0, + 1100.0 ], "mass_star": [ 1.05, @@ -2162,7 +2341,8 @@ }, "semi_major": [ 330.0, - 0.0 + -330.0, + 330.0 ], "mass_star": [ 0.33, @@ -2198,6 +2378,7 @@ }, "semi_major": [ 10.1, + -0.4, 0.4 ], "mass_star": [ @@ -2251,7 +2432,8 @@ }, "semi_major": [ 80.0, - 0.0 + -80.0, + 80.0 ], "mass_star": [ 2.32, @@ -2286,7 +2468,8 @@ }, "semi_major": [ 210.0, - 0.0 + -210.0, + 210.0 ], "mass_star": [ 0.35, @@ -2332,6 +2515,7 @@ }, "semi_major": [ 54.0, + -9.0, 9.0 ], "mass_star": [ @@ -2374,6 +2558,7 @@ }, "semi_major": [ 530.0, + -530.0, 530.0 ], "mass_star": [ @@ -2420,6 +2605,7 @@ }, "semi_major": [ 150.0, + -150.0, 150.0 ], "mass_star": [ diff --git a/species/data/database.py b/species/data/database.py index d2157e9..e1a2bf5 100644 --- a/species/data/database.py +++ b/species/data/database.py @@ -19,7 +19,7 @@ from astropy.coordinates import SkyCoord from astropy.io import fits from astropy.units.quantity import Quantity -from scipy.integrate import simps +from scipy.integrate import simpson from tqdm.auto import tqdm from typeguard import typechecked @@ -4203,7 +4203,7 @@ def add_retrieval( sample_scale = (sample_distance / sample_radius) ** 2 # Blackbody flux: sigma * Teff^4 - flux_int = simps(sample_scale * box_item.flux, box_item.wavelength) + flux_int = simpson(sample_scale * box_item.flux, box_item.wavelength) teff[i] = (flux_int / constants.SIGMA_SB) ** 0.25 db_tag = f"results/fit/{tag}/samples" @@ -4583,7 +4583,7 @@ def get_retrieval_teff( sample_scale = (sample_distance / sample_radius) ** 2 # Blackbody flux: sigma * Teff^4 - flux_int = simps(sample_scale * box_item.flux, box_item.wavelength) + flux_int = simpson(sample_scale * box_item.flux, box_item.wavelength) t_eff[i] = (flux_int / constants.SIGMA_SB) ** 0.25 # Bolometric luminosity: 4 * pi * R^2 * sigma * Teff^4 @@ -4879,7 +4879,7 @@ def petitcode_param( # Blackbody flux: sigma * Teff^4 # Scale the flux back to the planet surface - flux_int = simps( + flux_int = simpson( model_box.flux * (distance / radius) ** 2, model_box.wavelength ) pcode_param["teff"] = (flux_int / constants.SIGMA_SB) ** 0.25 diff --git a/species/data/model_data/model_spectra.py b/species/data/model_data/model_spectra.py index 5db0dcd..b0f6c21 100644 --- a/species/data/model_data/model_spectra.py +++ b/species/data/model_data/model_spectra.py @@ -103,15 +103,6 @@ def add_model_grid( "add_model of Database." ) - elif model_tag == "exo-rem": - warnings.warn( - "The Exo-Rem grid has been updated to the latest version " - "from https://lesia.obspm.fr/exorem/YGP_grids/. Please " - "consider removing the grid from the 'data_folder' if " - "needed such that the latest version of the grid will " - "be downloaded and added to the HDF5 database." - ) - elif model_tag == "exo-rem-highres": if teff_range is None: warnings.warn( diff --git a/species/fit/retrieval.py b/species/fit/retrieval.py index 1b3593b..880ca03 100644 --- a/species/fit/retrieval.py +++ b/species/fit/retrieval.py @@ -35,7 +35,7 @@ from molmass import Formula from PyAstronomy.pyasl import fastRotBroad from schwimmbad import MPIPool -from scipy.integrate import simps +from scipy.integrate import simpson from scipy.interpolate import interp1d from scipy.stats import invgamma, norm from typeguard import typechecked @@ -2331,7 +2331,7 @@ def _lnlike( plt.clf() # Bolometric flux (W m-2) from the low-resolution spectrum - f_bol_spec = simps(flux_lowres, wlen_lowres) + f_bol_spec = simpson(flux_lowres, wlen_lowres) # Calculate again a low-resolution spectrum (R = 10) but now # with the new Feautrier function from petitRADTRANS diff --git a/species/read/read_model.py b/species/read/read_model.py index 409ada4..27e10d2 100644 --- a/species/read/read_model.py +++ b/species/read/read_model.py @@ -1830,11 +1830,16 @@ def binary_spectrum( def integrate_spectrum(self, model_param: Dict[str, float]) -> float: """ Function for calculating the bolometric flux by integrating - a model spectrum at the requested parameters. In principle, - the calculated luminosity should be approximately the same - as the value that can be calculated directly from the - :math:`T_\\mathrm{eff}` and radius parameters, unless the - atmospheric model had not properly converged. + a model spectrum at the requested parameters. Therefore, when + extinction is applied to the spectrum, the luminosity is the + extinct luminosity and not the intrinsic luminosity. Without + applying extinction, the integrated luminosity should in + principle be the same as the luminosity calculated directly + from the :math:`T_\\mathrm{eff}` and radius parameters. Unless + a particular spectrum from a radiative-convective model had + not fully converged, so it can be useful to check if the + integrated luminosity is indeed consistent with the + :math:`T_\\mathrm{eff}` of the model. Parameters ---------- @@ -1855,7 +1860,7 @@ def integrate_spectrum(self, model_param: Dict[str, float]) -> float: raise ValueError( "Please include the 'radius' parameter " "in the 'model_param' dictionary, " - "which is require for calculating the " + "which is required for calculating the " "bolometric luminosity." ) diff --git a/species/util/model_util.py b/species/util/model_util.py index d605435..ce92afd 100644 --- a/species/util/model_util.py +++ b/species/util/model_util.py @@ -209,7 +209,7 @@ def gaussian_spectrum( # readmodel = ReadModel(modelbox.model) # fullspec = readmodel.get_model(modelbox.parameters) # -# flux = simps(fullspec.flux, fullspec.wavelength) +# flux = simpson(fullspec.flux, fullspec.wavelength) # # if "parallax" in modelbox.parameters: # luminosity = (