20
20
21
21
from farms import CLEAR_TYPES , ICE_TYPES , WATER_TYPES , SOLAR_CONSTANT
22
22
import farms .utilities as ut
23
+ from farms import farms_dni
23
24
24
25
25
26
def water_phase (tau , De , solar_zenith_angle ):
@@ -157,14 +158,32 @@ def farms(tau, cloud_type, cloud_effective_radius, solar_zenith_angle,
157
158
158
159
Returns
159
160
-------
160
- ghi : np.ndarray
161
- FARMS GHI values (this is the only output if debug is False).
162
- fast_data : collections.namedtuple
163
- Additional debugging variables if debug is True.
164
- Named tuple with irradiance data. Attributes:
165
- ghi : global horizontal irradiance (w/m2)
166
- dni : direct normal irradiance (w/m2)
167
- dhi : diffuse horizontal irradiance (w/m2)
161
+ If debug == True:
162
+ fast_data : collections.namedtuple
163
+ Named tuple with irradiance data with the following attributes:
164
+ ghi : np.ndarray
165
+ global horizontal irradiance (W/m2)
166
+ dni : np.ndarray
167
+ direct normal irradiance (W/m2)
168
+ dhi : np.ndarray
169
+ diffuse horizontal irradiance (W/m2)
170
+ Ruucld : np.ndarray
171
+ Aerosol reflectance for diffuse fluxes for cloudy
172
+ atmosphere.
173
+ Tddcld : np.ndarray
174
+ Transmittance of the cloudy atmosphere for direct incident
175
+ and direct outgoing fluxes (dd).
176
+ Tducld : np.ndarray
177
+ Transmittance of the cloudy atmosphere for direct incident
178
+ and diffuse outgoing fluxes (du).
179
+ else:
180
+ ghi: np.ndarray
181
+ Global horizontal irradiance (W/m2)
182
+ dni_farmsdni: np.ndarray
183
+ DNI computed by FARMS-DNI (W/m2).
184
+ dni0: np.ndarray
185
+ DNI computed by the Lambert law (W/m2). It only includes the narrow
186
+ beam in the circumsolar region.
168
187
"""
169
188
# disable divide by zero warnings
170
189
np .seterr (divide = 'ignore' )
@@ -208,6 +227,10 @@ def farms(tau, cloud_type, cloud_effective_radius, solar_zenith_angle,
208
227
dni = Fd / solar_zenith_angle # eq 2b from [1]
209
228
dhi = ghi - Fd # eq 7 from [1]
210
229
230
+ Fd , dni_farmsdni , dni0 = farms_dni .farms_dni (F0 , tau , solar_zenith_angle ,
231
+ De , phase , phase1 , phase2 ,
232
+ Tddclr , ghi , F1 )
233
+
211
234
clear_mask = np .in1d (cloud_type , CLEAR_TYPES ).reshape (cloud_type .shape )
212
235
if debug :
213
236
# Return NaN if clear-sky, else return cloudy sky data
@@ -223,5 +246,7 @@ def farms(tau, cloud_type, cloud_effective_radius, solar_zenith_angle,
223
246
224
247
return fast_data
225
248
else :
226
- # return only GHI
227
- return np .where (clear_mask , np .nan , ghi )
249
+ out = (np .where (clear_mask , np .nan , ghi ),
250
+ np .where (clear_mask , np .nan , dni_farmsdni ),
251
+ np .where (clear_mask , np .nan , dni0 ))
252
+ return out
0 commit comments