Tuesday, March 3, 2015

HP Prime: Solar Position (Right Ascension, Declination, Altitude, Azimuth)

HP Prime: Solar Position (Right Ascension, Declination, Altitude, Azimuth)

Input:
* Month
* Date
* Year
* Local Time (your local standard time – do not adjust for daylight savings time)
* Longitude
* Latitude


Local Time:  Use a 24 Hour clock. When entering time, you can enter a decimal or hours°minutes’seconds’’.

Longitude:  This is your location, going east from the Greenwich Prime Meridian.  East is positive, West is negative. Range: -180° to 180°

Latitude: This is your location, going north from the Equator.  North is positive, South is negative.  Range:  -90° to 90°

Entering HMS:

HP Prime:  Use Shift+9 and select the appropriate symbol (°, ‘, or ‘’)

Output:
r:  Distance from the Earth to the Sun in astronomical units (AU)
α:  Right ascension in decimal hours
δ:  Declination in decimal degrees
eot:  Equation of Time in minutes
alt:  Altitude/Elevation
azi:  Azimuth, from due North going clockwise

Please keep in mind that these are approximate answers.

Also, a 2-column matrix is returned to the home screen for reference.  The first column is the input column, the second is the output column.

[[ month,  distance ]
[ day,  right ascension ]
[ year, declination ]
[ local time, declination ]
[ longitude, altitude ]
[ latitude, azimuth ]]

HP Prime:  solar

EXPORT solar()
BEGIN
// aa.usno.navy.mil
// Updated 2015-03-01 EWS

// month, day, year, local standard
// time, longitude, latitude
LOCAL m,D,Y,lstd,long,lat;

INPUT({m,D,Y,lstd,long,lat},
"Data: Use Shift+9 for H°M′S″",
{"Month:","Date :","Year :",
"Local Time (24):", "Long (+E):",
"Lat (+N)"});

// Initialization
LOCAL d,g,q,L,r,ec,gmt;
LOCAL eot,alt,lha,azi,zen,loc;
LOCAL α,δ,g1,g2;
LOCAL w1,w2;
HAngle:=1;

// Greenwich Mean Time
gmt:=lstd-long/15;

// Julian Date
d:=367*Y-IP(7*(Y+IP((m+9)/12))/4)
+IP((275*m)/9)+D+1721013.5+gmt/24
-0.5*SIGN(100*Y+m-190002.5)+0.5;
d:=d-2451545;

// Intermediate Calculations
g:=(357.529+.98560028*d)  MOD 360;
q:=(280.459+.98564736*d) MOD 360;
L:=(q+1.915*SIN(g)+.02*SIN(2*g)) MOD 360;
r:=1.00014-.01671*COS(g)-.00014*COS(2*g);
ec:=23.439291-.00000036*d;

α:=ARG(COS(L)+SIN(L)*COS(ec)*i) MOD 360;

// Convert to hours
α:=α/15;

// Declination
δ:=ASIN(SIN(ec)*SIN(L));

// Equation of Time
eot:=q/15-α;
eot:=eot*60;

// Greenwich Mean Time (in hours)
g1:=-0.000319*SIN(−125.04-0.052954*d)
-2.4ᴇ−5*SIN(560.94+1.9713*d);
gmt:=(18.697374558+24.06570982441908*d
+g1*COS(ec)) MOD 24;

// Hour Angle (in degrees)
lha:=(gmt-α)*15+long;

// Altitude (approximate)
alt:=ASIN(SIN(lat)*SIN(δ)+
COS(lat)*COS(δ)*COS(lha));

// Azimuth
// Clockwise from South
azi:=ARG(SIN(lha)*i+COS(lha)*SIN(lat)
-TAN(δ)*COS(lat));
// Convert to clockwise from North
azi:=azi+180;

PRINT();
PRINT("Sun "+m+"/"+D+"/"+Y+" ; "+lstd);
PRINT("Distance: "+r);
PRINT("α (hours): "+α);
PRINT("δ (degrees): "+δ);
PRINT("eot (minutes): "+eot);
PRINT("Approximate");
PRINT("alt (elevation): "+alt);
PRINT("azi (North-clockwise): "+azi);

PRINT("DEGREES MODE SET");
RETURN [[m,r],[D,α],[Y,δ],[lstd,eot],
[long,alt],[lat,azi]];
END;


Example:

Input:
June 1, 2015; 12:00 PM , Longitude: -118°13’59”, Latitude: 34°3’

Output:
r = 1.01406353128 AU
α = 4.6292012064 hr
δ = 22.0919016903°
eot = 2.157339456 min
alt = 78.032250726°
azi = 182.442424012°


Resources:

The United States Naval Observatory (USNO)  Washington, D.C.:
“Approximate Solar Coordinates” (URL:  http://aa.usno.navy.mil/faq/docs/SunApprox.php )
“Approximate Sidereal Time” (URL: http://aa.usno.navy.mil/faq/docs/GAST.php )
“Computing Altitude and Azimuth from Greenwich Apparent Sidereal Time” (URL: http://aa.usno.navy.mil/faq/docs/Alt_Az.php )
“Converting Between Julian Dates and Gregorian Calendar Dates” (URL: http://aa.usno.navy.mil/faq/docs/JD_Formula.php )
Retrieved February 23, 2015 to March 1, 2015

This blog is property of Edward Shore - 2015