8000 Add function to retrieve example dataset paths by echedey-ls · Pull Request #1763 · pvlib/pvlib-python · GitHub
[go: up one dir, main page]

Skip to content

Add function to retrieve example dataset paths #1763

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

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e46a60f
Add function, tests and case example
echedey-ls Jun 7, 2023
29c7554
Fix type annotations
echedey-ls Jun 7, 2023
725e299
Yeet this stupid error
echedey-ls Jun 7, 2023
05dc263
Remove unneeded feature
echedey-ls Jun 8, 2023
b0f38d5
Renamed to locate_example_dataset
echedey-ls Jun 8, 2023
b236fce
Use pathlib & check existence of test files
echedey-ls Jun 8, 2023
884f2de
Add public documentation, hope it works
echedey-ls Jun 8, 2023
dad6835
I forgot this assert :v
echedey-ls Jun 8, 2023
5490561
Update plot_greensboro_kimber_soiling.py
echedey-ls Jun 8, 2023
8000
eacedae
Don't show examples backreference
echedey-ls Jun 9, 2023
28fe7de
Update v0.10.0.rst (without user name since I'm already mentioned at …
echedey-ls Jun 9, 2023
aa91f28
Apply Kevin's implementation suggestions
echedey-ls Jun 10, 2023
5954a79
Update plot_greensboro_kimber_soiling.py
echedey-ls Jun 10, 2023
0e55f18
Update iotools.rst
echedey-ls Jun 10, 2023
311f765
Will this fix the table?
echedey-ls Jun 10, 2023
3a91cd7
This should be fine now
echedey-ls Jun 10, 2023
4a38b0e
Substitute occurrences of pvlib.__file__ or similar where appropiate
echedey-ls Jun 10, 2023
5e1a33c
Merge branch 'main' into dataset-retrieve-function
echedey-ls Jun 10, 2023
64e8700
Merge branch 'main' into dataset-retrieve-function
echedey-ls Jun 14, 2023
f5bfcf6
Revert "Substitute occurrences of pvlib.__file__ or similar where app…
echedey-ls Jun 18, 2023
8c78cb4
Revert "Will this fix the table?"
echedey-ls Jun 18, 2023
6215608
Delete custom path behaviour, rename to get_example_dataset_path
echedey-ls Jun 18, 2023
aa08e09
Use function in tests only
echedey-ls Jun 18, 2023
61571be
Forgot to update tests
echedey-ls Jun 18, 2023
caec4f4
solve stupid errors
echedey-ls Jun 18, 2023
586381a
Merge branch 'main' into dataset-retrieve-function
echedey-ls Aug 3, 2023
e8c615e
Update whatsnew entries
echedey-ls Aug 3, 2023
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
Prev Previous commit
Next Next commit
Merge branch 'main' into dataset-retrieve-function
  • Loading branch information
echedey-ls committed Aug 3, 2023
commit 586381ad091d19b53a410cb1701f8881d8cd3edb
48 changes: 48 additions & 0 deletions docs/sphinx/source/whatsnew/v0.10.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,54 @@ Enhancements
* Add :py:func:`pvlib.tools.locate_example_dataset` to get example and test
files under `pvlib/data` path.
(:issue:`924`, :pull:`1763`)
* Added two new irradiance decomposition models: :py:func:`pvlib.irradiance.orgill_hollands` (:pull:`1730`)
and :py:func:`pvlib.irradiance.louche` (:pull:`1705`).
* The return values of :py:func:`pvlib.pvsystem.calcparams_desoto`,
:py:func:`pvlib.pvsystem.calcparams_cec`, and
:py:func:`pvlib.pvsystem.calcparams_pvsyst` are all numeric types and have
the same Python type as the ``effective_irradiance`` and ``temp_cell`` parameters. (:issue:`1626`, :pull:`1700`)
* Added ``map_variables`` parameter to :py:func:`pvlib.iotools.read_tmy3` (:issue:`1517`, :pull:`1623`),
:py:func:`pvlib.iotools.read_srml`, and :py:func:`pvlib.iotools.read_srml_month_from_solardat` (:pull:`1773`).
* Added :func:`pvlib.iotools.get_srml` that is similar to
:func:`pvlib.iotools.read_srml_month_from_solardat` but is able to fetch multiple months
of data using the ``start`` and ``end`` parameters.
(:pull:`1779`)
* Allow passing keyword arguments to :py:func:`scipy:scipy.optimize.brentq` and
:py:func:`scipy:scipy.optimize.newton` solvers in
:py:func:`~pvlib.singlediode.bishop88_mpp`,
:py:func:`~pvlib.singlediode.bishop88_i_from_v` and
:py:func:`~pvlib.singlediode.bishop88_v_from_i`. Among others,
tolerance and number of iterations can be set.
(:issue:`1249`, :pull:`1764`)
* Improved ``ModelChainResult.__repr__`` (:pull:`1236`)
* Exposes several functions useful for bifacial and shading calculations (:pull:`1666`):

* :py:func:`pvlib.bifacial.utils.vf_row_sky_2d`
* :py:func:`pvlib.bifacial.utils.vf_row_sky_2d_integ`
* :py:func:`pvlib.bifacial.utils.vf_row_ground_2d`
* :py:func:`pvlib.bifacial.utils.vf_row_ground_2d_integ`
* :py:func:`pvlib.bifacial.utils.vf_ground_sky_2d`
* :py:func:`pvlib.bifacial.utils.vf_ground_sky_2d_integ`
* :py:func:`pvlib.shading.ground_angle`

* Added a function :py:func:`pvlib.spectrum.spectral_factor_caballero`
to estimate spectral mismatch modifiers from atmospheric conditions. (:pull:`1296`)
* Add optional ``encoding`` parameter to :py:func:`pvlib.iotools.read_tmy3`. (:issue:`1732`, :pull:`1737`)
* Added function to retrieve horizon data from PVGIS
:py:func:`pvlib.iotools.get_pvgis_horizon`. (:issue:`1290`, :pull:`1395`)
* Update the URL used in the :py:func:`pvlib.iotools.get_cams` function. The new URL supports load-balancing
and redirects to the fastest server. (:issue:`1688`, :pull:`1740`)
* :py:func:`pvlib.iotools.get_psm3` now has a ``url`` parameter to give the user
the option of controlling what NSRDB endpoint is used. (:pull:`1736`)
* :py:func:`pvlib.iotools.get_psm3` now uses the new NSRDB 3.2.2 endpoint for
hourly and half-hourly single-year datasets. (:issue:`1591`, :pull:`1736`)
* The default solar position algorithm (NREL SPA) is now 50-100% faster. (:pull:`1748`)
* Added functions to retrieve daily precipitation, temperature, and snowfall data
from the NOAA's ACIS service: :py:func:`~pvlib.iotools.get_acis_prism`,
:py:func:`~pvlib.iotools.get_acis_nrcc`, :py:func:`~pvlib.iotools.get_acis_mpe`,
:py:func:`~pvlib.iotools.get_acis_station_data`, and
:py:func:`~pvlib.iotools.get_acis_available_stations`. (:issue:`1293`, :pull:`1767`)


Bug fixes
~~~~~~~~~
Expand Down
25 changes: 25 additions & 0 deletions pvlib/tests/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pvlib
from pvlib import tools
import numpy as np
import pandas as pd
import pathlib


Expand Down Expand Up @@ -99,6 +100,30 @@ def test_degrees_to_index_1():
tools._degrees_to_index(degrees=22.0, coordinate='width')


@pytest.mark.parametrize('args, args_idx', [
# no pandas.Series or pandas.DataFrame args
((1,), None),
(([1],), None),
((np.array(1),), None),
((np.array([1]),), None),
# has pandas.Series or pandas.DataFrame args
((pd.DataFrame([1], index=[1]),), 0),
((pd.Series([1], index=[1]),), 0),
((1, pd.Series([1], index=[1]),), 1),
((1, pd.DataFrame([1], index=[1]),), 1),
# first pandas.Series or pandas.DataFrame is used
((1, pd.Series([1], index=[1]), pd.DataFrame([2], index=[2]),), 1),
((1, pd.DataFrame([1], index=[1]), pd.Series([2], index=[2]),), 1),
])
def test_get_pandas_index(args, args_idx):
index = tools.get_pandas_index(*args)

if args_idx is None:
assert index is None
else:
pd.testing.assert_index_equal(args[args_idx].index, index)


def test_get_example_dataset_path_passes():
expected_dataset = '723170TYA.CSV'
assert pathlib.Path(pvlib.__path__[0], 'data',
Expand Down
22 changes: 22 additions & 0 deletions pvlib/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,28 @@ def _first_order_centered_difference(f, x0, dx=DX, args=()):
return df / 2 / dx


def get_pandas_index(*args):
"""
Get the index of the first pandas DataFrame or Series in a list of
arguments.

Parameters
----------
args: positional arguments
The numeric values to scan for a pandas index.

Returns
-------
A pandas index or None
None is returned if there are no pandas DataFrames or Series in the
args list.
"""
return next(
(a.index for a in args if isinstance(a, (pd.DataFrame, pd.Series))),
None
)


def get_example_dataset_path(dataset):
"""
Return a filepath to a dataset bundled with PVLIB with name `dataset`.
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.
0