def terrestrial_parallax(self, time_to_treat, altitude, longitude, latitude): """ Compute the position shift due to the distance of the obervatories from the Earth center. Please have a look on : "Parallax effects in binary microlensing events" Hardy, S.J and Walker, M.A. 1995. http://adsabs.harvard.edu/abs/1995MNRAS.276L..79H :param time_to_treat: a numpy array containing the time where you want to compute this effect. :param altitude: the altitude of the telescope in meter :param longitude: the longitude of the telescope in degree :param latitude: the latitude of the telescope in degree :return: the shift induce by the distance of the telescope to the Earth center. :rtype: array_like **WARNING** : slalib use MJD time definition, which is MJD = JD-2400000.5 """ radius = (self.Earth_radius + altitude) / self.AU Longitude = longitude * np.pi / 180.0 Latitude = latitude * np.pi / 180.0 delta_telescope = [] for time in time_to_treat: time_mjd = time - 2400000.5 sideral_time = slalib.sla_gmst(time_mjd) telescope_longitude = - Longitude - self.target_angles_in_the_sky[ 0] + sideral_time delta_telescope.append(radius * slalib.sla_dcs2c(telescope_longitude, Latitude)) delta_telescope = np.array(delta_telescope) delta_telescope_projected = np.array( [np.dot(delta_telescope, self.North), np.dot(delta_telescope, self.East)]) return delta_telescope_projected
def planet_J2000_geo_to_topo(self, gra, gdec, dist, radi, dut1, longitude, latitude, height): jd_utc = self.calc_jd_utc() date = jd_utc - 2400000.5 + dut1 / (24. * 3600.) jd = jd_utc - 2400000.5 + (self.tai_utc + 32.184) / (24. * 3600.) # reference => http://www.cv.nrao.edu/~rfisher/Ephemerides/times.html # Spherical to x,y,z v = slalib.sla_dcs2c(gra, gdec) for i in range (3): v[i] *= dist # Precession to date. rmat = slalib.sla_prec(2000.0, slalib.sla_epj(jd)) vgp = slalib.sla_dmxv(rmat, v) # Geocenter to observer (date). stl = slalib.sla_gmst(date) + longitude vgo = slalib.sla_pvobs(latitude, height, stl) # Observer to planet (date). for i in range (3): v[i] = vgp[i] - vgo[i] disttmp = dist dist = math.sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]) radi *= disttmp / dist # Precession to J2000 rmat = slalib.sla_prec(slalib.sla_epj(jd), 2000.) vgp = slalib.sla_dmxv(rmat, v) # To RA,Dec. ret = slalib.sla_dcc2s(vgp) tra = slalib.sla_dranrm(ret[0]) tdec = ret[1] return [dist, radi, tra, tdec]
def space_parallax(self, time_to_treat, satellite_name, telescope): """ Compute the position shift due to the distance of the obervatories from the Earth center. Please have a look on : "Parallax effects in binary microlensing events" Hardy, S.J and Walker, M.A. 1995. http://adsabs.harvard.edu/abs/1995MNRAS.276L..79H :param time_to_treat: a numpy array containing the time where you want to compute this effect. :param satellite_name: the name of the observatory. Have to be recognize by JPL HORIZON. :return: the shift induce by the distance of the telescope to the Earth center. :rtype: array_like **WARNING** : slalib use MJD time definition, which is MJD = JD-2400000.5 """ tstart = min(time_to_treat) - 1 tend = max(time_to_treat) + 1 if len(telescope.spacecraft_positions) != 0: # allow to pass the user to give his own ephemeris satellite_positions = np.array(telescope.spacecraft_positions) else: #call JPL! satellite_positions = produce_horizons_ephem( satellite_name, tstart, tend, observatory='Geocentric', step_size='60m', verbose=False)[1] satellite_positions = np.array(satellite_positions) dates = satellite_positions[:, 0].astype(float) ra = satellite_positions[:, 1].astype(float) dec = satellite_positions[:, 2].astype(float) distances = satellite_positions[:, 3].astype(float) interpolated_ra = interpolate.interp1d(dates, ra) interpolated_dec = interpolate.interp1d(dates, dec) interpolated_distance = interpolate.interp1d(dates, distances) ra_interpolated = interpolated_ra(time_to_treat) dec_interpolated = interpolated_dec(time_to_treat) distance_interpolated = interpolated_distance(time_to_treat) delta_satellite = [] for index_time in range(len(time_to_treat)): delta_satellite.append( distance_interpolated[index_time] * slalib.sla_dcs2c(ra_interpolated[index_time] * np.pi / 180, dec_interpolated[index_time] * np.pi / 180)) delta_satellite = np.array(delta_satellite) delta_satellite_projected = np.array([ np.dot(delta_satellite, self.North), np.dot(delta_satellite, self.East) ]) return delta_satellite_projected
def helio_geo_correction(ra, dec, mjd, st): """Motion of earth's center in heliocentric frame""" # line-of-sight unit vector to astronomical object k_los = sla_dcs2c(ra.radian, dec.radian) # Velocity and position of earth in barycentric and heliocentric frames # Units are AU and AU/s vel_bary, pos_bary, vel_hel, pos_hel = sla_evp(mjd, 2000.0) # Radial velocity correction (km/s) due to helio-geocentric transformation # Positive when earth is moving away from object return u.AU.to(u.km, -np.dot(vel_hel, k_los))
def ts_to_hjd(ts, target_position, debug=False): """Convert a UTC timestamp in YYYY-MM-DDTHH:MM:SS string format to HJD, for a given target position""" ra_rads = d2r( target_position[0] ) dec_rads = d2r( target_position[1] ) target_position = S.sla_dcs2c( ra_rads, dec_rads ) t = Time(ts, format='isot', scale='utc') hjd = jd_to_hjd(t, target_position, debug=debug) return hjd
def ts_to_hjd(ts, target_position, debug=False): """Convert a UTC timestamp in YYYY-MM-DDTHH:MM:SS string format to HJD, for a given target position""" ra_rads = d2r(target_position[0]) dec_rads = d2r(target_position[1]) target_position = S.sla_dcs2c(ra_rads, dec_rads) t = Time(ts, format='isot', scale='utc') hjd = jd_to_hjd(t, target_position, debug=debug) return hjd
def compute_lsrk(self): """ Computes the LSR in km/s uses the MJD, RA and DEC of observation to compute along with the telescope location. Requires pyslalib """ ra = Angle(self.header[b'src_raj'], unit='hourangle') dec = Angle(self.header[b'src_dej'], unit='degree') mjdd = self.header[b'tstart'] rarad = ra.to('radian').value dcrad = dec.to('radian').value last = self.compute_lst() tellat = np.deg2rad(self.coords[0]) tellong = np.deg2rad(self.coords[1]) # convert star position to vector starvect = s.sla_dcs2c(rarad, dcrad) # velocity component in ra,dec due to Earth rotation Rgeo = s.sla_rverot(tellat, rarad, dcrad, last) # get Barycentric and heliocentric velocity and position of the Earth. evp = s.sla_evp(mjdd, 2000.0) dvb = evp[0] # barycentric velocity vector, in AU/sec dpb = evp[1] # barycentric position vector, in AU dvh = evp[2] # heliocentric velocity vector, in AU/sec dph = evp[3] # heliocentric position vector, in AU # dot product of vector to object and heliocentric velocity # convert AU/sec to km/sec vcorhelio = -s.sla_dvdv(starvect, dvh) * 149.597870e6 vcorbary = -s.sla_dvdv(starvect, dvb) * 149.597870e6 # rvlsrd is velocity component in ra,dec direction due to the Sun's # motion with respect to the "dynamical" local standard of rest rvlsrd = s.sla_rvlsrd(rarad, dcrad) # rvlsrk is velocity component in ra,dec direction due to i # the Sun's motion w.r.t the "kinematic" local standard of rest rvlsrk = s.sla_rvlsrk(rarad, dcrad) # rvgalc is velocity component in ra,dec direction due to #the rotation of the Galaxy. rvgalc = s.sla_rvgalc(rarad, dcrad) totalhelio = Rgeo + vcorhelio totalbary = Rgeo + vcorbary totallsrk = totalhelio + rvlsrk totalgal = totalbary + rvlsrd + rvgalc return totallsrk
def rvel(self, mjdd, radeg, decdeg): global tellat, tellong, telelev last = self.hlst(mjdd) # apparent LST in radians # convert ra,dec to radians rarad = radeg * math.pi / 180.0 dcrad = decdeg * math.pi / 180.0 # convert star position to vector starvect = s.sla_dcs2c(rarad, dcrad) # velocity component in ra,dec due to Earth rotation Rgeo = s.sla_rverot(tellat, rarad, dcrad, last) # get Barycentric and heliocentric velocity and position of the Earth. evp = s.sla_evp(mjdd, 2000.0) dvb = evp[0] # barycentric velocity vector, in AU/sec dpb = evp[1] # barycentric position vector, in AU dvh = evp[2] # heliocentric velocity vector, in AU/sec dph = evp[3] # heliocentric position vector, in AU # dot product of vector to object and heliocentric velocity # convert AU/sec to km/sec vcorhelio = -s.sla_dvdv(starvect, dvh) * 149.597870e6 vcorbary = -s.sla_dvdv(starvect, dvb) * 149.597870e6 # rvlsrd is velocity component in ra,dec direction due to the Sun's motion with # respect to the "dynamical" local standard of rest rvlsrd = s.sla_rvlsrd(rarad, dcrad) # rvlsrk is velocity component in ra,dec direction due to the Sun's motion with # respect to the "kinematic" local standard of rest rvlsrk = s.sla_rvlsrk(rarad, dcrad) # rvgalc is velocity component in ra,dec direction due to the rotation of the Galaxy. rvgalc = s.sla_rvgalc(rarad, dcrad) totalhelio = Rgeo + vcorhelio totalbary = Rgeo + vcorbary totallsrk = totalhelio + rvlsrk totalgal = totalbary + rvlsrd + rvgalc # ('UTHr', 'LST', 'Geo', 'Helio', 'Total Helio', 'LSRK', 'Galacto') #(hour,last*12.0/math.pi,Rgeo,vcorb,totalhelio,totallsrk,totalgal) # resulting velocities in km/sec return ((mjdd, last * 12.0 / math.pi, Rgeo, totalhelio, totalbary, totallsrk, totalgal))
def space_parallax(self, time_to_treat, satellite_name): """ Compute the position shift due to the distance of the obervatories from the Earth center. Please have a look on : "Parallax effects in binary microlensing events" Hardy, S.J and Walker, M.A. 1995. http://adsabs.harvard.edu/abs/1995MNRAS.276L..79H :param time_to_treat: a numpy array containing the time where you want to compute this effect. :param satellite_name: the name of the observatory. Have to be recognize by JPL HORIZON. :return: the shift induce by the distance of the telescope to the Earth center. :rtype: array_like **WARNING** : slalib use MJD time definition, which is MJD = JD-2400000.5 """ tstart = min(time_to_treat) - 1 tend = max(time_to_treat) + 1 satellite_positions = produce_horizons_ephem(satellite_name, tstart, tend, observatory='Geocentric', step_size='60m', verbose=False)[1] satellite_positions = np.array(satellite_positions) dates = satellite_positions[:, 0].astype(float) ra = satellite_positions[:, 1].astype(float) dec = satellite_positions[:, 2].astype(float) distances = satellite_positions[:, 3].astype(float) interpolated_ra = interpolate.interp1d(dates, ra) interpolated_dec = interpolate.interp1d(dates, dec) interpolated_distance = interpolate.interp1d(dates, distances) ra_interpolated = interpolated_ra(time_to_treat) dec_interpolated = interpolated_dec(time_to_treat) distance_interpolated = interpolated_distance(time_to_treat) delta_satellite = [] for index_time in xrange(len(time_to_treat)): delta_satellite.append(distance_interpolated[index_time] * slalib.sla_dcs2c( ra_interpolated[index_time] * np.pi / 180, dec_interpolated[index_time] * np.pi / 180)) delta_satellite = np.array(delta_satellite) delta_satellite_projected = np.array( [np.dot(delta_satellite, self.North), np.dot(delta_satellite, self.East)]) return delta_satellite_projected
def planet_J2000_geo_to_topo(self, gra, gdec, dist, radi, dut1, longitude, latitude, height): jd_utc = self.calc_jd_utc() date = jd_utc - 2400000.5 + dut1 / (24. * 3600.) jd = jd_utc - 2400000.5 + (self.tai_utc + 32.184) / ( 24. * 3600. ) # reference => http://www.cv.nrao.edu/~rfisher/Ephemerides/times.html # Spherical to x,y,z v = slalib.sla_dcs2c(gra, gdec) for i in range(3): v[i] *= dist # Precession to date. rmat = slalib.sla_prec(2000.0, slalib.sla_epj(jd)) vgp = slalib.sla_dmxv(rmat, v) # Geocenter to observer (date). stl = slalib.sla_gmst(date) + longitude vgo = slalib.sla_pvobs(latitude, height, stl) # Observer to planet (date). for i in range(3): v[i] = vgp[i] - vgo[i] disttmp = dist dist = math.sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]) radi *= disttmp / dist # Precession to J2000 rmat = slalib.sla_prec(slalib.sla_epj(jd), 2000.) vgp = slalib.sla_dmxv(rmat, v) # To RA,Dec. ret = slalib.sla_dcc2s(vgp) tra = slalib.sla_dranrm(ret[0]) tdec = ret[1] return [dist, radi, tra, tdec]
def rvcorr(hdr): """Calculate helio- and geo-centric corrections to radial velocities The result should be subtracted from the observed (topocentric) velocities in order to give velocities in the heliocentric frame. """ # The following page was very helpful in pointing to the relevant # SLALIB routines and how to use them # http://star-www.rl.ac.uk/docs/sun67.htx/node230.html # Object coordinates ra = coord.RA(hdr["RA"], U.hour) dec = coord.Dec(hdr["DEC"], U.degree) # Modified Julian Date jdate = float(hdr["MJD"]) # Sidereal time st = coord.Angle((hdr["ST"]), U.hour) # line-of-sight unit vector to astronomical object k_los = sla_dcs2c(ra.radians, dec.radians) # Velocity and position of earth in barycentric and heliocentric frames # Units are AU and AU/s vel_bary, pos_bary, vel_hel, pos_hel = sla_evp(jdate, 2000.0) # Radial velocity correction (km/s) due to helio-geocentric transformation # Positive when earth is moving away from object vcorr_hel = U.AU.to(U.km, -np.dot(vel_hel, k_los)) # Long/lat/altitude of observatory (radians, radians, meters) obs_id, obs_name, obs_long, obs_lat, obs_height = sla_obs(0, "KECK1") # Radial velocity correction (km/s) due to geo-topocentric transformation # Positive when observatory is moving away from object vcorr_geo = sla_rverot(obs_lat, ra.radians, dec.radians, st.radians) return vcorr_hel + vcorr_geo