def annual_parallax(self, time_to_treat): """Compute the position shift due to the Earth movement. Please have a look on : "Resolution of the MACHO-LMC-5 Puzzle: The Jerk-Parallax Microlens Degeneracy" Gould, Andrew 2004. http://adsabs.harvard.edu/abs/2004ApJ...606..319G :param time_to_treat: a numpy array containing the time where you want to compute this effect. :return: the shift induce by the Earth motion around the Sun :rtype: array_like **WARNING** : this is a geocentric point of view. slalib use MJD time definition, which is MJD = JD-2400000.5 """ to_par_mjd = self.to_par - 2400000.5 Earth_position_time_reference = slalib.sla_epv(to_par_mjd) Sun_position_time_reference = -Earth_position_time_reference[0] Sun_speed_time_reference = -Earth_position_time_reference[1] delta_Sun = [] for time in time_to_treat: time_mjd = time - 2400000.5 Earth_position = slalib.sla_epv(time_mjd) Sun_position = -Earth_position[0] delta_sun = Sun_position - (time_mjd - to_par_mjd) * Sun_speed_time_reference - Sun_position_time_reference delta_Sun.append(delta_sun.tolist()) delta_Sun = np.array(delta_Sun) delta_Sun_projected = np.array( [np.dot(delta_Sun, self.North), np.dot(delta_Sun, self.East)]) return delta_Sun_projected
def annual_parallax(self, time_to_treat): """Compute the position shift due to the Earth movement. Please have a look on : "Resolution of the MACHO-LMC-5 Puzzle: The Jerk-Parallax Microlens Degeneracy" Gould, Andrew 2004. http://adsabs.harvard.edu/abs/2004ApJ...606..319G :param time_to_treat: a numpy array containing the time where you want to compute this effect. :return: the shift induce by the Earth motion around the Sun :rtype: array_like **WARNING** : this is a geocentric point of view. slalib use MJD time definition, which is MJD = JD-2400000.5 """ to_par_mjd = self.to_par - 2400000.5 Earth_position_time_reference = slalib.sla_epv(to_par_mjd) Sun_position_time_reference = -Earth_position_time_reference[0] Sun_speed_time_reference = -Earth_position_time_reference[1] delta_Sun = [] for time in time_to_treat: time_mjd = time - 2400000.5 Earth_position = slalib.sla_epv(time_mjd) Sun_position = -Earth_position[0] delta_sun = Sun_position - (time_mjd - to_par_mjd) * Sun_speed_time_reference - Sun_position_time_reference delta_Sun.append(delta_sun.tolist()) delta_Sun = np.array(delta_Sun) delta_Sun_projected = np.array( [np.dot(delta_Sun, self.North), np.dot(delta_Sun, self.East)]) return delta_Sun_projected
def jd_to_hjd(t, target_position, debug=False): """Calculate the HJD timestamp corresponding to the JD given for the current event. Inputs: t is an astropy Time object target_position is a tuple of (RA, Dec) in decimal degrees Outputs: hjd float """ if debug == True: print 'TIME JD: ',t, t.jd # Calculate the MJD (UTC) timestamp: mjd_utc = t.jd - 2400000.5 if debug == True: print 'TIME MJD_UTC: ',mjd_utc # Correct the MJD to TT: mjd_tt = mjd_utc2mjd_tt(mjd_utc) if debug == True: print 'TIME MJD_TT: ',mjd_tt, t.tt.jd # Calculate Earth's position and velocity, both heliocentric # and barycentric for this date (earth_helio_position, vh, pb, vb) = S.sla_epv( mjd_tt ) if debug == True: print 'Earth Cartesian position: ',earth_helio_position print 'Target cartesian position: ', target_position # Calculate the light travel time delay from the target to # the Sun: dv = S.sla_dvdv( earth_helio_position, target_position ) tcorr = dv * ( constants.au.value / constants.c.value ) if debug == True: print 'TIME tcorr: ', tcorr, 's', (tcorr/60.0),'mins' # Calculating the HJD: hjd = mjd_tt + tcorr/86400.0 + 2400000.5 if debug == True: print 'TIME HJD: ',hjd,'\n' return hjd
def HJD_to_JD(self, time_to_transform): """Transform the input time from HJD to JD. :param array_like time_to_transform: the numpy array containing the time in HJD you want to transform in JD. :return: the time in JD :rtype: array_like """ AU = self.AU light_speed = self.speed_of_light time_correction = [] # DTT=[] for time in time_to_transform: count = 0 jd = np.copy(time) while count < 3: Earth_position = slalib.sla_epv(jd) Sun_position = -Earth_position[0] Sun_angles = slalib.sla_dcc2s(Sun_position) target_angles_in_the_sky = self.target_angles_in_the_sky Time_correction = np.sqrt( Sun_position[0] ** 2 + Sun_position[1] ** 2 + Sun_position[ 2] ** 2) * AU / light_speed * ( np.sin(Sun_angles[1]) * np.sin( target_angles_in_the_sky[1]) + np.cos( Sun_angles[1]) * np.cos( target_angles_in_the_sky[1]) * np.cos( target_angles_in_the_sky[0] - Sun_angles[0])) / ( 3600 * 24.0) count = count + 1 # DTT.append(slalib.sla_dtt(jd)/(3600*24)) time_correction.append(Time_correction) JD = time_to_transform + np.array(time_correction) return JD
def jd_to_hjd(t, target_position, debug=False): """Calculate the HJD timestamp corresponding to the JD given for the current event. Inputs: t is an astropy Time object target_position is a tuple of (RA, Dec) in decimal degrees Outputs: hjd float """ if debug == True: print('TIME JD: ', t, t.jd) # Calculate the MJD (UTC) timestamp: mjd_utc = t.jd - 2400000.5 if debug == True: print('TIME MJD_UTC: ', mjd_utc) # Correct the MJD to TT: mjd_tt = mjd_utc2mjd_tt(mjd_utc) if debug == True: print('TIME MJD_TT: ', mjd_tt, t.tt.jd) # Calculate Earth's position and velocity, both heliocentric # and barycentric for this date (earth_helio_position, vh, pb, vb) = S.sla_epv(mjd_tt) if debug == True: print('Earth Cartesian position: ', earth_helio_position) print('Target cartesian position: ', target_position) # Calculate the light travel time delay from the target to # the Sun: dv = S.sla_dvdv(earth_helio_position, target_position) tcorr = dv * (constants.au.value / constants.c.value) if debug == True: print('TIME tcorr: ', tcorr, 's', (tcorr / 60.0), 'mins') # Calculating the HJD: hjd = mjd_tt + tcorr / 86400.0 + 2400000.5 if debug == True: print('TIME HJD: ', hjd, '\n') return hjd
def HJD_to_JD(self, time_to_transform): """Transform the input time from HJD to JD. :param array_like time_to_transform: the numpy array containing the time in HJD you want to transform in JD. :return: the time in JD :rtype: array_like """ AU = self.AU light_speed = self.speed_of_light time_correction = [] # DTT=[] for time in time_to_transform: count = 0 jd = np.copy(time) while count < 3: Earth_position = slalib.sla_epv(jd) Sun_position = -Earth_position[0] Sun_angles = slalib.sla_dcc2s(Sun_position) target_angles_in_the_sky = self.target_angles_in_the_sky Time_correction = np.sqrt( Sun_position[0] ** 2 + Sun_position[1] ** 2 + Sun_position[ 2] ** 2) * AU / light_speed * ( np.sin(Sun_angles[1]) * np.sin( target_angles_in_the_sky[1]) + np.cos( Sun_angles[1]) * np.cos( target_angles_in_the_sky[1]) * np.cos( target_angles_in_the_sky[0] - Sun_angles[0])) / ( 3600 * 24.0) count = count + 1 # DTT.append(slalib.sla_dtt(jd)/(3600*24)) time_correction.append(Time_correction) JD = time_to_transform + np.array(time_correction) return JD