[time-nuts] Calculating sidereal time

Didier Juges shalimr9 at gmail.com
Fri Jan 18 21:18:08 UTC 2019


Trying to add sidereal time to my Thunderbolt monitor (I am working on a
new design with an ARM Cortex chip so that I can have double precision
math), I am obviously not understanding something in the process as my
calculations are off.
Here what I am doing:
I have the GPS date which I convert to Julian date using Tom's fomulas:

/*===================================================================
* These functions are adapted to the 8051 from Tom VanBaak's web site,
* leapsecond.com
*
* For background on Julian Date and Modified Julian Date,
* see http://tycho.usno.navy.mil/mjd.html
*==================================================================*/
// Convert year/month/day calendar date to MJD (Modified Julian Day).
// - year is (4-digit calendar year), month is (1-12), day is (1-31)
// - valid for Gregorian dates from 17-Nov-1858 (adapted from sci.astro FAQ)
uint32_t ymd_to_mjd( struct sdate sd ){
int32_t year, month, day, mjd;

year = (int32_t)sd.y;
month = (int32_t)sd.m;
day = (int32_t)sd.d;
    mjd =
        367 * year
        - 7 * (year + (month + 9) / 12) / 4
        - 3 * ((year + (month - 9) / 7) / 100 + 1) / 4
        + 275 * month / 9
        + day + 1721028 - 2400000;

return( (uint32_t)mjd );

} // ymd_to_mjd()

I have adapted the formula to my existing TBMonitor code (this is 8051 code
which was part of the GPS offset issue of last July) but the calculations
should be unchanged and they seem to work (1st assumption).

So I believe when I feed the UTC date (integer) to  ymd_to_mjd() , I obtain
the Julian date, which is the same as the Julian time at midnight at
Greenwich (2nd assumption).

I have found a Mathlab function that converts Julian time to Greenwich
median sidereal time and converted the function to C as follows:

double mjd2gmst( double mjd ){
// MJD2GMST Convert modified julian date to greenwich mean sidereal time.
//   [gmst] = mjd2gmst(mjd) converts modified julian date to greenwich mean
//   sidereal time using the algorithm from the Astronomical Almanac 2002,
//   pg. B6.

//-----------------------------------------------------------------------
// Craig Haley 20/09/01
//   30-06-04 CSH made small changes
//   05-01-05 CSH modified to use mjd rather than converting to jd
// Didier Juges
//   18Jan19 converted to C.
//-----------------------------------------------------------------------
/* original Mathlab code:
* mjd2000 = 51544.5;        %Modified Julian Date of Epoch J2000.0
* int_mjd = floor(mjd);
* frac_mjd = mjd-int_mjd;
* Tu = (int_mjd-mjd2000)/36525.0;
* gmst = 24110.54841+Tu.*(8640184.812866+Tu.*(0.093104-Tu*6.2e-6));
* %add the mean sidereal time interval from midnight to time
* gmst = mod(gmst+frac_mjd*86400*1.00273790934,86400);
* %convert to hours
* gmst = gmst/3600;
*/

double mjd2000 = 51544.5;        //Modified Julian Date of Epoch J2000.0
uint32_t int_mjd = floor( mjd );
double frac_mjd = mjd - int_mjd;
double Tu = (int_mjd - mjd2000) / 36525.0;
double gmst = 24110.54841 + Tu * (8640184.812866 + Tu * (0.093104 - Tu *
0.0000062));

// add the mean sidereal time interval from midnight to time
gmst = (uint32_t)(gmst + frac_mjd * 86400 * 1.00273790934) % 86400;

// convert to hours
gmst = gmst / 3600;
return( gmst );
} // mjd2gmst()

I am unable to verify if my assumptions about the usage of this function or
my conversion to C are correct.
Assuming they are, to calculate the local sidereal time, I feed that
function the Julian date calculated above with Tom's function, for today
(January 18, 2019) it returns 7.807... which translates to a sidereal time
of 7:48:26 (3rd assumption)

If my understanding is correct, that should be the GMST today at midnight?

When I feed the online calculator a longitude of 0, it gives me a GMST
(Greenwich) of 4:25 (AM) when the local time (Central time zone) is 2:56
PM, that does not seem to reconcile with the 7:48:26 GMST at midnight since
being in Central time, we have 6 hours difference with Greenwich.

Assuming that I had GMST at midnight, to get local mean sidereal time, I
would have to add the UTC time of day now (from the Thunderbolt) and the
longitude in hours/mn/sec of my location (calculated from the Thunderbolt
also) (4th assumption).

When I do that I am off by several hours compared to two on-line sidereal
calculators and an app on my phone :(

I probably have a major mistake in one or more of the assumptions but I
can't see it.

Any suggestion appreciated!

Didier KO4BB



More information about the Time-nuts_lists.febo.com mailing list