@@ -261,16 +261,16 @@ def martin_ruiz_spectral_modifier(clearness_index, airmass_absolute,
261
261
airmass_absolute : numeric
262
262
Absolute airmass. Give attention to algorithm used (``kasten1966`` is
263
263
recommended for default parameters of ``monosi``, ``polysi`` and
264
- ``asi``, as used in [1]_).
264
+ ``asi``, see reference [1]_).
265
265
266
266
cell_type : string or None, default None
267
267
Specifies material of the cell in order to infer model parameters.
268
268
Allowed types are ``monosi``, ``polysi`` and ``asi``, either lower or
269
269
upper case. If None, the parameters must be provided.
270
270
271
271
model_parameters : dict-like or None, default None
272
- In case you want to specify your model parameters use a dict or a
273
- ``pd.DataFrame`` as follows:
272
+ In case you want to specify your model parameters and components
273
+ use a dict or a ``pd.DataFrame`` as follows:
274
274
275
275
.. code-block:: python
276
276
@@ -283,8 +283,7 @@ def martin_ruiz_spectral_modifier(clearness_index, airmass_absolute,
283
283
# Using a pd.DataFrame
284
284
model_parameters = pd.DataFrame({
285
285
'direct': [a1, b1, c1],
286
- 'sky diffuse': [a2, b2, c2],
287
- 'ground diffuse': [a3, b3, c3]},
286
+ 'diffuse': [a2, b2, c2]},
288
287
index=('a', 'b', 'c'))
289
288
290
289
``a``, ``b`` and ``c`` must be scalar.
@@ -300,7 +299,7 @@ def martin_ruiz_spectral_modifier(clearness_index, airmass_absolute,
300
299
Raises
301
300
------
302
301
ValueError
303
- If ``model_parameters`` is not suitable. See example given above.
302
+ If ``model_parameters`` is not suitable. See examples given above.
304
303
TypeError
305
304
If neither ``cell_type`` nor ``model_parameters`` are given.
306
305
NotImplementedError
@@ -311,7 +310,7 @@ def martin_ruiz_spectral_modifier(clearness_index, airmass_absolute,
311
310
The mismatch modifier is defined as
312
311
313
312
.. math:: M = c \cdot \exp( a \cdot (K_t - 0.74) + b \cdot (AM - 1.5) )
314
-
313
+
315
314
where ``a``, ``b`` and ``c`` are the model parameters, different for each
316
315
irradiance component.
317
316
@@ -329,11 +328,11 @@ def martin_ruiz_spectral_modifier(clearness_index, airmass_absolute,
329
328
pvlib.atmosphere.first_solar_spectral_correction
330
329
"""
331
330
332
- IRRAD_COMPONENTS = ('direct' , 'sky_diffuse' , 'ground_diffuse' )
331
+ irrad_components = ('direct' , 'sky_diffuse' , 'ground_diffuse' )
333
332
# Fitting parameters directly from [1]_
334
333
MARTIN_RUIZ_PARAMS = pd .DataFrame (
335
334
index = ('monosi' , 'polysi' , 'asi' ),
336
- columns = pd .MultiIndex .from_product ([IRRAD_COMPONENTS ,
335
+ columns = pd .MultiIndex .from_product ([irrad_components ,
337
336
('c' , 'a' , 'b' )]),
338
337
data = [ # Direct(c,a,b) | Sky diffuse(c,a,b) | Ground diffuse(c,a,b)
339
338
[1.029 , - .313 , 524e-5 , .764 , - .882 , - .0204 , .970 , - .244 , .0129 ],
@@ -354,14 +353,13 @@ def martin_ruiz_spectral_modifier(clearness_index, airmass_absolute,
354
353
elif cell_type is None and model_parameters is None :
355
354
raise TypeError ('You must pass at least "cell_type" '
356
355
'or "model_parameters" as arguments!' )
357
- elif model_parameters is not None :
358
- # Use user-defined model parameters
359
- # Validate 'model_parameters' dict keys and sub-dicts keys
360
- if (set (IRRAD_COMPONENTS ) != model_parameters .keys ()):
361
- raise ValueError ('You must specify model parameters for exact '
362
- f'irradiance components { IRRAD_COMPONENTS } ' )
363
- if any ([{'a' , 'b' , 'c' } != model_parameters [irrad_type ].keys ()
364
- for irrad_type in IRRAD_COMPONENTS ]):
356
+ elif model_parameters is not None : # Use user-defined model parameters
357
+ # Overwrite components, to later iterate over them,
358
+ # in case user wants to specify their components
359
+ irrad_components = model_parameters .keys ()
360
+ # Validate 'model_parameters' sub-dicts keys
361
+ if any ([{'a' , 'b' , 'c' } != set (model_parameters [component ].keys ())
362
+ for component in irrad_components ]):
365
363
raise ValueError ("You must specify model parameters with keys "
366
364
"'a','b','c' for each irradiation component." )
367
365
@@ -376,9 +374,8 @@ def martin_ruiz_spectral_modifier(clearness_index, airmass_absolute,
376
374
377
375
modifiers = pd .Series ()
378
376
379
- # Order of irradiations shouldn't be changed
380
377
# Values are tested in return order in test_martin_ruiz_spectral_modifier
381
- for irrad_type in IRRAD_COMPONENTS :
378
+ for irrad_type in irrad_components :
382
379
_coeffs = _params [irrad_type ]
383
380
384
381
modifier = _coeffs ['c' ] * np .exp (_coeffs ['a' ] * kt_delta
0 commit comments