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 setup_trajectory(self): """Return a trajectory using the parameters of this file""" trajectory = mm.Trajectory(self.data['Time'] + 2450000., parameters=self.parameters, parallax={'earth_orbital': True}, coords=self.coords) return trajectory
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]
def magnif(q, s, rho): """ Find the magnification, trajectory and caustics curve of the binary lens system Parameters: s:seperation between two lens q:mass ratio between two lens rho:source scaled size Output: light: magnification amplitude of of the binary lens system traj.x,traj,y: trajectory of the binary lens system in x and y direction X,Y: x and y coordination of points on caustics curve """ #find mass with q m_1 = 1 / (q + 1) m_2 = q / (q + 1) #reset parameters params.q = q params.s = s params.rho = rho #find trajectory traj = mm.Trajectory(times, params, coords=coord) #find magnification light = [] model_1 = mm.BinaryLens(m_1, m_2, s) for i in range(len(traj.x)): light.append(model_1.vbbl_magnification(traj.x[i], traj.y[i], rho)) #find caustics curves model_2 = mm.Caustics(q, s) X, Y = model_2.get_caustics() return light, traj.x, traj.y, X, Y
plt.plot(times_plot,2.5 * np.log10(curve_4),'b-',label='$\pi_E$=[0,0.5]') plt.plot(times_plot,2.5 * np.log10(curve_5),'r-',label='$\pi_E$=[0.5,0]') plt.xlabel('Time ($(t-t_0)/t_E$)') plt.ylabel('Magnification in $2.5log_{10}$ scale') plt.title('Light Curve of Point-source Lense') plt.grid() plt.legend() plt.savefig('1.3.1.pdf') plt.show() #find the trajectory traj_1 = mm.Trajectory(times,model_PSPL_2.parameters,coords=coord) traj_2 = mm.Trajectory(times,model_PSPL_2.parameters,coords=coord) traj_3 = mm.Trajectory(times,model_PSPL_3.parameters,coords=coord) traj_4 = mm.Trajectory(times,model_PSPL_4.parameters,parallax=paral,coords=coord) traj_5 = mm.Trajectory(times,model_PSPL_5.parameters,parallax=paral,coords=coord) #plot the trajectory plt.plot(traj_2.x,traj_2.y,'g--',label='Non-parallax') plt.plot(traj_4.x,traj_4.y,'b-',label='$\pi_E$=[0,0.5]') plt.plot(traj_5.x,traj_5.y,'r-',label='$\pi_E$=[0.5,0]') plt.xlabel('X coordinates of the Trajectory') plt.ylabel('Y coordinates of the Trajectory')
's': s, 'q': q }) params_3 = mm.modelparameters.ModelParameters({ 't_0': t_0, 'u_0': u_0, 't_E': t_E, 'pi_E_N': 0.2, 'pi_E_E': 0, 'rho': rho, 'alpha': alpha, 's': s, 'q': q }) #get the trajectory of the source traj_1 = mm.Trajectory(times, params_1, coords=coord) traj_2 = mm.Trajectory(times, params_2, coords=coord) traj_3 = mm.Trajectory(times, params_3, parallax=paral, coords=coord) #get the magnification of the model light_1 = [] light_2 = [] light_3 = [] model_1 = mm.BinaryLens(m_1 / 11, m_2 / 11, s) for i in range(len(traj_1.x)): light_1.append(model_1.vbbl_magnification(traj_1.x[i], traj_1.y[i], rho)) light_2.append(model_1.vbbl_magnification(traj_2.x[i], traj_2.y[i], rho)) light_3.append(model_1.vbbl_magnification(traj_3.x[i], traj_3.y[i], rho)) #plot the light curve