Skip to content

Commit

Permalink
Set detector type of filter to photon counting if not found in the SV…
Browse files Browse the repository at this point in the history
…O header
  • Loading branch information
tomasstolker committed Apr 13, 2021
1 parent 646d084 commit afd94c9
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
7 changes: 4 additions & 3 deletions species/analysis/emission_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,10 @@ def fit_gaussian(self,
Minimum number of live points (see
https://johannesbuchner.github.io/UltraNest/issues.html).
bounds : dict(str, tuple(float, float)), None
The boundaries that are used for the uniform priors. Conservative prior boundaries will
be estimated from the spectrum if the argument is set to ``None`` or if any of the
required parameters is missing in the ``bounds`` dictionary.
The boundaries that are used for the uniform priors of the 3 Gaussian parameters
(``gauss_amplitude``, ``gauss_mean``, and ``gauss_sigma``). Conservative prior
boundaries will be estimated from the spectrum if the argument is set to ``None``
or if any of the required parameters is missing in the ``bounds`` dictionary.
output : str
Path that is used for the output files from ``UltraNest``.
plot_filename : str
Expand Down
2 changes: 1 addition & 1 deletion species/analysis/photometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def spectrum_to_flux(self,
integrand1 = transmission[indices]*flux[indices]
integrand2 = transmission[indices]

if self.det_type == 'photon':
elif self.det_type == 'photon':
# Photon counting detector
integrand1 = wavelength[indices]*transmission[indices]*flux[indices]
integrand2 = wavelength[indices]*transmission[indices]
Expand Down
24 changes: 15 additions & 9 deletions species/data/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
"""

import os
import warnings
import urllib.request
import warnings

from typing import Optional, Tuple
from astropy.io.votable import parse_single_table

import numpy as np

from astropy.io.votable import parse_single_table
from typeguard import typechecked


Expand Down Expand Up @@ -44,7 +44,7 @@ def download_filter(filter_id: str) -> Tuple[Optional[np.ndarray],
wavelength, transmission, _, _ = np.loadtxt('VisAO_rp_filter_curve.dat', unpack=True)

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

os.remove('VisAO_rp_filter_curve.dat')

Expand All @@ -55,7 +55,7 @@ def download_filter(filter_id: str) -> Tuple[Optional[np.ndarray],
wavelength, transmission, _, _ = np.loadtxt('VisAO_ip_filter_curve.dat', unpack=True)

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

os.remove('VisAO_ip_filter_curve.dat')

Expand All @@ -66,11 +66,11 @@ def download_filter(filter_id: str) -> Tuple[Optional[np.ndarray],
wavelength, transmission, _, _ = np.loadtxt('VisAO_zp_filter_curve.dat', unpack=True)

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

os.remove('VisAO_zp_filter_curve.dat')

elif filter_id == 'LCO/VisAO.Ys' or filter_id == 'Magellan/VisAO.Ys':
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 All @@ -81,7 +81,7 @@ def download_filter(filter_id: str) -> Tuple[Optional[np.ndarray],
transmission = transmission[:-7]

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

os.remove('VisAO_Ys_filter_curve.dat')

Expand All @@ -91,7 +91,7 @@ def download_filter(filter_id: str) -> Tuple[Optional[np.ndarray],

wavelength, transmission = np.loadtxt('alma_band6.dat', unpack=True)

det_type = 'energy'
det_type = 'photon'

os.remove('alma_band6.dat')

Expand All @@ -101,7 +101,7 @@ def download_filter(filter_id: str) -> Tuple[Optional[np.ndarray],

wavelength, transmission = np.loadtxt('alma_band7.dat', unpack=True)

det_type = 'energy'
det_type = 'photon'

os.remove('alma_band7.dat')

Expand Down Expand Up @@ -144,6 +144,12 @@ def download_filter(filter_id: str) -> Tuple[Optional[np.ndarray],
elif int(det_type) == 1:
det_type = 'photon'

else:
det_type = 'photon'

warnings.warn(f'Detector type ({det_type}) not recognized. Setting detector type '
f'to photon-counting detector.')

wavelength *= 1e-4 # (um)

os.remove('filter.xml')
Expand Down
5 changes: 5 additions & 0 deletions species/read/read_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@ def __init__(self,

if self.filter_name is not None:
transmission = read_filter.ReadFilter(self.filter_name)

self.wavel_range = transmission.wavelength_range()
self.mean_wavelength = transmission.mean_wavelength()

else:
self.mean_wavelength = None

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

Expand Down

0 comments on commit afd94c9

Please sign in to comment.