示例#1
0
def get_lst(JD,e_long):
    MJD = convert_JD2MJD(JD)
    nb = len_all(JD)
    dT = sla.sla_dt(2000)
    if nb>1:
        lst = np.zeros(nb)
        for i in range(0,nb):
            gmst = sla.sla_gmst(MJD[i]) # [radian]
            MJD_eoe = MJD[i] + dT
            equation_of_equinoxes = sla.sla_eqeqx(MJD_eoe) # [radian]
            lst[i] = gmst + e_long + equation_of_equinoxes # [radian]
    if nb==1:
        MJD_eoe = MJD + dT
        equation_of_equinoxes = sla.sla_eqeqx(MJD_eoe)
        gmst = sla.sla_gmst(MJD)
        lst = gmst + e_long + equation_of_equinoxes
    lst = lst / pi * 180. / 15. # [hour]
    lst = lst % 24 # our within 0~24
    return np.array(lst) # [hour]
示例#2
0
def get_lst(JD, e_long):
    MJD = convert_JD2MJD(JD)
    nb = len_all(JD)
    dT = sla.sla_dt(2000)
    if nb > 1:
        lst = np.zeros(nb)
        for i in range(0, nb):
            gmst = sla.sla_gmst(MJD[i])  # [radian]
            MJD_eoe = MJD[i] + dT
            equation_of_equinoxes = sla.sla_eqeqx(MJD_eoe)  # [radian]
            lst[i] = gmst + e_long + equation_of_equinoxes  # [radian]
    if nb == 1:
        MJD_eoe = MJD + dT
        equation_of_equinoxes = sla.sla_eqeqx(MJD_eoe)
        gmst = sla.sla_gmst(MJD)
        lst = gmst + e_long + equation_of_equinoxes
    lst = lst / pi * 180. / 15.  # [hour]
    lst = lst % 24  # our within 0~24
    return np.array(lst)  # [hour]
示例#3
0
    def hlst(self, mjd):
        global tellat, tellong, telelev

        # test 0.2 sec UT1 correction
        # dut1 = (0.2 /3600.0) * math.pi/12.0
        dut1 = 0.0

        last = s.sla_gmst(mjd) - tellong + s.sla_eqeqx(mjd) + dut1

        # lmst = s.sla_gmst(mjd) - tellong
        if last < 0.0: last = last + 2.0 * math.pi
        return last
示例#4
0
def calc_apparent_sidereal_time(date):
    '''Return the apparent sidereal time (an Angle) for a given date.'''

    # Convert Gregorian to UT MJD
    mjd_utc = gregorian_to_ut_mjd(date)
    mjd_tdb = date_to_tdb(date)

    # Convert UT MJD to Greenwich mean sidereal time (in radians)
    gmst = ut_mjd_to_gmst(mjd_utc)

    # Find the apparent sidereal time (GAST)
    # GAST = GMST + Eqn. of equinoxes
    gast_in_rads = gmst.in_radians() + sla.sla_eqeqx(mjd_tdb)

    return Angle(radians=gast_in_rads)
示例#5
0
 def compute_lst(self):
     """ Compute LST for observation """
     if self.header[b'telescope_id'] == 6:
         self.coords = gbt_coords
     elif self.header[b'telescope_id'] == 4:
         self.coords = parkes_coords
     else:
         raise RuntimeError("Currently only Parkes and GBT supported")
     if HAS_SLALIB:
         # dut1 = (0.2 /3600.0) * np.pi/12.0
         dut1 = 0.0
         mjd = self.header[b'tstart']
         tellong = np.deg2rad(self.coords[1])
         last = s.sla_gmst(mjd) - tellong + s.sla_eqeqx(mjd) + dut1
         # lmst = s.sla_gmst(mjd) - tellong
         if last < 0.0: last = last + 2.0 * np.pi
         return last
     else:
         raise RuntimeError("This method requires pySLALIB")
示例#6
0
def findNightDuration(mjd):
    ctio_lat = -30.16527778
    ctio_lon = -70.8125
    ctio_height = 2215.

    degToRad = 2. * np.pi / 360.
    lat = ctio_lat * degToRad
    lon = ctio_lon * degToRad
    height = ctio_height

    imjd = np.int(mjd)
    start_mjd = imjd - 6. / 24.
    # before sunset at CTIO

    sunset = ""
    sunrise = ""
    # check every minute
    for i in np.arange(0, 1., 1. / (24. * 60)):
        mjd = start_mjd + i
        gmst = slalib.sla_gmst(mjd)
        eqEquinoxes = slalib.sla_eqeqx(mjd)
        lst = gmst + eqEquinoxes + lon

        sunra, sundec, diam = slalib.sla_rdplan(mjd, 0, lon, lat)
        sunha = lst - sunra
        sinAltRad = np.sin(lat)*np.sin(sundec) + \
            np.cos(lat)*np.cos(sundec)*np.cos(sunha)
        altRad = np.arcsin(sinAltRad)
        zenithDist = 90 * degToRad - altRad

        twilight = 100. * 2 * np.pi / 360.
        if zenithDist <= twilight:
            bright = True
        else:
            bright = False
        if sunset == "" and bright == False:
            sunset = mjd
        if sunset != "" and sunrise == "" and bright == True:
            sunrise = mjd
    duration = sunrise - sunset
    return duration, sunset, sunrise
示例#7
0
def datetime2st(d, obsvr_long=0.0):
    """Converts the passed datetime object in UTC to a Sidereal Time.
    If the site longitude [obsvr_long] (East +ve; radians) is passed, then
    the returned `stl` will be the Local Apparent Sidereal Time.
    If not passed (or zero), then the Greenwich Apparent Sidereal Time
    will be returned (Greenwich Mean Sidereal Time (GMST) plus the equation
    of the equinoxes.
    `stl`, the sidereal time, is returned in radians, normalized to the
    range 0...2*PI
    """

    # Compute MJD_UTC and MJD_TT
    mjd_utc = datetime2mjd_utc(d)
    mjd_tt = mjd_utc2mjd_tt(mjd_utc)
    # Determine UT1-UTC and hence MJD_UT1
    dut = ut1_minus_utc(mjd_utc)
    mjd_ut1 = mjd_utc + (dut / 86400.0)
    # Greenwich Mean Sidereal Time (GMST), just a function of UT1 ("Earth Rotation Angle")
    gmst = S.sla_gmst(mjd_ut1)
    # Compute Local Apparent Sidereal Time
    stl = gmst + obsvr_long + S.sla_eqeqx(mjd_tt)
    stl = S.sla_dranrm(stl)

    return stl
示例#8
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]
示例#9
0
 def mjdToLST(self, mjd, eastLongitude):
     if self.verbose: print "\t MJD to LST"
     gmst = slalib.sla_gmst(mjd)
     eqEquinoxes = slalib.sla_eqeqx(mjd)
     lst = gmst + eqEquinoxes + eastLongitude
     return lst