Showing posts with label latitude. Show all posts
Showing posts with label latitude. Show all posts

Saturday, September 5, 2026

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 in ft/sec^2 given:



1. The observer’s latitude on Earth (North or South; you don’t have to enter negative numbers for South)

2. The elevation where the observer is in feet.



The Python script is made with a TI-84 Evo, but it should work with all platforms with Python.



Equation Used: With Everything Converted to U.S. Units:



Calculating g_0 at sea level with latitude φ:

g_0 = 32.17192 – 0.08530 * cos(2 * φ°) = 32.17192 – 0.08530 * cos(2 * φ * π ÷ 180)



Calculating g_h with height h:

g_h = g_0 * (erad ÷ (erad + h ÷ 5280))^2



Where (Earth’s radius at latitude φ):

erad = √((a^4 + b^4 * tan(φ)^2) ÷ (a^2+ b^2 * tan(φ)^2)) 



a = 3963.1905919

b = 3949.90276423189



Code: gravus2.py


'''

Earth's Gravity in US Units

EWS 05/26/2026

'''


from math import *


# title screen

print("Earth's Gravity")

print("Given Latitude and Elevation")

print("U.S./Imperial Units")

print("-----------------")


# angles must be converted to radians


print("Latitude in DMS:")

l1=eval(input("Whole Degrees? "))

l2=eval(input("Whole Minutes? "))

l3=eval(input("Seconds? "))

langle=l1+l2/60+l3/3600

# convert to radians

langle*=pi/180

# elevation

elev=eval(input("Elevation in feet? "))

# calculate radius 

a=3963.1905919

b=3949.90276423189

erad=(a**4+b**4*(tan(langle))**2)

erad/=(a**2+b**2*(tan(langle))**2)

erad=sqrt(erad)

# calculation

g=32.17192-0.08530*cos(2*langle)

g*=(erad/(erad+elev/5280))**2

print("Earth's radius: {0:.5f} mi".format(erad))

print("Estimated Gravity: {0:.5f} ft/s**2".format(g))



Examples (Results are rounded to five decimal places)



Latitude (φ)

Height (h ft)

Earth’s Radius (mi)

g_h (ft/s^2)

34°03’00”

500

3959.04875

32.13857

64°11’27”

1650

3952.43868

32.21979

10°57’00”

395

3962.71501

32.09156





Source



Grainger Engineering Office of Marketing and Communications. (answer written by Rebecca H.) (2016, November 21). “How gravitational force varies at different locations on Earth.” Illinois. https://van.physics.illinois.edu/ask/listing/64061. Retrieved March 10, 2026.

Planetcalc. “Earth Radius by Latitude (WGS 84)” Timur. 2021. https://planetcalc.com/7721/ Retrieved March 22, 2026.



Eddie


All original content copyright, © 2011-2026. Edward Shore. Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited. This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.


Saturday, July 25, 2026

Earth's Radius by Latitude

Earth's Radius by Latitude




Introduction: Calculating the Earth’s Radius



In quick, general calculations, we assume that the shape of the Earth approximates the shape of sphere, with the radius to generally be approximated as 6371 km. However, the shape of the Earth is closer to an oblate ellipsoid. The Earth is flattened at the poles and bulges the greatest at the Equator.



There are several calculations to estimate the Earth’s radius given the latitude (degrees North or South from the Equator), this blog is working with the WGS 84 formula (see Source):



R = √[ ((a² * cos(φ))² + (b² * sin(φ))²) ÷ ((a * cos(φ))² + (b * sin(φ))²) ]



Which is simplified from:



