jamie stevens'
code


sidereal_time

Routine for calculating the sidereal time
written by Jamie Stevens 2006

Definition:
double sidereal_time(time_t time_now,int type,double longitude)

Source:
sidereal_time.c
sidereal_time.h

Usage:
This routine takes three arguments:
  • a time_t type value, the time
  • an integer type flag specifying which sidereal time you want returned, one of:
    • SIDEREAL_GMST = the Greenwich Mean Sidereal Time
    • SIDEREAL_GAST = the Greenwich Apparent Sidereal Time
    • SIDEREAL_LMST = the Local Mean Sidereal Time
    • SIDEREAL_LAST = the Local Apparent Sidereal Time
  • a double type value, the local longitude in degrees, only needs to be filled if you want a Local Sidereal Time, and east longitudes are positive
The return value of this routine is the requested type of sidereal time for the specified time and location.
This routine requires the julian_date routine, which can be found in the code section of this site.

Example:
To get the current Local Mean Sidereal Time for the Mt Pleasant radio telescope, the following code will work:

#include <stdio.h>
#include <time.h>
#include <math.h>
#include "sidereal_time.h"

void main(){
  time_t time_now;
  double mtp_long=147.4391667; /* the longitude of Mt Pleasant */
  double stime,st_hour,st_min,st_sec;

  time(&time_now);
  stime=sidereal_time(time_now,SIDEREAL_LMST,mtp_long);
  (void)modf(stime,&st_hour);
  stime-=st_hour; stime*=60.0;
  (void)modf(stime,&st_min);
  stime-=st_min; stime*=60.0;
  (void)modf(stime,&st_sec);
  printf("local mean sidereal time = %02d:%02d:%02d\n",
         (int)st_hour,(int)st_min,(int)st_sec);
}



this page last modified @ 2006/11/30 14:08
website maintained by jamie stevens, school of mathematics and physics, university of tasmania
this page, its contents and style are the responsibility of the author, and do not necessarily reflect the opinions of the university of tasmania
all images on this site are copyright jamie stevens unless specified otherwise
best viewed at resolutions higher than 800x600 (this centre thing is 600 pixels wide) and with a recent browser
Firefox 2