Beispiel #1
0
  def test_baryvel(self):
    dat = numpy.loadtxt("testPro/baryvel.test")
    err = 0
    for i in range(10000):
      jd = 2.4e6 + float(i)*10.37681
      a, b =  baryvel(jd, 0)
      delta = numpy.abs(dat[i,::] - numpy.concatenate((a,b)))
      if max(delta) > 1e-6:
        err += 1
        print "Baryvel error:", dat[i,::], a, b
        print "max: ", max(delta)
    self.assertEqual(err, 0)

    i = 0
    dat = numpy.loadtxt("testPro/baryvel2.test")
    for j in range(101):
      jd = 2.4e6 + float(j)*1000.37681
      for k in range(11):
        deq = jd + float(k-5) * 10000.0
        a, b =  baryvel(jd, deq)
        delta = numpy.abs(dat[i,0:6] - numpy.concatenate((a,b)))
        
        if abs(jd - dat[i,6]) > 1e-6:
          print "JD problem: ", jd, dat[i,6], i, k
        if abs(deq - dat[i,7]) > 1e-6:
          print "deq problem: ", deq, dat[i,7], i, k
        
        if max(delta) > 1e-6:
          err += 1
          print "Baryvel error:", dat[i,::], a, b
          print "max: ", max(delta)
          print "i, k: ", i, k
        i += 1
Beispiel #2
0
def helcorr(obs_long, obs_lat, obs_alt, ra2000, dec2000, jd, debug=False):

#calculates heliocentric Julian date, baricentric and heliocentric radial
#velocity corrections from:
#
#INPUT:
#<OBSLON> Longitude of observatory (degrees, western direction is positive)
#<OBSLAT> Latitude of observatory (degrees)
#<OBSALT> Altitude of observatory (meters)
#<RA2000> Right ascension of object for epoch 2000.0 (hours)
#<DE2000> Declination of object for epoch 2000.0 (degrees)
#<JD> Julian date for the middle of exposure
#[DEBUG=] set keyword to get additional results for debugging
#
#OUTPUT:
#<CORRECTION> baricentric correction - correction for rotation of earth,
#   rotation of earth center about the eart-moon barycenter, eart-moon
#   barycenter about the center of the Sun.
#<HJD> Heliocentric Julian date for middle of exposure
#
#Algorithms used are taken from the IRAF task noao.astutils.rvcorrect
#and some procedures of the IDL Astrolib are used as well.
#Accuracy is about 0.5 seconds in time and about 1 m/s in velocity.
#
#History:
#written by Peter Mittermayer, Nov 8,2003
#2005-January-13   Kudryavtsev   Made more accurate calculation of the sideral time.
#                                Conformity with MIDAS compute/barycorr is checked.
#2005-June-20      Kochukhov Included precession of RA2000 and DEC2000 to current epoch

   
   #covert JD to Gregorian calendar date
   xjd = array(2400000.).astype(float) + jd
   year,month,day,ut=daycnv(xjd)
   
   #current epoch
   epoch = year + month / 12. + day / 365.
   
   #precess ra2000 and dec2000 to current epoch
   ra,dec=precess(ra2000*15., dec2000, 2000.0, epoch)
   #calculate heliocentric julian date
   hjd = array(helio_jd(jd, ra, dec)).astype(float)
   
   #DIURNAL VELOCITY (see IRAF task noao.astutil.rvcorrect)
   #convert geodetic latitude into geocentric latitude to correct
   #for rotation of earth
   dlat = -(11. * 60. + 32.743) * sin(2 * obs_lat / _radeg) + 1.1633 * sin(4 * obs_lat / _radeg) - 0.0026 * sin(6 * obs_lat / _radeg)
   lat = obs_lat + dlat / 3600
   
   #calculate distance of observer from earth center
   r = 6378160.0 * (0.998327073 + 0.001676438 * cos(2 * lat / _radeg) - 0.00000351 * cos(4 * lat / _radeg) + 0.000000008 * cos(6 * lat / _radeg)) + obs_alt
   
   #calculate rotational velocity (perpendicular to the radius vector) in km/s
   #23.934469591229 is the siderial day in hours for 1986
   v = 2. * pi * (r / 1000.) / (23.934469591229 * 3600.)
   
   #calculating local mean siderial time (see astronomical almanach)
   tu = (jd - 51545.0) / 36525
   gmst = 6.697374558 + ut + (236.555367908 * (jd - 51545.0) + 0.093104 * tu ** 2 - 6.2e-6 * tu ** 3) / 3600
   lmst = (gmst - obs_long / 15) % 24
   
   #projection of rotational velocity along the line of sight
   vdiurnal = v * cos(lat / _radeg) * cos(dec / _radeg) * sin((ra - lmst * 15) / _radeg)
   
   #BARICENTRIC and HELIOCENTRIC VELOCITIES
   vh,vb=baryvel(xjd, 0)
   
   #project to line of sight
   vbar = vb[0] * cos(dec / _radeg) * cos(ra / _radeg) + vb[1] * cos(dec / _radeg) * sin(ra / _radeg) + vb[2] * sin(dec / _radeg)
   vhel = vh[0] * cos(dec / _radeg) * cos(ra / _radeg) + vh[1] * cos(dec / _radeg) * sin(ra / _radeg) + vh[2] * sin(dec / _radeg)
   
   corr = (vdiurnal + vbar) #using baricentric velocity for correction
   
   if debug:   
      print ''
      print '----- HELCORR.PRO - DEBUG INFO - START ----'
      print '(obs_long,obs_lat,obs_alt) Observatory coordinates [deg,m]: ', obs_long, obs_lat, obs_alt
      print '(ra,dec) Object coordinates (for epoch 2000.0) [deg]: ', ra, dec
      print '(ut) Universal time (middle of exposure) [hrs]: ', ut#, format='(A,F20.12)'
      print '(jd) Julian date (middle of exposure) (JD-2400000): ', jd#, format='(A,F20.12)'
      print '(hjd) Heliocentric Julian date (middle of exposure) (HJD-2400000): ', hjd#, format='(A,F20.12)'
      print '(gmst) Greenwich mean siderial time [hrs]: ', gmst % 24
      print '(lmst) Local mean siderial time [hrs]: ', lmst
      print '(dlat) Latitude correction [deg]: ', dlat
      print '(lat) Geocentric latitude of observer [deg]: ', lat
      print '(r) Distance of observer from center of earth [m]: ', r
      print '(v) Rotational velocity of earth at the position of the observer [km/s]: ', v
      print '(vdiurnal) Projected earth rotation and earth-moon revolution [km/s]: ', vdiurnal
      print '(vbar) Baricentric velocity [km/s]: ', vbar
      print '(vhel) Heliocentric velocity [km/s]: ', vhel
      print '(corr) Vdiurnal+vbar [km/s]: ', corr#, format='(A,F12.9)'
      print '----- HELCORR.PRO - DEBUG INFO - END -----'
      print ''
   
   
   return (corr, hjd)
