Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 1165: Checking datasets for MObs and Conforming w/ New Limb Darkening Updates #1217

Merged
merged 18 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
2e6cb15
- Added testing suite for ld.py
tamimfatahi Aug 8, 2023
a854291
Minor bug squashed
tamimfatahi Aug 8, 2023
9df27e6
Adding additional MicroObservatory default values
tamimfatahi Aug 8, 2023
170fd22
Adding additional MicroObservatory default values and reverting inits…
tamimfatahi Aug 8, 2023
0a0edec
Closes #1165: Updated to-str method to report description accurately.…
jpl-jengelke Aug 8, 2023
6ecb637
Moving test_ld.py file to top level directory
tamimfatahi Aug 9, 2023
bad0f31
Changing grammar for GUI. Closes #1124
tamimfatahi Aug 9, 2023
1e95b72
Allowing CBB and CV filters to be standard with custom ranges from us…
tamimfatahi Aug 9, 2023
54c6dba
Updating test to conform with new changes.
tamimfatahi Aug 9, 2023
be54e8b
Modifying incorrect argument format in inputs.py file.
tamimfatahi Aug 9, 2023
a7d8e26
Issue #1165: Minor grammar change in user feedback...
jpl-jengelke Aug 9, 2023
67a17df
Updating filters.py by adding in aliases and removing unknown FWHM.
tamimfatahi Aug 10, 2023
03f2ea6
Merge remote-tracking branch 'origin/issue_1165' into issue_1165
tamimfatahi Aug 10, 2023
8d7dd70
Moving test_ld.py file to top level directory
tamimfatahi Aug 10, 2023
960e4a4
Modifying ld.py back to previous changes
tamimfatahi Aug 10, 2023
578fae1
Merge remote-tracking branch 'origin/issue_1165' into issue_1165
tamimfatahi Aug 10, 2023
96099d3
Updating ld.py to include both filter and names in description that …
tamimfatahi Aug 11, 2023
f7705d3
Updating exotic.py to work with new additions in ld.py.
tamimfatahi Aug 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 13 additions & 119 deletions exotic/api/ld.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class LimbDarkening:

