python-astro 1.10__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- Astro.py +10 -0
- Geo.py +283 -0
- Moon.py +356 -0
- Sun.py +154 -0
- python_astro-1.10.dist-info/METADATA +12 -0
- python_astro-1.10.dist-info/RECORD +9 -0
- python_astro-1.10.dist-info/WHEEL +5 -0
- python_astro-1.10.dist-info/licenses/LICENSE +674 -0
- python_astro-1.10.dist-info/top_level.txt +4 -0
Sun.py
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import math
|
|
2
|
+
|
|
3
|
+
import Astro
|
|
4
|
+
from Astro import CelestialLocation
|
|
5
|
+
from Date import DateTime, Date, Time
|
|
6
|
+
|
|
7
|
+
RAD = math.pi / 180.0
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Sun:
|
|
11
|
+
def __init__(self, location, datetime):
|
|
12
|
+
self.location = location
|
|
13
|
+
self.datetime = datetime
|
|
14
|
+
|
|
15
|
+
def updateLocation(self, location):
|
|
16
|
+
self.location = location
|
|
17
|
+
|
|
18
|
+
def updateDateTime(self, datetime):
|
|
19
|
+
self.datetime = datetime
|
|
20
|
+
|
|
21
|
+
@property
|
|
22
|
+
def _midnight(self):
|
|
23
|
+
return DateTime(self.datetime.date, Time(0, 0, 0))
|
|
24
|
+
|
|
25
|
+
@property
|
|
26
|
+
def _lw(self):
|
|
27
|
+
return RAD * -self.location.longitude
|
|
28
|
+
|
|
29
|
+
@property
|
|
30
|
+
def _n(self):
|
|
31
|
+
return self._julianCycle(self._midnight.julianday, self._lw)
|
|
32
|
+
|
|
33
|
+
@property
|
|
34
|
+
def _ds(self):
|
|
35
|
+
return self._approxTransit(0.0, self._lw, self._n)
|
|
36
|
+
|
|
37
|
+
@property
|
|
38
|
+
def _M(self):
|
|
39
|
+
return self._solarMeanAnomaly(self._ds)
|
|
40
|
+
|
|
41
|
+
@property
|
|
42
|
+
def _L(self):
|
|
43
|
+
return self._eclipticLongitude(self._M)
|
|
44
|
+
|
|
45
|
+
@property
|
|
46
|
+
def distance(self):
|
|
47
|
+
return 149597870.7 + 2500000.0 * math.cos(
|
|
48
|
+
RAD * (357.5291 + 0.98560028 * self.datetime.julianDay2K)
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
@property
|
|
52
|
+
def celestialLocation(self):
|
|
53
|
+
days = self.datetime.julianDay2K
|
|
54
|
+
M = RAD * (357.5291 + 0.98560028 * days)
|
|
55
|
+
C = RAD * (1.9148 * math.sin(M) + 0.02 * math.sin(2.0 * M) + 0.0003 * math.sin(3.0 * M))
|
|
56
|
+
P = RAD * 102.9372
|
|
57
|
+
L = M + C + P + math.pi
|
|
58
|
+
dec = math.asin(
|
|
59
|
+
math.sin(0.0) * math.cos(Astro.EARTH_OBLIQUITY) +
|
|
60
|
+
math.cos(0.0) * math.sin(Astro.EARTH_OBLIQUITY) * math.sin(L)
|
|
61
|
+
)
|
|
62
|
+
ra = math.atan2(
|
|
63
|
+
math.sin(L) * math.cos(Astro.EARTH_OBLIQUITY) - math.tan(0.0) * math.sin(Astro.EARTH_OBLIQUITY),
|
|
64
|
+
math.cos(L)
|
|
65
|
+
)
|
|
66
|
+
return CelestialLocation(ra, dec)
|
|
67
|
+
|
|
68
|
+
@property
|
|
69
|
+
def noonJD(self):
|
|
70
|
+
return self._solarTransitJ(self._ds, self._M, self._L)
|
|
71
|
+
|
|
72
|
+
@property
|
|
73
|
+
def setJD(self):
|
|
74
|
+
phi = RAD * self.location.latitude
|
|
75
|
+
dec = self._declination(self._L, 0.0)
|
|
76
|
+
h0 = -0.833 * RAD
|
|
77
|
+
w = self._hourAngle(h0, phi, dec)
|
|
78
|
+
a = self._approxTransit(w, self._lw, self._n)
|
|
79
|
+
return self._solarTransitJ(a, self._M, self._L)
|
|
80
|
+
|
|
81
|
+
@property
|
|
82
|
+
def riseJD(self):
|
|
83
|
+
return self.noonJD - (self.setJD - self.noonJD)
|
|
84
|
+
|
|
85
|
+
@property
|
|
86
|
+
def noon(self):
|
|
87
|
+
return DateTime.fromjulianday(self.noonJD)
|
|
88
|
+
|
|
89
|
+
@property
|
|
90
|
+
def set(self):
|
|
91
|
+
return DateTime.fromjulianday(self.setJD)
|
|
92
|
+
|
|
93
|
+
@property
|
|
94
|
+
def rise(self):
|
|
95
|
+
return DateTime.fromjulianday(self.riseJD)
|
|
96
|
+
|
|
97
|
+
def dawnTime(self, angleDegrees):
|
|
98
|
+
return self._timeAtAltitude(-angleDegrees, True)
|
|
99
|
+
|
|
100
|
+
def duskTime(self, angleDegrees):
|
|
101
|
+
return self._timeAtAltitude(-angleDegrees, False)
|
|
102
|
+
|
|
103
|
+
def _timeAtAltitude(self, altitudeDeg, rising):
|
|
104
|
+
phi = RAD * self.location.latitude
|
|
105
|
+
dec = self._declination(self._L, 0.0)
|
|
106
|
+
h0 = altitudeDeg * RAD
|
|
107
|
+
w = self._hourAngle(h0, phi, dec)
|
|
108
|
+
a = self._approxTransit(w, self._lw, self._n)
|
|
109
|
+
Jset = self._solarTransitJ(a, self._M, self._L)
|
|
110
|
+
Jnoon = self.noonJD
|
|
111
|
+
return DateTime.fromjulianday(Jnoon - (Jset - Jnoon) if rising else Jset)
|
|
112
|
+
|
|
113
|
+
def _julianCycle(self, d, lw):
|
|
114
|
+
return round(d - Astro.J2000 - 0.0009 - lw / (2.0 * math.pi))
|
|
115
|
+
|
|
116
|
+
def _approxTransit(self, Ht, lw, n):
|
|
117
|
+
return 0.0009 + (Ht + lw) / (2.0 * math.pi) + n
|
|
118
|
+
|
|
119
|
+
def _solarTransitJ(self, ds, M, L):
|
|
120
|
+
return Astro.J2000 + ds + 0.0053 * math.sin(M) - 0.0069 * math.sin(2.0 * L)
|
|
121
|
+
|
|
122
|
+
def _solarMeanAnomaly(self, daysSinceJ2000):
|
|
123
|
+
return RAD * (357.5291 + 0.98560028 * daysSinceJ2000)
|
|
124
|
+
|
|
125
|
+
def _eclipticLongitude(self, M):
|
|
126
|
+
C = RAD * (1.9148 * math.sin(M) + 0.02 * math.sin(2.0 * M) + 0.0003 * math.sin(3.0 * M))
|
|
127
|
+
P = RAD * 102.9372
|
|
128
|
+
return M + C + P + math.pi
|
|
129
|
+
|
|
130
|
+
def _declination(self, L, b):
|
|
131
|
+
return math.asin(
|
|
132
|
+
math.sin(b) * math.cos(Astro.EARTH_OBLIQUITY) +
|
|
133
|
+
math.cos(b) * math.sin(Astro.EARTH_OBLIQUITY) * math.sin(L)
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
def _rightAscension(self, L, b):
|
|
137
|
+
return math.atan2(
|
|
138
|
+
math.sin(L) * math.cos(Astro.EARTH_OBLIQUITY) - math.tan(b) * math.sin(Astro.EARTH_OBLIQUITY),
|
|
139
|
+
math.cos(L)
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
def _siderealTime(self, daysSinceJ2000, lw):
|
|
143
|
+
return RAD * (280.16 + 360.9856235 * daysSinceJ2000) - lw
|
|
144
|
+
|
|
145
|
+
def _astroRefraction(self, h):
|
|
146
|
+
if h < 0.0:
|
|
147
|
+
h = 0.0
|
|
148
|
+
return 0.0002967 / math.tan(h + 0.00312536 / (h + 0.08901179))
|
|
149
|
+
|
|
150
|
+
def _hourAngle(self, h, phi, dec):
|
|
151
|
+
return math.acos(
|
|
152
|
+
(math.sin(h) - math.sin(phi) * math.sin(dec)) /
|
|
153
|
+
(math.cos(phi) * math.cos(dec))
|
|
154
|
+
)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: python-astro
|
|
3
|
+
Version: 1.10
|
|
4
|
+
Summary: Astronomy utilities — celestial location, sun/moon position calculations, and geo coordinates
|
|
5
|
+
License-Expression: GPL-3.0-or-later
|
|
6
|
+
Requires-Python: >=3.8
|
|
7
|
+
Description-Content-Type: text/plain
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Dist: python-date
|
|
10
|
+
Dynamic: license-file
|
|
11
|
+
|
|
12
|
+
Astronomy utilities — celestial location, sun/moon position calculations, and geo coordinates.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Astro.py,sha256=NV-Xd90Y_FqTn5x3jbAE0XlbwpLQ9uan8j-Lfdtbk8k,226
|
|
2
|
+
Geo.py,sha256=QcQEnSpinPGKHBU-ztUw_hxL4ryMVx47hfCZy8AOkMI,9928
|
|
3
|
+
Moon.py,sha256=n4uRiaXSv8T-ZMhpyv44S5MtRQw7CgP0_CSToeXgLfM,8795
|
|
4
|
+
Sun.py,sha256=-xBwd9ZcIX3jvtly33WW4ZMgGD60d03uOBG6b6OHm7I,4051
|
|
5
|
+
python_astro-1.10.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
6
|
+
python_astro-1.10.dist-info/METADATA,sha256=XjLP6oNIIL4vmaXCvFbzntHWtqYNougvnd81h0D1BI4,426
|
|
7
|
+
python_astro-1.10.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
8
|
+
python_astro-1.10.dist-info/top_level.txt,sha256=wqEI-LQ0S-XOj3Pm7tzRvqGgeLkrzm4AekXRBEIqje8,19
|
|
9
|
+
python_astro-1.10.dist-info/RECORD,,
|