Beispiel #3
0
def ugdoppler(ra, dec, julday, nlat=None, wlong=None, light=False, obspos_deg=None,lst_mean=None):
    """

    NAME: ugdoppler

    PURPOSE:
       computes the projected velocity of the telescope wrt
       four coordinate systems: geo, helio, bary, lsr.
       negative velocities mean approach

       the standard LSR is defined as follows: the sun moves at 20.0 km/s
       toward ra=18.0h, dec=30.0 deg in 1900 epoch coords

    CALLING SEQUENCE:
       vel = ugdoppler( ra, dec, julday, $
       nlat=nlat, wlong=wlong, $
       path=path, light=light, $
       obspos_deg=obspos_deg, lst_mean=lst_mean)

    INPUTS: fully vectorized...ALL THREE INPUTS MUST HAVE SAME DIMENSIONS!!
       ra[n] - the source ra in DECIMAL HOURS, equinox 2000
       dec[n] - the source dec in decimal degrees, equinox 2000
       julday[n] - the full (unmodified) julian day JD. MJD = JD - 2400000.5

    KEYWORD PARAMETERS
       nlat, wlong - specify nlat and wlong of obs in
       degrees.  if you set one, you must set the other
       also. For Leuschner, nlat=37.8732, wlong=+122.2573

       light - returns the velocity as a fraction of c

    OUTPUTS:
       program returns the velocity in km/s, or as a faction of c if
       the keyword /light is specified. the result is a 4-element
       vector whose elements are [geo, helio, bary, lsr]. quick
       comparison with phil's C doppler routines gives agreement to
       better than 100 m/s one arbitrary case.

    OPTIONAL OUTPUTS:
       obspos_deg: observatory [lat, wlong] in degrees that was used
       in the calculation. This is set by either (nlat and wlong) or
       path default is Arecibo.

       lst_mean: the lst at the observatory for the specified JD

    REVISION HISTORY: carlh 29oct04.
       from idoppler_ch changed calculation epoch to 2000
       19nov04: correct bad earth spin calculation
       7 jun 2005: vectorize to make faster for quantity calculations.
       20 Mar 2007: CH updated documentation for chdoppler and
       created this version, ugdoppler, which uses the locally-derived lst
       (from ilst.pro).
       5apr2011: updated documentation, tested with tst.ugdopp.idl and
       tst1.ugdopp.ilprc
    """

    dtor = np.pi/180.

    #------------------ORBITAL SECTION-------------------------
    try:
        nin = len(ra)
    except:
        ra, dec, julday = np.array([ra]), np.array([dec]), np.array([julday])
        nin = 1

    #GET THE COMPONENTS OF RA AND DEC, 2000u EPOCH
    rasource=ra*15.*dtor
    decsource=dec*dtor

    xxsource = np.zeros((3, nin))
    xxsource[0, :] = np.cos(decsource) * np.cos(rasource)
    xxsource[1, :] = np.cos(decsource) * np.sin(rasource)
    xxsource[2, :] = np.sin(decsource)
    pvorbit_helio= np.zeros( nin)
    pvorbit_bary= np.zeros( nin)
    pvlsr= np.zeros( nin)


    # GET THE EARTH VELOCITY WRT THE SUN CENTER
    # THEN MULTIPLY BY SOURCE TO GET PROJECTED VELOCITY
    # OF EARTH CENTER WRT SUN TO THE SOURCE
    for NR in range(nin):
        vvorbit, velb = baryvel(julday[NR], 2000.)
        pvorbit_helio[NR]= np.sum(vvorbit* xxsource[:,NR])
        pvorbit_bary[NR]= np.sum(velb* xxsource[:,NR])


    #-----------------------LSR SECTION-------------------------
    # THE STANDARD LSR IS DEFINED AS FOLLOWS: THE SUN MOVES AT 20.0 KM/S
    # TOWARD RA=18.0H, DEC=30.0 DEG IN 1900 EPOCH COORDS
    # using PRECESS, this works out to ra=18.063955 dec=30.004661 in 2000 coords.
    ralsr_rad= 2.*np.pi*18./24.
    declsr_rad= dtor*30.
    ralsr_rad, declsr_rad = precess(ralsr_rad, declsr_rad, 1900., 2000.,radian=True)

    #FIND THE COMPONENTS OF THE VELOCITY OF THE SUN WRT THE LSR FRAME
    xxlsr = np.zeros(3)
    xxlsr[0] = np.cos(declsr_rad) * np.cos(np.pi+ralsr_rad) #additional pi because Python and IDL just...
    xxlsr[1] = np.cos(declsr_rad) * np.sin(ralsr_rad)
    xxlsr[2] = np.sin(declsr_rad)
    vvlsr = 20.*xxlsr

    #PROJECTED VELOCITY OF THE SUN WRT LSR TO THE SOURCE
    for NR in range(nin): pvlsr[NR]=np.sum(vvlsr*xxsource[:, NR])


    #---------------------EARTH SPIN SECTION------------------------
    #NOTE: THE ORIGINAL VERSION WAS FLAWED. WE comment out those bad statements...

    # LEUSCHNER LAB COORDINATES...
    northlat = 37.91934
    westlong = 122.15385
    obspos_deg= [ northlat, westlong]


    # COORDS FROM NLAT, WLONG INPUT...
    if nlat and wlong:
        obspos_deg= [nlat, wlong]

    # GET THE LATITUDE...
    lat= obspos_deg[0]

    # GET THE LST
    lst_mean= rlab.getLST(juldate=julday, lon=-obspos_deg[1])

    # MODIFIED EARTH SPIN FROM GREEN PAGE 270
    pvspin= -0.465* np.cos(dtor* lat) * np.cos( decsource) * np.sin(( lst_mean- ra)* 15.*dtor)


    #---------------------NOW PUT IT ALL TOGETHER------------------

    vtotal= np.zeros((4, nin))
    vtotal[ 0,:]= -pvspin
    vtotal[ 1,:]= -pvspin- pvorbit_helio
    vtotal[ 2,:]= -pvspin- pvorbit_bary
    vtotal[ 3,:]= -pvspin- pvorbit_bary- pvlsr

    if light: vtotal=vtotal/(2.99792458e5)
    return vtotal