Skip to content

Commit

Permalink
updated docs, color-color features, companion magnitudes, automatic c…
Browse files Browse the repository at this point in the history
…reation of configuration file
  • Loading branch information
Tomas Stolker committed Jul 5, 2019
1 parent 0db44e2 commit 6ea1c24
Show file tree
Hide file tree
Showing 10 changed files with 221 additions and 84 deletions.
21 changes: 21 additions & 0 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.. _configuration:

Configuration
=============

A configuration file is required in the working folder with the name `species_config.ini`. The file contains the path to the HDF5 database, the path to the configuration file, and the folder where all the data is dowloaded before it is stored into the database.

The paths can be either absolute or relative to the working folder. It is recommended to use the same input folder for different configurations of `species` such that data only has to be downloaded once. As an example, this is what the content of the configuration file may look like:

.. code-block:: ini
[species]
database = species_database.hdf5
config = species_config.ini
input = /path/to/store/data/
A configuration file with default values is automatically created when `species` is initiated by running :class:`~species.core.setup.SpeciesInit` and no configuration file is present in the working folder, for example::

import species

species.SpeciesInit(config_path='./')
10 changes: 0 additions & 10 deletions docs/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,6 @@
Examples
========

Configuration file
------------------

A configuration file is required in the working folder. In this case, the configuration file is named *species_config.ini* and its content is::

[species]
database = species_database.hdf5
config = species_config.ini
input = /path/to/store/data/

Conversion of photometry units
------------------------------

Expand Down
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Documentation for species
:caption: User Documentation

overview
configuration
examples
modules

Expand Down
2 changes: 1 addition & 1 deletion docs/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Data which are read from the database, as well as the output of the various *spe

import species

species.SpeciesInit('./')
species.SpeciesInit(config_path='./')

database = species.Database()
database.add_companion(name='PZ Tel B')
Expand Down
49 changes: 26 additions & 23 deletions species/core/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,15 @@ class SpeciesInit:
def __init__(self,
config_path):
"""
:param config_path: Location of the configuration file (species_config.ini).
:type config_path: str
:return: None
Parameters
----------
config_path : str
Location of the configuration file named *species_config.ini*.
Returns
-------
NoneType
None
"""

sys.stdout.write('Initiating species v'+species.__version__+'...')
Expand All @@ -32,15 +37,29 @@ def __init__(self,

config_file = os.path.join(self.config_path, 'species_config.ini')

sys.stdout.write(' [DONE]\n')
sys.stdout.flush()

if not os.path.isfile(config_file):

sys.stdout.write('Creating species_config.ini...')
sys.stdout.flush()

with open(config_file, 'w') as file_obj:
file_obj.write('[species]\n')
file_obj.write('database = species_database.hdf5\n')
file_obj.write('config = species_config.ini\n')
file_obj.write('input = ./')

sys.stdout.write(' [DONE]\n')
sys.stdout.flush()

config = configparser.ConfigParser()
config.read_file(open(config_file))

database_file = config['species']['database']
input_path = config['species']['input']

sys.stdout.write(' [DONE]\n')
sys.stdout.flush()

if not os.path.exists(input_path):
sys.stdout.write('Creating input folder...')
sys.stdout.flush()
Expand All @@ -59,19 +78,3 @@ def __init__(self,

sys.stdout.write(' [DONE]\n')
sys.stdout.flush()

if not os.path.isfile(config_file):
sys.stdout.write('Creating species_config.ini...')
sys.stdout.flush()

config = configparser.ConfigParser()

config['species'] = {'database': database_file,
'config': config_file,
'input': input_path}

with open(config_file, 'w') as config_ini:
config.write(config_ini)

sys.stdout.write(' [DONE]\n')
sys.stdout.flush()
5 changes: 5 additions & 0 deletions species/data/ames_dusty.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ def add_ames_dusty(input_path,
data_wavel.append(float(line[1:23].replace('D', 'E')))
data_flux.append(float(line[25:35].replace('D', 'E')))

elif len(tmp_wavel) == 21 and tmp_wavel[-4] == 'E' \
and tmp_flux[-4] == 'E':
data_wavel.append(float(line[1:23]))
data_flux.append(float(line[25:35]))

# See https://phoenix.ens-lyon.fr/Grids/FORMAT
data_wavel = np.asarray(data_wavel)*1e-4 # [Angstrom] -> [micron]
data_flux = 10.**(np.asarray(data_flux)-8.) # [erg s-1 cm-2 Angstrom-1]
Expand Down
40 changes: 16 additions & 24 deletions species/data/companions.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def get_data():
'Keck/NIRC2.Ks': (17.03, 0.08), # Marois et al. 2010
'Paranal/SPHERE.IRDIS_D_K12_1': (17.15, 0.06), # Zurlo et al. 2016
'Paranal/SPHERE.IRDIS_D_K12_2': (16.97, 0.09), # Zurlo et al. 2016
'Keck/NIRC2.Lp': (15.58, 0.10), # Currie et al. 2014
'Paranal/NACO.NB405': (14.92, 0.18), # Currie et al. 2014
'Paranal/NACO.Lp': (15.52, 0.10), # Currie et al. 2014
'Paranal/NACO.NB405': (14.82, 0.18), # Currie et al. 2014
'Keck/NIRC2.Ms': (16.05, 0.30)}}, # Galicher et al. 2011

'HR 8799 c': {'distance': 41.29,
Expand All @@ -60,31 +60,31 @@ def get_data():
'Keck/NIRC2.Ks': (16.11, 0.08), # Marois et al. 2010
'Paranal/SPHERE.IRDIS_D_K12_1': (16.19, 0.05), # Zurlo et al. 2016
'Paranal/SPHERE.IRDIS_D_K12_2': (15.86, 0.07), # Zurlo et al. 2016
'Keck/NIRC2.Lp': (15.72, 0.08), # Currie et al. 2014
'Paranal/NACO.NB405': (14.07, 0.08), # Currie et al. 2014
'Paranal/NACO.Lp': (14.65, 0.11), # Currie et al. 2014
'Paranal/NACO.NB405': (13.97, 0.11), # Currie et al. 2014
'Keck/NIRC2.Ms': (15.03, 0.14)}}, # Galicher et al. 2011

