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
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);
}
