def test_too_many_parameters_for_init(self): with self.assertRaises(KeyError): mp = mm.ModelParameters( {'pi_E': (1., 1.), 'pi_E_N': 1.}) with self.assertRaises(KeyError): mp = mm.ModelParameters( {'pi_E': (1., 1.), 'pi_E_E': 1.})
def test_coords_format(): """ Simple test of __init__ and calculation of .x and .y. It checks if coordinates are passed properly in different formats. """ times = np.linspace(2456789.0123, 2468013.579) parameters = {'t_0': 2462401., 'u_0': 0.1, 't_E': 2000.} params = mm.ModelParameters(parameters) coords_txt = "18:18:18.18 -30:30:30.30" coords = [ None, coords_txt, mm.Coordinates(coords_txt), SkyCoord(coords_txt, unit=(u.hourangle, u.deg)) ] trajecotories = [mm.Trajectory(times, params, coords=c) for c in coords] for trajectory in trajecotories: assert np.all(trajectory.x == trajecotories[0].x) assert np.all(trajectory.y == trajecotories[0].y) parameters['pi_E_E'] = 0.1 parameters['pi_E_N'] = -0.15 params = mm.ModelParameters(parameters) coords = coords[1:] p = {'earth_orbital': True, 'satellite': False, 'topocentric': False} kwargs = {'times': times, 'parameters': params, 'parallax': p} trajecotories = [mm.Trajectory(coords=c, **kwargs) for c in coords] for trajectory in trajecotories: assert np.all(trajectory.x == trajecotories[0].x) assert np.all(trajectory.y == trajecotories[0].y)
def test_rho_t_e_t_star(): """check if conversions between rho, t_E, and t_star work ok""" t_0 = 2450000. u_0 = 0.1 t_E_1 = 20. t_E_2 = t_E_1 * u.day rho = 0.001 t_star_1 = t_E_1 * rho t_star_2 = t_E_2 * rho for (t_E, t_star) in zip([t_E_1, t_E_2], [t_star_1, t_star_2]): params_1 = mm.ModelParameters({ 't_0': t_0, 'u_0': u_0, 't_E': t_E, 'rho': rho }) np.testing.assert_almost_equal(params_1.t_star, t_star_1) params_2 = mm.ModelParameters({ 't_0': t_0, 'u_0': u_0, 't_star': t_star, 'rho': rho }) np.testing.assert_almost_equal(params_2.t_E, t_E_1) params_3 = mm.ModelParameters({ 't_0': t_0, 'u_0': u_0, 't_star': t_star, 't_E': t_E }) np.testing.assert_almost_equal(params_3.rho, rho)
def test_t_0_kep(): """test reference epoch for orbital motion""" dict_static = {'t_0': 2456789.01234, 'u_0': 1., 't_E': 12.345, 's': 1.2345, 'q': 0.01234, 'alpha': 30.} dict_motion = dict_static.copy() dict_motion.update({'dalpha_dt': 10., 'ds_dt': 0.1}) dict_motion_2 = dict_motion.copy() dict_motion_2.update({'t_0_kep': 2456789.01234-18.2625}) motion = mm.ModelParameters(dict_motion) motion_2 = mm.ModelParameters(dict_motion_2) assert motion.t_0_kep == motion.t_0 assert motion_2.t_0_kep == dict_motion_2['t_0_kep'] epoch_1 = dict_static['t_0'] - 18.2625 epoch_2 = dict_static['t_0'] # Test motion. np.testing.assert_almost_equal(motion.get_alpha(epoch_1).value, 29.5) np.testing.assert_almost_equal(motion.get_alpha(epoch_2).value, 30.) np.testing.assert_almost_equal(motion.get_s(epoch_1), 1.2295) np.testing.assert_almost_equal(motion.get_s(epoch_2), 1.2345) # Test motion_2. np.testing.assert_almost_equal(motion_2.get_alpha(epoch_1).value, 30.) np.testing.assert_almost_equal(motion_2.get_alpha(epoch_2).value, 30.5) np.testing.assert_almost_equal(motion_2.get_s(epoch_1), 1.2345) np.testing.assert_almost_equal(motion_2.get_s(epoch_2), 1.2395)
def test_orbital_motion_1(): """basic tests of orbital motion""" dict_static = { 't_0': 2456789.01234, 'u_0': 1., 't_E': 12.345, 's': 1.2345, 'q': 0.01234, 'alpha': 30. } dict_motion = dict_static.copy() dict_motion.update({'dalpha_dt': 10., 'ds_dt': 0.1}) static = mm.ModelParameters(dict_static) motion = mm.ModelParameters(dict_motion) assert static.is_static() assert not motion.is_static() epoch_1 = dict_static['t_0'] - 18.2625 epoch_2 = dict_static['t_0'] epoch_3 = dict_static['t_0'] + 18.2625 # Test get_s() and get_alpha() for static case. assert static.get_s(epoch_1) == static.get_s(epoch_2) assert static.get_s(epoch_1) == static.get_s(epoch_3) assert static.get_s(epoch_1) == dict_static['s'] assert static.get_alpha(epoch_1) == static.get_alpha(epoch_3) assert static.get_alpha(epoch_1) == dict_static['alpha'] * u.deg # Test get_s() and get_alpha() for orbital motion case. np.testing.assert_almost_equal(motion.get_alpha(epoch_1).value, 29.5) np.testing.assert_almost_equal(motion.get_alpha(epoch_2).value, 30.) np.testing.assert_almost_equal(motion.get_alpha(epoch_3).value, 30.5) np.testing.assert_almost_equal(motion.get_s(epoch_1), 1.2295) np.testing.assert_almost_equal(motion.get_s(epoch_2), 1.2345) np.testing.assert_almost_equal(motion.get_s(epoch_3), 1.2395) # Test arguments as list or array. np.testing.assert_almost_equal( motion.get_alpha([epoch_1, epoch_2, epoch_3]).value, [29.5, 30., 30.5]) np.testing.assert_almost_equal( motion.get_alpha(np.array([epoch_1, epoch_2, epoch_3])).value, [29.5, 30., 30.5]) np.testing.assert_almost_equal(motion.get_s([epoch_1, epoch_2, epoch_3]), [1.2295, 1.2345, 1.2395]) np.testing.assert_almost_equal( motion.get_s(np.array([epoch_1, epoch_2, epoch_3])), [1.2295, 1.2345, 1.2395]) # Test get_alpha() units. assert static.get_alpha(epoch_1).unit == u.deg assert static.get_alpha(epoch_2).unit == u.deg assert motion.get_alpha(epoch_1).unit == u.deg assert motion.get_alpha(epoch_2).unit == u.deg assert motion.alpha == 30. * u.deg assert motion.s == 1.2345
def test_is_finite_source(): """ Test if .is_finite_source() works properly for 1L1S """ common = {'t_0': 1.23, 'u_0': 0.123, 't_E': 23.456} params_1 = mm.ModelParameters(common) params_2 = mm.ModelParameters({'rho': 0.001, **common}) params_3 = mm.ModelParameters({'t_star': 0.012, **common}) assert not params_1.is_finite_source() assert params_2.is_finite_source() assert params_3.is_finite_source()
def test_n_lenses(): """ Test if lenses are counted properly """ p_1 = mm.ModelParameters({'t_0': 10, 'u_0': 1, 't_E': 3, 'rho': 0.001}) p_2 = mm.ModelParameters({'t_0': 10, 'u_0': 1, 't_E': 3, 'rho': 0.001, 's': 10, 'q': 0.5, 'alpha': 100.}) p_3 = mm.ModelParameters({'x_caustic_in': 0.1, 'x_caustic_out': 0.15, 't_caustic_in': 1000, 't_caustic_out': 2000., 's': 1, 'q': 0.8}) assert p_1.n_lenses == 1 assert p_2.n_lenses == 2 assert p_3.n_lenses == 2
def test_Lee09_and_WittMao94(): """ test Lee et al. 2009 and Witt & Mao 1994 finite source calculation """ t_vec = np.array([3.5, 2., 1., 0.5, 0.]) # The values below were calculated using code developed by P. Mroz. expected_0 = np.array([1.01084060513, 1.06962639343, 1.42451408166, 2.02334097551, 2.13919086656]) expected_1 = np.array([1.01110609638, 1.07461016241, 1.57232954942, 2.21990790526, 2.39458814753]) expected_2 = np.array([1.0110829794, 1.07404148634, 1.55620547462, 2.24809136704, 2.44503143812]) # The last values are for 2-parameter LD with same settings and lambda=0.3. # Correction is: # -lambda*(1-1.25*sqrt(costh)) # and for 1-parameter LD we used: # 1-gamma*(1-1.5*costh) # Test uniform source first. params_0 = mm.ModelParameters( {'t_0': 0., 'u_0': 0.5, 't_E': 1., 'rho': 1.}) mag_curve_0 = mm.MagnificationCurve(times=t_vec, parameters=params_0) methods_0 = [-5., 'finite_source_uniform_Lee09', 5.] mag_curve_0.set_magnification_methods(methods_0, 'point_source') results_0 = mag_curve_0.get_point_lens_magnification() np.testing.assert_almost_equal(expected_0, results_0, decimal=4) # Then test 1-parameter limb-darkening. params_1 = mm.ModelParameters( {'t_0': 0., 'u_0': 0.1, 't_E': 1., 'rho': 1.}) mag_curve_1 = mm.MagnificationCurve(times=t_vec, parameters=params_1, gamma=0.5) methods_1 = [-5., 'finite_source_LD_Lee09', 5.] mag_curve_1.set_magnification_methods(methods_1, 'point_source') results_1 = mag_curve_1.get_point_lens_magnification() np.testing.assert_almost_equal(expected_1, results_1, decimal=3) # Tests for Witt & Mao 1994 start here methods_2 = [-5., 'finite_source_uniform_WittMao94', 5.] mag_curve_0.set_magnification_methods(methods_2, 'point_source') results_2 = mag_curve_0.get_point_lens_magnification() np.testing.assert_almost_equal(expected_0, results_2, decimal=4) methods_3 = [-5., 'finite_source_LD_WittMao94', 5.] mag_curve_1.set_magnification_methods(methods_3, 'point_source') results_3 = mag_curve_1.get_point_lens_magnification() np.testing.assert_almost_equal(expected_1, results_3, decimal=3)
def test_binary_source(): """ Test if binary source parameters are properly set and changed """ params = mm.ModelParameters({ 't_0_1': 2455000.1, 'u_0_1': 0.05, 't_star_1': 0.025, 't_0_2': 2455123.4, 'u_0_2': 0.15, 't_star_2': 0.050, 't_E': 25.}) assert params.t_E == 25. assert params.source_1_parameters.rho == 0.001 assert params.source_2_parameters.rho == 0.002 params.t_0_1 = 2456789.012345 assert params.t_0_1 == 2456789.012345 assert params.source_1_parameters.t_0 == 2456789.012345 params.t_star_2 = 0.075 assert params.source_2_parameters.t_star == 0.075 assert params.t_star_2 == 0.075 assert params.source_2_parameters.rho == 0.003 assert params.rho_2 == 0.003 params.t_E = 12.5 assert params.t_star_1 == 0.025 assert params.source_1_parameters.t_star == 0.025 assert params.rho_1 == 0.002 assert params.source_1_parameters.rho == 0.002 assert params.t_star_2 == 0.075 assert params.source_2_parameters.t_star == 0.075 assert params.rho_2 == 0.006 assert params.source_2_parameters.rho == 0.006
def test_fspl(): """ check if FSPL magnification is calculate properly """ t_0 = 2456789.012345 t_E = 23.4567 u_0 = 1e-4 rho = 1e-3 gamma = 0.56789 t_vec = np.array([-(rho**2-u_0**2)**0.5, 0., ((0.5*rho)**2-u_0**2)**0.5]) t_vec = t_vec * t_E + t_0 params = mm.ModelParameters( {'t_0': t_0, 'u_0': u_0, 't_E': t_E, 'rho': rho}) mag_curve = mm.MagnificationCurve( times=t_vec, parameters=params, gamma=gamma) methods = [t_0-t_E, 'finite_source_LD_Yoo04', t_0+t_E] mag_curve.set_magnification_methods(methods, 'point_source') results = mag_curve.get_point_lens_magnification() u = np.array([rho, u_0, 0.5*rho]) pspl = (u**2 + 2.) / np.sqrt(u**2 * (u**2 + 4.)) expected = np.array([1.27323965-gamma*0.09489869, 0.19949906-gamma*-0.03492121, 0.93421546-gamma*-0.09655794]) # These values were calculated by Andy Gould (file b0b1.dat). expected *= pspl np.testing.assert_almost_equal(expected/results, 1., decimal=4)
def test_update(): t_0 = 2456141.593 u_0 = 0.5425 t_E = 62.63 * u.day params = mm.ModelParameters({'t_0': t_0, 'u_0': u_0, 't_E': t_E}) params.as_dict().update({'rho': 0.001}) assert len(params.parameters.keys()) == 4
def test_magnification_type(): """ Check type of magnification returned for model with t_eff. At some point it was astropy quantity. """ parameters = mm.ModelParameters({'t_0': 1., 't_eff': 0.2, 't_E': 3.}) magnification_curve = mm.MagnificationCurve(2., parameters) assert type(magnification_curve.get_magnification()) == np.ndarray
def test_init_parameters(): t_0 = 6141.593 u_0 = 0.5425 t_E = 62.63 * u.day params = mm.ModelParameters({'t_0': t_0, 'u_0': u_0, 't_E': t_E}) np.testing.assert_almost_equal(params.t_0, t_0) np.testing.assert_almost_equal(params.u_0, u_0) np.testing.assert_almost_equal(params.t_E, t_E.value)
def test_init_parameters(): """are parameters properly passed between Model and ModelParameters?""" t_0 = 6141.593 u_0 = 0.5425 t_E = 62.63 * u.day params = mm.ModelParameters({'t_0': t_0, 'u_0': u_0, 't_E': t_E}) model = mm.Model(parameters=params) almost(model.parameters.t_0, t_0) almost(model.parameters.u_0, u_0) almost(model.parameters.t_E, t_E.value)
def test_repr_parameters(): t_0 = 2456141.593 u_0 = 0.5425 t_E = 62.63 * u.day params = mm.ModelParameters({'t_0': t_0, 'u_0': u_0, 't_E': t_E}) out_1 = " t_0 (HJD) u_0 t_E (d) \n" out_2 = "2456141.59300 0.542500 62.6300 \n" assert (out_1 + out_2) == str(params)
def test_too_much_rho_t_e_t_star(self): with self.assertRaises(KeyError): t_0 = 2450000. u_0 = 0.1 t_E = 20. * u.day rho = 0.001 t_star = t_E * rho mm.ModelParameters({ 't_0': t_0, 'u_0': u_0, 't_E': t_E, 'rho': rho, 't_star': t_star})
def test_update(): """ check if the number of parameters can be changed """ t_0 = 2456141.593 u_0 = 0.5425 t_E = 62.63*u.day params = mm.ModelParameters({'t_0': t_0, 'u_0': u_0, 't_E': t_E}) params.as_dict().update({'rho': 0.001}) assert len(params.parameters.keys()) == 4
def get_file_params(filename): """Read in the model parameters used to create the file""" with open(filename) as data_file: lines = data_file.readlines() ulens_params = lines[2].split() return (mm.ModelParameters({ 't_0': float(ulens_params[1]), 'u_0': float(ulens_params[2]), 't_E': float(ulens_params[3]), 'rho': float(ulens_params[4]) }), float(ulens_params[5]))
def test_init_parameters(): """ make sure that parameters are properly stored """ t_0 = 6141.593 u_0 = 0.5425 t_E = 62.63*u.day params = mm.ModelParameters({'t_0': t_0, 'u_0': u_0, 't_E': t_E}) np.testing.assert_almost_equal(params.t_0, t_0) np.testing.assert_almost_equal(params.u_0, u_0) np.testing.assert_almost_equal(params.t_E, t_E.value)
def test_PSPL_for_binary(): """ test PSPL model used in a model that is defined as binary """ t_0 = 1000. t_E = 20. u_0 = 1. t_vec = np.array([10., 100.]) * t_E + t_0 params = mm.ModelParameters({ 't_0': t_0, 'u_0': u_0, 't_E': t_E, 's': 1.2, 'q': 0.1, 'alpha': 0.}) mag_curve = mm.MagnificationCurve(times=t_vec, parameters=params) mag_curve.set_magnification_methods(None, 'point_source_point_lens') u2 = u_0**2 + ((t_vec - t_0) / t_E)**2 pspl = (u2 + 2.) / np.sqrt(u2 * (u2 + 4.)) np.testing.assert_almost_equal(pspl, mag_curve.get_magnification())
def test_BLPS_01(): """simple binary lens with point source""" params = mm.ModelParameters({ 't_0': t_0, 'u_0': u_0, 't_E': t_E, 'alpha': alpha, 's': s, 'q': q }) model = mm.Model(parameters=params) t = np.array([2456112.5]) data = mm.MulensData(data_list=[t, t * 0. + 16., t * 0. + 0.01]) magnification = model.get_magnification(data.time[0]) almost(magnification, 4.691830781584699)
def test_orbital_motion_gammas(): """test .gamma_parallel .gamma_perp .gamma""" dict_params = {'t_0': 2457123.456, 'u_0': 0.0345, 't_E': 30.00, 's': 1.5, 'ds_dt': 0.5, 'q': 0.987, 'alpha': 12.345, 'dalpha_dt': 50.} params = mm.ModelParameters(dict_params) # Test values. np.testing.assert_almost_equal(params.gamma_parallel.value, 0.333333333) np.testing.assert_almost_equal(params.gamma_perp.value, -0.872664626) np.testing.assert_almost_equal(params.gamma.value, 0.934159869) # Test units. assert params.gamma_parallel.unit == 1. / u.year assert params.gamma_perp.unit == u.rad / u.year assert params.gamma.unit == 1. / u.year
def test_BLPS_02_AC(): """ simple binary lens with extended source and different methods to evaluate magnification - version with adaptivecontouring """ params = mm.ModelParameters({ 't_0': t_0, 'u_0': u_0, 't_E': t_E, 'alpha': alpha, 's': s, 'q': q, 'rho': rho }) model = mm.Model(parameters=params) t = np.array([6112.5, 6113., 6114., 6115., 6116., 6117., 6118., 6119]) t += 2450000. ac_name = 'Adaptive_Contouring' methods = [ 2456113.5, 'Quadrupole', 2456114.5, 'Hexadecapole', 2456116.5, ac_name, 2456117.5 ] accuracy_1 = {'accuracy': 0.04} accuracy_2 = {'accuracy': 0.01, 'ld_accuracy': 0.00001} model.set_magnification_methods(methods) model.set_magnification_methods_parameters({ac_name: accuracy_1}) data = mm.MulensData(data_list=[t, t * 0. + 16., t * 0. + 0.01]) result = model.get_magnification(data.time) expected = np.array([ 4.69183078, 2.87659723, 1.83733975, 1.63865704, 1.61038135, 1.63603122, 1.69045492, 1.77012807 ]) almost(result, expected, decimal=3) # Below we test passing the limb coeff to VBBL function. # data.bandpass = '******' model.set_limb_coeff_u('I', 10.) # This is an absurd value but I needed something quick. model.set_magnification_methods_parameters({ac_name: accuracy_2}) # result = model.data_magnification[0] result = model.get_magnification(data.time, gamma=model.get_limb_coeff_gamma('I')) almost(result[5], 1.6366862, decimal=3)
def parameters(self): """Model parameters""" model_parameters = mm.ModelParameters({ 't_0': float(self.ulens_params[1]) + 2450000., 'u_0': float(self.ulens_params[3]), 't_E': float(self.ulens_params[4]), 'pi_E_N': float(self.ulens_params[5]), 'pi_E_E': float(self.ulens_params[6]), 't_0_par': self.t_0_par }) return model_parameters
def test_BLPS_02(): """ simple binary lens with extended source and different methods to evaluate magnification """ params = mm.ModelParameters({ 't_0': t_0, 'u_0': u_0, 't_E': t_E, 'alpha': alpha, 's': s, 'q': q, 'rho': rho }) model = mm.Model(parameters=params) t = np.array([6112.5, 6113., 6114., 6115., 6116., 6117., 6118., 6119]) t += 2450000. methods = [ 2456113.5, 'Quadrupole', 2456114.5, 'Hexadecapole', 2456116.5, 'VBBL', 2456117.5 ] model.set_magnification_methods(methods) data = mm.MulensData(data_list=[t, t * 0. + 16., t * 0. + 0.01]) result = model.get_magnification(data.time) expected = np.array([ 4.69183078, 2.87659723, 1.83733975, 1.63865704, 1.61038135, 1.63603122, 1.69045492, 1.77012807 ]) almost(result, expected) # Possibly, this test should be re-created in test_FitData.py # Below we test passing the limb coeff to VBBL function. # data.bandpass = '******' model.set_limb_coeff_u('I', 10.) # This is an absurd value but I needed something quick. result = model.get_magnification(data.time, gamma=model.get_limb_coeff_gamma('I')) almost(result[5], 1.6366862) result_2 = model.get_magnification(data.time, bandpass='******') almost(result, result_2)
def test_BLPS_shear(): """ simple binary lens with point source and external convergence and shear """ params = mm.ModelParameters({ 't_0': t_0, 'u_0': u_0, 't_E': t_E, 'alpha': alpha, 's': s, 'q': q, 'convergence_K': 0.0, 'shear_G': complex(0, 0) }) model = mm.Model(parameters=params) t = np.array([2456112.5]) data = mm.MulensData(data_list=[t, t * 0. + 16., t * 0. + 0.01]) magnification = model.get_magnification(data.time[0]) almost(magnification, 4.691830781584699)
def test_methods_parameters(): """ make sure additional parameters are properly passed to very inner functions """ params = mm.ModelParameters({ 't_0': t_0, 'u_0': u_0, 't_E': t_E, 'alpha': alpha, 's': s, 'q': q, 'rho': rho }) model = mm.Model(parameters=params) t = np.array([2456117.]) methods = [ 2456113.5, 'Quadrupole', 2456114.5, 'Hexadecapole', 2456116.5, 'VBBL', 2456117.5 ] model.set_magnification_methods(methods) data = mm.MulensData(data_list=[t, t * 0. + 16., t * 0. + 0.01]) model.set_datasets([data]) result_1 = model.data_magnification[0] vbbl_options = {'accuracy': 0.1} methods_parameters = {'VBBL': vbbl_options} model.set_magnification_methods_parameters(methods_parameters) result_2 = model.data_magnification[0] vbbl_options = {'accuracy': 1.e-5} methods_parameters = {'VBBL': vbbl_options} model.set_magnification_methods_parameters(methods_parameters) result_3 = model.data_magnification[0] assert result_1[0] != result_2[0] assert result_1[0] != result_3[0] assert result_2[0] != result_3[0]
def get_d_perp(ra_deg, dec_deg, t_0_par, ephemeris_file): """ extract D_perp for satellite for given epoch """ parameters = { 't_0': t_0_par, 'u_0': 0, 't_E': 100., 'pi_E_N': 2.**-0.5, 'pi_E_E': 2.**-0.5, 't_0_par': t_0_par } params = MM.ModelParameters(parameters) coords = MM.Coordinates(SkyCoord(ra_deg, dec_deg, unit=u.deg)) satellite = MM.SatelliteSkyCoord(ephemerides_file=ephemeris_file) ephemeris = satellite.get_satellite_coords([t_0_par]) trajectory = MM.Trajectory([t_0_par], params, coords=coords, parallax={'satellite': True}, satellite_skycoord=ephemeris) return np.sqrt(trajectory.x**2 + trajectory.y**2)[0]
# FSPL: 't_0', 'u_0', 't_E', 'rho' # PSPL w/ parallax: 't_0', 'u_0', 't_E', 'pi_E_N', 'pi_E_E' # (OPTIONAL: 't_0_par') # FSBL: 't_0', 'u_0', 't_E', 'rho', 's', 'q', 'alpha' # BSPL: 't_0_1', 'u_0_1', 't_0_2', 'u_0_2', 't_E' # By Effect: # parallax: 'pi_E_N', 'pi_E_E' OR 'pi_E' (OPTIONAL: 't_0_par') # xallarap: 'xi_E_N', 'xi_E_E', 'period' # finite source: 'rho' (1 source) OR 'rho_1', 'rho_2' (if 2 sources) # lens orbital motion: 'dsdt', 'dalphadt' (OPTIONAL: 'z', 'dzdt') # Alternative parameterizations: # any two of 'u_0', 't_E', 't_eff' (t_eff = u_0 * t_E) # any two of 't_E', 'rho', 't_star' (t_star = rho * t_E) # FSBL: 't_1', 'u_0', 't_2', 'rho', 's', 'q', 'alpha' (Cassan) PSPL_params = mm.ModelParameters({'t_0': 2458060., 'u_0': 0.2, 't_E': 30.5}) my_PSPL_model = mm.Model({'t_0': 2458060., 'u_0': 0.2, 't_E': 30.5}) print(my_PSPL_model.parameters) print(my_PSPL_model.parameters.t_eff) print(my_PSPL_model.parameters.rho) # Returns: AttributeError('rho is not defined for this model.') FSPL_params = dict(my_PSPL_model.parameters.parameters) FSPL_params['rho'] = 0.001 my_FSPL_model = mm.Model(FSPL_params) my_PSPL_model = mm.Model(parameters={ 't_0': 2458060., 'u_0': 0.2,
plt.figure() ground_model.plot_magnification(label='ground') space_model.plot_magnification(label='space') plt.title('OB140939 Models with Parallax') plt.legend() # Specifying coordinates for an event ground_data = mm.MulensData( file_name=os.path.join(data_dir, 'ob140939_OGLE.dat')) space_data = mm.MulensData( file_name=os.path.join(data_dir, 'ob140939_Spitzer.dat'), ephemerides_file=os.path.join( ephemeris_dir, 'Spitzer_ephemeris_01.dat')) model_params = mm.ModelParameters( {'t_0': t_0, 'u_0': u_0, 't_E': t_E, 'pi_E_N': pi_E_N, 'pi_E_E': pi_E_E}) event = mm.Event(datasets=[ground_data, space_data], model=mm.Model(parameters=model_params), coords=ra_dec) plt.figure() event.plot_model() event.plot_data(label_list=['OGLE', 'Spitzer']) (fs_ogle, fb_ogle) = event.get_ref_fluxes(data_ref=event.datasets[0]) space_model.plot_lc(f_source=fs_ogle, f_blend=fb_ogle) plt.title('OB140939 Models with Data') plt.legend(loc='best') plt.xlim(2456780., 2456880.)