Skip to content

Lookup altitude2 #1547

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 12 commits into from
Closed

Lookup altitude2 #1547

wants to merge 12 commits into from

Conversation

nicomt
Copy link
Contributor

@nicomt nicomt commented Sep 9, 2022

  • Closes Altitude lookup table #1516
  • 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.

In this pull request, I fix the outstanding issues from the last pull request and replace functions to use lookup_altitude by default

@nicomt nicomt marked this pull request as draft September 10, 2022 22:27
@nicomt nicomt marked this pull request as ready for review September 13, 2022 05:28
@nicomt
Copy link
Contributor Author

nicomt commented Sep 13, 2022

The coverage for the spa_c solar position method keeps failing even though it is covered in tests.
Could that be caused by a dependency issue? Like the spa.c and spa.h files missing from the test?

@kandersolar
Copy link
Member

The coverage for the spa_c solar position method keeps failing even though it is covered in tests. Could that be caused by a dependency issue? Like the spa.c and spa.h files missing from the test?

Yep, we don't include the SPA C code in the pvlib repository and tests due to licensing issues (#9). Any CI coverage issues around SPA C can/should be ignored.

@kandersolar
Copy link
Member

@nicomt we're on the cusp of releasing 0.9.3, which includes your last PR. Do you agree that there is no problem making that release without including this PR? Since some defaults are changing, I think it makes sense to wait for 0.10.0 here, just want to confirm that the previous PR can stand on its own without this one.

@kandersolar kandersolar added this to the 0.10.0 milestone Sep 14, 2022
@nicomt
Copy link
Contributor Author

nicomt commented Sep 14, 2022

@kanderso-nrel You are right the last release should stand on its own. I don't see any problem delaying this PR.

Copy link
Member

@AdamRJensen AdamRJensen left a comment

Choose a reason for hiding this comment

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

Took a brief look and everything seems to check out.

Still a little skeptical about relying on an external file, which may be updated in the future and cause inconsistencies between versions.

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.

Thanks again @nicomt for this PR. I think I like the Location class looking up its own altitude, but I'm not sure it's a good idea to also do the lookup inside the pvlib.solarposition functions. It's okay for the classes to have a little "magic" under the hood if it makes things more convenient, but I think we want more transparency in the functions. I'm also nervous about the (probably small) runtime cost of the lookup, since most people will not be specifying altitude themselves. I lean towards keeping the current static defaults in the pvlib.solarposition.* functions, but I'm curious what other maintainers think about it.

We'll also need a "what's new" entry, but let's decide where to go with this PR first.

@cwhanse
Copy link
Member

cwhanse commented May 17, 2023

I lean to agree with @kandersolar: leave the default altitude to be sea level in the solarposition functions.

@nicomt
Copy link
Contributor Author

nicomt commented May 17, 2023

Those concerns are valid, and leaving sea level as the default seems reasonable.
I can close this PR, but then that leaves us with a few options:

  1. We make the altitude lookup automatic for the Location class only.
loc = Location(latitude, longitude)  # altitude == location.lookup_altitude
spa_c(times, latitude, longitude) # altitude == 0
  1. We integrate the altitude lookup everywhere but make it more explicit
loc = Location(latitude, longitude)  # altitude == 0
spa_c(times, latitude, longitude) # altitude == 0
loc = Location(latitude, longitude, altitude="lookup")  # altitude == location.lookup_altitude
spa_c(times, latitude, longitude, altitude="lookup")  # altitude == location.lookup_altitude
  1. We make the altitude lookup explicit and only available for the Location class.
loc = Location(latitude, longitude)  # altitude == 0
loc = Location(latitude, longitude, altitude="lookup")  # altitude == location.lookup_altitude
spa_c(times, latitude, longitude)  # altitude == 0
  1. We leave it as it is and let the user pass the altitude manually
loc = Location(latitude, longitude, altitude=location.lookup_altitude(latitude, longitude))
spa_c(times, latitude, longitude, altitude=location.lookup_altitude(latitude, longitude))

What do you guys think?

@nicomt
Copy link
Contributor Author

nicomt commented May 17, 2023

Closing for now.
While we decide what to do.

@nicomt nicomt closed this May 17, 2023
@cwhanse
Copy link
Member

cwhanse commented May 17, 2023

@nicomt my vote is #1, let Location lookup altitude, but require it explicitly for the solar position functions.

nicomt added a commit to nicomt/pvlib-python that referenced this pull request Sep 11, 2023
Set altitude automatically from built-in map when not specified.
See pvlib#1547
kandersolar added a commit that referenced this pull request Jun 21, 2024
* Adding altitude lookup for location class
Set altitude automatically from built-in map when not specified.
See #1547

* Readding change removed by accident by patch

* Note about fallback to zero when there is no data

* Adding description to "what's new"

* Update pvlib/location.py

Better type definition

Co-authored-by: Kevin Anderson <[email protected]>

* Fix wording for altitude param

* move whatsnew entry to 0.11.0

* docstring tweak

* fix 0.10.2 whatsnew file

---------

Co-authored-by: Kevin Anderson <[email protected]>
@nicomt nicomt deleted the lookup_altitude2 branch June 21, 2024 16:32
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.

Altitude lookup table
4 participants