<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On 6 December 2013 14:11, David Berry <span dir="ltr"><<a href="mailto:d.berry@jach.hawaii.edu" target="_blank">d.berry@jach.hawaii.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">GPS is offset by 19 seconds from TAI. TAI is itself offset from UTC by an integer number of seconds that increments each time a leap second occurs. So it's pretty easy to code, but you need to know what the current UTC-TAI value is.  <div>

<br></div><div>As an example, here is how to could be done using pyast. pyast does not yet support GPS directly, but it's a simple job to add on the extra 19 seconds.</div><div><br></div><div>David</div><div>
<br></div><div><br></div></div></blockquote><div><br></div><div><br></div><div style>Spot the obvious error! It should have been...</div><div><br></div><div><div><br></div><div>import starlink.Ast as Ast</div><div><br></div>
<div>#  Create frames describing UTC and TAI, in seconds. Indicate that values</div><div>#  should be formatted using a standard ISO date and time string with 3</div><div>#  decimal places in the seconds field.</div><div>
tai_frame = Ast.TimeFrame( "TimeScale=TAI,Unit=s,Format=iso.3" )</div><div>utc_frame = Ast.TimeFrame( "TimeScale=UTC,Unit=s,Format=iso.3" )</div><div><br></div><div>#  Get a mapping from TAI to UTC.</div>
<div>tai_to_utc = tai_frame.convert( utc_frame )</div><div><br></div><div>#  TAI is GPS plus 19 seconds. Create a Mapping to describe this shift.</div><div>gps_to_tai = Ast.ShiftMap( 19.0 )</div><div><br></div><div>#  Conbine these mappings to get the total GPS to UTC mapping.</div>
<div>gps_to_utc = Ast.CmpMap( gps_to_tai, tai_to_utc )</div><div><br></div><div>#  Convert an example GPS date and time string to a floating point</div><div>#  value in seconds. We use the TAI frame here as a convenience - it's</div>
<div>#  only being used to do the parsing,  which is the same for all timescales.</div><div>( nc, gps_value ) = tai_frame.unformat( 1, "2013-10-03 12:22:02.1" )</div><div><br></div><div>#  Using the above mapping to transform it to UTC.</div>
<div>utc_value = gps_to_utc.tran( gps_value )</div><div><br></div><div>#  Convert the result to a date and time string and print. </div><div>print( utc_frame.format( 1, utc_value ) )</div></div><div><br></div><div> </div>
</div></div></div>