def __init__(self, stellar):
self.filter_name = self.filter_desc = None
self.ld0 = self.ld1 = self.ld2 = self.ld3 = None
self.ld0 = self.ld1 = self.ld2 = self.ld3 = [0, 0]
self.priors = {
'T*': stellar.get('teff'),
'T*_uperr': stellar.get('teffUncPos'),
Expand Down Expand Up @@ -96,9 +96,9 @@ def check_standard(self, filter_: dict = None, loose: bool = False, loose_len: i
# eliminate errant spaces on edges
filter_[k] = filter_[k].strip()
if k == 'name' and filter_[k]: # format 'name' (if exists) to uppercase, no spaces
filter_[k] = ''.join(filter_[k].upper().split())
filter_[k] = filter_[k].upper().replace(' ', '')
if filter_['filter']: # make matcher by removing spaces, remove punctuation and lowercase
filter_matcher = ''.join(filter_['filter'].lower().split())
filter_matcher = filter_['filter'].lower().replace(' ', '')
filter_matcher = re.sub(ld_re_punct_p, '', filter_matcher)
# identify defined filters via optimized lookup table
if filter_matcher and filter_matcher in LimbDarkening.fwhm_lookup:
Expand Down Expand Up @@ -207,119 +207,13 @@ def set_ld(self, ld0, ld1, ld2, ld3):
self.ld3 = ld3
return

def output_ld(self):
print("\nEXOTIC-calculated nonlinear limb-darkening coefficients: ")
print(f"{self.ld0[0]:5f} +/- + {self.ld0[1]:5f}")
print(f"{self.ld1[0]:5f} +/- + {self.ld1[1]:5f}")
print(f"{self.ld2[0]:5f} +/- + {self.ld2[1]:5f}")
print(f"{self.ld3[0]:5f} +/- + {self.ld3[1]:5f}")
return


def test_ld(ld_obj_, filter_):
try:
ld_obj_.check_standard(filter_)
ld_obj_.calculate_ld()
except BaseException as be:
log.exception(be)
log.error("Continuing with default operations. ...")
filter_['filter'] = "Custom"
if filter_['wl_min'] and filter_['wl_max']:
ld_obj_.set_filter('N/A', filter_['filter'], float(filter_['wl_min']), float(filter_['wl_max']))
ld_obj_.calculate_ld()
else:
ld_ = [(filter_[key]["value"], filter_[key]["uncertainty"]) for key in filter_.keys()
if key in ['u0', 'u1', 'u2', 'u3']]
ld_obj_.set_filter('N/A', filter_['filter'], filter_['wl_min'], filter_['wl_max'])
ld_obj_.set_ld(ld_[0], ld_[1], ld_[2], ld_[3])
return


if __name__ == "__main__": # tests
stellar_params = {
'teff': 6001.0,
'teffUncPos': 88.0,
'teffUncNeg': -88.0,
'met': -0.16,
'metUncPos': 0.08,
'metUncNeg': -0.08,
'logg': 4.22,
'loggUncPos': 0.04,
'loggUncNeg': -0.04
}

# Test existing filter
filter_info1 = {
'filter': "CV",
'wl_min': None,
'wl_max': None,
'u0': {"value": None, "uncertainty": None},
'u1': {"value": None, "uncertainty": None},
'u2': {"value": None, "uncertainty": None},
'u3': {"value": None, "uncertainty": None}
}

# Test alias filter
filter_info2 = {
'filter': "LCO SDSS u'",
'wl_min': None,
'wl_max': None,
'u0': {"value": None, "uncertainty": None},
'u1': {"value": None, "uncertainty": None},
'u2': {"value": None, "uncertainty": None},
'u3': {"value": None, "uncertainty": None}
}

# Test given only FWHM
filter_info3 = {
'filter': None,
'wl_min': "350",
'wl_max': "850.0",
'u0': {"value": None, "uncertainty": None},
'u1': {"value": None, "uncertainty": None},
'u2': {"value": None, "uncertainty": None},
'u3': {"value": None, "uncertainty": None}
}

# Test custom-entered ld coefficients
filter_info4 = {
'filter': None,
'wl_min': None,
'wl_max': None,
'u0': {"value": 2.118, "uncertainty": 0.051},
'u1': {"value": -3.88, "uncertainty": 0.21},
'u2': {"value": 4.39, "uncertainty": 0.27},
'u3': {"value": -1.63, "uncertainty": 0.12}
}

filter_info5 = {
'filter': 'N/A',
'wl_min': 351.2,
'wl_max': 3999.,
'u0': {"value": 2.118, "uncertainty": 0.051},
'u1': {"value": -3.88, "uncertainty": 0.21},
'u2': {"value": 4.39, "uncertainty": 0.27},
'u3': {"value": -1.63, "uncertainty": 0.12}
}

ld_obj = LimbDarkening(stellar_params)
LimbDarkening.standard_list()

print(ld_obj.check_fwhm(filter_info5))
print(ld_obj.check_standard(filter_info5, True, 4))
print(ld_obj.check_standard(filter_info5))
print(str(filter_info5))
test_ld(ld_obj, filter_info5)
print(str(filter_info5))
print(f"{ld_obj.filter_desc}, {ld_obj.filter_name}, {ld_obj.wl_min}, {ld_obj.wl_max}")

LimbDarkening.check_fwhm(filter_info5)
LimbDarkening.check_fwhm(filter_info3)
test_ld(ld_obj, filter_info1)
# test_ld(ld_obj, filter_info2)
# test_ld(ld_obj, filter_info3)
# test_ld(ld_obj, filter_info4)

ld = [ld_obj.ld0[0], ld_obj.ld1[0], ld_obj.ld2[0], ld_obj.ld3[0]]
ld_unc = [ld_obj.ld0[1], ld_obj.ld1[1], ld_obj.ld2[1], ld_obj.ld3[1]]
ld_obj.output_ld()
def __str__(self):
return (f"\nFilter Name: {self.filter_name}"
jpl-jengelke marked this conversation as resolved.
Show resolved Hide resolved
f"\nFilter Abbreviation: {self.filter_desc}"
f"\nMinimum Wavelength (nm): {self.wl_min}"
f"\nMaxiumum Wavelength (nm):: {self.wl_max}"
"\nEXOTIC-calculated nonlinear limb-darkening coefficients: "
f"\n\t- {self.ld0[0]:5f} +/- + {self.ld0[1]:5f}"
f"\n\t- {self.ld1[0]:5f} +/- + {self.ld1[1]:5f}"
f"\n\t- {self.ld2[0]:5f} +/- + {self.ld2[1]:5f}"
f"\n\t- {self.ld3[0]:5f} +/- + {self.ld3[1]:5f}")
38 changes: 38 additions & 0 deletions exotic/api/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# ########################################################################### #
# Copyright (c) 2019-2020, California Institute of Technology.
# All rights reserved. Based on Government Sponsored Research under
# contracts NNN12AA01C, NAS7-1407 and/or NAS7-03001.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name of the California Institute of
# Technology (Caltech), its operating division the Jet Propulsion
# Laboratory (JPL), the National Aeronautics and Space
# Administration (NASA), nor the names of its contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE CALIFORNIA
# INSTITUTE OF TECHNOLOGY BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# ########################################################################### #
# EXOplanet Transit Interpretation Code (EXOTIC)
# # NOTE: See companion file version.py for version info.
# ########################################################################### #
ignore = False
Loading