Skip to content

Commit

Permalink
Merge d1c24be into c5fec94
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomas Stolker committed May 6, 2020
2 parents c5fec94 + d1c24be commit f3d88ba
Show file tree
Hide file tree
Showing 11 changed files with 502 additions and 54 deletions.
1 change: 1 addition & 0 deletions docs/overview.rst
Expand Up @@ -30,6 +30,7 @@ The following data are currently supported by *species* (support for other data
- Photometry from `Sandy Leggett <http://www.gemini.edu/staff/sleggett>`_
- Photometry of directly imaged planets and brown dwarfs (see dictionary in :class:`~species.data.companions`)
- Calibration spectrum of `Vega <http://ssb.stsci.edu/cdbs/calspec/>`_
- Optical constants compiled by `Mollière et al. (2019) <https://ui.adsabs.harvard.edu/abs/2019A%26A...627A..67M/abstract>`_ (see :func:`~species.data.database.Database.add_dust`)

Please give credit to the relevant authors when using these data in a publication. More information is available on the respective websites.

Expand Down
8 changes: 8 additions & 0 deletions docs/species.data.rst
Expand Up @@ -60,6 +60,14 @@ species.data.drift\_phoenix module
:undoc-members:
:show-inheritance:

species.data.dust module
------------------------

.. automodule:: species.data.dust
:members:
:undoc-members:
:show-inheritance:

species.data.exo\_rem module
----------------------------

Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Expand Up @@ -6,9 +6,10 @@ h5py ~= 2.10
matplotlib ~= 3.2
numpy ~= 1.18
pandas ~= 0.25
PyMieScatt ~= 1.7
pymultinest ~= 2.9
scipy ~= 1.4
spectres ~= 2.1
tqdm ~= 4.45
tqdm ~= 4.46
typeguard ~= 2.7
xlrd ~= 1.2
2 changes: 1 addition & 1 deletion species/analysis/photometry.py
Expand Up @@ -39,7 +39,7 @@ def __init__(self,
self.filter_interp = None
self.wavel_range = None

self.vega_mag = 0.03 # [mag]
self.vega_mag = 0.03 # (mag)

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

Expand Down
6 changes: 3 additions & 3 deletions species/data/companions.py
Expand Up @@ -104,9 +104,9 @@ def get_data():
'Paranal/SPHERE.IRDIS_D_H23_3': (17.95, 0.17), # Keppler et al. 2018
'Paranal/SPHERE.IRDIS_D_K12_1': [(16.78, 0.31), (16.72, 0.05)], # Stolker et al. in prep.
'Paranal/SPHERE.IRDIS_D_K12_2': [(16.23, 0.32), (16.38, 0.06)], # Stolker et al. in prep.
# 'Paranal/NACO.Lp': (14.08, 0.33), # Stolker et al. in prep.
# 'Paranal/NACO.NB405': (13.91, 0.34), # Stolker et al. in prep.
# 'Paranal/NACO.Mp': (13.64, 0.22), # Stolker et al. in prep.
'Paranal/NACO.Lp': (14.08, 0.33), # Stolker et al. in prep.
'Paranal/NACO.NB405': (13.91, 0.34), # Stolker et al. in prep.
'Paranal/NACO.Mp': (13.64, 0.22), # Stolker et al. in prep.
'Keck/NIRC2.Lp': (14.64, 0.18)}}, # Wang et al. 2020

