Ejemplo n.º 1
0
def mean_to_apparent(target, tdb):
    '''Given a target and TDB, return an apparent (RA, Dec) tuple.
       Thin wrapper for SLA_MAP.
    '''

    # Complain if the minimum target fields aren't present
    if not target.get('ra'):
        raise IncompleteTargetError("Missing RA in target definition")

    if not target.get('dec'):
        raise IncompleteTargetError("Missing Declination in target definition")

    target = make_ra_dec_target(
        target['ra'],
        target['dec'],
        ra_proper_motion=target.get('ra_proper_motion'),
        dec_proper_motion=target.get('dec_proper_motion'),
        parallax=target.get('parallax'),
        rad_vel=target.get('rad_vel'),
        epoch=target.get('epoch'))

    (ra_app_rads, dec_app_rads) = sla.sla_map(
        target['ra'].in_radians(), target['dec'].in_radians(),
        target['ra_proper_motion'].in_radians_per_year(),
        target['dec_proper_motion'].in_radians_per_year(), target['parallax'],
        target['rad_vel'], target['epoch'], tdb)

    ra_apparent = Angle(radians=ra_app_rads)
    dec_apparent = Angle(radians=dec_app_rads)

    return (ra_apparent, dec_apparent)
Ejemplo n.º 2
0
    def calc_star_azel(self, ra, dec, mjd):
        ra = ra * math.pi / 180.
        dec = dec * math.pi / 180.

        ret = slalib.sla_map(ra, dec, 0, 0, 0, 0, 2000,
                             mjd + (self.tai_utc + 32.184) / (24. * 3600.))
        ret = list(ret)
        ret = slalib.sla_aop(ret[0],
                             ret[1],
                             mjd,
                             self.dut1,
                             -67.70308139 * math.pi / 180,
                             -22.96995611 * math.pi / 180,
                             4863.85,
                             0,
                             0,
                             283,
                             500,
                             0.1,
                             0.5,
                             tlr=0.0065)
        real_az = ret[0]
        real_el = math.pi / 2. - ret[1]

        real_az = real_az * 180. / math.pi
        real_el = real_el * 180. / math.pi
        return [real_az, real_el]
Ejemplo n.º 3
0
 def calc_star_azel(self, ra, dec, mjd):
     ra = ra*math.pi/180.
     dec = dec*math.pi/180.
     
     ret = slalib.sla_map(ra, dec, 0, 0, 0, 0, 2000, mjd + (self.tai_utc + 32.184)/(24.*3600.))
     ret = list(ret)
     ret = slalib.sla_aop(ret[0], ret[1], mjd, self.dut1, -67.70308139*math.pi/180, -22.96995611*math.pi/180, 4863.85, 0, 0, 283, 500, 0.1, 0.5, tlr=0.0065)
     real_az = ret[0]
     real_el = math.pi/2. - ret[1]
        
     real_az = real_az*180./math.pi
     real_el = real_el*180./math.pi
     return [real_az, real_el]
Ejemplo n.º 4
0
def radec_to_azza(ra, dec, MJD, fctr=350.0, atm=1010.0, temp=283.0, humid=0.5, scope='GBT'):
    """
    redec_to_azza(ra, dec, MJD):
        Return AZ and ZA (in deg) from RA and DEC (J2000 in deg) at MJD.  Keyword params
           are fctr=350.0, atm=1010.0, temp=283.0, humid=0.5, scope='GBT'.
    """
    scope, x, lon, lat, hgt = s.sla_obs(0, scope)
    microns = 3e8/(fctr*1e6)*1e6
    app_rarad, app_decrad = s.sla_map(ra*DEGTORAD,dec*DEGTORAD,0.0,0.0,0.0,0.0,2000.0,MJD)
    az, za, hob, rob, dob  = s.sla_aop(app_rarad,app_decrad,MJD,
                                       0.0,-lon,lat,hgt,0.0,0.0,temp,atm,humid,microns,0.0065)
    az = s.sla_dranrm(az)
    return az*RADTODEG, za*RADTODEG
