Skip to content

Commit 8a5d9f5

Browse files
authored
Merge branch 'main' into docstring-guidelines-units-etc
2 parents 30b875a + 6d886dc commit 8a5d9f5

File tree

5 files changed

+77
-64
lines changed

5 files changed

+77
-64
lines changed

docs/sphinx/source/user_guide/nomenclature.rst

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -102,20 +102,21 @@ There is a convention on consistent variable names throughout the library:
102102
Photocurrent
103103

104104
poa_diffuse
105-
Total diffuse irradiation in plane. Sum of ground and sky diffuse.
105+
Total diffuse irradiance in plane [Wm⁻²]. Sum of ground and sky diffuse
106+
components of global irradiance.
106107

107108
poa_direct
108-
Direct/beam irradiation in plane
109+
Direct/beam irradiance in plane [Wm⁻²].
109110

110111
poa_global
111-
Global irradiation in plane. sum of diffuse and beam projection.
112+
Global irradiance in plane. Sum of diffuse and beam projection [Wm⁻²].
112113

113114
poa_ground_diffuse
114-
In plane ground reflected irradiation
115+
In plane ground reflected irradiance [Wm⁻²].
115116

116117
poa_sky_diffuse
117-
Diffuse irradiation in plane from scattered light in the atmosphere
118-
(without ground reflected irradiation)
118+
Diffuse irradiance in plane from scattered light in the atmosphere
119+
(without ground reflected irradiance) [Wm⁻²].
119120

120121
precipitable_water
121122
Total precipitable water contained in a column of unit cross section
@@ -168,10 +169,6 @@ There is a convention on consistent variable names throughout the library:
168169
temp_module
169170
Temperature of the module
170171

171-
transposition_factor
172-
The gain ratio of the radiation on inclined plane to global horizontal
173-
irradiation: :math:`\frac{poa\_global}{ghi}`
174-
175172
tz
176173
Timezone
177174

docs/sphinx/source/whatsnew/v0.11.2.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ Documentation
4848

4949
* Added a section in the style guide for parameter naming and units best practices.
5050
See :ref:`documentation-units`. (:issue:`2205`, :pull:`2248`)
51+
* Added a example to :py:func:`~pvlib.pvsystem.retrieve_sam` docstring to
52+
demonstrate how to retrieve a database from the SAM repo. (:pull:`2313`)
5153

5254
Testing
5355
~~~~~~~

pvlib/ivtools/sdm.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -562,27 +562,34 @@ def fit_desoto_sandia(ivcurves, specs, const=None, maxiter=5, eps1=1.e-3):
562562
-------
563563
dict
564564
I_L_ref : float
565-
light current at STC [A]
565+
Light current at STC [A]
566566
I_o_ref : float
567-
dark current at STC [A]
567+
Dark current at STC [A]
568568
EgRef : float
569-
effective band gap at STC [eV]
569+
Effective band gap at STC [eV]
570570
R_s : float
571-
series resistance at STC [ohm]
571+
Series resistance at STC [ohm]
572572
R_sh_ref : float
573-
shunt resistance at STC [ohm]
573+
Shunt resistance at STC [ohm]
574574
cells_in_series : int
575-
number of cells in series
575+
Number of cells in series
576576
iph : array
577-
light current for each IV curve [A]
577+
Light current for each IV curve [A]
578578
io : array
579-
dark current for each IV curve [A]
579+
Dark current for each IV curve [A]
580580
rs : array
581-
series resistance for each IV curve [ohm]
581+
Series resistance for each IV curve [ohm]
582582
rsh : array
583-
shunt resistance for each IV curve [ohm]
583+
Shunt resistance for each IV curve [ohm]
584+
a_ref : float
585+
The product of the usual diode ideality factor (n, unitless),
586+
number of cells in series (Ns), and cell thermal voltage at
587+
reference conditions, in units of V.
588+
dEgdT : float
589+
The temperature dependence of the energy bandgap (Eg) at reference
590+
conditions [1/K].
584591
u : array
585-
boolean for each IV curve indicating that the parameter values
592+
Boolean for each IV curve indicating that the parameter values
586593
are deemed reasonable by the private function ``_filter_params``
587594
588595
Notes

