diff --git a/developers_board.md b/developers_board.md index d3465302..e93c3985 100644 --- a/developers_board.md +++ b/developers_board.md @@ -46,6 +46,8 @@ * t\_eff as a parameter - see [Andy's paper](https://arxiv.org/abs/1312.6692) * Transform t\_E and other parameters between geocentric and heliocentric frames. * Errorbar scaling, in particular the two parameter. +* see "To be done:" in mulensobjects/lens.py::Lens docstring +* mulensobjects/lens.py q.setter - see comments there * get gamma/u LD coefs from Claret papers etc. * Class Event should have not only set\_datasets() methods but also add\_datasets(), i.e. a similar method that appends datasets to self.\_datasets. * Class Model should not allow accessing attributes that shouldn't be there, eg., q for single lens case. diff --git a/examples/use_cases/use_case_11_bad_data.py b/examples/use_cases/use_case_11_bad_data.py index b8a33908..a0c99a13 100644 --- a/examples/use_cases/use_case_11_bad_data.py +++ b/examples/use_cases/use_case_11_bad_data.py @@ -1,14 +1,12 @@ import MulensModel import matplotlib.pyplot as pl + data = MulensModel.MulensData(file_name="my_data.dat") model = MulensModel.Model(n_components=1) - -#pandas style. Does this work without pandas??? data.bad[np.isnan(data.err)] = True - event = MulensModel.Event(datasets=data, model=model) event.estimate_model_params() #aspirational event.get_chi2() @@ -21,6 +19,7 @@ event.get_chi2() #should mask bad data pl.scatter(data.time, data.mag, marker="o", facecolor=None) -pl.scatter(data.time[data.good], data.mag[not data.bad], marker="o", facecolor="black") +pl.scatter(data.time[data.good], data.mag[not data.bad], marker="o", + facecolor="black") pl.scatter(data.time[data.bad], data.mag[data.bad], marker="x") diff --git a/source/MulensModel/caustics.py b/source/MulensModel/caustics.py index 5775f88c..85f2460e 100644 --- a/source/MulensModel/caustics.py +++ b/source/MulensModel/caustics.py @@ -112,7 +112,6 @@ def _calculate(self, n_points=5000): xcm_offset = self.q * self.s / (1. + self.q) #Solve for the critical curve (and caustic) in complex coordinates. - #TO DO: Optimize using vectors instead of a loop for phi in np.arange(0., 2.*np.pi, 2*np.pi/n_points): #Change the angle to a complex number x = np.cos(phi) diff --git a/source/MulensModel/event.py b/source/MulensModel/event.py index 2329b1b6..b2700742 100644 --- a/source/MulensModel/event.py +++ b/source/MulensModel/event.py @@ -83,7 +83,9 @@ def model(self): @model.setter def model(self, new_value): - #Needs a check for MulensModel class + if not isinstance(new_value, Model): + raise TypeError(('wrong type of Event.model: {:} instead of ' + + 'MulensModel').format(type(new_value))) self._model = new_value if self._datasets is not None: self._model.set_datasets(self._datasets) diff --git a/source/MulensModel/mulensobjects/lens.py b/source/MulensModel/mulensobjects/lens.py index 5281096d..46275608 100644 --- a/source/MulensModel/mulensobjects/lens.py +++ b/source/MulensModel/mulensobjects/lens.py @@ -32,7 +32,7 @@ class Lens(object): <50, it is assumed the value is given in kpc. Otherwise, pc are assumed. - TO DO: + To be done: - __repr__ function needs work - a_proj, couples with source distance in mulensmodel to determine s. - 2-body example 3 is missing s. Why? Does that work? @@ -89,7 +89,7 @@ def __init__(self, total_mass=None, mass=None, mass_1=None, mass_2=None, self._a_proj = a_proj def __repr__(self): - """Make a nice string representation of the object. NEEDS WORK.""" + """Make a nice string representation of the object.""" #Lens Distance try: dist_str = 'Lens Distance: {0}\n'.format(self._distance) diff --git a/source/MulensModel/tests/test_Model_Parallax.py b/source/MulensModel/tests/test_Model_Parallax.py index c6b9b625..5d2a7a94 100644 --- a/source/MulensModel/tests/test_Model_Parallax.py +++ b/source/MulensModel/tests/test_Model_Parallax.py @@ -187,14 +187,16 @@ def test_annual_parallax_calculation_5(): def test_annual_parallax_calculation_6(): do_annual_parallax_test(SAMPLE_ANNUAL_PARALLAX_FILE_05) -#This unit test needs to be reworked so all data sets and ephemerides files are on the same 245XXXX time system. def test_satellite_and_annual_parallax_calculation(): """test parallax calculation with Spitzer data""" - model_with_par = Model(t_0=2457181.93930, u_0=0.08858, t_E=20.23090, pi_E_N=-0.05413, pi_E_E=-0.16434, coords="18:17:54.74 -22:59:33.4") - model_with_par.parallax(satellite=True, earth_orbital=True, topocentric=False) + model_with_par = Model(t_0=2457181.93930, u_0=0.08858, t_E=20.23090, + pi_E_N=-0.05413, pi_E_E=-0.16434, + coords="18:17:54.74 -22:59:33.4") + model_with_par.parallax(satellite=True, earth_orbital=True, + topocentric=False) model_with_par.t_0_par = 2457181.9 - data_OGLE = MulensData(file_name=SAMPLE_FILE_02,add_2450000=True) + data_OGLE = MulensData(file_name=SAMPLE_FILE_02, add_2450000=True) data_Spitzer = MulensData( file_name=SAMPLE_FILE_03, ephemerides_file=SAMPLE_FILE_03_EPH, add_2450000=True) @@ -203,8 +205,10 @@ def test_satellite_and_annual_parallax_calculation(): ref_OGLE = np.loadtxt(SAMPLE_FILE_02_REF, unpack=True, usecols=[5]) ref_Spitzer = np.loadtxt(SAMPLE_FILE_03_REF, unpack=True, usecols=[5]) - np.testing.assert_almost_equal(model_with_par.data_magnification[0], ref_OGLE, decimal=2) - np.testing.assert_almost_equal(model_with_par.data_magnification[1]/ref_Spitzer, np.array([1]*len(ref_Spitzer)), decimal=3) + np.testing.assert_almost_equal(model_with_par.data_magnification[0], + ref_OGLE, decimal=2) + ratio = model_with_par.data_magnification[1] / ref_Spitzer + np.testing.assert_almost_equal(ratio, [1.]*len(ratio), decimal=3) def test_satellite_parallax_magnification(): """