'HR 8799 d': {'distance': 41.29,
'app_mag': {'Paranal/SPHERE.IRDIS_B_J': (18.59, 0.37), # Zurlo et al. 2016
'Keck/NIRC2.H': (16.71, 0.24), # Currie et al. 2012
'Paranal/SPHERE.IRDIS_D_H23_2': (17.02, 0.17), # Zurlo et al. 2016
'Paranal/SPHERE.IRDIS_D_H23_3': (16.68, 0.21), # Zurlo et al. 2016
'Paranal/SPHERE.IRDIS_D_H23_3': (16.85, 0.16), # Zurlo et al. 2016
'Keck/NIRC2.Ks': (16.09, 0.12), # Marois et al. 2010
'Paranal/SPHERE.IRDIS_D_K12_1': (16.20, 0.07), # Zurlo et al. 2016
'Paranal/SPHERE.IRDIS_D_K12_2': (15.84, 0.10), # Zurlo et al. 2016
'Keck/NIRC2.Lp': (14.56, 0.09), # Currie et al. 2014
'Paranal/NACO.NB405': (13.97, 0.14), # Currie et al. 2014
'Paranal/NACO.Lp': (14.55, 0.14), # Currie et al. 2014
'Paranal/NACO.NB405': (13.87, 0.15), # Currie et al. 2014
'Keck/NIRC2.Ms': (14.65, 0.35)}}, # Galicher et al. 2011

'HR 8799 e': {'distance': 41.29,
'app_mag': {'Paranal/SPHERE.IRDIS_B_J': (18.40, 0.21), # Zurlo et al. 2016
'Paranal/SPHERE.IRDIS_D_H23_2': (16.91, 0.20), # Zurlo et al. 2016
'Paranal/SPHERE.IRDIS_D_H23_3': (16.85, 0.16), # Zurlo et al. 2016
'Paranal/SPHERE.IRDIS_D_H23_3': (16.68, 0.21), # Zurlo et al. 2016
'Keck/NIRC2.Ks': (15.91, 0.22), # Marois et al. 2010
'Paranal/SPHERE.IRDIS_D_K12_1': (16.12, 0.10), # Zurlo et al. 2016
'Paranal/SPHERE.IRDIS_D_K12_2': (15.82, 0.11), # Zurlo et al. 2016
'Keck/NIRC2.Lp': (14.55, 0.12), # Currie et al. 2014
'Paranal/NACO.NB405': (13.82, 0.20)}}, # Currie et al. 2014
'Paranal/NACO.Lp': (14.49, 0.21), # Currie et al. 2014
'Paranal/NACO.NB405': (13.72, 0.20)}}, # Currie et al. 2014

