-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsolpos.py
205 lines (196 loc) · 7.77 KB
/
solpos.py
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
195
196
197
198
199
200
201
202
203
204
205
from typing import NamedTuple
from _solpos import _solpos
class SolposResult(NamedTuple):
"""Container for the results returned by :func:`solpos.solpos`.
:param year: 4-digit year
:param month: Month number (Jan = 1, Feb = 2, etc.)
:param day: Day of month (May 27 = 27, etc.)
:param hour: Hour of day, 0 - 24. (Time 24:00:00 is treated internally as
time 00:00:00 of the following day.)
:param minute: Minute of hour, 0 - 59
:param second: Second of minute, 0 - 59
:param timezone: Time zone, east (west negative). USA: Mountain = -7, Central = -6, etc.
:param latitude: Latitude, *degrees* north (south negative)
:param longitude: Longitude, *degrees* east (west negative)
:param interval: Interval of a measurement period in *seconds*
:param aspect: Azimuth of panel surface in *degrees* (direction it faces)
N=0, E=90, S=180, W=270.
:param press: Surface pressure, *millibars*
:param sbwid: Shadow-band width (*cm*)
:param sbrad: Shadow-band radius (*cm*)
:param sbsky: Shadow-band sky factor (-1 - 1)
:param solcon: Solar constant (*W/m²*)
:param temp: Ambient dry-bulb temperature, *degrees C*
:param tilt: *Degrees* tilt from horizontal of panel (-180 - 180)
:param amass: Relative optical airmass
:param ampress: Pressure-corrected airmass
:param azim: Solar azimuth angle (*degrees*): N=0, E=90, S=180,W=270
:param cosinc: Cosine of solar incidence angle on panel
:param coszen: Cosine of refraction corrected solar zenith angle
:param dayang: Day angle :math:`\\frac{daynum * 360}{year\\_length}`, *degrees*
:param declin: Declination-zenith angle of solar noon at equator *degrees NORTH*
:param eclong: Ecliptic longitude, *degrees*
:param ecobli: Obliquity of ecliptic
:param ectime: Time of ecliptic calculations
:param elevetr: Solar elevation, no atmospheric correction (= ETR)
:param elevref: Solar elevation angle, *degrees* from horizon, refracted
:param eqntim: Equation of time (TST - LMT), *minutes*
:param erv: Earth radius vector(multiplied to solar constant)
:param etr: Extraterrestrial (top-of-atmosphere) *W/m²* global horizontal solar irradiance
:param etrn: Extraterrestrial (top-of-atmosphere) *W/m²* direct normal solar irradiance
:param etrtilt: Extraterrestrial (top-of-atmosphere) *W/m²* global irradiance on a tilted surface
:param gmst: Greenwich mean sidereal time, *hours*
:param hrang: Hour angle--hour of sun from solar noon *degrees WEST*
:param julday: Julian Day of 1 JAN 2000 minus 2,400,000 days (in order to regain single precision)
:param lmst: Local mean sidereal time, *degrees*
:param mnanom: Mean anomaly, *degrees*
:param mnlong: Mean longitude, *degrees*
:param rascen: Right ascension, *degrees*
:param press: Surface pressure, *millibars*, used for refraction correction and ``ampress``
:param prime: Factor that normalizes :math:`K_t`, :math:`K_n`, etc.
:param sbcf: Shadow-band correction factor
:param sbwid: Shadow-band width (*cm*)
:param sbrad: Shadow-band radius (*cm*)
:param sbsky: Shadow-band sky factor
:param solcon: Solar constant, *W/m²*
:param ssha: Sunset(/rise) hour angle, *degrees*
:param sretr: Sunrise time, minutes from midnight, local, **without** refraction
:param ssetr: Sunset time, minutes from midnight, local, **without** refraction
:param temp: Ambient dry-bulb temperature, *degrees C*, used for refraction correction
:param tilt: *Degrees* tilt from horizontal of panel
:param tst: True solar time, *minutes* from midnight
:param tstfix: True solar time - local standard time
:param unprime: Factor that denormalizes :math:`K_t'`, :math:`K_n'`, etc.
:param utime: Universal (Greenwich) standard time
:param zenetr: Solar zenith angle, no atmospheric correction (= ETR)
:param zenref: Solar zenith angle, *degrees* from zenith, refracted.
""" # noqa: E501
year: int
month: int
day: int
hour: int
minute: int
second: float
timezone: float
interval: int
latitude: float
longitude: float
amass: float
ampress: float
aspect: float
azim: float
cosinc: float
coszen: float
dayang: float
declin: float
eclong: float
ecobli: float
ectime: float
elevetr: float
elevref: float
eqntim: float
erv: float
etr: float
etrn: float
etrtilt: float
gmst: float
hrang: float
julday: float
lmst: float
mnanom: float
mnlong: float
rascen: float
press: float
prime: float
sbcf: float
sbwid: float
sbrad: float
sbsky: float
solcon: float
ssha: float
sretr: float
ssetr: float
temp: float
tilt: float
tst: float
tstfix: float
unprime: float
utime: float
zenetr: float
zenref: float
def solpos(
year: int,
month: int,
day: int,
hour: int,
minute: int,
second: int,
timezone: float,
*,
latitude: float,
longitude: float,
interval: int = 0,
aspect: float = 180.0,
press: float = 1013.0,
sbwid: float = 7.6,
sbrad: float = 31.7,
sbsky: float = 0.04,
solcon: float = 1367.0,
temp: float = 15.0,
tilt: float = 0.0,
) -> SolposResult:
"""Computes the solar position and intensity from time and place.
The underlying ``posdata pdat->function`` struct is set to ``S_ALL``
meaning all possible parameters are calculated using the defaults or the
user defined values.
:param year: 4-digit year (2-digit years are **NOT** allowed)
:param month: Month number (Jan = 1, Feb = 2, etc.)
:param day: Day of month (May 27 = 27, etc.)
:param hour: Hour of day, 0 - 24. (Time 24:00:00 is treated internally as
time 00:00:00 of the following day.)
:param minute: Minute of hour, 0 - 59
:param second: Second of minute, 0 - 59
:param timezone: Time zone, east (west negative). USA: Mountain = -7,
Central = -6, etc.
:param latitude: Latitude, *degrees* north (south negative)
:param longitude: Longitude, *degrees* east (west negative)
:param interval: Interval of a measurement period in *seconds*. Forces
solpos to use the time and date from the interval midpoint. The input
time (``hour``, ``minute``, and ``second``) is assumed to be the
**END** of the measurement interval (right labelled) (default: ``0.0``)
:param aspect: Azimuth of panel surface in *degrees* (direction it faces)
N=0, E=90, S=180, W=270. (default: ``180.0``)
:param press: Surface pressure, *millibars*, used for refraction correction
and ampress (default: ``1013.0``)
:param sbwid: Shadow-band width (*cm*) (default: ``7.6``)
:param sbrad: Shadow-band radius (*cm*) (default: ``31.7``)
:param sbsky: Shadow-band sky factor (-1 - 1) (default: ``0.04``)
:param solcon: Solar constant (NREL uses 1367 *W/m²*) (default: ``1367.0``)
:param temp: Ambient dry-bulb temperature, *degrees C*, used for refraction
correction (default: ``15.0``)
:param tilt: *Degrees* tilt from horizontal of panel (-180 - 180)
(default: ``0.0``)
:return: A :func:`solpos.SolposResult` object with all parameters that
SOLPOS is able to calculate (including all input parameters)
"""
result = _solpos(
year=year,
month=month,
day=day,
hour=hour,
minute=minute,
second=second,
timezone=timezone,
latitude=latitude,
longitude=longitude,
interval=interval,
aspect=aspect,
press=press,
sbwid=sbwid,
sbrad=sbrad,
sbsky=sbsky,
solcon=solcon,
temp=temp,
tilt=tilt,
)
return SolposResult(**result)