makeUT1.frink

Download or view makeUT1.frink in plain text format


/** This program reads UT1-UTC and UT2-UT1 data from IERS Bulletin A (which is
    not really in a machine-friendly format) and turns it into usable equations
    for predicting these values in the short term.  This file then generates
    the text for UT1.frink

    IERS Bulletin A can be found at:
    https://www.iers.org/IERS/EN/DataProducts/EarthOrientationData/eop.html

    And the latest can be specifically found at:
    https://datacenter.iers.org/data/latestVersion/bulletinA.txt

    but somehow they return an HTTP 400 (Bad Request) error code on that
    request?!  So let's try:

    https://maia.usno.navy.mil/ser7/ser7.dat
*/


parseBulletinA[str] :=
{
   if [ut2] = str =~ %r/UT2-UT1\s*=\s*(.*?)\s*where/s
   {
      ut2 =~ %s/\n//g       // Remove newlines
      ut2 =~ %s/\s{2,}/ /g  // compress spaces
      ut2 =~ %s/\(/\[/g
      ut2 =~ %s/\)/\]/g
      ut2 =~ %s/\*/ /g
      // println["UT2-UT1=$ut2"]
   }
   
   if [ut1] = str =~ %r/UT1-UTC\s*=\s*(.*?)\s*where/m
   {
      ut1 =~ %s/\n//g    
      ut1 =~ %s/\s{2,}/ /g
//      ut1 =~ %s/\(/\[/g
//      ut1 =~ %s/\)/\]/g
      ut1 =~ %s/MJD/(MJD[date]\/day)/g
      ut1 =~ %s/(.*)\s*\-\s*\(UT2-UT1\)/($1) s - UT2MinusUT1\[date\]/g
      ut1 =~ %s/\*/ /g
      // println["UT1-UTC=$ut1"]
   }

   return [ut1, "($ut2) s"]
}

parseLatestBulletinA[] :=
{
   //str = read["https://datacenter.iers.org/data/latestVersion/bulletinA.txt"]
   str = read["https://maia.usno.navy.mil/ser7/ser7.dat"]
//   println["str is $str"]
   return parseBulletinA[str]
}

[ut1, ut2] = parseLatestBulletinA[]

println["""
/** This file is generated by makeUT1.frink !

    This contains calculations for UT1 and UT2.  These are time corrections
    for DeltaT:
       
    DeltaT = 32.184 s + (TAI-UTC) - (UT1-UTC)
    TT = TAI + 32.184 s

    Where TAI-UTC can be obtained from the function TAIMinusUTC[date].  In Frink
    notation, DeltaT can be predicted *in the short-term* by:

    deltaTPred[date] := 32.184 s + TAIMinusUTC[date] - UT1MinusUTC[date]

    The primary source of UT1-UTC corrections is IERS Bulletin A, found at:
    https://www.iers.org/IERS/EN/DataProducts/EarthOrientationData/eop.html

    as well as:
    https://maia.usno.navy.mil/products/deltaT

    TODO:  Parse either IERS Bulletin A or the maia.usno.navy.mil predictions
    although they are in a hodgepodge non-computer-parseable format.  Otherwise
    the equations here will have to be periodically updated from the ones
    published in IERS Bulletin A.
*/


// This is just to get the definition of BesselianDate.  Should probably be
// made into a native Frink function.
use sun.frink

/** Return (UT2-UT1).  This equation is found at the top of IERS Bulletin A. */
UT2MinusUT1[date] :=
{
   T = BesselianDate[date]
   return $ut2
}

/** This uses the extrapolating equation from IERS Bulletin A which states
    "The following formulas will not reproduce the predictions given below,   
      but may be used to extend the predictions beyond the end of this table."
    LOL.

    For more accuracy in the short term, this value should be interpolated from
    the values published in IERS Bulletin A.
*/

UT1MinusUTC[date] :=
{
   return $ut1
}

/** Short-range predictions for deltaT */
deltaTPred[date] := 32.184 s + TAIMinusUTC[date] - UT1MinusUTC[date]
"""]


Download or view makeUT1.frink in plain text format


This is a program written in the programming language Frink.
For more information, view the Frink Documentation or see More Sample Frink Programs.

Alan Eliasen, eliasen@mindspring.com