Skip to content

Commit

Permalink
Reading corr_len and corr_amp parameters from bounds and use default …
Browse files Browse the repository at this point in the history
…values otherwise, added effective_width method to ReadFilter, minor maintenance
  • Loading branch information
tomasstolker committed Jan 4, 2021
1 parent 6bafb97 commit 40bbe15
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 16 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018-2020 Tomas Stolker
Copyright (c) 2018-2021 Tomas Stolker

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: help pypi ppypi-test docs coverage test clean
.PHONY: help pypi pypi-test docs coverage test clean

help:
@echo "pypi - submit package to the PyPI server"
Expand Down Expand Up @@ -29,7 +29,7 @@ docs:
$(MAKE) -C docs html

coverage:
coverage run -m pytest
coverage run --source=species -m pytest
coverage report -m

test:
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'species', 'species Documentation',
author, 'species', 'Toolkit for atmospheric characterization of exoplanets and brown dwarf',
author, 'species', 'Toolkit for atmospheric characterization of directly imaged exoplanets',
'Miscellaneous'),
]

Expand All @@ -194,4 +194,4 @@
epub_exclude_files = ['search.html']


# -- Extension configuration -------------------------------------------------
# -- Extension configuration -------------------------------------------------
6 changes: 3 additions & 3 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
nbsphinx ~= 0.7
pandoc ~= 1.0
jupyter ~= 1.0
nbsphinx
pandoc
jupyter
2 changes: 1 addition & 1 deletion docs/tutorials/spectral_library.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.10"
"version": "3.8.6"
}
},
"nbformat": 4,
Expand Down
11 changes: 7 additions & 4 deletions species/analysis/fit_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,8 +726,11 @@ def __init__(self,
self.modelpar.append(f'corr_len_{item}')
self.modelpar.append(f'corr_amp_{item}')

self.bounds[f'corr_len_{item}'] = (-3., 0.) # log10(corr_len) (um)
self.bounds[f'corr_amp_{item}'] = (0., 1.)
if f'corr_len_{item}' not in self.bounds:
self.bounds[f'corr_len_{item}'] = (-3., 0.) # log10(corr_len/um)

if f'corr_amp_{item}' not in self.bounds:
self.bounds[f'corr_amp_{item}'] = (0., 1.)

self.n_corr_par += 2

Expand Down Expand Up @@ -963,8 +966,8 @@ def run_mcmc(self,

for item in self.spectrum:
if item in self.fit_corr:
sigma[f'corr_len_{item}'] = 0.01 # (dex)
guess[f'corr_len_{item}'] = None # (um)
sigma[f'corr_len_{item}'] = 0.01 # log10(corr_len/um)
guess[f'corr_len_{item}'] = None # log10(corr_len/um)

sigma[f'corr_amp_{item}'] = 0.1
guess[f'corr_amp_{item}'] = None
Expand Down
21 changes: 19 additions & 2 deletions species/read/read_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def filter_fwhm(self) -> float:
Returns
-------
float
Filter full width at half maximum (um).
Full width at half maximum (um).
"""

data = self.get_filter()
Expand All @@ -155,10 +155,27 @@ def filter_fwhm(self) -> float:

return root2 - root1

@typechecked
def effective_width(self) -> np.float32:
"""
Calculate the effective width of the filter profile. The effective width is equivalent to
the horizontal size of a rectangle with height equal to the maximum transmission and with
the same area as the one covered by the filter profile.
Returns
-------
float
Effective width (um).
"""

data = self.get_filter()

return np.trapz(data[:, 1], data[:, 0]) / np.amax(data[:, 1])

@typechecked
def detector_type(self) -> str:
"""
Function for returning the detector type.
Return the detector type.
Returns
-------
Expand Down
2 changes: 1 addition & 1 deletion test/test_read/test_calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ def test_get_magnitude(self):
app_mag, abs_mag = read_calib.get_magnitude(model_param=self.model_param)

assert app_mag[0] == 0.03
assert abs_mag[0] == None
assert abs_mag[0] is None

0 comments on commit 40bbe15

Please sign in to comment.