Skip to content

Commit

Permalink
resolving conflict after merging plot_warning branch
Browse files Browse the repository at this point in the history
  • Loading branch information
rpoleski committed Dec 14, 2023
2 parents fb76154 + 57fc116 commit fe5b981
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

[**Detailed documentation: https://rpoleski.github.io/MulensModel/**](https://rpoleski.github.io/MulensModel/)

[Latest release: 2.19.0](https://github.com/rpoleski/MulensModel/releases/latest) and we're working on further developing the code.
[Latest release: 2.19.2](https://github.com/rpoleski/MulensModel/releases/latest) and we're working on further developing the code.

MulensModel can generate a microlensing light curve for a given set of microlensing parameters, fit that light curve to some data, and return a chi2 value. That chi2 (and its gradient in some cases) can then be input into an arbitrary likelihood function to find the best-fit parameters.

Expand Down
41 changes: 24 additions & 17 deletions source/MulensModel/mulensdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,26 +451,11 @@ def _plot_datapoints(
y_bad = y_value[self.bad]

if show_errorbars:
if np.any(y_err[self.good] < 0.):
ind_neg_err = np.where((y_err < 0.) & self.good)
warnings.warn(
"Some points have errorbars with negative values. " +
"Setting to zero. \n" +
"Dataset: " + self._get_name() +
"\nEpochs: {0}".format(self.time[ind_neg_err]))
y_err[ind_neg_err] = 0.

self._mask_negative_errorbars(y_err, kind='good')
container = self._plt_errorbar(time_good, y_good,
y_err[self.good], properties)
if show_bad:
if np.any(y_err[self.bad] < 0.):
ind_neg_err = np.where((y_err < 0.) & self.bad)
warnings.warn(
"Some (bad data) points have errorbars with " +
"negative values. Setting to zero. \n" +
"Dataset: " + self._get_name() +
"\nEpochs: {0}".format(self.time[ind_neg_err]))
y_err[ind_neg_err] = 0.
self._mask_negative_errorbars(y_err, kind='bad')

if not ('color' in properties_bad or 'c' in properties_bad):
properties_bad['color'] = container[0].get_color()
Expand Down Expand Up @@ -549,6 +534,28 @@ def _set_plot_properties(self, show_errorbars=True, bad=False, **kwargs):

return properties

def _mask_negative_errorbars(self, y_err, kind):
"""
Change negative uncertainties to 0.
Parameters kind should be 'good' or 'bad'.
"""
if kind == 'good':
mask = self.good
elif kind == 'bad':
mask = self.bad
else:
raise ValueError('internal error: {:}'.format(kind))

if not np.any(y_err[mask] < 0.):
return

indexes = ((y_err < 0.) & mask)
msg = ("Some {:} data points have scaled errorbars with negative "
"values. Setting them to zero for plotting.\nDataset: {:}\n"
"Epochs: {:}")
warnings.warn(msg.format(kind, self._get_name(), self.time[indexes]))
y_err[indexes] = 0.

def _plt_errorbar(self, time, y, yerr, kwargs):
"""
save run of matplotlib.pyplot.errorbar(); returns ErrorbarContainer
Expand Down
2 changes: 1 addition & 1 deletion source/MulensModel/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2.19.1"
__version__ = "2.19.2"

0 comments on commit fe5b981

Please sign in to comment.