Skip to content

Commit

Permalink
Merge pull request #716 from kevin218/tjb_working
Browse files Browse the repository at this point in the history
S5 bug patches
  • Loading branch information
taylorbell57 authored Nov 9, 2024
2 parents 7483bc0 + 2fc424c commit 41e611f
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 31 deletions.
10 changes: 5 additions & 5 deletions docs/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Installation methods
--------------------

In order to have consistent, repeatable results across the ``Eureka!`` user community, we recommend that all general users install
the most recent stable release of ``Eureka!``, v1.0. The following installation instructions are written with this in mind,
and the most recent stable release is also available as a zipped archive `here <https://github.com/kevin218/Eureka/releases/tag/v1.0>`_.
the most recent stable release of ``Eureka!``, v1.1. The following installation instructions are written with this in mind,
and the most recent stable release is also available as a zipped archive `here <https://github.com/kevin218/Eureka/releases/tag/v1.1>`_.
Also note that if you are using a macOS device with an Apple Silicon processor (e.g., M1), you may need to use the ``conda`` environment.yml file
installation instructions below as the ``pip`` dependencies have been reported to fail to build on Apple Silicon processors.

Expand Down Expand Up @@ -35,7 +35,7 @@ Once in your new conda environment, you can install ``Eureka!`` directly from so

.. code-block:: bash
git clone -b v1.0 https://github.com/kevin218/Eureka.git
git clone -b v1.1 https://github.com/kevin218/Eureka.git
cd Eureka
pip install -e '.[jwst]'
Expand All @@ -47,7 +47,7 @@ Once in your new conda environment, you can install the ``Eureka!`` package with

.. code-block:: bash
pip install -e 'eureka[jwst]@git+https://github.com/kevin218/Eureka.git@v1.0'
pip install -e 'eureka[jwst]@git+https://github.com/kevin218/Eureka.git@v1.1'
Other specific branches can be installed using:

Expand Down Expand Up @@ -88,7 +88,7 @@ To install using conda:

.. code-block:: bash
git clone -b v1.0 https://github.com/kevin218/Eureka.git
git clone -b v1.1 https://github.com/kevin218/Eureka.git
cd Eureka
conda env create --file environment.yml --force
conda activate eureka
Expand Down
40 changes: 18 additions & 22 deletions src/eureka/S5_lightcurve_fitting/models/AstroModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,15 @@ def __init__(self, model, pid=0, channel=0, eval=True):
value = getattr(parameterObject, item0)
if eval:
value = value.value
setattr(self, 'rprs', value)
self.rprs = value
if (self.rp is None) and ('rprs' in model.parameters.dict.keys()):
item0 = 'rprs' + self.pid_id
if model.parameters.dict[item0][1] == 'free':
item0 += self.channel_id
value = getattr(parameterObject, item0)
if eval:
value = value.value
setattr(self, 'rp', value)
self.rp = value
# Allow for rp2 or rprs2
if (self.rprs2 is None) and ('rp2' in model.parameters.dict.keys()):
item0 = 'rp2' + self.pid_id
Expand All @@ -169,15 +169,15 @@ def __init__(self, model, pid=0, channel=0, eval=True):
value = getattr(parameterObject, item0)
if eval:
value = value.value
setattr(self, 'rprs2', value)
self.rprs2 = value
if (self.rp2 is None) and ('rprs2' in model.parameters.dict.keys()):
item0 = 'rprs2' + self.pid_id
if model.parameters.dict[item0][1] == 'free':
item0 += self.channel_id
value = getattr(parameterObject, item0)
if eval:
value = value.value
setattr(self, 'rp2', value)
self.rp2 = value
# Allow for a or ars
if (self.ars is None) and ('a' in model.parameters.dict.keys()):
item0 = 'a' + self.pid_id
Expand All @@ -186,22 +186,22 @@ def __init__(self, model, pid=0, channel=0, eval=True):
value = getattr(parameterObject, item0)
if eval:
value = value.value
setattr(self, 'ars', value)
self.ars = value
if (self.a is None) and ('ars' in model.parameters.dict.keys()):
item0 = 'ars' + self.pid_id
if model.parameters.dict[item0][1] == 'free':
item0 += self.channel_id
value = getattr(parameterObject, item0)
if eval:
value = value.value
setattr(self, 'a', value)
self.a = value
# Allow for (ecc, w) or (ecosw, esinw)
if (self.ecosw is None) and self.ecc == 0:
self.ecosw = 0.
self.esinw = 0.
elif (self.ecc is None) and self.ecosw == 0 and self.sinw == 0:
elif (self.ecc is None) and self.ecosw == 0 and self.esinw == 0:
self.ecc = 0.
self.w = None
self.w = 180.
if (self.ecosw is None) and ('ecc' in model.parameters.dict.keys()):
item0 = 'ecc' + self.pid_id
item1 = 'w' + self.pid_id
Expand All @@ -216,10 +216,8 @@ def __init__(self, model, pid=0, channel=0, eval=True):
value1 = value1.value
ecc = value0
w = value1
ecosw = ecc*lib.cos(w*np.pi/180)
esinw = ecc*lib.sin(w*np.pi/180)
setattr(self, 'ecosw', ecosw)
setattr(self, 'esinw', esinw)
self.ecosw = ecc*lib.cos(w*np.pi/180)
self.esinw = ecc*lib.sin(w*np.pi/180)
elif (self.ecc is None) and ('ecosw' in model.parameters.dict.keys()):
item0 = 'ecosw' + self.pid_id
item1 = 'esinw' + self.pid_id
Expand All @@ -234,10 +232,8 @@ def __init__(self, model, pid=0, channel=0, eval=True):
value1 = value1.value
ecosw = value0
esinw = value1
ecc = lib.sqrt(ecosw**2+esinw**2)
w = lib.arctan2(esinw, ecosw)*180/np.pi
setattr(self, 'ecc', ecc)
setattr(self, 'w', w)
self.ecc = lib.sqrt(ecosw**2+esinw**2)
self.w = lib.arctan2(esinw, ecosw)*180/np.pi
# Allow for fp or fpfs
if (self.fpfs is None) and ('fp' in model.parameters.dict.keys()):
item0 = 'fp' + self.pid_id
Expand All @@ -246,19 +242,19 @@ def __init__(self, model, pid=0, channel=0, eval=True):
value = getattr(parameterObject, item0)
if eval:
value = value.value
setattr(self, 'fpfs', value)
self.fpfs = value
elif self.fpfs is None:
setattr(self, 'fpfs', 0.)
self.fpfs = 0.
if (self.fp is None) and ('fpfs' in model.parameters.dict.keys()):
item0 = 'fpfs' + self.pid_id
if model.parameters.dict[item0][1] == 'free':
item0 += self.channel_id
value = getattr(parameterObject, item0)
if eval:
value = value.value
setattr(self, 'fp', value)
self.fp = value
elif self.fp is None:
setattr(self, 'fp', 0.)
self.fp = 0.
# Set stellar radius
if 'Rs' in model.parameters.dict.keys():
item0 = 'Rs'
Expand All @@ -275,7 +271,7 @@ def __init__(self, model, pid=0, channel=0, eval=True):
raise AssertionError(message)
if eval:
value = value.value
setattr(self, 'Rs', value)
self.Rs = value

