rpoleski / MulensModel

Microlensing Modelling package
https://rpoleski.github.io/MulensModel/
Other
57 stars 15 forks source link

Magnification Curve Exception Not Helpful #58

Closed jenniferyee closed 2 years ago

jenniferyee commented 2 years ago

The exception handling in magnificationcurve.py starting at Line 436 is not good. Specifically, the message is vague and only prints the model. If this exception is caught by some other code (e.g. likelihood function), it is not even clear where the error comes from.

Proposed solution:

  1. Add "magnificationcurve.py: " to the beginning of the error text.

  2. Include information from the original exception in the output.

  3. Make the message more specific, e.g. add "point_source (binary lens)" to the output.

jenniferyee commented 2 years ago

This code was used for testing:

import MulensModel as mm import numpy as np import sys

params = { 't_0': 2459326.11297, 'u_0': 0.039329, 't_E': 1.4744, 'rho': 0.07401, 's': 0.11427, 'q': 0.00000426, 'alpha': 35.36022 }

times = np.arange(2459200., 2459450., 1.)

mag_curve = mm.MagnificationCurve(times, mm.ModelParameters(params)) mag_curve.set_magnification_methods([], 'point_source') try: mags = mag_curve.get_magnification() except Exception as e: sys.stderr.write('ERROR in loglikelihood: %s\n' % e) sys.exit(1)

print(mags)


Fixed in latest commit: 57bd409e5c4d6a3f9c26413e0b0f92dce9988076 V 2.13.1