Ejemplo n.º 5
0
def calc_star_azel(ra, dec, mjd):
    ra = ra*math.pi/180.
    dec = dec*math.pi/180.
    
    ret = slalib.sla_map(ra, dec, 0, 0, 0, 0, 2000, mjd + (tai_utc + 32.184)/(24.*3600.))
    ret = list(ret)
    ret = slalib.sla_aop(ret[0], ret[1], mjd, dut1, -67.70308139*math.pi/180, -22.96995611*math.pi/180, 4863.85, 0, 0, 283, 500, 0.1, 0.5, tlr=0.0065)
    real_az = ret[0]
    real_el = math.pi/2. - ret[1]
       
    real_az = real_az*180./math.pi
    real_el = real_el*180./math.pi
    ret = coord.apply_kisa(real_az, real_el, "/home/amigos/NECST/soft/server/hosei_opt.txt")
    real_az += ret[0]
    real_el += ret[1]
    return [real_az, real_el]
Ejemplo n.º 6
0
def radec_to_azza(ra,
                  dec,
                  MJD,
                  fctr=350.0,
                  atm=1010.0,
                  temp=283.0,
                  humid=0.5,
                  scope='GBT'):
    """
    redec_to_azza(ra, dec, MJD):
        Return AZ and ZA (in deg) from RA and DEC (J2000 in deg) at MJD.  Keyword params
           are fctr=350.0, atm=1010.0, temp=283.0, humid=0.5, scope='GBT'.
    """
    scope, x, lon, lat, hgt = s.sla_obs(0, scope)
    microns = 3e8 / (fctr * 1e6) * 1e6
    app_rarad, app_decrad = s.sla_map(ra * DEGTORAD, dec * DEGTORAD, 0.0, 0.0,
                                      0.0, 0.0, 2000.0, MJD)
    az, za, hob, rob, dob = s.sla_aop(app_rarad, app_decrad, MJD, 0.0, -lon,
                                      lat, hgt, 0.0, 0.0, temp, atm, humid,
                                      microns, 0.0065)
    az = s.sla_dranrm(az)
    return az * RADTODEG, za * RADTODEG