# Nicely packaging limb-darkening coefficients
if not hasattr(model.parameters, 'limb_dark'):
Expand Down Expand Up @@ -303,7 +299,7 @@ def __init__(self, model, pid=0, channel=0, eval=True):
# Make sure (e, w, ecosw, and esinw) are all defined (assuming e=0)
if self.ecc is None:
self.ecc = 0
self.w = None
self.w = 180.
self.ecosw = 0
self.esinw = 0

Expand Down
6 changes: 6 additions & 0 deletions src/eureka/S5_lightcurve_fitting/models/FleckModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ def light_curve(self, pl_params):
spotlon = np.concatenate([
spotlon, [getattr(pl_params, f'spotlon{spot_id}'),]])

if np.any((np.abs(spotlat) > 90) | (np.abs(spotlon) > 180) |
(spotrad > 1)):
# Returning nans or infs breaks the fits, so this was the
# best I could think of
return 1e6*np.ma.ones(self.t.shape)

if pl_params.spotnpts is None:
# Have a default spotnpts for fleck
pl_params.spotnpts = 300
Expand Down
20 changes: 16 additions & 4 deletions src/eureka/S5_lightcurve_fitting/plots_s5.py
Original file line number Diff line number Diff line change
Expand Up @@ -813,9 +813,15 @@ def plot_fleck_star(lc, model, meta, fitter):
fitter : str
The name of the fitter (for plot filename).
"""
for channel in lc.fitted_channels:
for c in range(lc.nchannel_fitted):
channel = lc.fitted_channels[c]
if lc.nchannel_fitted > 1:
chan = channel
else:
chan = 0

# Initialize PlanetParams object
pl_params = PlanetParams(model, 0, channel)
pl_params = PlanetParams(model, 0, chan)

# create arrays to hold values
spotrad = np.zeros(0)
Expand Down Expand Up @@ -877,9 +883,15 @@ def plot_starry_star(lc, model, meta, fitter):
fitter : str
The name of the fitter (for plot filename).
"""
for channel in lc.fitted_channels:
for c in range(lc.nchannel_fitted):
channel = lc.fitted_channels[c]
if lc.nchannel_fitted > 1:
chan = channel
else:
chan = 0

# Initialize PlanetParams object
pl_params = PlanetParams(model, 0, channel, eval=True)
pl_params = PlanetParams(model, 0, chan, eval=True)

# create arrays to hold values
spotrad = np.zeros(0)
Expand Down

0 comments on commit 41e611f

Please sign in to comment.