-
-
Notifications
You must be signed in to change notification settings - Fork 88
Expand file tree
/
Copy pathellipsoid.py
More file actions
194 lines (163 loc) · 6.65 KB
/
ellipsoid.py
File metadata and controls
194 lines (163 loc) · 6.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
"""Minimal class for planetary ellipsoids"""
from __future__ import annotations
from math import sqrt
from dataclasses import dataclass, field
from typing import TypedDict
class Model(TypedDict):
"""Ellipsoid parameters"""
name: str
a: float
b: float
@dataclass
class Ellipsoid:
"""
generate reference ellipsoid parameters
as everywhere else in pymap3d, distance units are METERS
Ellipsoid sources
-----------------
maupertuis, plessis, everest1830, everest1830m, everest1967,
airy, bessel, clarke1866, clarke1878, clarke1860, helmert, hayford,
international1924, krassovsky1940, wgs66, australian, international1967,
grs67, sa1969, wgs72, iers1989, iers2003:
- https://en.wikipedia.org/wiki/Earth_ellipsoid#Historical_Earth_ellipsoids
- https://en.wikibooks.org/wiki/PROJ.4#Spheroid
wgs84: https://en.wikipedia.org/wiki/World_Geodetic_System#WGS84
wgs84_mean: https://en.wikipedia.org/wiki/Earth_radius#Mean_radii
grs80: https://en.wikipedia.org/wiki/GRS_80
io: https://doi.org/10.1006/icar.1998.5987
pz90.11: https://structure.mil.ru/files/pz-90.pdf
gsk2011: https://racurs.ru/downloads/documentation/gost_r_32453-2017.pdf
mars: https://tharsis.gsfc.nasa.gov/geodesy.html
mercury, venus, moon, jupiter, saturn, uranus, neptune:
- https://nssdc.gsfc.nasa.gov/planetary/factsheet/index.html
feel free to suggest additional ellipsoids
"""
model: str # short name
name: str # name for printing
semimajor_axis: float
semiminor_axis: float
flattening: float
thirdflattening: float
eccentricity: float
models = field(default_factory=dict[str, Model])
def __init__(
self,
semimajor_axis: float,
semiminor_axis: float,
name: str = "",
model: str = "",
flattening: float | None = None,
thirdflattening: float | None = None,
eccentricity: float | None = None,
):
"""
Ellipsoidal model of world
Parameters
----------
semimajor_axis : float
semimajor axis in meters
semiminor_axis : float
semiminor axis in meters
name: str, optional
Human-friendly name for the ellipsoid
model: str, optional
Short name for the ellipsoid
"""
self.flattening = (
flattening
if flattening is not None
else (semimajor_axis - semiminor_axis) / semimajor_axis
)
assert self.flattening >= 0, "flattening must be >= 0"
self.thirdflattening = (
thirdflattening
if thirdflattening is not None
else (semimajor_axis - semiminor_axis) / (semimajor_axis + semiminor_axis)
)
self.eccentricity = (
eccentricity
if eccentricity is not None
else sqrt(2 * self.flattening - self.flattening**2)
)
self.name = name
self.model = model
self.semimajor_axis = semimajor_axis
self.semiminor_axis = semiminor_axis
models = {
# Earth ellipsoids
"maupertuis": {"name": "Maupertuis (1738)", "a": 6397300.0, "b": 6363806.283},
"plessis": {"name": "Plessis (1817)", "a": 6376523.0, "b": 6355862.9333},
"everest1830": {"name": "Everest (1830)", "a": 6377299.365, "b": 6356098.359},
"everest1830m": {
"name": "Everest 1830 Modified (1967)",
"a": 6377304.063,
"b": 6356103.039,
},
"everest1967": {
"name": "Everest 1830 (1967 Definition)",
"a": 6377298.556,
"b": 6356097.55,
},
"airy": {"name": "Airy (1830)", "a": 6377563.396, "b": 6356256.909},
"bessel": {"name": "Bessel (1841)", "a": 6377397.155, "b": 6356078.963},
"clarke1866": {"name": "Clarke (1866)", "a": 6378206.4, "b": 6356583.8},
"clarke1878": {"name": "Clarke (1878)", "a": 6378190.0, "b": 6356456.0},
"clarke1860": {"name": "Clarke (1880)", "a": 6378249.145, "b": 6356514.87},
"helmert": {"name": "Helmert (1906)", "a": 6378200.0, "b": 6356818.17},
"hayford": {"name": "Hayford (1910)", "a": 6378388.0, "b": 6356911.946},
"international1924": {
"name": "International (1924)",
"a": 6378388.0,
"b": 6356911.946,
},
"krassovsky1940": {
"name": "Krassovsky (1940)",
"a": 6378245.0,
"b": 6356863.019,
},
"wgs66": {"name": "WGS66 (1966)", "a": 6378145.0, "b": 6356759.769},
"australian": {
"name": "Australian National (1966)",
"a": 6378160.0,
"b": 6356774.719,
},
"international1967": {
"name": "New International (1967)",
"a": 6378157.5,
"b": 6356772.2,
},
"grs67": {"name": "GRS-67 (1967)", "a": 6378160.0, "b": 6356774.516},
"sa1969": {"name": "South American (1969)", "a": 6378160.0, "b": 6356774.719},
"wgs72": {"name": "WGS-72 (1972)", "a": 6378135.0, "b": 6356750.52001609},
"grs80": {"name": "GRS-80 (1979)", "a": 6378137.0, "b": 6356752.31414036},
"wgs84": {"name": "WGS-84 (1984)", "a": 6378137.0, "b": 6356752.31424518},
"wgs84_mean": {
"name": "WGS-84 (1984) Mean",
"a": 6371008.7714,
"b": 6371008.7714,
},
"iers1989": {"name": "IERS (1989)", "a": 6378136.0, "b": 6356751.302},
"pz90.11": {"name": "ПЗ-90 (2011)", "a": 6378136.0, "b": 6356751.3618},
"iers2003": {"name": "IERS (2003)", "a": 6378136.6, "b": 6356751.9},
"gsk2011": {"name": "ГСК (2011)", "a": 6378136.5, "b": 6356751.758},
# Other worlds
"mercury": {"name": "Mercury", "a": 2440500.0, "b": 2438300.0},
"venus": {"name": "Venus", "a": 6051800.0, "b": 6051800.0},
"moon": {"name": "Moon", "a": 1738100.0, "b": 1736000.0},
"mars": {"name": "Mars", "a": 3396900.0, "b": 3376097.80585952},
"jupyter": {"name": "Jupiter", "a": 71492000.0, "b": 66770054.3475922},
"io": {"name": "Io", "a": 1829.7, "b": 1815.8},
"saturn": {"name": "Saturn", "a": 60268000.0, "b": 54364301.5271271},
"uranus": {"name": "Uranus", "a": 25559000.0, "b": 24973000.0},
"neptune": {"name": "Neptune", "a": 24764000.0, "b": 24341000.0},
"pluto": {"name": "Pluto", "a": 1188000.0, "b": 1188000.0},
}
@classmethod
def from_name(cls, name: str) -> Ellipsoid:
"""Create an Ellipsoid from a name."""
return cls(
cls.models[name]["a"],
cls.models[name]["b"],
name=cls.models[name]["name"],
model=name,
)