|
37 | 37 | 'dirty steel': 0.08}
|
38 | 38 |
|
39 | 39 |
|
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): |
42 | 42 | """
|
43 | 43 | Determine extraterrestrial radiation from day of year.
|
44 | 44 |
|
@@ -86,6 +86,40 @@ def extraradiation(datetime_or_doy, solar_constant=1366.1, method='spencer',
|
86 | 86 | Thermal Processes, 2nd edn. J. Wiley and Sons, New York.
|
87 | 87 | """
|
88 | 88 |
|
| 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): |
89 | 123 | # This block will set the functions that can be used to convert the
|
90 | 124 | # inputs to either day of year or pandas DatetimeIndex, and the
|
91 | 125 | # 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',
|
118 | 152 | epoch_year=epoch_year)
|
119 | 153 | to_output = tools._array_out
|
120 | 154 |
|
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 |
144 | 156 |
|
145 | 157 |
|
146 | 158 | def aoi_projection(surface_tilt, surface_azimuth, solar_zenith, solar_azimuth):
|
|
0 commit comments