Skip to content
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

Match pvsystem.i_from_v, v_from_i single diode parameters with singlediode order. #1719

Merged
merged 10 commits into from
May 24, 2023

Conversation

reepoi
Copy link
Contributor

@reepoi reepoi commented Apr 27, 2023

The argument order for i_from_v, v_from_i is changed to:

voltage/current, photocurrent, saturation_current, resistance_series, resistance_shunt, nNsVth

In tests/test_singlediode.py, the tests test_method_spr_e20_327, test_newton_fs_495 call i_from_v with the comment:

# the singlediode method doesn't actually get the MPP correct

singlediode does get the MPP correct now, so I updated the tests to compare all returned values from the pvs and out variables.

The test test_newton_fs_495 passes ivcurve_pnts but then does nothing with the returned i, v values.
Since the precision of the i, v values are tested below this test, I updated the test to pass ivcurve_pnts as None.

@cwhanse
Copy link
Member

cwhanse commented Apr 27, 2023

I'm +1 on this change.

It would be nice to deprecate. But I can't think of an easy way to do that for a change in the order of positional arguments. Because these functions are likely used by a small minority of pvlib users, I'd be OK with this breaking change without deprecation.

@kandersolar
Copy link
Member

I think this change would make the next version 0.10.0 instead of 0.9.6. Doesn't matter, just pointing it out.

The only deprecation mechanism I can think of that could work here is to inspect the input and guess whether it is more likely to be a voltage or a resistance based on the range/value. We've done something similar in the past, but it's inelegant and unreliable. I'd be okay with no deprecation.

For documenting, in addition to the what'snew entry, a .. versionchanged:: docstring entry seems appropriate. Example:

.. versionchanged:: 0.9.0
The function now returns a tuple where the first element is a dataframe
and the second element is a dictionary containing metadata. Previous
versions of this function had the return values switched.

@cwhanse cwhanse added this to the 0.10.0 milestone May 3, 2023
Copy link
Member

@kandersolar kandersolar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few minor comments but LGTM. Thanks @reepoi, it's great to see consistency improvements like this!

docs/sphinx/source/whatsnew/v0.10.0.rst Outdated Show resolved Hide resolved
docs/sphinx/source/whatsnew/v0.10.0.rst Outdated Show resolved Hide resolved
pvlib/pvsystem.py Outdated Show resolved Hide resolved
pvlib/pvsystem.py Outdated Show resolved Hide resolved
pvlib/tests/test_pvsystem.py Outdated Show resolved Hide resolved
@reepoi
Copy link
Contributor Author

reepoi commented May 18, 2023

I missed updating the argument order of pvlib.tracking.SingleAxisTracker.i_from_v. I will do that next.

@reepoi
Copy link
Contributor Author

reepoi commented May 18, 2023

Nevermind on updating pvlib.tracking.SingleAxisTracker.i_from_v. SingleAxisTracker inherits from PVSystem, so the documentation for it is already updated.

@kandersolar
Copy link
Member

I missed updating the argument order of pvlib.tracking.SingleAxisTracker.i_from_v. I will do that next.

No need to update SingleAxisTracker IMHO. It's deprecated and only still included for legacy code while people migrate to the better alternative, so there's no need to make any changes motivated by long-term benefits (like consistent parameter ordering, for example).

@kandersolar kandersolar requested a review from cwhanse May 19, 2023 21:03
@@ -684,7 +675,8 @@ def _pwr_optfcn(df, loc):
Function to find power from ``i_from_v``.
'''

I = _lambertw_i_from_v(df['r_sh'], df['r_s'], # noqa: E741, N806
df['nNsVth'], df[loc], df['i_0'], df['i_l'])
I = _lambertw_i_from_v(df[loc], df['photocurrent'],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to rename this internal I here and elsewhere to mollify stickler. Not important.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I renamed I to current. To make the rest of the code match, I changed I to current and V to voltage everywhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind, I changed it only at the stickler comments. I is also used as part of a variable name in many places.

@reepoi reepoi force-pushed the i-from-v-argument-order branch from 2336b17 to cbadd89 Compare May 23, 2023 18:20
@kandersolar kandersolar merged commit 26579be into pvlib:main May 24, 2023
@kandersolar
Copy link
Member

Thanks again @reepoi!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Match pvsystem.i_from_v, v_from_i single diode parameters with singlediode order.
3 participants