Sun position
Sun position algorithm
demo3_moon.c

Single calculation of the Moon's position

void demo3(void)
/*! Sample code demonstrating the calculation of the position of the Moon using
* rectangular coordinates
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
{
Sky_DeltaTs deltaTs; /* Differences between timescales */
Sky_SiteProp site; /* Properties of the site */
Sky_SiteHorizon topo; /* Moon position, as seen from the site */
double j2kUtc_d; /* Time, expressed as a count of days */
char azStr[24], elStr[24];
/* Set up the various delta T values. Values are taken from Bulletin A of
* 23-Jul-2020, using the value for date 2020-07-25 (column UT1-UTC(sec))
* for deltaUT_s */
sky_initTime(37, -0.21342, &deltaTs);
/* Set up the fixed site data */
&site);
&site);
/* Get the current time in days since 2000-01-01 Greenwich noon */
j2kUtc_d = sky_unixTimeToJ2kd(time(NULL));
/* Get moon position */
moon_nrelTopocentric(j2kUtc_d, &deltaTs, &site, &topo);
/* Print out time and place */
printf("Full moon calculation\n");
skyio_printJ2kd(j2kUtc_d + site.timeZone_d);
skyio_radToDmsStr(azStr, sizeof(azStr), topo.azimuth_rad, 2);
skyio_radToDmsStr(elStr, sizeof(elStr), topo.elevation_rad, 2);
printf(" Sun Azimuth: %s, Elevation: %s\n", azStr, elStr);
}
SITE_TIMEZONE_h
#define SITE_TIMEZONE_h
East zones +ve, west -ve (hours)
Definition: main.c:61
Sky_DeltaTs
This structure contains relatively constant data, and is set up by one of the three functions sky_ini...
Definition: sky.h:166
skyio_radToDmsStr
static char * skyio_radToDmsStr(char destStr[], size_t destStrSize, double angle_rad, unsigned decimals)
Routine to take an angle in radian and return a string in degrees, arcminutes and arcseconds form - [...
Definition: skyio.h:111
SITE_PRESSURE_hPa
#define SITE_PRESSURE_hPa
Atmospheric pressure (hPa = mbar)
Definition: main.c:59
sky_setSiteLocation
void sky_setSiteLocation(double latitude_deg, double longitude_deg, double height_m, Sky_SiteProp *site)
Initialise the site structure by calculating those site-related values that do not change with time.
Definition: sky-site.c:105
SITE_TEMPERATURE_degC
#define SITE_TEMPERATURE_degC
Temperature (degrees Celsius)
Definition: main.c:60
SITE_LONGITUDE_deg
#define SITE_LONGITUDE_deg
East lons +ve, west -ve (degrees)
Definition: main.c:57
SITE_HEIGHT_m
#define SITE_HEIGHT_m
Height above sea level (metres)
Definition: main.c:58
Sky_SiteProp
Site properties.
Definition: sky.h:315
Sky_SiteHorizon::azimuth_rad
double azimuth_rad
azimuth (radian)
Definition: sky.h:131
SITE_LATITUDE_deg
#define SITE_LATITUDE_deg
North lats +ve, south -ve (deg)
Definition: main.c:56
Sky_SiteProp::timeZone_d
double timeZone_d
time zone offset from UTC (fraction of a day)
Definition: sky.h:323
sky_unixTimeToJ2kd
double sky_unixTimeToJ2kd(time_t unixTime)
Convert a time in Unix system time format to days since 2000 Jan 1, noon UTC.
Definition: sky-time.c:275
sky_setSiteTimeZone
void sky_setSiteTimeZone(double timeZone_h, Sky_SiteProp *site)
Set the time zone offset for this site.
Definition: sky-site.c:293
moon_nrelTopocentric
void moon_nrelTopocentric(double j2kdUtc, const Sky_DeltaTs *deltas, const Sky_SiteProp *site, Sky_SiteHorizon *topo)
Calls moon_nrelApparent() to calculate the Moon's position in apparent coordinates using the NREL Moo...
Definition: moon.c:278
sky_setSiteTempPress
void sky_setSiteTempPress(double temperature_degC, double pressure_hPa, Sky_SiteProp *site)
Set refraction coefficients based on atmospheric temperature and pressure at the site.
Definition: sky-site.c:261
sky_initTime
void sky_initTime(int deltaAT_s, double deltaUT_s, Sky_DeltaTs *d)
This is one of three alternative routines for setting up the various delta time values for use in ong...
Definition: sky-time.c:96
skyio_printJ2kd
void skyio_printJ2kd(double j2kd)
Write out a J2KD as a calendar date and time.
Definition: skyio.c:426
Sky_SiteHorizon::elevation_rad
double elevation_rad
elevation (or altitude) (radian)
Definition: sky.h:132
Sky_SiteHorizon
Coordinates of a celestial object in the horizon frame, in both rectangular and polar forms.
Definition: sky.h:129