'PDS 70 c': {'distance': (113.43, 0.52),
Expand Down
39 changes: 38 additions & 1 deletion species/data/database.py
Expand Up @@ -25,7 +25,7 @@
from species.core import box, constants
from species.data import drift_phoenix, btnextgen, vega, irtf, spex, vlm_plx, leggett, \
companions, filters, btsettl, ames_dusty, ames_cond, \
isochrones, petitcode, exo_rem
isochrones, petitcode, exo_rem, dust
from species.read import read_model, read_calibration, read_planck
from species.util import data_util
# from species.util import data_util, retrieval_util
Expand Down Expand Up @@ -164,6 +164,43 @@ def add_companion(self,
distance=data[item]['distance'],
app_mag=data[item]['app_mag'])

@typechecked
def add_dust(self) -> None:
"""
Function for adding optical constants of MgSiO3 and Fe to the database. The optical
constants have been compiled by Mollière et al. (2019) for petitRADTRANS from the
following sources:
- MgSiO3, crystalline
- Scott & Duley (1996), ApJS, 105, 401
- Jäger et al. (1998), A&A, 339, 904
- MgSiO3, amorphous
- Jäger et al. (2003), A&A, 408, 193
- Fe, crystalline
- Henning & Stognienko (1996), A&A, 311, 291
- Fe, amorphous
- Pollack et al. (1994), ApJ, 421, 615
Returns
-------
NoneType
None
"""

h5_file = h5py.File(self.database, 'a')

if 'dust' in h5_file:
del h5_file['dust']

h5_file.create_group('dust')

dust.add_optical_constants(self.input_path, h5_file)

h5_file.close()

def add_filter(self,
filter_name,
filename=None):
Expand Down
92 changes: 92 additions & 0 deletions species/data/dust.py
@@ -0,0 +1,92 @@
"""
Module for optical constants of dust grains.
"""

import os
import zipfile
import urllib.request

import h5py
import numpy as np

from typeguard import typechecked


@typechecked
def add_optical_constants(input_path: str,
database: h5py._hl.files.File) -> None:
"""
Function for adding the optical constants of crystalline and amorphous MgSiO3 and Fe to the
database.
Parameters
----------
input_path : str
Folder where the data is located.
database : h5py._hl.files.File
Database.
Returns
-------
None
NoneType
"""

if not os.path.exists(input_path):
os.makedirs(input_path)

url = 'https://people.phys.ethz.ch/~stolkert/species/optical_constants.zip'

data_file = os.path.join(input_path, 'optical_constants.zip')

if not os.path.isfile(data_file):
print('Downloading optical constants (87 kB)...', end='', flush=True)
urllib.request.urlretrieve(url, data_file)
print(' [DONE]')

print('Unpacking optical constants...', end='', flush=True)

with zipfile.ZipFile(data_file, 'r') as zip_ref:
zip_ref.extractall(input_path)

print(' [DONE]')

print('Adding optical constants of MgSiO3...', end='')

nk_file = os.path.join(input_path, 'optical_constants/mgsio3/crystalline/'
'mgsio3_jaeger_98_scott_96_axis1.dat')

data = np.loadtxt(nk_file)
database.create_dataset('dust/mgsio3/crystalline/axis_1/', data=data)

nk_file = os.path.join(input_path, 'optical_constants/mgsio3/crystalline/'
'mgsio3_jaeger_98_scott_96_axis2.dat')

data = np.loadtxt(nk_file)
database.create_dataset('dust/mgsio3/crystalline/axis_2/', data=data)

nk_file = os.path.join(input_path, 'optical_constants/mgsio3/crystalline/'
'mgsio3_jaeger_98_scott_96_axis3.dat')

data = np.loadtxt(nk_file)
database.create_dataset('dust/mgsio3/crystalline/axis_3/', data=data)

nk_file = os.path.join(input_path, 'optical_constants/mgsio3/amorphous/'
'mgsio3_jaeger_2003_reformat.dat')

data = np.loadtxt(nk_file)
database.create_dataset('dust/mgsio3/amorphous', data=data)

print(' [DONE]')

print('Adding optical constants of Fe...', end='')

nk_file = os.path.join(input_path, 'optical_constants/fe/crystalline/fe_henning_1996.dat')
data = np.loadtxt(nk_file)
database.create_dataset('dust/fe/crystalline', data=data)

nk_file = os.path.join(input_path, 'optical_constants/fe/amorphous/fe_pollack_1994.dat')
data = np.loadtxt(nk_file)
database.create_dataset('dust/fe/amorphous', data=data)

print(' [DONE]')

0 comments on commit f3d88ba

Please sign in to comment.