Ejemplo n.º 7
0
    def move_radec(self, gx, gy, gpx, gpy, code_mode, temp, pressure, humid, lamda, dcos, hosei = 'hosei_230.txt', off_coord = "HORIZONTAL", off_x = 0, off_y = 0, az_max_rate=16000, el_max_rate=12000):
        ##debug
        #print('moving!!!, {gx}, {gy}, {code_mode}'.format(**locals()))
        ##debug-end
        #if off_x != 0 or off_y != 0: #for test
        self.set_offset(off_coord, off_x, off_y)
        self.off_eq = gx*180./math.pi#self.off_list["off_az"]
        self.off_ga = gy*180./math.pi#self.off_list["off_l"]
        self.ra_off_ra = self.off_list["off_ra"]#
        self.ra_off_dec = self.off_list["off_dec"]#
        #lamda not equals lambda
        # Calculate current MJD
        tv = time.time()
        mjd = tv/24./3600. + 40587.0 # 40587.0 = MJD0
        #tv = time.time()
        #tv_sec = int(tv)
        #tv_usec = tv - tv_sec
        #mjd = (tv_sec + tv_usec/1000000.)/24./3600. + 40587.0 # 40587.0 = MJD0
        if dcos == 0:
            gy = gy + float(self.off_list["off_dec"])*math.pi/180/3600.
            gx = gx + float(self.off_list["off_ra"])*math.pi/180/3600.
        else:
            gy = gy + float(self.off_list["off_dec"])*math.pi/180/3600.
            gx = gx + float(self.off_list["off_ra"])*math.pi/180/3600./math.cos(gy)

        tai_utc = 36.0 # tai_utc=TAI-UTC  2015 July from ftp://maia.usno.navy.mil/ser7/tai-utc.dat
        
        # lamda is wavelength(not lambda)
        if code_mode == "b1950":
            ret = slalib.sla_fk425(gx, gy, gpx, gpy, 0, 0)
            gaJ2000 = ret[0]
            gdJ2000 = ret[1]
            gpaJ2000 = ret[2]
            gpdJ2000 = ret[3]
        else: # code mode == "J2000"
            gaJ2000 = gx # for check
            gdJ2000 = gy # for check
            gpaJ2000 = gpx # for check
            gpdJ2000 = gpy # for check
        
        ret = slalib.sla_map(gaJ2000, gdJ2000, gpaJ2000, gpdJ2000, 0, 0, 2000, mjd + (tai_utc + 32.184)/(24.*3600.))
        ret = list(ret)
        """
        ret[0] = apparent_ra
        ret[1] = apparent_dec
        """
        self.ra_real_ra = ret[0]*3600.
        self.ra_real_dec = ret[1]*3600.
        #if dcos == 0:
            #print(type(ret), ret[1], self.off_list['off_dec'])
            #ret[1] = ret[1]
            #ret[0] = ret[0]
        #else:
            #ret[1] = ret[1]
            #ret[0] = ret[0]
        ret = slalib.sla_aop(ret[0], ret[1], mjd, self.dut1, self.longitude, self.latitude, self.height, 0, 0, temp, pressure, humid, lamda, tlr=0.0065)
        """
        ret[0] = azimath(radian, N=0, E=90)
        ret[1] = zenith(radian)
        """
        #f = open('radec.txt','a')
        #while self.cc < 1:
        #f.write('gx : ' + 'gy : ' + 'off_ra : ' + 'off_dec : ' + 'real_ra : ' + 'real_dec' + '\n')
        #self.cc += 1
        #self.ra_real_ra = self.ra_real_ra - 83.80613*3600.
        #f.write(str(self.off_eq) +' '+ str(self.off_ga) +' '+ str(self.ra_off_ra) +' '+ str(self.ra_off_dec) +' '+ str(self.ra_real_ra) +' '+ str(self.ra_real_dec) + '\n')
        #f.write('bug_eq : ' + str(self.off_eq) +'\n')
        #f.write('bug_ga : ' + str(self.off_ga) +'\n')
        #f.write('off_ra : ' + str(self.ra_off_ra) +'\n')
        #f.write('off_dec : ' + str(self.ra_off_dec) +'\n')
        #f.write('real_ra : ' + str(self.ra_real_ra) +'\n')
        #f.write('real_dec : ' + str(self.ra_real_dec) +'\n')
        #f.close()
        #From zenith angle to elevation 
        real_az = ret[0]
        real_el = math.pi/2. - ret[1]
        real_az = real_az*180./math.pi*3600.
        real_el = real_el*180./math.pi*3600.
        track = self.move_azel(real_az, real_el, dcos, hosei, off_az=off_x,off_el=off_y,az_max_rate=az_max_rate, el_max_rate=el_max_rate, off_coord=off_coord)
        return track
Ejemplo n.º 8
0
tab['pmd'] = np.radians(tab['pmd'] / 3600.0) / 100.0

utc = slalib.sla_caldj(2010, 1, 1)[0]
tt = slalib.sla_dtt(utc) / 86400.0 + utc
dut = 1.4823561643834426  # from TPM.

aob = np.zeros((len(tab['raj2']), ), dtype=np.float64)
zob = aob.copy()
hob = aob.copy()
dob = aob.copy()
rob = aob.copy()
lon = np.radians(-111.598333)
lat = np.radians(31.956389)

for j, i in enumerate(tab):
    r1, d1 = slalib.sla_map(i['raj2'], i['decj2'], i['pma'], i['pmd'], i['px'],
                            0.0, 2000.0, tt)
    aob[j], zob[j], hob[j], dob[j], rob[j] = \
        slalib.sla_aop(r1, d1, utc, dut, lon, lat, 2093.093, 0.0, 0.0,
                       273.15, 1013.25, 0.0, 0.550, 0.0065)

