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

Add functions to fit and convert IAM models #1827

Merged
merged 72 commits into from Dec 18, 2023
Merged

Conversation

ajonesr
Copy link
Contributor

@ajonesr ajonesr commented Aug 3, 2023

  • Closes Functions to fit and convert IAM models #1824
  • I am familiar with the contributing guidelines
  • Tests added
  • Updates entries in docs/sphinx/source/reference for API changes.
  • Adds description and name entries in the appropriate "what's new" file in docs/sphinx/source/whatsnew for all changes. Includes link to the GitHub Issue with :issue:`num` or this Pull Request with :pull:`num`. Includes contributor name and/or GitHub username (link with :ghuser:`user`).
  • New code is fully documented. Includes numpydoc compliant docstrings, examples, and comments where necessary.
  • Pull request is nearly complete and ready for detailed review.
  • Maintainer: Appropriate GitHub Labels (including remote-data) and Milestone are assigned to the Pull Request and linked Issue.

@cwhanse cwhanse added this to the v0.10.2 milestone Aug 23, 2023
@cwhanse
Copy link
Member

cwhanse commented Nov 28, 2023

Very well done!

One question, when fitting an IAM curve to data is there a way to account for potentially uneven sampling of IAM measurements with respect to AOI values?

The fitting doesn't require evenly spaced IAM measurements.

@cwhanse
Copy link
Member

cwhanse commented Nov 28, 2023

Here's the reference, now published but it won't appear on OSTI or other sources for a few months.

iam_models_SAND_final.pdf

@cwhanse
Copy link
Member

cwhanse commented Nov 28, 2023

Ready for another round of reviews. @kandersolar I didn't make the residual function a user input, if that's important I can revisit.

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 quick look. Haven't examined the tests yet. tests look great!

pvlib/iam.py Outdated Show resolved Hide resolved
pvlib/iam.py Outdated Show resolved Hide resolved
pvlib/iam.py Outdated Show resolved Hide resolved
pvlib/iam.py Outdated Show resolved Hide resolved
pvlib/iam.py Outdated Show resolved Hide resolved
pvlib/iam.py Outdated Show resolved Hide resolved
pvlib/iam.py Outdated Show resolved Hide resolved
@kandersolar
Copy link
Member

One question, when fitting an IAM curve to data is there a way to account for potentially uneven sampling of IAM measurements with respect to AOI values?

The fitting doesn't require evenly spaced IAM measurements.

In the case of nonuniform samples, more weight being given to the regions of denser samples, I think. Not necessarily a problem, but something to consider documenting.

# data.

# Create and perturb IAM data.
aoi = np.linspace(0, 90, 100)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
aoi = np.linspace(0, 90, 100)
aoi = np.linspace(0, 85, 18)

This would more representative for measurements.

# %%
# The weight function
# -------------------
# :py:func:`pvlib.iam.fit` uses a weight function when computing residuals
Copy link
Member

Choose a reason for hiding this comment

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

I suggest you say a bit more about the shape and purpose of these functions. I see there is more in the other example, but I think it is more relevant or important here.

pvlib/iam.py Show resolved Hide resolved
pvlib/iam.py Show resolved Hide resolved
@cwhanse cwhanse mentioned this pull request Dec 8, 2023
15 tasks
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.

One more minor doc comment...

@cwhanse good to merge?

\\sum_{\\theta=0}^{90} weight \\left(\\theta \\right) \\times
\\| source \\left(\\theta \\right) - target \\left(\\theta \\right) \\|

The sum is over :math:`\\theta = 0, 1, 2, ..., 90`.
Copy link
Member

Choose a reason for hiding this comment

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

Not quite true; the code actually uses np.linspace(0, 90, 100)

Copy link
Member

Choose a reason for hiding this comment

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

Changed to code to linspace(0, 90, 90)

Ready to merge from my point of view.

Copy link
Member

Choose a reason for hiding this comment

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

Pedantic nitpick: linspace(0, 90, 90) produces [0., 1.0112, 2.0225, ... , 87.9775, 88.9888, 90.]. To produce theta = 0, 1, 2, ..., 90 as the docstring states, I think we need linspace(0, 90, 91).

Copy link
Member

Choose a reason for hiding this comment

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

Not a nit, rather, that's the intent, because it feels natural to step by 1.0000000000000...

Copy link
Member

Choose a reason for hiding this comment

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

I agree it feels natural to step by unity. I was trying to point out that the current code (np.linspace(0, 90, 90)) steps by 90/89 $\approx$ 1.011236. To step by unity from 0 to 90 inclusive, it should be changed to linspace(0, 90, 91).

@cwhanse
Copy link
Member

cwhanse commented Dec 18, 2023

@kandersolar codecov error.

@kandersolar
Copy link
Member

Thanks @ajonesr and @cwhanse for this substantial contribution!

@kandersolar kandersolar merged commit 12ba8ee into pvlib:main Dec 18, 2023
33 of 34 checks passed
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.

Functions to fit and convert IAM models
5 participants