pvlib/pvsystem.py

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1986,10 +1986,10 @@ def retrieve_sam(name=None, path=None):
19861986
19871987
This function will retrieve either:
19881988
1989-
* CEC module database
1990-
* Sandia Module database
1991-
* CEC Inverter database
1992-
* Anton Driesse Inverter database
1989+
* CEC module database
1990+
* Sandia Module database
1991+
* CEC Inverter database
1992+
* Anton Driesse Inverter database
19931993
19941994
and return it as a pandas DataFrame.
19951995
@@ -2002,20 +2002,20 @@ def retrieve_sam(name=None, path=None):
20022002
Use one of the following strings to retrieve a database bundled with
20032003
pvlib:
20042004
2005-
* 'CECMod' - returns the CEC module database
2006-
* 'CECInverter' - returns the CEC Inverter database
2007-
* 'SandiaInverter' - returns the CEC Inverter database
2005+
* ``'CECMod'`` - returns the CEC module database
2006+
* ``'CECInverter'`` - returns the CEC Inverter database
2007+
* ``'SandiaInverter'`` - returns the CEC Inverter database
20082008
(CEC is only current inverter db available; tag kept for
20092009
backwards compatibility)
2010-
* 'SandiaMod' - returns the Sandia Module database
2011-
* 'ADRInverter' - returns the ADR Inverter database
2010+
* ``'SandiaMod'`` - returns the Sandia Module database
2011+
* ``'ADRInverter'`` - returns the ADR Inverter database
20122012
20132013
path : string, optional
20142014
Path to a CSV file or a URL.
20152015
20162016
Returns
20172017
-------
2018-
samfile : DataFrame
2018+
DataFrame
20192019
A DataFrame containing all the elements of the desired database.
20202020
Each column represents a module or inverter, and a specific
20212021
dataset can be retrieved by the command
@@ -2033,14 +2033,13 @@ def retrieve_sam(name=None, path=None):
20332033
-----
20342034
Files available at
20352035
https://github.com/NREL/SAM/tree/develop/deploy/libraries
2036-
Documentation for module and inverter data sets:
2037-
https://sam.nrel.gov/photovoltaic/pv-sub-page-2.html
20382036
20392037
Examples
20402038
--------
2039+
Using a database bundled with pvlib:
20412040
20422041
>>> from pvlib import pvsystem
2043-
>>> invdb = pvsystem.retrieve_sam('CECInverter')
2042+
>>> invdb = pvsystem.retrieve_sam(name='CECInverter')
20442043
>>> inverter = invdb.AE_Solar_Energy__AE6_0__277V_
20452044
>>> inverter
20462045
Vac 277
@@ -2060,7 +2059,15 @@ def retrieve_sam(name=None, path=None):
20602059
CEC_Date NaN
20612060
CEC_Type Utility Interactive
20622061
Name: AE_Solar_Energy__AE6_0__277V_, dtype: object
2063-
"""
2062+
2063+
Using a remote database, via URL:
2064+
2065+
>>> url = "https://raw.githubusercontent.com/NREL/SAM/refs/heads/develop/deploy/libraries/CEC%20Inverters.csv"
2066+
>>> inv_db = pvsystem.retrieve_sam(path=url)
2067+
>>> inv_db.keys()
2068+
Index(['ABB__PVI_3_0_OUTD_S_US_A__208V_', 'ABB__PVI_3_0_OUTD_S_US_A__240V_', ...],
2069+
dtype='object', length=...)
2070+
""" # noqa: E501
20642071
# error: path was previously silently ignored if name was given GH#2018
20652072
if name is not None and path is not None:
20662073
raise ValueError("Please provide either 'name' or 'path', not both.")

