Geo Stars Library  0.9.3
Geodetic and Astrometry library
geoAstro.c File Reference

This file contains the wrapper routines to interface to the Novas (Naval Observatory Vector Astrometry Subroutine) Library. More...

#include <stdio.h>
#include <time.h>
#include "geoStars.h"
#include "novas.h"
Include dependency graph for geoAstro.c:

Go to the source code of this file.

Macros

#define MAJOR_PLANET   0
 
#define BODY_EARTH   3
 
#define BODY_SUN   10
 
#define REDUCED_ACC   1
 

Functions

int geoSunAzElNow (GEO_LOCATION *loc, double *az, double *el)
 this routine uses ANSI C time routines to obtain the current time and then get the az and el of the sun at this location More...
 
double geoSunNowEl (double lat, double lon, double hgt)
 this routine uses the location and current time to get the elevation of the sun at this location More...
 
double geoSunNowAz (double lat, double lon, double hgt)
 this routine uses the location and current time to get the azimuth of the sun at this location More...
 
int geoSunAzEltm (GEO_LOCATION *loc, double *az, double *el, struct tm *newtime)
 this routine ingests an ANSI C time structure and then gets the az and el of the sun at this location based on this time. More...
 
int geoGettm (int part)
 
int geoSunAzElJD (GEO_LOCATION *loc, double *az, double *el, double tjd_now)
 This routine uses a previously determined Julian date and then gets the Az and El of the sun at this location based on the Julian date. More...
 
int geoGetSunError (void)
 

Variables

int geoSunError = 0
 
struct tm tError
 

Detailed Description

This file contains the wrapper routines to interface to the Novas (Naval Observatory Vector Astrometry Subroutine) Library.

http://aa.usno.navy.mil/software/novas/novas_info.html

Definition in file geoAstro.c.

Macro Definition Documentation

#define BODY_EARTH   3

Definition at line 129 of file geoAstro.c.

#define BODY_SUN   10

Definition at line 130 of file geoAstro.c.

Referenced by geoSunAzElJD().

#define MAJOR_PLANET   0

Definition at line 128 of file geoAstro.c.

Referenced by geoSunAzElJD().

#define REDUCED_ACC   1

Definition at line 131 of file geoAstro.c.

Referenced by geoSunAzElJD().

Function Documentation

int geoGetSunError ( void  )

Definition at line 198 of file geoAstro.c.

References geoSunError.

199 {
200  return(geoSunError);
201 }
int geoGettm ( int  part)

Definition at line 116 of file geoAstro.c.

References tError.

117 {
118  switch(part)
119  {
120  case 1: return(tError.tm_year);
121  case 2: return(tError.tm_mon);
122  case 3: return(tError.tm_mday);
123  }
124  return(-999);
125 }
int geoSunAzElJD ( GEO_LOCATION loc,
double *  az,
double *  el,
double  tjd_now 
)

This routine uses a previously determined Julian date and then gets the Az and El of the sun at this location based on the Julian date.

Parameters
GEO_LOCATION*loc : Location structure
double*az : Azimuth in decimal degrees
double*el : Elevation in decimal degrees
Return values
GEO_OKon success
GEO_ERRORon error

Definition at line 147 of file geoAstro.c.

References BODY_SUN, GEO_ERROR, GEO_OK, geoSunError, GEO_LOCATION::hgt, GEO_LOCATION::lat, GEO_LOCATION::lon, MAJOR_PLANET, and REDUCED_ACC.

Referenced by geoSunAzEltm().

148 {
149  on_surface geo_loc;
150  cat_entry dummy_star;
151  object sun;
152  double deltat = 60.0; // 'deltat' is the difference in time scales, TT - UT1.
153  double ra, dec, dis;
154  double rar,decr;
155  // int error;
156 
157  /* Convert geo library info into Novas info */
158  // geo_loc.latitude = loc->lat;
159  // geo_loc.longitude = loc->lon;
160  // geo_loc.height = loc->hgt;
161  // geo_loc.temperature = 30.0; // degrees celcius
162  // geo_loc.pressure = 1000.0; // pressure in millibars
163  make_on_surface(loc->lat, loc->lon, loc->hgt, 30.0, 1000.0, &geo_loc);
164 
165 
166  /* Set the planetary bodies to be worked with */
167  /*geoSunError = set_body (MAJOR_PLANET,BODY_EARTH,"Earth", &earth);
168  if(geoSunError)
169  {
170  // printf ("Error %d from set_body.\n", geoSunError);
171  return(GEO_ERROR);
172  }
173 */
174 
175  geoSunError = make_object (MAJOR_PLANET,BODY_SUN,"Sun",&dummy_star, &sun);
176  if(geoSunError)
177  {
178  //printf ("Error %d from make_object.\n", geoSunError);
179  return(GEO_ERROR);
180  }
181 
182  /* Compute the Sun's position */
183  // geoSunError = topo_planet (tjd_now,&sun,&earth,deltat,&geo_loc, &ra,&dec,&dis);
184  geoSunError = topo_planet (tjd_now,&sun,deltat,&geo_loc, REDUCED_ACC, &ra,&dec,&dis);
185  if(geoSunError)
186  {
187  // printf ("Error %d from topo_planet.\n", geoSunError);
188  return(GEO_ERROR);
189  }
190 
191  /* Convert to Azimuth and Elevation */
192  equ2hor(tjd_now,deltat,REDUCED_ACC,0,0,&geo_loc,ra,dec,0,el,az,&rar,&decr);
193  *el = 90.0 - *el; // correct elevation from zenith
194 
195  return(GEO_OK);
196 }
int geoSunAzElNow ( GEO_LOCATION loc,
double *  az,
double *  el 
)

