8000 Accept albedo in weather input to ModelChain.run_model method by cwhanse · Pull Request #1478 · pvlib/pvlib-python · GitHub
[go: up one dir, main page]

Skip to content

Accept albedo in weather input to ModelChain.run_model method #1478

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 32 commits into from
Aug 19, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
d0c52b6
permit albedo to be a Series
cwhanse Jun 9, 2022
e64a940
work on modelchain
cwhanse Jun 10, 2022
de34639
Merge branch 'master' of https://github.com/pvlib/pvlib-python into a…
cwhanse Jun 13, 2022
0fa45e8
fix tests
cwhanse Jun 13, 2022
cdf853e
shh stickler, docstrings
cwhanse Jun 13, 2022
b3ee156
improve coverage
cwhanse Jun 13, 2022
9e1ce0e
improve coverage correctly
cwhanse Jun 13, 2022
59a37da
finalize coverage, stickler
cwhanse Jun 13, 2022
0295dd0
whatsnew
cwhanse Jun 13, 2022
b9a7308
from review
cwhanse Jun 13, 2022
e518996
Merge branch 'master' of https://github.com/pvlib/pvlib-python into a…
cwhanse Jun 20, 2022
e4c5fa5
don't mutate inputs
cwhanse Jun 20, 2022
acb3657
get_irradiance in tracking.py
cwhanse Jun 20, 2022
2bd97b8
shh stickler
cwhanse Jun 20, 2022
5f0d455
shh stickler
cwhanse Jun 20, 2022
0a10e56
improvements from review
cwhanse Jun 21, 2022
122e992
Merge branch 'pvlib:master' into albedo
cwhanse Jun 21, 2022
cbe2099
update whatsnew
cwhanse Jun 21, 2022
15ff086
Merge branch 'master' of https://github.com/pvlib/pvlib-python into a…
cwhanse Jun 21, 2022
d787675
Merge branch 'albedo' of https://github.com/cwhanse/pvlib-python into…
cwhanse Jun 21, 2022
18a4ed1
Apply suggestions from code review
cwhanse Jun 23, 2022
e2e9f5e
docstring improvements
cwhanse Jun 23, 2022
18bb4d5
Merge branch 'master' into albedo
cwhanse Jul 22, 2022
0bde3c7
Apply suggestions from code review
cwhanse Jul 30, 2022
2ea9c97
Update pvlib/tests/test_irradiance.py
cwhanse Jul 30, 2022
ab2c11a
from review
cwhanse Jul 30, 2022
4340bb0
one more
cwhanse Jul 30, 2022
6193147
more use of fixture, add Array.get_irradiance test
cwhanse Aug 1, 2022
0ecfb7d
more decimal places
cwhanse Aug 1, 2022
af6ff0e
spacing
cwhanse Aug 10, 2022
100a8a1
line length
cwhanse Aug 17, 2022
1a835b1
write albedo from system.arrays to ModelChainResult
cwhanse Aug 18, 2022
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
shh stickler, docstrings
  • Loading branch information
cwhanse committed Jun 13, 2022
commit cdf853e4e6a3aeb003a9cffc7f4458d0794bdd56
35 changes: 28 additions & 7 deletions pvlib/modelchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -1473,9 +1473,11 @@ def prepare_inputs(self, weather):
----------
weather : DataFrame, or tuple or list of DataFrame
Required column names include ``'dni'``, ``'ghi'``, ``'dhi'``.
Optional column names are ``'wind_speed'``, ``'temp_air'``; if not
Optional column names are ``'wind_speed'``, ``'temp_air'``, ``'albedo'``.

If optional columns ``'wind_speed'``, ``'temp_air'`` are not
provided, air temperature of 20 C and wind speed
of 0 m/s will be added to the DataFrame.
of 0 m/s will be added to the `weather` DataFrame.

If `weather` is a tuple or list, it must be of the same length and
order as the Arrays of the ModelChain's PVSystem.
Expand All @@ -1490,6 +1492,9 @@ def prepare_inputs(self, weather):
ValueError
If `weather` is a tuple or list with a different length than the
number of Arrays in the system.
ValueError
If ``'albedo'`` is a column in `weather` and is also an attribute
of the ModelChain's PVSystem.Arrays.

Notes
-----
Expand Down Expand Up @@ -1742,16 +1747,32 @@ def run_model(self, weather):
Parameters
----------
weather : DataFrame, or tuple or list of DataFrame
Irradiance column names must include ``'dni'``, ``'ghi'``, and
``'dhi'``. If optional columns ``'temp_air'`` and ``'wind_speed'``
Column names must include:

