Skip to content

Commit

Permalink
Added adapt_logg parameter to ReadIsochrone.get_color_magnitude, stor…
Browse files Browse the repository at this point in the history
…ing the masses and raddi in the Box from ReadIsochrone, added read_util.get_radius function for converting a log(g) and mass into a radius, updated companion data, bug fix and additional output in Database.add_comparison, support for the Keck/NIRC2.NB_4.05 filter, pylint improvements
  • Loading branch information
tomasstolker committed May 15, 2021
1 parent 6157890 commit 727983c
Show file tree
Hide file tree
Showing 12 changed files with 245 additions and 80 deletions.
2 changes: 1 addition & 1 deletion species/analysis/compare_spectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def compare_model(self,
"""
Method for finding the best fitting spectrum from a grid of atmospheric model spectra by
evaluating the goodness-of-fit statistic from Cushing et al. (2008). Currently, this method
only supports model grids with only :math:`T_\mathrm{eff}` and :math:`\log(g)` as free
only supports model grids with only :math:`T_\\mathrm{eff}` and :math:`\\log(g)` as free
parameters (e.g. BT-Settl). Please create an issue on Github if support for models with
more than two parameters is required.
Expand Down
22 changes: 18 additions & 4 deletions species/core/box.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,13 @@ def create_box(boxtype,
box.filter_mag = kwargs['filter_mag']
box.color = kwargs['color']
box.magnitude = kwargs['magnitude']
box.sptype = kwargs['sptype']
box.names = kwargs['names']
if 'sptype' in kwargs:
box.sptype = kwargs['sptype']
if 'mass' in kwargs:
box.mass = kwargs['mass']
if 'radius' in kwargs:
box.radius = kwargs['radius']

if boxtype == 'colorcolor':
box = ColorColorBox()
Expand All @@ -37,8 +42,13 @@ def create_box(boxtype,
box.filters = kwargs['filters']
box.color1 = kwargs['color1']
box.color2 = kwargs['color2']
box.sptype = kwargs['sptype']
box.names = kwargs['names']
if 'sptype' in kwargs:
box.sptype = kwargs['sptype']
if 'mass' in kwargs:
box.mass = kwargs['mass']
if 'radius' in kwargs:
box.radius = kwargs['radius']

elif boxtype == 'isochrone':
box = IsochroneBox()
Expand Down Expand Up @@ -171,8 +181,10 @@ def __init__(self):
self.filter_mag = None
self.color = None
self.magnitude = None
self.sptype = None
self.names = None
self.sptype = None
self.mass = None
self.radius = None


class ColorColorBox(Box):
Expand All @@ -193,8 +205,10 @@ def __init__(self):
self.filters = None
self.color1 = None
self.color2 = None
self.sptype = None
self.names = None
self.sptype = None
self.mass = None
self.radius = None


class IsochroneBox(Box):
Expand Down
1 change: 1 addition & 0 deletions species/core/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
M_EARTH = 5.9722e24 # (kg)
R_EARTH = 6.3781e6 # (m)
SIGMA_SB = 5.670374419e-8 # (W m−2 K−4)
ATOMIC_MASS = 1.66053906660e-27 # (kg)
80 changes: 63 additions & 17 deletions species/data/companions.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ def get_data() -> Dict[str, Dict[str, Union[bool, Tuple[float, float],
'Paranal/NACO.Lp': (15.33, 0.12), # Stolker et al. 2020
'Paranal/NACO.NB405': (15.23, 0.22), # Stolker et al. 2020
'Paranal/NACO.Mp': (14.65, 0.29)}, # Stolker et al. 2020
'semi_major': (110., 45.), # Cheetham et al. 2019
'mass_star': (1.96, 0.04), # Chauvin et al. 2017
'mass_companion': (9.9, 1.8), # Marleau et al. 2019
'accretion': False},
'semi_major': (110., 45.), # Cheetham et al. 2019
'mass_star': (1.96, 0.04), # Chauvin et al. 2017
'mass_companion': (9.9, 1.8), # Marleau et al. 2019
'accretion': False},

'51 Eri b': {'distance': (29.78, 0.12),
'app_mag': {'MKO/NSFCam.J': (19.04, 0.40), # Rajan et al. 2017
Expand Down Expand Up @@ -158,7 +158,9 @@ def get_data() -> Dict[str, Dict[str, Union[bool, Tuple[float, float],
'semi_major': (20.8, 0.7), # Wang et al. 2021
'mass_star': (0.98, 0.07), # Wang et al. 2021
'mass_companion': (3.2, 1.6), # Wang et al. 2021
'accretion': True}, # Haffert et al. 2019
'accretion': True, # Haffert et al. 2019
'line_flux': {'h-alpha': (8.1e-19, 0.3e-19), # Hashimoto et al. 2020
'h-beta': (2.3e-19, 2.3e-19)}}, # Hashimoto et al. 2020

'PDS 70 c': {'distance': (113.43, 0.52),
'app_mag': {'Paranal/NACO.NB405': (14.91, 0.35), # Stolker et al. 2020
Expand All @@ -179,7 +181,7 @@ def get_data() -> Dict[str, Dict[str, Union[bool, Tuple[float, float],
'Paranal/NACO.Lp': (15.28, 0.14)}, # Chauvin et al. 2004
'semi_major': (46., 46.), # Patience et al. 2010
'mass_star': (25.*constants.M_JUP/constants.M_SUN,
5.*constants.M_JUP/constants.M_SUN), # Mohanty et al. 2007
5.*constants.M_JUP/constants.M_SUN), # Mohanty et al. 2007
'mass_companion': (8., 2.), # Mohanty et al. 2007
'accretion': False},

Expand Down Expand Up @@ -223,6 +225,9 @@ def get_data() -> Dict[str, Dict[str, Union[bool, Tuple[float, float],
'Magellan/VisAO.ip': (18.89, 0.24), # Wu et al. 2017
'Magellan/VisAO.zp': (16.40, 0.10), # Wu et al. 2017
'Magellan/VisAO.Ys': (15.88, 0.10), # Wu et al. 2017
'MKO/NSFCam.H': (14.02, 0.13), # Stolker et al. in prep.
'Paranal/NACO.NB405': (12.29, 0.07), # Stolker et al. in prep.
'Paranal/NACO.Mp': (11.97, 0.08), # Stolker et al. in prep.
'Paranal/NACO.Ks': [(13.474, 0.031), # Ginski et al. 2014
(13.386, 0.032), # Ginski et al. 2014
(13.496, 0.050), # Ginski et al. 2014
Expand All @@ -233,7 +238,10 @@ def get_data() -> Dict[str, Dict[str, Union[bool, Tuple[float, float],
'semi_major': (150., 50.), # Schwarz et al. 2016
'mass_star': (1.03, 0.05), # MacGregor et al. 2017
'mass_companion': (25., 15.), # Wu et al. 2017
'accretion': True}, # Seifahrt et al. 2007
'radius_companion': (3.6, 0.1), # Stolker et al. in prep.
'accretion': True, # Seifahrt et al. 2007
'line_flux': {'h-alpha': (3.31e-18, 0.04e-18), # Stolker et al. in prep.
'pa-beta': (1.32e-18, 0.01e-18)}}, # Stolker et al. in prep.

'PZ Tel B': {'distance': (47.13, 0.13),
'app_mag': {'Paranal/SPHERE.ZIMPOL_R_PRIM': (17.84, 0.31), # Maire et al. 2015
Expand All @@ -250,17 +258,18 @@ def get_data() -> Dict[str, Dict[str, Union[bool, Tuple[float, float],
'Paranal/NACO.Mp': (10.93, 0.03), # Stolker et al. 2020
'Gemini/NICI.ED286': (11.68, 0.14), # Biller et al. 2010
'Gemini/NIRI.H2S1v2-1-G0220': (11.39, 0.14)}, # Biller et al. 2010
'semi_major': (25., 25.), # Maire et al. 2016
'mass_star': (1.2, 1.2), # Ginski et al. 2014
'mass_companion': (55., 17.), # Maire et al. 2016
'accretion': False},
'semi_major': (25., 25.), # Maire et al. 2016
'mass_star': (1.2, 1.2), # Ginski et al. 2014
'mass_companion': (55., 17.), # Maire et al. 2016
'accretion': False,
'line_flux': {'h-alpha': (2.2e-18, 0.9e-18)}}, # Musso Barcucci et al. 2019

'kappa And b': {'distance': (50.06, 0.87),
'app_mag': {'Subaru/CIAO.J': (15.86, 0.21), # Bonnefoy et al. 2014
'Subaru/CIAO.H': (14.95, 0.13), # Bonnefoy et al. 2014
'Subaru/CIAO.Ks': (14.32, 0.09), # Bonnefoy et al. 2014
'Keck/NIRC2.Lp': (13.12, 0.1), # Bonnefoy et al. 2014
# 'Keck/NIRC2.NB_4.05': (13.0, 0.2), # Bonnefoy et al. 2014
'Keck/NIRC2.NB_4.05': (13.0, 0.2), # Bonnefoy et al. 2014
'LBT/LMIRCam.M_77K': (13.3, 0.3)}, # Bonnefoy et al. 2014
'semi_major': (55., 55.), # Bonnefoy et al. 2014
'mass_star': (2.7, 0.1), # Jones et al. 2016
Expand Down Expand Up @@ -292,7 +301,7 @@ def get_data() -> Dict[str, Dict[str, Union[bool, Tuple[float, float],
'Keck/NIRC2.H': (15.88, 0.05), # Daemgen et al. 2017
'Keck/NIRC2.Ks': (15.01, 0.06), # Daemgen et al. 2017
'Keck/NIRC2.Lp': (13.97, 0.06), # Daemgen et al. 2017
# 'Keck/NIRC2.NB_4.05': (13.90, 0.08), # Daemgen et al. 2017
'Keck/NIRC2.NB_4.05': (13.90, 0.08), # Daemgen et al. 2017
'Keck/NIRC2.Ms': (14.01, 0.23)}, # Daemgen et al. 2017
'semi_major': (157., 157.), # Currie et al. 2014
'mass_star': (0.89, 0.08), # Kraus et al. 2014
Expand Down Expand Up @@ -337,7 +346,9 @@ def get_data() -> Dict[str, Dict[str, Union[bool, Tuple[float, float],
'semi_major': (84., 84.), # Delorme et al. 2013
'mass_star': (0.19, 0.02), # Delorme et al. 2013
'mass_companion': (13., 1.), # Delorme et al. 2013
'accretion': True}, # Eriksson et al. 2020
'accretion': True, # Eriksson et al. 2020
'line_flux': {'h-alpha': (12.80e-19, 0.70e-19),
'h-beta': (1.39e-19, 0.10e-19)}}, # Eriksson et al. 2020

'1RXS 1609 B': {'distance': (139.67, 1.33),
'app_mag': {'Gemini/NIRI.J-G0202w': (17.90, 0.12), # Lafreniere et al. 2008
Expand All @@ -358,7 +369,9 @@ def get_data() -> Dict[str, Dict[str, Union[bool, Tuple[float, float],
'semi_major': (320., 320.), # Bowler et al. 2011
'mass_star': (0.9, 0.1), # Bowler et al. 2011
'mass_companion': (14., 2.), # Bowler et al. 2011
'accretion': True}, # Bowler et al. 2011
'accretion': True, # Bowler et al. 2011
'line_flux': {'h-alpha': (7.08e-19, 2.12e-18), # Zhou et al. 2014
'pa-beta': (1.12e-18, 0.03e-18)}}, # Bowler et al. 2011

'HD 72946 B': {'distance': (25.87, 0.03),
'app_mag': {'Paranal/SPHERE.IRDIS_D_H23_2': (14.56, 0.07), # Maire et al. 2019
Expand Down Expand Up @@ -434,7 +447,9 @@ def get_data() -> Dict[str, Dict[str, Union[bool, Tuple[float, float],
'mass_star': (2.0, 0.3), # Mendigutía et al. 2014
'mass_companion': (0.13*constants.M_SUN/constants.M_JUP,
0.03*constants.M_SUN/constants.M_JUP), # Lacour et al. 2016
'accretion': True}, # Close et al. 2014
'radius_companion': (19.1, 1.0), # Christiaens et al. 2018
'accretion': True, # Close et al. 2014
'line_flux': {'h-alpha': (7.6e-17, 3.5e-17)}}, # Cugno et al. 2019 TODO extinction?

'CS Cha B': {'distance': (168.77, 1.92),
'app_mag': {'Paranal/SPHERE.IRDIS_B_J': (19.16, 0.21), # Ginski et al. 2018
Expand All @@ -444,6 +459,37 @@ def get_data() -> Dict[str, Dict[str, Union[bool, Tuple[float, float],
'mass_star': (1.0, 0.1), # Ginski et al. 2018
'mass_companion': (0.3*constants.M_SUN/constants.M_JUP,
0.1*constants.M_SUN/constants.M_JUP), # Haffert et al. 2020
'accretion': True}} # Haffert et al. 2020
'accretion': True, # Haffert et al. 2020
'line_flux': {'h-alpha': (17.3e-20, 2.1e-20)}}, # Haffert et al. 2020

'CT Cha B': {'distance': (189.95, 0.42),
'app_mag': {'Paranal/NACO.J': (16.61, 0.30), # Schmidt et al. 2008
'Paranal/NACO.Ks': [(14.95, 0.30), # Schmidt et al. 2008
(14.89, 0.30)]}, # Schmidt et al. 2008
'semi_major': (430., 0.), # Wu et al. 2015
'mass_star': (0.55, 0.), # Hartmann et al. 1998
'mass_companion': (19., 5.), # Wu et al. 2015
'accretion': True}, # Wu et al. 2015

'SR 12 C': {'distance': (125., 25.), # Bouvier & Appenzeller 1992
'app_mag': {'MKO/NSFCam.J': (15.93, 0.03), # Kuzuhara et al. 2011
'MKO/NSFCam.H': (15.18, 0.03), # Kuzuhara et al. 2011
'MKO/NSFCam.Ks': (14.57, 0.03), # Kuzuhara et al. 2011
'MKO/NSFCam.Lp': (13.10, 0.08)}, # Kuzuhara et al. 2011
'semi_major': (1100., 0.), # Bowler et al. 2014
'mass_star': (1.05, 0.05), # Bowler et al. 2014
'mass_companion': (13., 7.), # Kuzuhara et al. 2011
'accretion': True, # Santamaría-Miranda et al. 2017
'line_flux': {'h-alpha': (1.34e-18, 0.05e-18), # Santamaría-Miranda et al. 2017 (erratum)
'h-beta': (2.19e-19, 0.03e-19)}}, # Santamaría-Miranda et al. 2017 (erratum)

'DH Tau B': {'distance': (133.45, 0.45),
'app_mag': {'Subaru/CIAO.J': (15.71, 0.05), # Itoh et al. 2005
'Subaru/CIAO.H': (14.96, 0.04), # Itoh et al. 2005
'Subaru/CIAO.Ks': (14.19, 0.02)}, # Itoh et al. 2005
'semi_major': (330., 0.), # Patience et al. 2012
'mass_star': (0.33, 0.), # Patience et al. 2012
'mass_companion': (11., 3.), # Patience et al. 2012
'accretion': True}} # Zhou et al. 2014

return data
10 changes: 7 additions & 3 deletions species/data/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -1432,7 +1432,8 @@ def get_compare_sample(self,
model_param['distance'] = dset.attrs['distance']

if n_spec_name == 1:
model_param['radius'] = dset.attrs[f'radius_{item}']
spec_name = dset.attrs['spec_name0']
model_param['radius'] = dset.attrs[f'radius_{spec_name}']

else:
if spec_fix is None:
Expand Down Expand Up @@ -2070,12 +2071,15 @@ def add_comparison(self,

# Indices of the best-fit model
best_index = np.unravel_index(goodness_sum.argmin(), goodness_sum.shape)
dset.attrs['best_fit'] = goodness_sum[best_index]

print('Best-fit parameters:')
print(f' - Goodness-of-fit = {goodness_sum[best_index]:.2e}')

for i, item in enumerate(model_param):
best_param = coord_points[i][best_index[i]]
dset.attrs[f'best_param{i}'] = best_param
print(f' - {item} = {best_param}')

for i, item in enumerate(spec_name):
scaling = flux_scaling[best_index[0], best_index[1], best_index[2], i]
Expand All @@ -2084,7 +2088,7 @@ def add_comparison(self,
radius /= constants.R_JUP # (Rjup)

dset.attrs[f'radius_{item}'] = radius
print(f' - {item} radius (Rjup) = {radius:.2f}')
print(f' - {item} radius (Rjup) = {radius:.2f}')

dset.attrs[f'scaling_{item}'] = scaling
print(f' - {item} scaling = {scaling:.2e}')
print(f' - {item} scaling = {scaling:.2e}')
14 changes: 14 additions & 0 deletions species/data/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,20 @@ def download_filter(filter_id: str) -> Tuple[Optional[np.ndarray],

os.remove('VisAO_zp_filter_curve.dat')

elif filter_id == 'Keck/NIRC2.NB_4.05':
# The filter profile of Br_alpha has been digitized from
# https://www2.keck.hawaii.edu/inst/nirc2/filters.html

url = 'https://home.strw.leidenuniv.nl/~stolker/species/Keck_NIRC2.NB_4.05.dat'
urllib.request.urlretrieve(url, 'Keck_NIRC2.NB_4.05.dat')

wavelength, transmission = np.loadtxt('Keck_NIRC2.NB_4.05.dat', unpack=True)

# Not sure if energy- or photon-counting detector
det_type = 'photon'

os.remove('Keck_NIRC2.NB_4.05.dat')

elif filter_id in ['LCO/VisAO.Ys', 'Magellan/VisAO.Ys']:
url = 'https://xwcl.science/magao/visao/VisAO_Ys_filter_curve.dat'
urllib.request.urlretrieve(url, 'VisAO_Ys_filter_curve.dat')
Expand Down
Loading

0 comments on commit 727983c

Please sign in to comment.