Skip to content

Commit c154171

Browse files
authored
Merge pull request #11 from NREL/FARMS-DNI
FARMS-DNI
2 parents e27e763 + 0d9baf6 commit c154171

File tree

4 files changed

+586
-11
lines changed

4 files changed

+586
-11
lines changed

farms/farms.py

+35-10
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
from farms import CLEAR_TYPES, ICE_TYPES, WATER_TYPES, SOLAR_CONSTANT
2222
import farms.utilities as ut
23+
from farms import farms_dni
2324

2425

2526
def water_phase(tau, De, solar_zenith_angle):
@@ -157,14 +158,32 @@ def farms(tau, cloud_type, cloud_effective_radius, solar_zenith_angle,
157158
158159
Returns
159160
-------
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.
168187
"""
169188
# disable divide by zero warnings
170189
np.seterr(divide='ignore')
@@ -208,6 +227,10 @@ def farms(tau, cloud_type, cloud_effective_radius, solar_zenith_angle,
208227
dni = Fd / solar_zenith_angle # eq 2b from [1]
209228
dhi = ghi - Fd # eq 7 from [1]
210229

230+
Fd, dni_farmsdni, dni0 = farms_dni.farms_dni(F0, tau, solar_zenith_angle,
231+
De, phase, phase1, phase2,
232+
Tddclr, ghi, F1)
233+
211234
clear_mask = np.in1d(cloud_type, CLEAR_TYPES).reshape(cloud_type.shape)
212235
if debug:
213236
# 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,
223246

224247
return fast_data
225248
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

Comments
 (0)