Skip to content

Commit

Permalink
Small changes and two functions shortened, issue rpoleski#129
Browse files Browse the repository at this point in the history
  • Loading branch information
rapoliveira committed Apr 25, 2024
1 parent a5941fa commit 24e7f56
Showing 1 changed file with 25 additions and 12 deletions.
37 changes: 25 additions & 12 deletions source/MulensModel/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,13 @@ def _get_lc(self, times, t_range, t_start, t_stop, dt, n_epochs, gamma,

flux += blend_flux

return self._return_mag_or_flux(times, flux, return_times, phot_fmt)

def _return_mag_or_flux(self, times, flux, return_times, phot_fmt):
"""
Obtain what is returned in function _get_lc, where phot_fmt and
return_times are explicitly given
"""
if phot_fmt == 'mag':
mag_or_flux = Utils.get_mag_from_flux(flux)
elif phot_fmt == 'flux':
Expand Down Expand Up @@ -387,7 +394,7 @@ def plot_lc(
use *source_flux* or *blend_flux* instead.
phot_fmt: *str*
Specifies whether the photometry is provided in magnitude or
Specifies whether the photometry is plotted in magnitude or
flux space. Accepts either 'mag' or 'flux'. Default = 'mag'.
``**kwargs``:
Expand Down Expand Up @@ -436,6 +443,23 @@ def plot_lc(
subtract_2460000=subtract_2460000)

self._plt_plot(times-subtract, mag_or_flux, kwargs)
self._plt_settings(phot_fmt, subtract_2450000, subtract_2460000)

def _plt_plot(self, x, y, kwargs):
"""
safe run of matplotlib.pyplot.plot()
"""
try:
plt.plot(x, y, **kwargs)
except Exception:
print("kwargs passed to plt.plot():")
print(kwargs)
raise

def _plt_settings(self, phot_fmt, subtract_2450000, subtract_2460000):
"""
Arrange the plot settings, regarding axes labels and ranges
"""
if phot_fmt == 'mag':
plt.ylabel('Magnitude')
elif phot_fmt == 'flux':
Expand All @@ -449,17 +473,6 @@ def plot_lc(
if ymax > ymin and phot_fmt == 'mag':
plt.gca().invert_yaxis()

def _plt_plot(self, x, y, kwargs):
"""
safe run of matplotlib.pyplot.plot()
"""
try:
plt.plot(x, y, **kwargs)
except Exception:
print("kwargs passed to plt.plot():")
print(kwargs)
raise

def plot_caustics(self, n_points=5000, epoch=None, **kwargs):
"""
Plot the caustic structure. See
Expand Down

0 comments on commit 24e7f56

Please sign in to comment.