'HD 95086 b': {'distance': 86.44,
'app_mag': {'Gemini/GPI.H': (20.51, 0.25), # De Rosa et al. 2016
Expand All @@ -100,12 +100,12 @@ def get_data():

'2M1207 b': {'distance': 64.42,
'app_mag': {'HST/NICMOS1.F090M': (22.58, 0.35), # Song et al. 2006
'HST/NICMOS1.F110M': (20.61, 0.15), # Song et al. 2006
'HST/NICMOS1.F145M': (19.05, 0.03), # Song et al. 2006
'HST/NICMOS1.F160W': (18.27, 0.02), # Song et al. 2006
'Paranal/NACO.J': (20.0, 0.20), # Mohanty et al. 200z
'Paranal/NACO.J': (20.0, 0.2), # Mohanty et al. 200z
'Paranal/NACO.H': (18.09, 0.21), # Chauvin et al. 2004
'Paranal/NACO.Ks': (16.93, 0.11), # Chauvin et al. 2004
# 'Magellan/MagAO.3.3': (15.46, 0.10), # Skemer et al. 2014
'Paranal/NACO.Lp': (15.28, 0.14)}}, # Chauvin et al. 2004

'AB Pic B': {'distance': 50.12,
Expand Down Expand Up @@ -152,34 +152,28 @@ def get_data():
'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

'ROXs 42B b': {'distance': 144.16,
'ROXs 42 Bb': {'distance': 144.16,
'app_mag': {'Keck/NIRC2.J': (16.91, 0.11), # Daemgen et al. 2017
'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

'GJ 504 b': {'distance': 17.54,
'app_mag': {'Paranal/SPHERE.IRDIS_D_Y23_2': (20.98, 0.20), # Bonnefoy et al. 2018
'Paranal/SPHERE.IRDIS_D_Y23_3': (20.14, 0.09), # Bonnefoy et al. 2018
# 'Paranal/SPHERE.IRDIS_D_J23_2': (>21.28, ), # Bonnefoy et al. 2018
'Paranal/SPHERE.IRDIS_D_J23_3': (19.01, 0.17), # Bonnefoy et al. 2018
'Paranal/SPHERE.IRDIS_D_H23_2': (18.95, 0.30), # Bonnefoy et al. 2018
'Paranal/SPHERE.IRDIS_D_H23_3': (21.81, 0.35), # Bonnefoy et al. 2018
'Paranal/SPHERE.IRDIS_D_K12_1': (18.77, 0.20), # Bonnefoy et al. 2018
# 'Paranal/SPHERE.IRDIS_D_K12_2': (>19.96, ), # Bonnefoy et al. 2018
'Subaru/CIAO.J': (19.78, 0.10), # Janson et al. 2013
'Subaru/CIAO.H': (20.01, 0.14), # Janson et al. 2013
'Subaru/CIAO.Ks': (19.38, 0.11), # Janson et al. 2013
'Subaru/CIAO.CH4s': (19.58, 0.13), # Janson et al. 2013
# 'Subaru/CIAO.CH4l': (>20.63, ), # Janson et al. 2013
# 'LBTI/LMIRcam.L_NB6': (17.59, 0.17), # Skemer et al. 2016
# 'LBTI/LMIRcam.L_NB7': (16.47, 0.19), # Skemer et al. 2016
# 'LBTI/LMIRcam.L_NB8': (15.85, 0.17), # Skemer et al. 2016
'Subaru/IRCS.Lp': (16.70, 0.17)}}, # Kuzuhara et al. 2013

'GU Psc b': {'distance': 47.61,
Expand All @@ -191,7 +185,7 @@ def get_data():
'WISE/WISE.W1': (17.17, 0.33), # Naud et al. 2014
'WISE/WISE.W2': (15.41, 0.22)}}, # Naud et al. 2014

'2M1207 ABb': {'distance': 47.2,
'2M0103 ABb': {'distance': 47.2,
'app_mag': {'Paranal/NACO.J': (15.47, 0.30), # Delorme et al. 2013
'Paranal/NACO.H': (14.27, 0.20), # Delorme et al. 2013
'Paranal/NACO.Ks': (13.67, 0.20), # Delorme et al. 2013
Expand All @@ -201,8 +195,6 @@ def get_data():
'app_mag': {'Gemini/NIRI.J-G0202w': (17.90, 0.12), # Lafreniere et al. 2008
'Gemini/NIRI.H-G0203w': (16.87, 0.07), # Lafreniere et al. 2008
'Gemini/NIRI.K-G0204w': (16.17, 0.18), # Lafreniere et al. 2008
# 'MMT/Clio.3.1': (15.65, 0.21), # Bailey et al. 2013
# 'MMT/Clio.3.3': (15.2, 0.16), # Bailey et al. 2013
'Gemini/NIRI.Lprime-G0207w': (14.8, 0.3)}}, # Lafreniere et al. 2010

'GSC 06214 B': {'distance': 108.84,
Expand Down
15 changes: 10 additions & 5 deletions species/data/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,14 @@ def add_object(self,
error = {}

for item in app_mag:
synphot = photometry.SyntheticPhotometry(item)
flux[item], error[item] = synphot.magnitude_to_flux(app_mag[item][0],
app_mag[item][1])
try:
synphot = photometry.SyntheticPhotometry(item)
flux[item], error[item] = synphot.magnitude_to_flux(app_mag[item][0],
app_mag[item][1])

except ValueError:
# Write NaNs if the filter is not available
flux[item], error[item] = np.nan, np.nan

for item in app_mag:
if 'objects/'+object_name+'/'+item in h5_file:
Expand Down Expand Up @@ -477,9 +482,9 @@ def add_spectrum(self,
Parameters
----------
spectrum : str
Spectral library.
Spectral library ('vega', 'irtf' or 'spex').
sptypes : tuple(str, )
Spectral types ('F', 'G', 'K', 'M', 'L', 'T'). Currently only implemented for IRTF.
Spectral types ('F', 'G', 'K', 'M', 'L', 'T'). Currently only implemented for 'irtf'.
Returns
-------
Expand Down
Loading

0 comments on commit 6ea1c24

Please sign in to comment.