this routine uses ANSI C time routines to obtain the current time and then get the az and el of the sun at this location

Parameters
GEO_LOCATION*loc : Location structure
double*az : Azimuth in decimal degrees
double*el : Elevation in decimal degrees
Return values
GEO_OKon success
GEO_ERRORon error

Definition at line 31 of file geoAstro.c.

References geoSunAzEltm().

Referenced by geoSunNowAz(), and geoSunNowEl().

32 {
33  struct tm *newtime;
34  long ltime=0L;
35 
36  /* Obtain coordinated universal time: */
37  time( &ltime );
38  newtime = gmtime( &ltime );
39 
40  return ( geoSunAzEltm(loc, az, el, newtime) );
41 }

Here is the call graph for this function:

int geoSunAzEltm ( GEO_LOCATION loc,
double *  az,
double *  el,
struct tm *  newtime 
)

this routine ingests an ANSI C time structure and then gets the az and el of the sun at this location based on this time.

Parameters
GEO_LOCATION*loc : Location structure
double*az : Azimuth in decimal degrees
double*el : Elevation in decimal degrees
Return values
GEO_OKon success
GEO_ERRORon error

Definition at line 98 of file geoAstro.c.

References geoSunAzElJD(), and tError.

Referenced by geoSunAzElNow().

99 {
100  /* Obtain coordinated universal time: */
101  double tjd_now;
102 
103  tError.tm_year=newtime->tm_year;
104  tError.tm_mon=newtime->tm_mon;
105  tError.tm_mday=newtime->tm_mday;
106 
107  tjd_now = julian_date((short)(newtime->tm_year+1900),
108  (short)(newtime->tm_mon+1),
109  (short)newtime->tm_mday,
110  newtime->tm_hour + (newtime->tm_min/60.0)+(newtime->tm_sec/3600.0));
111 
112  return ( geoSunAzElJD(loc, az, el,tjd_now) );
113 }

Here is the call graph for this function:

double geoSunNowAz ( double  lat,
double  lon,
double  hgt 
)

this routine uses the location and current time to get the azimuth of the sun at this location

Parameters
doublelat : Latitude in degrees
doublelon : Longitude in degrees
doublehgt : Height in meters
Return values
double: Azimuth in decimal degrees

Definition at line 75 of file geoAstro.c.

References GEO_DATUM_DEFAULT, geoInitLocation(), and geoSunAzElNow().

76 {
77  GEO_LOCATION loc;
78  double az,el;
79 
80  geoInitLocation(&loc, lat, lon, hgt, GEO_DATUM_DEFAULT, "now");
81  geoSunAzElNow(&loc, &az, &el);
82  return(az);
83 }

Here is the call graph for this function:

double geoSunNowEl ( double  lat,
double  lon,
double  hgt 
)

this routine uses the location and current time to get the elevation of the sun at this location

Parameters
doublelat : Latitude in degrees
doublelon : Longitude in degrees
doublehgt : Height in meters
Return values
double: Elevation in decimal degrees

Definition at line 54 of file geoAstro.c.

References GEO_DATUM_DEFAULT, geoInitLocation(), and geoSunAzElNow().

55 {
56  GEO_LOCATION loc;
57  double az,el;
58 
59  geoInitLocation(&loc, lat, lon, hgt, GEO_DATUM_DEFAULT, "now");
60  geoSunAzElNow(&loc, &az, &el);
61  return(el);
62 }

Here is the call graph for this function:

Variable Documentation

int geoSunError = 0

Definition at line 15 of file geoAstro.c.

Referenced by geoGetSunError(), and geoSunAzElJD().

struct tm tError

Definition at line 16 of file geoAstro.c.

Referenced by geoGettm(), and geoSunAzEltm().