Skip to content

Commit

Permalink
Updated tutorials, added backward compatibility for the det_type attr…
Browse files Browse the repository at this point in the history
…ibute
  • Loading branch information
Tomas Stolker committed Aug 4, 2020
1 parent b998137 commit 660f70a
Show file tree
Hide file tree
Showing 7 changed files with 372 additions and 152 deletions.
283 changes: 199 additions & 84 deletions docs/tutorials/atmospheric_models.ipynb

Large diffs are not rendered by default.

21 changes: 17 additions & 4 deletions docs/tutorials/flux_magnitude.ipynb
Expand Up @@ -38,15 +38,18 @@
"output_type": "stream",
"text": [
"Initiating species v0.3.1... [DONE]\n",
"Creating species_config.ini... [DONE]\n",
"Database: /Users/tomasstolker/applications/species/docs/tutorials/species_database.hdf5\n",
"Data folder: /Users/tomasstolker/applications/species/docs/tutorials/data\n",
"Working folder: /Users/tomasstolker/applications/species/docs/tutorials\n"
"Working folder: /Users/tomasstolker/applications/species/docs/tutorials\n",
"Creating species_database.hdf5... [DONE]\n",
"Creating data folder... [DONE]\n"
]
},
{
"data": {
"text/plain": [
"<species.core.setup.SpeciesInit at 0x10e35c550>"
"<species.core.setup.SpeciesInit at 0x1087e0630>"
]
},
"execution_count": 1,
Expand Down Expand Up @@ -77,7 +80,15 @@
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Adding filter: JWST/NIRCam.F115W... [DONE]\n"
]
}
],
"source": [
"synphot = species.SyntheticPhotometry('JWST/NIRCam.F115W')"
]
Expand All @@ -98,6 +109,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Downloading Vega spectrum (270 kB)... [DONE]\n",
"Adding Vega spectrum... [DONE]\n",
"Flux (W m-2 um-1) = 4.08e-15 +/- 7.56e-16\n"
]
}
Expand Down Expand Up @@ -145,7 +158,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"As expected, we obtain again the magnitude that we start out with."
"As expected, we obtain again the magnitude that we started out with."
]
},
{
Expand Down
70 changes: 55 additions & 15 deletions docs/tutorials/running_species.ipynb

Large diffs are not rendered by default.

106 changes: 70 additions & 36 deletions docs/tutorials/spectral_library.ipynb

Large diffs are not rendered by default.

20 changes: 13 additions & 7 deletions docs/tutorials/synthetic_photometry.ipynb

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions species/plot/plot_color.py
Expand Up @@ -69,12 +69,14 @@ def plot_color_magnitude(boxes: list,
to None.
companion_labels : bool
Plot labels with the names of the directly imaged companions.
reddening : list(tuple(str, str, str, float, str, float, tuple(float, float)), None
reddening : list(tuple(tuple(str, str), tuple(str, float), str, float, tuple(float, float)), None
Include reddening arrows by providing a list with tuples. Each tuple contains the filter
names for the color, the filter name for the magnitude, the particle radius (um), and the
start position (color, mag) of the arrow in the plot, so (filter_color_1, filter_color_2,
filter_mag, composition, radius, (x_pos, y_pos)). The composition can be either 'Fe' or
'MgSiO3' (both with crystalline structure). The parameter is not used if set to ``None``.
names for the color, the filter name and value of the magnitude, the particle radius (um),
and the start position (color, mag) of the arrow in the plot, so ``((filter_color_1,
filter_color_2), (filter_mag, mag_value), composition, radius, (x_pos, y_pos))``. The
composition can be either ``'Fe'`` or ``'MgSiO3'`` (both with crystalline structure). Both
``xlim`` and ``ylim`` need to be set for the correct rotation of the reddening label. The
parameter is not used if set to ``None``.
field_range : tuple(str, str), None
Range of the discrete colorbar for the field dwarfs. The tuple should contain the lower
and upper value ('early M', 'late M', 'early L', 'late L', 'early T', 'late T', 'early Y).
Expand Down
12 changes: 11 additions & 1 deletion species/read/read_filter.py
Expand Up @@ -3,6 +3,7 @@
"""

import os
import warnings
import configparser

from typing import Union, Tuple
Expand Down Expand Up @@ -167,6 +168,15 @@ def detector_type(self) -> str:

with h5py.File(self.database, 'r') as h5_file:
dset = h5_file[f'filters/{self.filter_name}']
det_type = dset.attrs['det_type']

if 'det_type' in dset.attrs:
det_type = dset.attrs['det_type']

else:
warnings.warn('Detector type not found. The database was probably created '
'before the detector type was introduced in species (v0.3.1). '
'Assuming an energy-counting detector.')

det_type = 'energy'

return det_type

0 comments on commit 660f70a

Please sign in to comment.