- ``'dni'``
- ``'ghi'``
- ``'dhi'``

Optional columns are:

- ``'temp_air'``
- ``'cell_temperature'``
- ``'module_temperature'``
- ``'wind_speed'``
- ``'albedo'``

If optional columns ``'temp_air'`` and ``'wind_speed'``
are not provided, air temperature of 20 C and wind speed of 0 m/s
are added to the DataFrame. If optional column
``'cell_temperature'`` is provided, these values are used instead
of `temperature_model`. If optional column `module_temperature`
of `temperature_model`. If optional column ``'module_temperature'``
is provided, `temperature_model` must be ``'sapm'``.

If list or tuple, must be of the same length and order as the
Arrays of the ModelChain's PVSystem.
If optional column ``'albedo'`` is provided, ``'albedo'`` may not
be present on the ModelChain's PVSystem or PVSystem.Arrays.

If weather is a list or tuple, it must be of the same length and
order as the Arrays of the ModelChain's PVSystem.

Returns
-------
Expand Down
10 changes: 6 additions & 4 deletions pvlib/pvsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class PVSystem:
a single array is created from the other parameters (e.g.
`surface_tilt`, `surface_azimuth`). Must contain at least one Array,
if length of arrays is 0 a ValueError is raised. If `arrays` is
specified the following parameters are ignored:
specified the following PVSystem parameters are ignored:

- `surface_tilt`
- `surface_azimuth`
Expand All @@ -156,11 +156,13 @@ class PVSystem:
Azimuth angle of the module surface.
North=0, East=90, South=180, West=270.

albedo : None or numeric, default None
albedo : None or float, default None
Ground surface albedo. If ``None``, then ``surface_type`` is used
to look up a value in ``irradiance.SURFACE_ALBEDOS``.
If ``surface_type`` is also None then a ground surface albedo
of 0.25 is used.
of 0.25 is used. For time-dependent albedos, add ``'albedo'`` to
the input ``'weather'`` DataFrame for
:py:class:`pvlib.modelchain.ModelChain` methods.

surface_type : None or string, default None
The ground surface type. Required if ``albedo`` is None.
Expand Down Expand Up @@ -1258,7 +1260,7 @@ class Array:
single axis tracker. Mounting is used to determine module orientation.
If not provided, a FixedMount with zero tilt is used.

albedo : None or numeric, default None
albedo : None or float, default None
Ground surface albedo. If ``None``, then ``surface_type`` is used
to look up a value in ``irradiance.SURFACE_ALBEDOS``.
If ``surface_type`` is also None then a ground surface albedo
Expand Down
3 changes: 0 additions & 3 deletions pvlib/tests/test_clearsky.py
8000
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,3 @@ def test_bird():
testdata2[['Direct Beam', 'Direct Hz', 'Global Hz', 'Dif Hz']].iloc[11],
rtol=1e-3)
return pd.DataFrame({'Eb': Eb, 'Ebh': Ebh, 'Gh': Gh, 'Dh': Dh}, index=times)


test_bird()
2 changes: 1 addition & 1 deletion pvlib/tests/test_irradiance.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def test_get_ground_diffuse_albedo_0(irrad_data):
def test_get_ground_diffuse_albedo_series(times):
albedo = pd.Series(0.2, index=times)
ground_irrad = irradiance.get_ground_diffuse(
45, pd.Series(1000, index=times), albedo)
45, pd.Series(1000, index=times), albedo)
expected = albedo * 0.5 * (1 - np.sqrt(2) / 2.) * 1000
expected.name = 'diffuse_ground'
assert_series_equal(ground_irrad, expected)
Expand Down
4 changes: 2 additions & 2 deletions pvlib/tests/test_modelchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,14 +519,14 @@ def test_prepare_inputs_transfer_albedo(
del a.albedo
mc = ModelChain(pvsystem, location)
mc = mc.prepare_inputs(weather)
assert (mc.system.arrays[0].albedo.values==0.5).all()
assert (mc.system.arrays[0].albedo.values == 0.5).all()
# again with weather as a tuple
for a in pvsystem.arrays:
del a.albedo
mc = ModelChain(pvsystem, location)
mc = mc.prepare_inputs(input_type((weather, weather)))
for a in mc.system.arrays:
assert (a.albedo.values==0.5).all()
assert (a.albedo.values == 0.5).all()


def test_prepare_inputs_no_irradiance(sapm_dc_snl_ac_system, location):
Expand Down
0