Skip to content

Commit

Permalink
Per #2966, add new solar_time() function to the vx_solar library.
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnHalleyGotway committed Nov 4, 2024
1 parent 5784b8a commit 2c13fda
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/libcode/vx_solar/solar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,49 @@ return;
////////////////////////////////////////////////////////////////////////


double solar_time(unixtime gmt, double lon)

{

//
// right ascension and declination
//

double Ra;
double Dec;

solar_radec(gmt, Ra, Dec);

//
// local hour angle
//

double lha = gmt_to_gmst(gmt) - lon - Ra;

//
// rescale angle to -180 to 180
//

lha -= 360.0*floor((lha + 180.0)/360.0);

//
// rescale local hour angle to decimal hours of the solar day
//

double solar_hr = (lha + 180.0)/360.0 * 24;

//
// done
//

return solar_hr;

}


////////////////////////////////////////////////////////////////////////


void dh_to_aa(double lat, double Dec, double lha, double & alt, double & azi)

{
Expand Down
19 changes: 19 additions & 0 deletions src/libcode/vx_solar/solar.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,25 @@ extern void solar_altaz(unixtime gmt, double lat, double lon, double & alt, doub
////////////////////////////////////////////////////////////////////////


extern double solar_time(unixtime gmt, double lon);

//
// calculates the solar time for the given longitude.
//
//
// Input: gmt, greenwich mean time expressed as unix time
//
// lon, longitude (degrees) of given location (+ west, - east)
//
//
// Output: decimal hours f the solar day in range [0, 24),
// where 12 is solar noon
//


////////////////////////////////////////////////////////////////////////


extern void solar_radec(unixtime gmt, double & Ra, double & Dec);

//
Expand Down

0 comments on commit 2c13fda

Please sign in to comment.