Skip to content

Commit 9c87e5e

Browse files
Add example of remote fetch of database with pvsystem.retrieve_sam (#2313)
* Update pvsystem.py * Update v0.11.2.rst * Update pvsystem.py * review Co-authored-by: Kevin Anderson <[email protected]> * remove returns name rationale: misleading var name * do not format bulleted list into citation block * Format strings as code * Add titles to each example * Pass database name as keyword Rationale: be more explicit --------- Co-authored-by: Kevin Anderson <[email protected]>
1 parent cbd72f5 commit 9c87e5e

File tree

2 files changed

+23
-12
lines changed

2 files changed

+23
-12
lines changed

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

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

4747
- `spectra` and `spectra_components` (:issue:`2150`, :pull:`2264`)
4848

49+
* Added a example to :py:func:`~pvlib.pvsystem.retrieve_sam` docstring to
50+
demonstrate how to retrieve a database from the SAM repo. (:pull:`2313`)
4951

5052
Testing
5153
~~~~~~~

pvlib/pvsystem.py

Lines changed: 21 additions & 12 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
@@ -2036,9 +2036,10 @@ def retrieve_sam(name=None, path=None):
20362036
20372037
Examples
20382038
--------
2039+
Using a database bundled with pvlib:
20392040
20402041
>>> from pvlib import pvsystem
2041-
>>> invdb = pvsystem.retrieve_sam('CECInverter')
2042+
>>> invdb = pvsystem.retrieve_sam(name='CECInverter')
20422043
>>> inverter = invdb.AE_Solar_Energy__AE6_0__277V_
20432044
>>> inverter
20442045
Vac 277
@@ -2058,7 +2059,15 @@ def retrieve_sam(name=None, path=None):
20582059
CEC_Date NaN
20592060
CEC_Type Utility Interactive
20602061
Name: AE_Solar_Energy__AE6_0__277V_, dtype: object
2061-
"""
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
20622071
# error: path was previously silently ignored if name was given GH#2018
20632072
if name is not None and path is not None:
20642073
raise ValueError("Please provide either 'name' or 'path', not both.")

0 commit comments

Comments
 (0)