コード例 #1
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)
コード例 #2
0
ファイル: aard.py プロジェクト: michaeljtbrooks/astrorobot
def checkAltAz ( rawAltAz ):
    """Check and convert a pair of horizon py.

      [ rawAltAz is a string ->
          if rawAltAz is a valid set of horizon py ->
            return those py as a sidereal.AltAz instance
          else ->
            sys.stderr  +:=  error message
            stop execution ]
    """
    #-- 1 --
    # [ if rawAltAz 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 ( rawAltAz )
    if  m is None:
        usage ( "Equatorial py must be separated by "
                "'+' or '-'." )
    #-- 2 --
    # [ rawAz  :=  rawAltAz up to the match described by m
    #   sign  :=  characters matched by m
    #   rawAlt  :=  rawAltAz past the match described by m ]
    rawAz  =  rawAltAz[:m.start()]
    sign  =  m.group()
    rawAlt  =  rawAltAz[m.end():]

    #-- 3 --
    # [ if rawAz is a valid angle ->
    #     az  :=  that angle as radians
    #   else ->
    #     sys.stderr  +:=  error message
    #     stop execution ]
    try:
        az  =  sidereal.parseAngle ( rawAz )
    except SyntaxError, detail:
        usage ( "Azimuth '%s' should have the form "
                "'NNNd[NNm[NN.NNNs]]'." % rawAz )
コード例 #3
0
ファイル: aard.py プロジェクト: fjankowsk/ionFR
def checkAltAz(rawAltAz):
    """Check and convert a pair of horizon coordinates.

      [ rawAltAz is a string ->
          if rawAltAz is a valid set of horizon coordinates ->
            return those coordinates as a sidereal.AltAz instance
          else ->
            sys.stderr  +:=  error message
            stop execution ]
    """
    #-- 1 --
    # [ if rawAltAz 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(rawAltAz)
    if m is None:
        usage("Equatorial coordinates must be separated by " "'+' or '-'.")
    #-- 2 --
    # [ rawAz  :=  rawAltAz up to the match described by m
    #   sign  :=  characters matched by m
    #   rawAlt  :=  rawAltAz past the match described by m ]
    rawAz = rawAltAz[:m.start()]
    sign = m.group()
    rawAlt = rawAltAz[m.end():]

    #-- 3 --
    # [ if rawAz is a valid angle ->
    #     az  :=  that angle as radians
    #   else ->
    #     sys.stderr  +:=  error message
    #     stop execution ]
    try:
        az = sidereal.parseAngle(rawAz)
    except SyntaxError, detail:
        usage("Azimuth '%s' should have the form "
              "'NNNd[NNm[NN.NNNs]]'." % rawAz)
コード例 #4
0
ファイル: aard.py プロジェクト: michaeljtbrooks/astrorobot
    #     sys.stderr  +:=  error message
    #     stop execution ]
    try:
        az  =  sidereal.parseAngle ( rawAz )
    except SyntaxError, detail:
        usage ( "Azimuth '%s' should have the form "
                "'NNNd[NNm[NN.NNNs]]'." % rawAz )

    #-- 4 --
    # [ if rawAlt is a valid angle ->
    #     alt  :=  that angle as radians
    #   else ->
    #     sys.stderr  +:=  error message
    #     stop execution ]
    try:
        absAlt  =  sidereal.parseAngle ( rawAlt )
    except SyntaxError, detail:
        usage ( "Altitude '%s' should have the form "
                "'NNd[NNm[NN.NNNs]]'." % rawAlt )

    #-- 5 --
    if  sign == '-':   alt  =  - absAlt
    else:              alt  =  absAlt

    #-- 6 --
    return  sidereal.AltAz ( alt, az )
#================================================================
# Epilogue
#----------------------------------------------------------------

if  __name__ == "__main__":
コード例 #5
0
ファイル: rdaa.py プロジェクト: michaeljtbrooks/astrorobot
    #   else ->
    #     sys.stderr  +:=  error message
    #     stop execution ]
    try:
        raHours  =  sidereal.parseHours ( rawRA )
        ra  =  sidereal.hoursToRadians ( raHours )
    except SyntaxError, 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, 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 )
#================================================================
# Epilogue
#----------------------------------------------------------------

if  __name__ == "__main__":
    main()
コード例 #6
0
ファイル: aard.py プロジェクト: fjankowsk/ionFR
    #     sys.stderr  +:=  error message
    #     stop execution ]
    try:
        az = sidereal.parseAngle(rawAz)
    except SyntaxError, detail:
        usage("Azimuth '%s' should have the form "
              "'NNNd[NNm[NN.NNNs]]'." % rawAz)

    #-- 4 --
    # [ if rawAlt is a valid angle ->
    #     alt  :=  that angle as radians
    #   else ->
    #     sys.stderr  +:=  error message
    #     stop execution ]
    try:
        absAlt = sidereal.parseAngle(rawAlt)
    except SyntaxError, detail:
        usage("Altitude '%s' should have the form "
              "'NNd[NNm[NN.NNNs]]'." % rawAlt)

    #-- 5 --
    if sign == '-': alt = -absAlt
    else: alt = absAlt

    #-- 6 --
    return sidereal.AltAz(alt, az)


#================================================================
# Epilogue
#----------------------------------------------------------------