Showing posts with label length of daylight. Show all posts
Showing posts with label length of daylight. Show all posts

Sunday, November 29, 2015

HP Prime: Approximate Length of Daylight

I hope you had a great weekend and a great Thanksgiving.  For those of you in the United States, hopefully Friday was peaceful and not crazy.

HP Prime: Approximating the Length of Daylight in Hours

This time, we are taking a slightly more complex formula.   The inputs are:

lat = Earth's latitude of the observer.  (from -90° (South) to 90° (North))

day = the number of days since the December solstice (around December 21-22).  Note that is different from many approximate formulas which used the vernal equinox as a starting point.  

The formula used is a simplification of the Final Formula presented by Herbert Glarner (http://www.gandraxa.com/).  For the complete article and the derivation, please click on link:

http://www.gandraxa.com/length_of_day.xml    (Retrieved November 23, 2015)

The algorithm used in the DAYLIGHT is:

With the inputs lat and day:

m = 1 – tan(lat°) * tan(23.439° * cos(480/487 * day))

If m > 2, let m = 2.   If m < 0, let m = 0.

Then:

b = acos(1 – m)/180 *24

Where b is the length of daylight in hours.

I adjusted the formula to allow for all inputs to be in degrees.  Glamer had mixed inputs for the trigonometric functions.

Here is the program:

Program DAYLIGHT:

EXPORT DAYLIGHT(lat,day)
BEGIN
// latitude, days from
// December solstice
LOCAL m,b,a:=HAngle;
HAngle:=1; // Degrees
m:=1-TAN(lat)*TAN(23.439*COS(
480/487*day));
IF m<0 THEN
m:=0;
END;
IF m>2 THEN
m:=2;
END;
b:=ACOS(1-m)/180*24; // hours
RETURN b;
HAngle:=a;
// www.grandraxa.com
END;

Examples:

Let’s assume a 365 day and the December solstice was December 22. 

Latitude:  -60°, March 1  (day = 69)
Result:  Approx. 16.67808 hours

Latitude: 54°,  July 24  (day = 214)
Result:  Approx. 16.03426 hours

For another approximate formula, I wrote on one for the HP 35S here:  http://edspi31415.blogspot.com/2013/05/hp-35s-approximate-length-of-sunlight.html


Have a great day, 

Eddie


This blog is property of Edward Shore.  2015





Friday, January 16, 2015

fx-5800p: Large Factorials, Length of Daylight, & Moments/Skewness

fx-5800p: Large Factorials, Length of Daylight, & Moments/Skewness

Large Factorials

This allows the user to calculate n! for any positive n, even n > 69.

Program BIGFACT
"N"?→N
Σ(log(K),K,1,N) → S
"N = "
10^(Frac(S)) ◢
"* 10^( )"
Int(S)


Examples:
36! ≈ 3.719933268 * 10^ 41
134! ≈ 1.992942746 * 10^ 228

Length of Daylight

D = days after March 21. A 365 day year is assumed.

Program DAYLIGHT
"DAYS AFTER"
"MARCH 21"? → D
Deg
23.45 * sin(D*.9856) → T
"LATITUDE"
"D ● M ● S ●"? → L // for ● press [ ° ' " ]
cos⁻¹ (-tan(L) * tan(T) ) → A
2 * A / 15 → H
"HOURS="
H


Example:
D = 302 (January 17)
L = 40° N (+40°)
Result: H = 9.525548719 hours

D = 302 (January 17)
L = 40° S (-40°)
Result H = 14.47445128

Moments/Skewness

Source: HP 33 Math Pak, 1979

Formulas:

1st Moment: A = Σx ÷ n
2nd Moment: B = Σ(x^2) ÷ n - A^2
3rd Moment: C = (Σ(x^3) - 3 * A * Σ(x^2)) ÷ n + 2 * A^3
Coefficient of Skewness: D = C / B^1.5

Program MOMENTS
0 → N // Initialization
0 → U
0 → V
0 → W
Lbl 0 // Main Loop
N + 1 → N
U + X → U
V + X^2 → V
W + X^(3) → W
"NO. OF PTS."
N ◢
"ANOTHER PT.?" // are you done?
"0=NO 1=YES"
? → Y
Y ≠ 0 ⇒ Goto 0
U ÷ N → A // analysis
V ÷ N - A^2 → B
(W - 3*A*V) ÷ N + 2 * A^(3) → C
C ÷ B^(1.5) → D
"1ST MOMENT"
A ◢
"2ND MOMENT"
B ◢
"3RD MOMENT"
C ◢
"SKEWNESS"
D


Example:

Data: 1.5, 2.8, 2.9, 3.6, 4.7

Results:
1st Moment = 3.1
2nd Moment = 1.1
3rd Moment = 0.018
4th Moment = 0.0156021151

See you all next time - have a great weekend! Go have some fun!

This blog is property of Edward Shore. 2015

Sunday, May 19, 2013

HP 35S: Approximate Length of Sunlight During a Day

HP 35S: Length of Sunlight During a Day

Source: Total Daily Amount of Solar Radiation - HP 67/97 Energy Conservation Pac, December 1978, Author: Hewlett Packard

(This is a slight variation instead of a direct port)

Input

You are prompted for D and L where:
D = the number of days from March 21, a 365 day year is assumed
L = latitude (North as positive, South as negative), entered as D.MMSS (degrees-minutes-seconds) format

Output

Approximate number of hours of sunlight, in hours, minutes, seconds

Examples

Los Angeles, April 17: latitude of 34°03' N, 27 days after March 21
D = 27, L = 34.03, answer is approximately 12.573501 (12 hours, 57 minutes, 35.01 seconds)

Rome, September 1: latitude 41°51' N, 164 days after March 21
D = 164, L = 41.52, answer is approximately 12.532269 (12 hours, 53 minutes, 22.69 seconds)

Sydney, June 21: latitude 33°51'31" S, 92 days after March 21
D = 92, L = -33.5131, answer is approximately 9.443922 (9 hours, 44 minutes, 39.22 seconds)

Formulas

This version uses the estimate of sun declination:
D = 23.45 sin(d * 0.9856°)

Since 360/365.25 ≈ 0.985626283368

θ = acos(-tan L × tan D)

L = 24 * θ in radians ÷ π

Program
S001 LBL S
S002 DEG
S003 INPUT D
S004 0.9856
S005 ×
S006 SIN
S007 23.45
S008 ×
S009 INPUT L
S010 HMS→
S011 TAN
S012 x<>y
S013 TAN
S014 ×
S015 +/-
S016 ACOS
S017 ->RAD
S018 24
S019 ×
S020 π
S021 ÷
S022 ->HMS
S023 RTN



This blog is property of Edward Shore. 2013

Python – Earth’s Radius and Gravity in US Units

Python – Earth’s Radius and Gravity in US Units Introduction The following script, gravus2.py, estimates the Earth’s gravity i...