49
49
def all_sky (alpha , aod , asymmetry , cloud_type , cld_opd_dcomp , cld_reff_dcomp ,
50
50
ozone , solar_zenith_angle , ssa , surface_albedo , surface_pressure ,
51
51
time_index , total_precipitable_water , cloud_fill_flag = None ,
52
- variability_kwargs = None , scale_outputs = True , farmsdni = True ):
52
+ variability_kwargs = None , scale_outputs = True , disc_on = False ):
53
53
"""Calculate the all-sky irradiance.
54
54
Updated by Yu Xie on 3/29/2023 to compute DNI by FARMS-DNI.
55
55
@@ -109,8 +109,8 @@ def all_sky(alpha, aod, asymmetry, cloud_type, cld_opd_dcomp, cld_reff_dcomp,
109
109
nsrdb.all_sky.utilities.cloud_variability for kwarg definitions.
110
110
scale_outputs : bool
111
111
Flag to safely scale and dtype convert output arrays.
112
- farmsdni : bool
113
- Compute cloudy-sky DNI using FARMS-DNI (True ) or DISC (False ).
112
+ disc_on : bool
113
+ Compute cloudy-sky DNI using FARMS-DNI (False ) or DISC (True ).
114
114
115
115
Returns
116
116
-------
@@ -163,16 +163,15 @@ def all_sky(alpha, aod, asymmetry, cloud_type, cld_opd_dcomp, cld_reff_dcomp,
163
163
164
164
# use FARMS to calculate cloudy GHI
165
165
ghi , dni_farmsdni , _ = farms (tau = cld_opd_dcomp ,
166
- cloud_type = cloud_type ,
167
- cloud_effective_radius = cld_reff_dcomp ,
168
- solar_zenith_angle = solar_zenith_angle ,
169
- radius = radius ,
170
- Tuuclr = Tuuclr ,
171
- Ruuclr = rest_data .Ruuclr ,
172
- Tddclr = rest_data .Tddclr ,
173
- Tduclr = rest_data .Tduclr ,
174
- albedo = surface_albedo ,
175
- )
166
+ cloud_type = cloud_type ,
167
+ cloud_effective_radius = cld_reff_dcomp ,
168
+ solar_zenith_angle = solar_zenith_angle ,
169
+ radius = radius ,
170
+ Tuuclr = Tuuclr ,
171
+ Ruuclr = rest_data .Ruuclr ,
172
+ Tddclr = rest_data .Tddclr ,
173
+ Tduclr = rest_data .Tduclr ,
174
+ albedo = surface_albedo )
176
175
177
176
# merge the clearsky and cloudy irradiance into all-sky irradiance
178
177
ghi = merge_rest_farms (rest_data .ghi , ghi , cloud_type )
@@ -182,16 +181,13 @@ def all_sky(alpha, aod, asymmetry, cloud_type, cld_opd_dcomp, cld_reff_dcomp,
182
181
ghi = cloud_variability (ghi , rest_data .ghi , cloud_type ,
183
182
** variability_kwargs )
184
183
185
- # calculate the DNI using the DISC model
186
- dni = disc (ghi , solar_zenith_angle , doy = time_index .dayofyear .values ,
187
- pressure = surface_pressure )
188
-
189
184
# merge the clearsky and cloudy irradiance into all-sky irradiance
190
- #
191
- if farmsdni :
192
- dni = merge_rest_farms (rest_data .dni , dni_farmsdni , cloud_type )
193
- else :
185
+ if disc_on :
186
+ dni = disc (ghi , solar_zenith_angle , doy = time_index .dayofyear .values ,
187
+ pressure = surface_pressure )
194
188
dni = merge_rest_farms (rest_data .dni , dni , cloud_type )
189
+ else :
190
+ dni = merge_rest_farms (rest_data .dni , dni_farmsdni , cloud_type )
195
191
196
192
# make a fill flag where bad data exists in the GHI irradiance
197
193
fill_flag = make_fill_flag (ghi , rest_data .ghi , cloud_type , missing_props ,
@@ -239,7 +235,7 @@ def all_sky(alpha, aod, asymmetry, cloud_type, cld_opd_dcomp, cld_reff_dcomp,
239
235
return output
240
236
241
237
242
- def all_sky_h5 (f_source , rows = slice (None ), cols = slice (None )):
238
+ def all_sky_h5 (f_source , rows = slice (None ), cols = slice (None ), disc_on = False ):
243
239
"""Run all-sky from .h5 files.
244
240
245
241
Parameters
@@ -251,6 +247,8 @@ def all_sky_h5(f_source, rows=slice(None), cols=slice(None)):
251
247
Subset of rows to run.
252
248
cols : slice
253
249
Subset of columns to run.
250
+ disc_on : bool
251
+ Compute cloudy sky dni with disc model or farms-dni model.
254
252
255
253
Returns
256
254
-------
@@ -275,6 +273,7 @@ def all_sky_h5(f_source, rows=slice(None), cols=slice(None)):
275
273
all_sky_input = {dset : source [dset , rows , cols ]
276
274
for dset in ALL_SKY_ARGS }
277
275
all_sky_input ['time_index' ] = source .time_index [rows ].tz_convert (None )
276
+ all_sky_input ['disc_on' ] = disc_on
278
277
279
278
try :
280
279
out = all_sky (** all_sky_input )
@@ -286,7 +285,7 @@ def all_sky_h5(f_source, rows=slice(None), cols=slice(None)):
286
285
287
286
288
287
def all_sky_h5_parallel (f_source , rows = slice (None ), cols = slice (None ),
289
- col_chunk = 10 , max_workers = None ):
288
+ col_chunk = 10 , max_workers = None , disc_on = False ):
290
289
"""Run all-sky from .h5 files.
291
290
292
291
Parameters
@@ -304,6 +303,8 @@ def all_sky_h5_parallel(f_source, rows=slice(None), cols=slice(None),
304
303
significantly faster.
305
304
max_workers : int | None
306
305
Number of workers to run in parallel.
306
+ disc_on : bool
307
+ Compute cloudy sky dni with disc model or farms-dni model.
307
308
308
309
Returns
309
310
-------
@@ -361,7 +362,7 @@ def all_sky_h5_parallel(f_source, rows=slice(None), cols=slice(None),
361
362
362
363
loggers = ['farms' , 'nsrdb' , 'rest2' , 'rex' ]
363
364
with SpawnProcessPool (max_workers = max_workers , loggers = loggers ) as exe :
364
- futures = {exe .submit (all_sky_h5 , f_source , rows = rows ,
365
+ futures = {exe .submit (all_sky_h5 , f_source , rows = rows , disc_on = disc_on ,
365
366
cols = c_slices_all [c ]): c for c in c_range }
366
367
367
368
for future in as_completed (futures ):
0 commit comments