aob = np.degrees(aob)
zob = np.degrees(zob)
hob = np.degrees(hob)
dob = np.degrees(dob)
rob = np.degrees(rob)

with open("slalib_hip_aop.txt", "w") as f:
    f.write("# Az, Zd, HA, Dec, RA in degrees.\n")
    s = "%14.9f %14.9f %14.9f %14.9f %14.9f\n"
    for i in range(len(aob)):
        f.write(s % (aob[i], zob[i], hob[i], dob[i], rob[i]))
Ejemplo n.º 9
0
    def _convert_coordinates(self, lat, long, ra_ref, dec_ref, date, time):
        """ Accurate conversion from equatorial coordiantes (RA, DEC) to Spherical (TH,PH) coordinates.
        The code uses the pyslalib library for a number of functions from the SLALIB Fortran library converted to Python.
        :param lat: latitude (decimal degrees)
        :param long: longitude (decimal degrees)
        :param ra_ref: RA(J2000) (decimal hours)
        :param dec_ref: Dec(J2000) (decimal degrees)
        :param date: vector date [iyear, imonth, iday]
        :param time: vector time [ihour imin isec]
        :return: [theta, pi]: Theta and Phi angles (degrees)
        """

        const_2pi = 2.0 * math.pi
        d2r = math.pi / 180
        r2d = 180 / math.pi

        # Conversion factor seconds of time to days
        const_st2day = 1.0/(24 * 3600)

        # Specify latitude and longitude (radians)
        lat *= d2r
        long *= d2r

        # Specify catalogued position (J2000 coordinates, radians)
        ra_ref = ra_ref * 15 * d2r
        dec_ref *= d2r

        # Specify current time and date %
        isec   = time[2]
        imin   = time[1]
        ihour  = time[0]
        iday   = date[2]
        imonth = date[1]
        iyear  = date[0]

        # Convert current UTC to Modified Julian date
        djm, j1   = slalib.sla_cldj(iyear, imonth, iday)
        fdutc, j2 = slalib.sla_dtf2d(ihour, imin, isec)
        djutc     = djm + fdutc

        # Calculate Greenwich Mean Sidereal Time from MJD
        gmst1 = slalib.sla_gmst(djutc)

        # Add longitude and Equation of Equinoxes for Local Apparent ST
        djtt = djutc + slalib.sla_dtt(djutc)*const_st2day
        last = gmst1 + long + slalib.sla_eqeqx(djtt)
        if last < 0.0:
            last += const_2pi

        # Convert catalogued position to apparent RA, Dec at current date
        pr = 0.e0
        pd = 0.e0
        px = 0.e0
        rv = 0.e0
        eq = 2000.0e0
        [raobs, decobs] = slalib.sla_map(ra_ref, dec_ref, pr, pd, px, rv, eq, djutc)

        # Get Hour Angle and Declination
        ha = last - raobs
        if ha < -math.pi:
            ha += const_2pi

        if ha > math.pi:
            ha -= const_2pi
        dec = decobs

        # Convert to Azimuth and Elevation
        azim, elev = slalib.sla_de2h(ha, dec, lat)

        theta = (90 - elev * r2d).real
        phi = (azim * r2d).real

        return [theta, phi]
    def move_radec(self, gx, gy, gpx, gpy, code_mode, temp, pressure, humid, lamda, dcos, hosei = 'hosei_230.txt', off_coord = "HORIZONTAL", off_x = 0, off_y = 0, az_max_rate=16000, el_max_rate=12000):
        ##debug
        #print('moving!!!, {gx}, {gy}, {code_mode}'.format(**locals()))
        ##debug-end
        #if off_x != 0 or off_y != 0: #for test
        self.set_offset(off_coord, off_x, off_y)
        self.off_eq = gx*180./math.pi#self.off_list["off_az"]
        self.off_ga = gy*180./math.pi#self.off_list["off_l"]
        self.ra_off_ra = self.off_list["off_ra"]#
        self.ra_off_dec = self.off_list["off_dec"]#
        #lamda not equals lambda
        # Calculate current MJD
        tv = time.time()
        mjd = tv/24./3600. + 40587.0 # 40587.0 = MJD0
        #tv = time.time()
        #tv_sec = int(tv)
        #tv_usec = tv - tv_sec
        #mjd = (tv_sec + tv_usec/1000000.)/24./3600. + 40587.0 # 40587.0 = MJD0
        if dcos == 0:
            gy = gy + float(self.off_list["off_dec"])*math.pi/180/3600.
            gx = gx + float(self.off_list["off_ra"])*math.pi/180/3600.
        else:
            gy = gy + float(self.off_list["off_dec"])*math.pi/180/3600.
            gx = gx + float(self.off_list["off_ra"])*math.pi/180/3600./math.cos(gy)

        tai_utc = 36.0 # tai_utc=TAI-UTC  2015 July from ftp://maia.usno.navy.mil/ser7/tai-utc.dat
        
        # lamda is wavelength(not lambda)
        if code_mode == "b1950":
            ret = slalib.sla_fk425(gx, gy, gpx, gpy, 0, 0)
            gaJ2000 = ret[0]
            gdJ2000 = ret[1]
            gpaJ2000 = ret[2]
            gpdJ2000 = ret[3]
        else: # code mode == "J2000"
            gaJ2000 = gx # for check
            gdJ2000 = gy # for check
            gpaJ2000 = gpx # for check
            gpdJ2000 = gpy # for check
        
        ret = slalib.sla_map(gaJ2000, gdJ2000, gpaJ2000, gpdJ2000, 0, 0, 2000, mjd + (tai_utc + 32.184)/(24.*3600.))
        ret = list(ret)
        """
        ret[0] = apparent_ra
        ret[1] = apparent_dec
        """
        self.ra_real_ra = ret[0]*3600.
        self.ra_real_dec = ret[1]*3600.
        #if dcos == 0:
            #print(type(ret), ret[1], self.off_list['off_dec'])
            #ret[1] = ret[1]
            #ret[0] = ret[0]
        #else:
            #ret[1] = ret[1]
            #ret[0] = ret[0]
        ret = slalib.sla_aop(ret[0], ret[1], mjd, self.dut1, self.longitude, self.latitude, self.height, 0, 0, temp, pressure, humid, lamda, tlr=0.0065)
        """
        ret[0] = azimath(radian, N=0, E=90)
        ret[1] = zenith(radian)
        """
        #f = open('radec.txt','a')
        #while self.cc < 1:
        #f.write('gx : ' + 'gy : ' + 'off_ra : ' + 'off_dec : ' + 'real_ra : ' + 'real_dec' + '\n')
        #self.cc += 1
        #self.ra_real_ra = self.ra_real_ra - 83.80613*3600.
        #f.write(str(self.off_eq) +' '+ str(self.off_ga) +' '+ str(self.ra_off_ra) +' '+ str(self.ra_off_dec) +' '+ str(self.ra_real_ra) +' '+ str(self.ra_real_dec) + '\n')
        #f.write('bug_eq : ' + str(self.off_eq) +'\n')
        #f.write('bug_ga : ' + str(self.off_ga) +'\n')
        #f.write('off_ra : ' + str(self.ra_off_ra) +'\n')
        #f.write('off_dec : ' + str(self.ra_off_dec) +'\n')
        #f.write('real_ra : ' + str(self.ra_real_ra) +'\n')
        #f.write('real_dec : ' + str(self.ra_real_dec) +'\n')
        #f.close()
        #From zenith angle to elevation 
        real_az = ret[0]
        real_el = math.pi/2. - ret[1]
        real_az = real_az*180./math.pi*3600.
        real_el = real_el*180./math.pi*3600.
        track = self.move_azel(real_az, real_el, dcos, hosei, off_az=off_x,off_el=off_y,az_max_rate=az_max_rate, el_max_rate=el_max_rate, off_coord=off_coord)
        return track