Skip to content

Commit 62cf064

Browse files
committed
clean up rebase. shorten long lines
1 parent 5279c74 commit 62cf064

File tree

1 file changed

+97
-84
lines changed

1 file changed

+97
-84
lines changed

pvlib/atmosphere.py

Lines changed: 97 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -239,31 +239,37 @@ def relativeairmass(zenith, model='kastenyoung1989'):
239239
try:
240240
am[z > 90] = np.nan
241241
except TypeError:
242-
<<<<<<< d0f47c72742abc87169ec1e15705b75bb8affb88
243242
am = np.nan if z > 90 else am
244243

245244
return am
246-
=======
247-
AM = np.nan if z > 90 else AM
248-
249-
return AM
250245

251246

252247
def calc_pw(temp_air, relative_humidity):
253248
"""
254-
Calculates precipitable water (cm) from ambient air temperature (C) and
255-
relatively humidity (%) using an empirical model [1]. The model was
256-
developed by expanding Eq. 1 in [2]:
257-
w = 0.1 H_v \rho_v
249+
Calculates precipitable water (cm) from ambient air temperature (C)
250+
and relatively humidity (%) using an empirical model [1]. The model
251+
was developed by expanding Eq. 1 in [2]:
252+
.. math::
253+
254+
w = 0.1 H_v \rho_v
255+
258256
using Eq. 2 in [2]
259-
\rho_v = 216.7 RH/T e_s
260-
H_v is the apparant water vapor scale height (km). The expression for
261-
H_v is Eq. 4 in [2]:
262-
H_v = 0.4976 + 1.5265.*T./273.15 + exp(13.6897.*T./273.15 - 14.9188.*(T./273.15).^3)
263-
\rho_v is the surface water vapor density (g/m^3). In the expression
264-
\rho_v, e_s is the saturation water vapor pressure (millibar). The
265-
expression for e_s is Eq. 1 in [3]
266-
e_s = exp(22.330 - 49.140.*(100./T) - 10.922.*(100./T).^2 - 0.39015.*T./100)
257+
.. math::
258+
259+
\rho_v = 216.7 RH/T e_s
260+
261+
H_v is the apparant water vapor scale height (km). The expression
262+
for H_v is Eq. 4 in [2]:
263+
.. math::
264+
265+
H_v = 0.4976 + 1.5265*T/273.15 + exp(13.6897*T/273.15 - 14.9188*(T/273.15)^3)
266+
267+
\rho_v is the surface water vapor density (g/m^3). In the
268+
expression \rho_v, e_s is the saturation water vapor pressure
269+
(millibar). The expression for e_s is Eq. 1 in [3]
270+
.. math::
271+
272+
e_s = exp(22.330 - 49.140*(100./T) - 10.922*(100./T).^2 - 0.39015*T/100)
267273
268274
Parameters
269275
----------
@@ -273,13 +279,13 @@ def calc_pw(temp_air, relative_humidity):
273279
relative humidity at the surface (%)
274280
275281
Returns
276-
-------
282+
-------
277283
pw : array-like
278284
precipitable water (cm)
279285
280286
Reference:
281-
[1] W. M. Keogh and A. W. Blakers, Accurate Measurement, Using Natural
282-
Sunlight, of Silicon Solar Cells, Prog. in Photovoltaics: Res.
287+
[1] W. M. Keogh and A. W. Blakers, Accurate Measurement, Using Natural
288+
Sunlight, of Silicon Solar Cells, Prog. in Photovoltaics: Res.
283289
and Appl. 2004, vol 12, pp. 1-19 (DOI: 10.1002/pip.517)
284290
[2] C. Gueymard, Analysis of Monthly Average Atmospheric Precipitable
285291
Water and Turbidity in Canada and Northern United States,
@@ -296,7 +302,7 @@ def calc_pw(temp_air, relative_humidity):
296302
#RH[RH>100 | RH<=0] = NaN; #Filter RH for unreasonable Values
297303

298304
# Eq. 1 from Keogh and Blakers
299-
pw = ( 0.1 *
305+
pw = ( 0.1 *
300306
(0.4976 + 1.5265*T/273.15 +
301307
np.exp(13.6897*T/273.15 - 14.9188*(T/273.15)**3)) *
302308
(216.7*RH/(100.*T)*np.exp(22.330 - 49.140*(100./T) -
@@ -310,33 +316,37 @@ def calc_pw(temp_air, relative_humidity):
310316
def first_solar_spectral_correction(pw, airmass_absolute, module_type=None,
311317
coefficients=None):
312318
"""
313-
Spectral mismatch modifier based on precipitable water and
314-
absolute (pressure corrected) airmass.
315-
316-
Estimates a spectral mismatch modifier M representing the effect on
317-
module short circuit current of variation in the spectral irradiance.
318-
M is estimated from absolute (pressure currected) air mass, AMa, and
319-
precipitable water, Pwat, using the following function:
320-
321-
M = coeff(1) + coeff(2)*AMa + coeff(3)*Pwat + coeff(4)*AMa.^.5
322-
+ coeff(5)*Pwat.^.5 + coeff(6)*AMa./Pwat (1)
323-
324-
Default coefficients are determined for several cell types with
325-
known quantum efficiency curves, by using the Simple Model of the
326-
Atmospheric Radiative Transfer of Sunshine (SMARTS) [1].
327-
Using SMARTS, spectrums are simulated with all combinations of AMa
328-
and Pwat where:
329-
* 0.5 cm <= Pwat <= 5 cm
330-
* 0.8 <= AMa <= 4.75 (Pressure of 800 mbar and 1.01 <= AM <= 6)
331-
* Spectral range is limited to that of CMP11 (280 nm to 2800 nm)
332-
* spectrum simulated on a plane normal to the sun
333-
* All other parameters fixed at G173 standard
334-
From these simulated spectra, M is calculated using the known quantum
335-
efficiency curves. Multiple linear regression is then applied to fit
336-
Eq. 1 to determine the coefficients for each module.
337-
338-
Based on the PVLIB Matlab function pvl_FSspeccorr
339-
by Mitchell Lee and Alex Panchula, at First Solar, 2015.
319+
Spectral mismatch modifier based on precipitable water and absolute
320+
(pressure corrected) airmass.
321+
322+
Estimates a spectral mismatch modifier M representing the effect on
323+
module short circuit current of variation in the spectral
324+
irradiance. M is estimated from absolute (pressure currected) air
325+
mass, AMa, and precipitable water, Pwat, using the following
326+
function:
327+
328+
.. math::
329+
M = coeff(1) + coeff(2)*AMa + coeff(3)*Pwat + coeff(4)*AMa^.5
330+
+ coeff(5)*Pwat^.5 + coeff(6)*AMa/Pwat
331+
332+
Default coefficients are determined for several cell types with
333+
known quantum efficiency curves, by using the Simple Model of the
334+
Atmospheric Radiative Transfer of Sunshine (SMARTS) [1]. Using
335+
SMARTS, spectrums are simulated with all combinations of AMa and
336+
Pwat where:
337+
338+
* 0.5 cm <= Pwat <= 5 cm
339+
* 0.8 <= AMa <= 4.75 (Pressure of 800 mbar and 1.01 <= AM <= 6)
340+
* Spectral range is limited to that of CMP11 (280 nm to 2800 nm)
341+
* spectrum simulated on a plane normal to the sun
342+
* All other parameters fixed at G173 standard
343+
344+
From these simulated spectra, M is calculated using the known
345+
quantum efficiency curves. Multiple linear regression is then
346+
applied to fit Eq. 1 to determine the coefficients for each module.
347+
348+
Based on the PVLIB Matlab function pvl_FSspeccorr by Mitchell Lee
349+
and Alex Panchula, at First Solar, 2015.
340350
341351
Parameters
342352
----------
@@ -347,69 +357,72 @@ def first_solar_spectral_correction(pw, airmass_absolute, module_type=None,
347357
absolute (pressure corrected) airmass.
348358
349359
module_type : None or string
350-
a string specifying a cell type. Can be lower or upper case
351-
letters. Admits values of 'cdte', 'monosi'='xsi', 'multisi'='polysi'.
352-
If provided, this input
353-
selects coefficients for the following default modules:
354-
355-
'cdte' - coefficients for First Solar Series 4-2 CdTe modules.
356-
'monosi','xsi' - coefficients for First Solar TetraSun modules.
357-
'multisi','polysi' - coefficients for multi-crystalline silicon
358-
modules.
359-
360-
The module used to calculate the spectral
361-
correction coefficients corresponds to the Mult-crystalline
362-
silicon Manufacturer 2 Model C from [2].
360+
a string specifying a cell type. Can be lower or upper case
361+
letters. Admits values of 'cdte', 'monosi'='xsi',
362+
'multisi'='polysi'. If provided, this input selects coefficients
363+
for the following default modules:
364+
365+
* 'cdte' - coefficients for First Solar Series 4-2 CdTe modules.
366+
* 'monosi','xsi' - coefficients for First Solar TetraSun modules.
367+
* 'multisi','polysi' - coefficients for multi-crystalline silicon
368+
modules.
369+
370+
The module used to calculate the spectral correction
371+
coefficients corresponds to the Mult-crystalline silicon
372+
Manufacturer 2 Model C from [2].
363373
364374
coefficients : array-like
365375
allows for entry of user defined spectral correction
366-
coefficients. Coefficients must be of length 6.
367-
Derivation of coefficients requires use
368-
of SMARTS and PV module quantum efficiency curve. Useful for modeling
369-
PV module types which are not included as defaults, or to fine tune
370-
the spectral correction to a particular mono-Si, multi-Si, or CdTe
371-
PV module. Note that the parameters for modules with very
372-
similar QE should be similar, in most cases limiting the need for
373-
module specific coefficients.
374-
376+
coefficients. Coefficients must be of length 6. Derivation of
377+
coefficients requires use of SMARTS and PV module quantum
378+
efficiency curve. Useful for modeling PV module types which are
379+
not included as defaults, or to fine tune the spectral
380+
correction to a particular mono-Si, multi-Si, or CdTe PV module.
381+
Note that the parameters for modules with very similar QE should
382+
be similar, in most cases limiting the need for module specific
383+
coefficients.
375384
376385
Returns
377386
-------
378387
modifier: array-like
379388
spectral mismatch factor (unitless) which is can be multiplied
380389
with broadband irradiance reaching a module's cells to estimate
381-
effective irradiance, i.e., the irradiance that is converted
382-
to electrical current.
390+
effective irradiance, i.e., the irradiance that is converted to
391+
electrical current.
383392
384393
References
385394
----------
386-
[1] Gueymard, Christian. SMARTS2: a simple model of the atmospheric
387-
radiative transfer of sunshine: algorithms and performance
395+
[1] Gueymard, Christian. SMARTS2: a simple model of the atmospheric
396+
radiative transfer of sunshine: algorithms and performance
388397
assessment. Cocoa, FL: Florida Solar Energy Center, 1995.
389-
[2] Marion, William F., et al. User's Manual for Data for Validating
390-
Models for PV Module Performance. National Renewable Energy Laboratory, 2014.
391-
http://www.nrel.gov/docs/fy14osti/61610.pdf
398+
[2] Marion, William F., et al. User's Manual for Data for Validating
399+
Models for PV Module Performance. National Renewable Energy
400+
Laboratory, 2014. http://www.nrel.gov/docs/fy14osti/61610.pdf
392401
"""
393402

394403
_coefficients = {}
395-
_coefficients['cdte'] = (0.8752, -0.04588, -0.01559, 0.08751, 0.09158, -0.002295)
396-
_coefficients['monosi'] = (0.8478, -0.03326, -0.0022953, 0.1565, 0.01566, -0.001712)
404+
_coefficients['cdte'] = (
405+
0.8752, -0.04588, -0.01559, 0.08751, 0.09158, -0.002295)
406+
_coefficients['monosi'] = (
407+
0.8478, -0.03326, -0.0022953, 0.1565, 0.01566, -0.001712)
397408
_coefficients['xsi'] = _coefficients['monosi']
398-
_coefficients['polysi'] = (0.83019, -0.04063, -0.005281, 0.1695, 0.02974, -0.001676)
409+
_coefficients['polysi'] = (
410+
0.83019, -0.04063, -0.005281, 0.1695, 0.02974, -0.001676)
399411
_coefficients['multisi'] = _coefficients['polysi']
400412

401413
if module_type is not None and coefficients is None:
402414
coefficients = _coefficients[module_type.lower()]
403415
elif module_type is None and coefficients is not None:
404416
pass
405417
else:
406-
raise TypeError('ambiguous input, must supply only 1 of module_type and coefficients')
418+
raise TypeError('ambiguous input, must supply only 1 of ' +
419+
'module_type and coefficients')
407420

408421
# Evaluate Spectral Shift
409422
coeff = coefficients
410423
AMa = airmass_absolute
411-
modifier = (coeff[0] + coeff[1]*AMa + coeff[2]*pw + coeff[3]*np.sqrt(AMa) +
412-
+ coeff[4]*np.sqrt(pw) + coeff[5]*AMa/pw)
424+
modifier = (
425+
coeff[0] + coeff[1]*AMa + coeff[2]*pw + coeff[3]*np.sqrt(AMa) +
426+
+ coeff[4]*np.sqrt(pw) + coeff[5]*AMa/pw)
413427

414428
return modifier
415-
>>>>>>> add first solar spec correction. needs tests

0 commit comments

Comments
 (0)