Skip to content

Add example of remote fetch of database with pvsystem.retrieve_sam #2313

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/sphinx/source/whatsnew/v0.11.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ Documentation

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

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

Testing
~~~~~~~
Expand Down
33 changes: 21 additions & 12 deletions pvlib/pvsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -1986,10 +1986,10 @@ def retrieve_sam(name=None, path=None):

This function will retrieve either:

* CEC module database
* Sandia Module database
* CEC Inverter database
* Anton Driesse Inverter database
* CEC module database
* Sandia Module database
* CEC Inverter database
* Anton Driesse Inverter database

and return it as a pandas DataFrame.

Expand All @@ -2002,20 +2002,20 @@ def retrieve_sam(name=None, path=None):
Use one of the following strings to retrieve a database bundled with
pvlib:

* 'CECMod' - returns the CEC module database
* 'CECInverter' - returns the CEC Inverter database
* 'SandiaInverter' - returns the CEC Inverter database
* ``'CECMod'`` - returns the CEC module database
* ``'CECInverter'`` - returns the CEC Inverter database
* ``'SandiaInverter'`` - returns the CEC Inverter database
(CEC is only current inverter db available; tag kept for
backwards compatibility)
* 'SandiaMod' - returns the Sandia Module database
* 'ADRInverter' - returns the ADR Inverter database
* ``'SandiaMod'`` - returns the Sandia Module database
* ``'ADRInverter'`` - returns the ADR Inverter database

path : string, optional
Path to a CSV file or a URL.

Returns
-------
samfile : DataFrame
DataFrame
A DataFrame containing all the elements of the desired database.
Each column represents a module or inverter, and a specific
dataset can be retrieved by the command
Expand All @@ -2038,9 +2038,10 @@ def retrieve_sam(name=None, path=None):

Examples
--------
Using a database bundled with pvlib:

>>> from pvlib import pvsystem
>>> invdb = pvsystem.retrieve_sam('CECInverter')
>>> invdb = pvsystem.retrieve_sam(name='CECInverter')
>>> inverter = invdb.AE_Solar_Energy__AE6_0__277V_
>>> inverter
Vac 277
Expand All @@ -2060,7 +2061,15 @@ def retrieve_sam(name=None, path=None):
CEC_Date NaN
CEC_Type Utility Interactive
Name: AE_Solar_Energy__AE6_0__277V_, dtype: object
"""

Using a remote database, via URL:

>>> url = "https://github.com/raw/NREL/SAM/refs/heads/develop/deploy/libraries/CEC%20Inverters.csv"
>>> inv_db = pvsystem.retrieve_sam(path=url)
>>> inv_db.keys()
Index(['ABB__PVI_3_0_OUTD_S_US_A__208V_', 'ABB__PVI_3_0_OUTD_S_US_A__240V_', ...],
dtype='object', length=...)
""" # noqa: E501
# error: path was previously silently ignored if name was given GH#2018
if name is not None and path is not None:
raise ValueError("Please provide either 'name' or 'path', not both.")
Expand Down
Loading