Example #1
0
 def test_slalib(self, mjd, config):
     from pyslalib import slalib
     ra = numpy.zeros(len(mjd), 'float')
     dec = numpy.zeros(len(mjd), 'float')
     for i in range(len(mjd)):
         # Calculate sun's (topocentric) position.
         #ra_RAD, dec_RAD, diam = slalib.sla_rdplan(mjd[i], 0,
         #                                          config['longitude']*_deg2rad, config['latitude']*_deg2rad)
         # Sun's (geocentric?) position.
         bary_vel, bary_pos, helio_vel, helio_pos = slalib.sla_evp(
             mjd, 2000)
         sun_pos = -1 * (bary_pos)
         ra_RAD, dec_RAD = slalib.sla_dcc2s(sun_pos)
         ra[i] = ra_RAD * _rad2deg
         dec[i] = dec_RAD * _rad2deg
     print "Sun: Test_slalib results"
     print " ... ra(slalib)"
     print ra
     print "  ... ra(self)"
     print self.ra
     print self.ra.min(), self.ra.max()
     print " ... dec(slalib)"
     print dec
     print " ... dec(self)"
     print self.dec
Example #2
0
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 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
Example #4
0
    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))
Example #5
0
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
Example #6
0
 def test_slalib(self, mjd, config):
     from pyslalib import slalib
     ra = numpy.zeros(len(mjd), 'float')
     dec = numpy.zeros(len(mjd), 'float')
     for i in range(len(mjd)):
         # Calculate sun's (topocentric) position. 
         #ra_RAD, dec_RAD, diam = slalib.sla_rdplan(mjd[i], 0,
         #                                          config['longitude']*_deg2rad, config['latitude']*_deg2rad)
         # Sun's (geocentric?) position.
         bary_vel, bary_pos, helio_vel, helio_pos = slalib.sla_evp(mjd, 2000)
         sun_pos = -1 * (bary_pos)
         ra_RAD, dec_RAD = slalib.sla_dcc2s(sun_pos)
         ra[i] = ra_RAD * _rad2deg
         dec[i] = dec_RAD * _rad2deg
     print "Sun: Test_slalib results"
     print " ... ra(slalib)"
     print ra
     print "  ... ra(self)"
     print self.ra
     print self.ra.min(), self.ra.max()
     print " ... dec(slalib)"    
     print dec
     print " ... dec(self)"
     print self.dec