R = √[ (a^4 + b^4 * tan²(φ)) ÷ (a² + b² * tan²(φ))



where:

φ: latitude (in degrees)

a: semi-major axis: 6378.137 km

b: semi-minor axis: 6356.7523142 km

R: radius of kilometers



HP 15C Code: Earth’s Radius by Latitude

Step; Key; Key Code

001: LBL E; 42, 21, 15

002: DEG; 43, 7

003: →H; 43, 2

004: TAN; 25

005: x²; 43, 11

006: STO 1; 44, 1

007: 6; 6

008: 3; 3

009: 7; 7

010: 8; 8

011: . ; 48

012: 1; 1

013: 3; 3

014: 7; 7

015: STO 2; 44, 2

016: 4; 4

017: 14; y^x

018: 6; 6

019: 3; 3

020: 5; 5

021: 6; 6

022: . ; 48

023: 7; 7

024: 5; 5

025: 2; 2

026: 3; 3

027: 1; 1

028: 4; 4

029: 2; 2

030: STO 3; 44, 3

031: 4; 4

032: y^x; 14

033: RCL 1; 45, 1

034: ×; 20

035: +; 40

036: RCL 2; 45, 2

037: x²; 43, 11

038: RCL 3; 45, 3

039: x²; 43, 11

040: RCL 1; 45, 1

041: ×; 20

042: +; 40

043: ÷; 10

044: √; 11

045: RTN; 43, 32



TI-60 Code: Earth’s Radius by Latitude

Step; Key; Key Code



Set degrees mode before beginning.



00: DMS-DD; 39

01: TAN; 34

02: x²; 96

03: STO; 61

04: 1; 01

05: ( ; 53

06: 6; 06

07: 3; 03

08: 7; 07

09: 8; 08

10: . ; 93

11: 1; 01

12: 3; 03

13: 7; 07

14: STO; 61

15: 2; 02

16: y^x; 45

17: 4; 04

18: +; 85

19: 6; 06

20: 3; 03

21: 5; 05

22: 6; 06

23: . ; 93

24: 7; 07

25: 5; 05

26: 2; 02

27: 3; 03

28: 1; 01

29: 4; 04

30: 2; 02

31: STO; 61

32: 3; 03

33: y^x; 45

34: 4; 04

35: ×; 25

36: RCL; 71

37: 1; 01

38: ) ; 54

39: ÷; 55

40: ( ; 53

41: RCL; 71

42: 2; 02

43: x²; 96

44: +; 85

45: RCL; 71

46: 3; 03

47: x²; 96

48: ×; 65

49: RCL; 71

50: 1; 01

51: ) ; 54

52: = ; 95

53: √; 86

54: R/S; 13

55: RST; 22



Examples



Latitude: 80° 00’; Radius (km): 6357.402412

Latitude: 57° 24’; Radius (km): 6362.996788

Latitude: 43° 40’; Radius (km): 6367.986902

Latitude: 9° 15’; Radius (km): 6377.588959

Latitude: 2° 56’; Radius (km): 6378.081467


Source


Planetcalc. “Earth Radius by Latitude (WGS 84)” Timur. 2021. https://planetcalc.com/7721/ Retrieved March 22, 2026.



Eddie


All original content copyright, © 2011-2026. Edward Shore. Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited. This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.

Saturday, April 30, 2022

Casio fx-CG 50: Solar Panel Calculations

 Casio fx-CG 50: Solar Panel Calculations


Note:  The calculator programs can be modified for the monochrome Casio graphing calculators by removing the Color commands (Black, Blue, etc.).  The programs use ClrText and Locate to generate a result screen.


Optimum Tilt of a Solar Panel


The program SLRPANEL estimates the optimum tilt of a solar panel given your latitude (North/South), time of day, and day of the year.  The program assumes a 365 day year.   


For the time of day, enter the time in hours before noon.  Example:  For 9:00 AM, enter 3.   For 3:00 PM, enter -3.   


The declination of the sun is estimated at:


δ ≈ -23.44° * (cos(360°/365° * (n + 10)))

n = number of days from January 1, n = 0 for January 1.  


The program is listed in text file mode.


Casio fx-CG50 Program: SLRPANEL

(464 bytes)


'ProgramMode:RUN

Deg

ClrText

Locate 1,1,"SOLAR PANEL TILT"

Yellow Locate 1,3,"EWS 2022"

For 1->I To 750:Next


ClrText

"365 DAY YEAR ASSUMED"

"MONTH"?->M

"DAY"?->D

"HOURS FROM NOON"?->T

"LATITUDE (N//S)"?->L

0->X

M>2=>Int (0.4*M+2.3)->X

31*(M-1)+D-X-1->N

(-)23.44*(cos (360/365*(N+10)))->E

sin^-1 (sin L*sin E+cos E*cos L*cos (15*T))->H

sin^-1 (sin (15*T)*cos E/cos H)->Z

Z=0=>1Exp(-)9->Z

2/3*(tan^-1 (tan H/tan Z)-30)->P

ClrText

Black Locate 1,1,"MONTH:"

Blue Locate 8,1,M

Black Locate 11,1,"DAY:"

Blue Locate 16,1,D

Black Locate 1,3,"DEC:"

Blue Locate 7,3,E

Blue Locate 21,3,"_deg_"

Black Locate 1,5,"TILT:"

Blue Locate 7,5,P

Blue Locate 21,5,"_deg_"


Example:


April 30, 11:30 AM, at Latitude 40°20'11"


Inputs:

Month:  4

Day:  30

Hours From Noon:  0.5

Latitude:  40°20°11°   ( [ OPTN ], [ F6 ] ( > ), [ F5 ] (ANGLE), [ F4 ] ( ° ' " ))


Result Screen:

MONTH:  4   DAY: 30


DEC:  14.18251427 °


TILT:  34.39287954 °


Solar Energy Reflected


Given an incidence angle and the type of material, the program SOLARENG estimates the ratio of solar reflected.   The program offers three types of material:


Glass, average index of refraction of 1.52 is used

Silicon, average index of refraction of 3.45 is used

Diamond, average index of refraction of 2.417 is used


The program is listed in text file mode.


Casio fx-CG50 Program: SOLARENG

(324 bytes)


'ProgramMode:RUN

Deg

"INCIDENCE ANGLE"?->I

Menu "MATERIAL","GLASS",1,"SILICON",2,"DIAMOND",3

Lbl 1:1.52->R:Goto 4

Lbl 2:3.45->R:Goto 4

Lbl 3:2.417->R:Goto 4

Lbl 4

sin^-1 (sin I/R)->W

0.5*((sin (I-W))^<2>/(sin (I+W))^<2>+(tan (I-W))^<2>/(tan (I+W))^<2>)*100->P

ClrText

Black Locate 1,1,"AT ANGLE "

Black Locate 10,1,I

Black Locate 21,1,"_deg_"

Green Locate 1,2,"INDEX="

Red Locate 9,2,R

Green Locate 1,3,"REFLECT="

Red Locate 9,3,P

Red Locate 21,3,"%"


Example:


Incidence Angle: 6°, glass


Inputs:

INCIDENCE ANGLE: 6

MATERIAL: 1: GLASS


Result Screen:

AT ANGLE 6 °

INDEX = 1.52

REFLECT = 4.25820312 %


HP 32S and HP 32SII Week:  May 2, 2022 - May 6, 2022


Source:


Rosenstein, Morton.  Computing With the Scientific Calculator Casio 1986  ISBN-13:  978-1124161433


Eddie


All original content copyright, © 2011-2022.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 


HP 71B Basic and Casio fx-CG 100: Weighted Random Sample

HP 71B Basic and Casio fx-CG 100: Weighted Random Sample Introduction In calculators, it is fairly easy to generate a rand...