コード例 #1
0
ファイル: at.py プロジェクト: photometr/alttime
def CalcAlt(conf, eqcoords, timebins):
    Altitudes = []
    hmsSystem = sidereal.MixedUnits((60, 60))
    RA, DEC = eqcoords
    if conf.tabobdec:
        RA = float(RA)
        DEC = float(DEC)
    else:
        RA = ToSingleValue(RA) * 15  #RA in degrees
        DEC = ToSingleValue(DEC)
    calc_date = datetime.strptime(date, "%Y-%m-%d %H:%M:%S")
    year = calc_date.year
    month = calc_date.month
    day = calc_date.day
    for time in timebins:
        hour, minute, second = hmsSystem.singleToMix(time)
        curtime = datetime(year, month, day, hour, minute, int(second))
        Gst = sidereal.SiderealTime.fromDatetime(curtime)  #FIXME
        Lst = Gst.lst(math.radians(conf.longitude))
        Lst = Lst.hours * 15  #local siderial time - in degrees
        Hourangle = red_to_pos(Lst - RA)
        RADec = sidereal.RADec(math.radians(RA), math.radians(DEC))
        AltAz = RADec.altAz(math.radians(Hourangle * 15.0),
                            math.radians(conf.latitude))
        Altitudes.append(math.degrees(AltAz.alt))
    return Altitudes
コード例 #2
0
ファイル: rdalaz.py プロジェクト: fjankowsk/ionFR
def checkRADec(rawRADec):
    """Check and convert a pair of equatorial coordinates.

      [ rawRADec is a string ->
          if rawRADec is a valid set of equatorial coordinates ->
            return those coordinates as a sidereal.RADec instance
          else ->
            sys.stderr  +:=  error message
            stop execution ]
    """
    #-- 1 --
    # [ if rawRADec contains either a '+' or a '-' ->
    #     m  :=  a re.match instance describing the first matching
    #            character
    #   else ->
    #     sys.stderr  +:=  error message
    #     stop execution ]
    m = SIGN_PAT.search(rawRADec)
    if m is None:
        usage("Equatorial coordinates must be separated by " "'+' or '-'.")
    #-- 2 --
    # [ rawRA  :=  rawRADec up to the match described by m
    #   sign  :=  characters matched by m
    #   rawDec  :=  rawRADec past the match described by m ]
    rawRA = rawRADec[:m.start()]
    sign = m.group()
    rawDec = rawRADec[m.end():]
    #-- 3 --
    # [ if rawRA is a valid hours expression ->
    #     ra  :=  rawRA as radians
    #   else ->
    #     sys.stderr  +:=  error message
    #     stop execution ]
    try:
        raHours = sidereal.parseHours(rawRA)
        ra = sidereal.hoursToRadians(raHours)
    except SyntaxError as detail:
        usage("Right ascension '%s' should have the form "
              "'NNh[NNm[NN.NNNs]]'." % rawRA)
    #-- 4 --
    # [ if rawDec is a valid angle expression ->
    #     absDec  :=  that angle in radians
    #     sys.stderr  +:=  error message
    #     stop execution ]
    try:
        absDec = sidereal.parseAngle(rawDec)
    except SyntaxError as detail:
        usage("Right ascension '%s' should have the form "
              "'NNd[NNm[NN.NNNs]]'." % rawDec)
    #-- 5 --
    if sign == '-': dec = -absDec
    else: dec = absDec

    #-- 6 --
    return sidereal.RADec(ra, dec)
コード例 #3
0
ファイル: coordinates.py プロジェクト: NIDES-SD71/PiTelescope
    def getAzAlt(self, Ra, Dec):

        RaDec = sidereal.RADec(Ra.r, Dec.r)

        AltAz = RaDec.altAz(RaDec.hourAngle(self.sysTime, self.Lon.r),
                            self.Lat.r)

        Az = angles.Angle(r=AltAz.az)
        Alt = angles.Angle(r=AltAz.alt)

        return [Az, Alt]
コード例 #4
0
 def CalcAlt(self, ev):
     if self.conf.is_utc:
         curtime = datetime.now()
     else:
         curtime = datetime.utcnow()
     Gst = sidereal.SiderealTime.fromDatetime(curtime)
     Lst = Gst.lst(math.radians(self.conf.longitude))
     Lst = Lst.hours * 15  #local siderial time - in degrees
     hourangle = red_to_pos(Lst - ev.RA)
     RADec = sidereal.RADec(math.radians(ev.RA), math.radians(ev.DEC))
     AltAz = RADec.altAz(math.radians(hourangle * 15.0),
                         math.radians(self.conf.latitude))
     return math.degrees(AltAz.alt)
コード例 #5
0
plt.xlim([binned.index.min(), binned.index.max()])
plt.grid(axis='x')
ax1.xaxis.set_major_formatter(plt.NullFormatter())
ax1.fill_between(binned.index, 0, binned.counts, alpha=.3, color='blue')
ax1.spines["top"].set_visible(False)
ax1.spines["right"].set_visible(False)

# Plot radiant altitude
if show_radiant_altitude:
    JDs = map(utils.toJD, rad_pos.keys())
    pos = np.deg2rad(rad_pos.values()).tolist()
    retrieve = interpolate.interp1d(JDs, pos, axis=0)
    ax1b = ax1.twinx()
    for utc in utils.perdelta(min(dt), max(dt), timedelta(minutes=60)):
        RA, Dec = retrieve(utils.toJD(utc))
        equ_coord = sidereal.RADec(RA, Dec)
        h = equ_coord.hourAngle(utc, lon)
        horiz_coord = equ_coord.altAz(h, lat)
        ax1b.set_ylabel('Radiant elevation [$\degree$]',
                        size=14,
                        style='italic',
                        color='green')
        ax1b.scatter(utc,
                     np.rad2deg(horiz_coord.alt),
                     marker='.',
                     color='green')
ax1.autoscale(True, axis='x', tight=True)

ax2 = plt.subplot(2, 1, 2)
ax2.spines["top"].set_visible(False)
ax2.spines["right"].set_visible(False)