pvlib/solarposition.py

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
def get_solarposition(time, latitude, longitude,
3131
altitude=None, pressure=None,
3232
method='nrel_numpy',
33-
temperature=12, **kwargs):
33+
temperature=12.0, **kwargs):
3434
"""
3535
A convenience wrapper for the solar position calculators.
3636
@@ -125,8 +125,8 @@ def get_solarposition(time, latitude, longitude,
125125
return ephem_df
126126

127127

128-
def spa_c(time, latitude, longitude, pressure=101325, altitude=0,
129-
temperature=12, delta_t=67.0,
128+
def spa_c(time, latitude, longitude, pressure=101325., altitude=0.,
129+
temperature=12., delta_t=67.0,
130130
raw_spa_output=False):
131131
r"""
132132
Calculate the solar position using the C implementation of the NREL
@@ -149,11 +149,11 @@ def spa_c(time, latitude, longitude, pressure=101325, altitude=0,
149149
longitude : float
150150
Longitude in decimal degrees. Positive east of prime meridian,
151151
negative to west.
152-
pressure : float, default 101325
152+
pressure : float, default 101325.0
153153
Pressure in Pascals
154-
altitude : float, default 0
154+
altitude : float, default 0.0
155155
Height above sea level. [m]
156-
temperature : float, default 12
156+
temperature : float, default 12.0
157157
Temperature in C
158158
delta_t : float, default 67.0
159159
Difference between terrestrial time and UT1.
@@ -279,7 +279,7 @@ def _datetime_to_unixtime(dtindex):
279279

280280

281281
def spa_python(time, latitude, longitude,
282-
altitude=0, pressure=101325, temperature=12, delta_t=67.0,
282+
altitude=0., pressure=101325., temperature=12., delta_t=67.0,
283283
atmos_refract=None, how='numpy', numthreads=4):
284284
"""
285285
Calculate the solar position using a python implementation of the
@@ -302,11 +302,11 @@ def spa_python(time, latitude, longitude,
302302
longitude : float
303303
Longitude in decimal degrees. Positive east of prime meridian,
304304
negative to west.
305-
altitude : float, default 0
305+
altitude : float, default 0.0
306306
Distance above sea level.
307-
pressure : int or float, optional, default 101325
307+
pressure : int or float, optional, default 101325.0
308308
avg. yearly air pressure in Pascals.
309-
temperature : int or float, optional, default 12
309+
temperature : int or float, optional, default 12.0
310310
avg. yearly air temperature in degrees C.
311311
delta_t : float or array, optional, default 67.0
312312
Difference between terrestrial time and UT1.
@@ -507,9 +507,9 @@ def _ephem_setup(latitude, longitude, altitude, pressure, temperature,
507507

508508
def sun_rise_set_transit_ephem(times, latitude, longitude,
509509
next_or_previous='next',
510-
altitude=0,
511-
pressure=101325,
512-
temperature=12, horizon='0:00'):
510+
altitude=0.,
511+
pressure=101325.,
512+
temperature=12., horizon='0:00'):
513513
"""
514514
Calculate the next sunrise and sunset times using the PyEphem package.
515515
@@ -523,11 +523,11 @@ def sun_rise_set_transit_ephem(times, latitude, longitude,
523523
Longitude in degrees, positive east of prime meridian, negative to west
524524
next_or_previous : str
525525
'next' or 'previous' sunrise and sunset relative to time
526-
altitude : float, default 0
526+
altitude : float, default 0.0
527527
distance above sea level in meters.
528-
pressure : int or float, optional, default 101325
528+
pressure : int or float, optional, default 101325.0
529529
air pressure in Pascals.
530-
temperature : int or float, optional, default 12
530+
temperature : int or float, optional, default 12.0
531531
air temperature in degrees C.
532532
horizon : string, format +/-X:YY
533533
arc degrees:arc minutes from geometrical horizon for sunrise and
@@ -590,8 +590,8 @@ def sun_rise_set_transit_ephem(times, latitude, longitude,
590590
'transit': trans})
591591

592592

593-
def pyephem(time, latitude, longitude, altitude=0, pressure=101325,
594-
temperature=12, horizon='+0:00'):
593+
def pyephem(time, latitude, longitude, altitude=0., pressure=101325.,
594+
temperature=12., horizon='+0:00'):
595595
"""
596596
Calculate the solar position using the PyEphem package.
597597
@@ -605,11 +605,11 @@ def pyephem(time, latitude, longitude, altitude=0, pressure=101325,
605605
longitude : float
606606
Longitude in decimal degrees. Positive east of prime meridian,
607607
negative to west.
608-
altitude : float, default 0
608+
altitude : float, default 0.0
609609
Height above sea level in meters. [m]
610-
pressure : int or float, optional, default 101325
610+
pressure : int or float, optional, default 101325.0
611611
air pressure in Pascals.
612-
temperature : int or float, optional, default 12
612+
temperature : int or float, optional, default 12.0
613613
air temperature in degrees C.
614614
horizon : string, optional, default '+0:00'
615615
arc degrees:arc minutes from geometrical horizon for sunrise and
@@ -679,7 +679,7 @@ def pyephem(time, latitude, longitude, altitude=0, pressure=101325,
679679
return sun_coords
680680

681681

682-
def ephemeris(time, latitude, longitude, pressure=101325, temperature=12):
682+
def ephemeris(time, latitude, longitude, pressure=101325.0, temperature=12.0):
683683
"""
684684
Python-native solar position calculator.
685685
The accuracy of this code is not guaranteed.
@@ -695,9 +695,9 @@ def ephemeris(time, latitude, longitude, pressure=101325, temperature=12):
695695
longitude : float
696696
Longitude in decimal degrees. Positive east of prime meridian,
697697
negative to west.
698-
pressure : float or Series, default 101325
698+
pressure : float or Series, default 101325.0
699699
Ambient pressure (Pascals)
700-
temperature : float or Series, default 12
700+
temperature : float or Series, default 12.0
701701
Ambient temperature (C)
702702
703703
Returns
@@ -856,8 +856,8 @@ def ephemeris(time, latitude, longitude, pressure=101325, temperature=12):
856856

857857

858858
def calc_time(lower_bound, upper_bound, latitude, longitude, attribute, value,
859-
altitude=0, pressure=101325, temperature=12, horizon='+0:00',
860-
xtol=1.0e-12):
859+
altitude=0.0, pressure=101325.0, temperature=12.0,
860+
horizon='+0:00', xtol=1.0e-12):
861861
"""
862862
Calculate the time between lower_bound and upper_bound
863863
where the attribute is equal to value. Uses PyEphem for
@@ -879,12 +879,12 @@ def calc_time(lower_bound, upper_bound, latitude, longitude, attribute, value,
879879
and 'az' (which must be given in radians).
880880
value : int or float
881881
The value of the attribute to solve for
882-
altitude : float, default 0
882+
altitude : float, default 0.0
883883
Distance above sea level.
884-
pressure : int or float, optional, default 101325
884+
pressure : int or float, optional, default 101325.0
885885
Air pressure in Pascals. Set to 0 for no
886886
atmospheric correction.
887-
temperature : int or float, optional, default 12
887+
temperature : int or float, optional, default 12.0
888888
Air temperature in degrees C.
889889
horizon : string, optional, default '+0:00'
890890
arc degrees:arc minutes from geometrical horizon for sunrise and

0 commit comments

Comments
 (0)