Skip to content

Commit a8eb819

Browse files
committed
extraradiation to get_extra_radiation
1 parent 26f9224 commit a8eb819

File tree

2 files changed

+39
-25
lines changed

2 files changed

+39
-25
lines changed

docs/sphinx/source/whatsnew/v0.5.2.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ API Changes
1111
* Added irradiance.poa_components. Function is the same as the now-deprecated
1212
irradiance.globalinplane, but adds 'poa_sky_diffuse' and
1313
'poa_ground_diffuse' to the output. (:issue:`422`)
14+
* Deprecated irradiance.extraradiation. Use irradiance.extra_radiation instead.
15+
irradiance.extraradiation will be removed in 0.5. (:issue:`422`)
1416

1517
Enhancements
1618
~~~~~~~~~~~~

pvlib/irradiance.py

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
'dirty steel': 0.08}
3838

3939

40-
def extraradiation(datetime_or_doy, solar_constant=1366.1, method='spencer',
41-
epoch_year=2014, **kwargs):
40+
def get_extra_radiation(datetime_or_doy, solar_constant=1366.1,
41+
method='spencer', epoch_year=2014, **kwargs):
4242
"""
4343
Determine extraterrestrial radiation from day of year.
4444
@@ -86,6 +86,40 @@ def extraradiation(datetime_or_doy, solar_constant=1366.1, method='spencer',
8686
Thermal Processes, 2nd edn. J. Wiley and Sons, New York.
8787
"""
8888

89+
to_doy, to_datetimeindex, to_output = \
90+
_handle_extra_radiation_types(datetime_or_doy, epoch_year)
91+
92+
# consider putting asce and spencer methods in their own functions
93+
method = method.lower()
94+
if method == 'asce':
95+
B = solarposition._calculate_simple_day_angle(to_doy(datetime_or_doy))
96+
RoverR0sqrd = 1 + 0.033 * np.cos(B)
97+
elif method == 'spencer':
98+
B = solarposition._calculate_simple_day_angle(to_doy(datetime_or_doy))
99+
RoverR0sqrd = (1.00011 + 0.034221 * np.cos(B) + 0.00128 * np.sin(B) +
100+
0.000719 * np.cos(2 * B) + 7.7e-05 * np.sin(2 * B))
101+
elif method == 'pyephem':
102+
times = to_datetimeindex(datetime_or_doy)
103+
RoverR0sqrd = solarposition.pyephem_earthsun_distance(times) ** (-2)
104+
elif method == 'nrel':
105+
times = to_datetimeindex(datetime_or_doy)
106+
RoverR0sqrd = \
107+
solarposition.nrel_earthsun_distance(times, **kwargs) ** (-2)
108+
else:
109+
raise ValueError('Invalid method: %s', method)
110+
111+
Ea = solar_constant * RoverR0sqrd
112+
113+
Ea = to_output(Ea)
114+
115+
return Ea
116+
117+
118+
extraradiation = deprecated('0.5.2', alternative='get_extra_radiation',
119+
name='extraradiation')(get_extra_radiation)
120+
121+
122+
def _handle_extra_radiation_types(datetime_or_doy, epoch_year):
89123
# This block will set the functions that can be used to convert the
90124
# inputs to either day of year or pandas DatetimeIndex, and the
91125
# functions that will yield the appropriate output type. It's
@@ -118,29 +152,7 @@ def extraradiation(datetime_or_doy, solar_constant=1366.1, method='spencer',
118152
epoch_year=epoch_year)
119153
to_output = tools._array_out
120154

121-
method = method.lower()
122-
if method == 'asce':
123-
B = solarposition._calculate_simple_day_angle(to_doy(datetime_or_doy))
124-
RoverR0sqrd = 1 + 0.033 * np.cos(B)
125-
elif method == 'spencer':
126-
B = solarposition._calculate_simple_day_angle(to_doy(datetime_or_doy))
127-
RoverR0sqrd = (1.00011 + 0.034221 * np.cos(B) + 0.00128 * np.sin(B) +
128-
0.000719 * np.cos(2 * B) + 7.7e-05 * np.sin(2 * B))
129-
elif method == 'pyephem':
130-
times = to_datetimeindex(datetime_or_doy)
131-
RoverR0sqrd = solarposition.pyephem_earthsun_distance(times) ** (-2)
132-
elif method == 'nrel':
133-
times = to_datetimeindex(datetime_or_doy)
134-
RoverR0sqrd = \
135-
solarposition.nrel_earthsun_distance(times, **kwargs) ** (-2)
136-
else:
137-
raise ValueError('Invalid method: %s', method)
138-
139-
Ea = solar_constant * RoverR0sqrd
140-
141-
Ea = to_output(Ea)
142-
143-
return Ea
155+
return to_doy, to_datetimeindex, to_output
144156

145157

146158
def aoi_projection(surface_tilt, surface_azimuth, solar_zenith, solar_azimuth):

0 commit comments

Comments
 (0)