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

stream_temperature_function #2104

Closed

Conversation

IoannisSifnaios
Copy link
Contributor

@IoannisSifnaios IoannisSifnaios commented Jun 22, 2024

  • Related to Google Summer of Code: Floating PV #2068
  • 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.

Addition of the Stefan and Preud'homme equation for estimating the mean daily stream water temperature using the ambient air temperature as input. The paper can be found here.

Although this equation was created for estimating stream temperature, there are a number of publications that have used it for estimating the lakewater and seawater temperature (not sure if this is a good approach, though). From a quick search, some indicative publications that used it for estimating water temperature for floating PV are: 1, 2, 3, 4, 5.

Doc rendering

@IoannisSifnaios
Copy link
Contributor Author

IoannisSifnaios commented Jun 22, 2024

This function was not tested for very low mean daily ambient temperatures. Thus, if air temperatures lower than -6.6 degC are provided, the water temperature from this function will be negative. This can be true in some cases (e.g. if there is supercooling), but under normal conditions, it is not possible. So the question is: Should we limit the water surface temperature to 0 or return np.nan when low ambient air temperatures are used? I implemented the latter since I felt it was more in line with the paper.

@IoannisSifnaios IoannisSifnaios marked this pull request as ready for review June 22, 2024 11:08
Copy link
Contributor

@echedey-ls echedey-ls left a comment

Choose a reason for hiding this comment

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

I can't access the paper so this is a bit of a blind review, but here are some initial ideas.

As always, feel free to make (or not) the changes with your own style.

pvlib/floating.py Outdated Show resolved Hide resolved
pvlib/floating.py Outdated Show resolved Hide resolved
pvlib/tests/test_floating.py Outdated Show resolved Hide resolved
pvlib/tests/test_floating.py Outdated Show resolved Hide resolved
@IoannisSifnaios
Copy link
Contributor Author

Thanks @echedey-ls and @AdamRJensen for all the help with the pytest.fixture.

Is there a way to use fixture values as input to a pytest.mark.parametrize test?

@cwhanse cwhanse added enhancement GSoC Contributions related to Google Summer of Code. labels Jun 24, 2024
@cwhanse cwhanse added this to the v0.11.1 milestone Jun 24, 2024
@cwhanse
Copy link
Member

cwhanse commented Jun 24, 2024

Looks good so far @IoannisSifnaios

pvlib/floating.py Outdated Show resolved Hide resolved
pvlib/floating.py Outdated Show resolved Hide resolved
pvlib/floating.py Outdated Show resolved Hide resolved
pvlib/floating.py Outdated Show resolved Hide resolved
pvlib/floating.py Outdated Show resolved Hide resolved
IoannisSifnaios and others added 6 commits June 24, 2024 22:43
Co-authored-by: Cliff Hansen <cwhanse@sandia.gov>
Co-authored-by: Cliff Hansen <cwhanse@sandia.gov>
Co-authored-by: Cliff Hansen <cwhanse@sandia.gov>
Co-authored-by: Cliff Hansen <cwhanse@sandia.gov>
Co-authored-by: Cliff Hansen <cwhanse@sandia.gov>
@kandersolar
Copy link
Member

Although this equation was created for estimating stream temperature, there are a number of publications that have used it for estimating the lakewater and seawater temperature (not sure if this is a good approach, though).

Perhaps it is worth noting this in the function's docstring?

pvlib/floating.py Outdated Show resolved Hide resolved
pvlib/floating.py Outdated Show resolved Hide resolved
pvlib/floating.py Outdated Show resolved Hide resolved
pvlib/floating.py Show resolved Hide resolved
pvlib/floating.py Show resolved Hide resolved
@adriesse
Copy link
Member

adriesse commented Jul 5, 2024

Thinking about this again, it seems unlikely that floating PV will be built on the type of water body modeled here, so are we encouraging the possible misuse for other types of bodies of water? I would suspect that a more suitable model for lakes and larger bodies exists somewhere.

IoannisSifnaios and others added 2 commits July 6, 2024 15:11
Co-authored-by: Anton Driesse <anton.driesse@pvperformancelabs.com>
Co-authored-by: Adam R. Jensen <39184289+AdamRJensen@users.noreply.github.com>
pvlib/floating.py Outdated Show resolved Hide resolved
pvlib/floating.py Outdated Show resolved Hide resolved
Co-authored-by: RDaxini <143435106+RDaxini@users.noreply.github.com>
Co-authored-by: Anton Driesse <anton.driesse@pvperformancelabs.com>
Copy link
Contributor

@echedey-ls echedey-ls left a comment

Choose a reason for hiding this comment

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

I can't access the paper, but this proposal looks perfectly fine. Nice job!

Non-blocking comments down below.

docs/sphinx/source/reference/floating.rst Show resolved Hide resolved
pvlib/floating.py Outdated Show resolved Hide resolved
@IoannisSifnaios
Copy link
Contributor Author

IoannisSifnaios commented Jul 17, 2024

Thinking about this again, it seems unlikely that floating PV will be built on the type of water body modeled here, so are we encouraging the possible misuse for other types of bodies of water? I would suspect that a more suitable model for lakes and larger bodies exists somewhere.

@adriesse I also thought about this (and asked some oceanography researchers regarding models for sea temperature), but there are no simple models that can estimate the sea surface temperature, which I think is the reason why people used this model in the first place (although it might not be very appropriate). Thus, since we have mentioned the limitations of the model very explicitly, I still think it makes sense to add it in lack of a more appropriate model. Hopefully, in the future, some simple model might be developed, and then it could be directly compared to this one in order to estimate how "off" the results are...

IoannisSifnaios and others added 3 commits July 17, 2024 17:15
Co-authored-by: Echedey Luis <80125792+echedey-ls@users.noreply.github.com>
@adriesse
Copy link
Member

Thinking about this again, it seems unlikely that floating PV will be built on the type of water body modeled here, so are we encouraging the possible misuse for other types of bodies of water? I would suspect that a more suitable model for lakes and larger bodies exists somewhere.

@adriesse I also thought about this (and asked some oceanography researchers regarding models for sea temperature), but there are no simple models that can estimate the sea surface temperature, which I think is the reason why people used this model in the first place (although it might not be very appropriate). Thus, since we have mentioned the limitations of the model very explicitly, I still think it makes sense to add it in lack of a more appropriate model. Hopefully, in the future, some simple model might be developed, and then it could be directly compared to this one in order to estimate how "off" the results are...

I haven't read these papers, but it sounds pretty questionable to take a model out of one context and use it in another context without some kind of checks or validation. If we put that in pvlib it's like giving someone a hammer when you know they need a screwdriver.

I suggest putting in an empty lake_temperature function that raises a NotImplementedError instead. Maybe that will encourage people to look into it!!

@cwhanse
Copy link
Member

cwhanse commented Sep 11, 2024

@adriesse @IoannisSifnaios it's been a while - can you recap where we are with this PR and its reviews?

@IoannisSifnaios
Copy link
Contributor Author

@adriesse @IoannisSifnaios it's been a while - can you recap where we are with this PR and its reviews?

I have implemented all the suggested review comments. However, we haven't reached an agreement regarding whether this function should be included in pvlib.

The main argument for not including it is that it calculates the temperature of moving water bodies (i.e., streams), which is an unlikely choice for installing a floating PV system. As Anton mentioned, some lake or sea temperature models would be more appropriate.

The main argument for including it is that I could not find functions that estimate lake or sea temperature using ambient measurements and that this expression has been used in some publications (see description of the PR). So if we decide to include it in pvlib, it is with a warning about its usage and limitations.

I think we should maybe put it to a vote and possibly close this PR if we agree not to include this function.

Copy link
Member

@cwhanse cwhanse left a comment

Choose a reason for hiding this comment

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

I think the function has place in the library with the appropriate caveats (a warning about application).

docs/sphinx/source/whatsnew/v0.11.1.rst Outdated Show resolved Hide resolved
pvlib/floating.py Outdated Show resolved Hide resolved
@RDaxini
Copy link
Contributor

RDaxini commented Sep 11, 2024

Since there's no concern about the technical soundness of the model itself and it is a model that is used by the PV modelling community, then as a library of models for the modelling community I think it makes sense to include it.

As for concerns about its application, I think the function is clearly labelled for what it is so users are adequately informed of the relevant caveats concerning its application.

@cwhanse
Copy link
Member

cwhanse commented Sep 11, 2024

@IoannisSifnaios I see a number of papers referring lake surface water temperature (LWST) models, or sea surface temperature (SST) models. Most models appear to be dynamic; basically, future temperature is a function of past temperature and exogenous variables. Are these models more complex that your application needs?

This discussion (about water surface temperature models for non-flowing water bodies) probably needs its own issue.

RDaxini
RDaxini approved these changes Sep 11, 2024
@IoannisSifnaios
Copy link
Contributor Author

IoannisSifnaios commented Sep 11, 2024

@IoannisSifnaios I see a number of papers referring lake surface water temperature (LWST) models, or sea surface temperature (SST) models. Most models appear to be dynamic; basically, future temperature is a function of past temperature and exogenous variables. Are these models more complex that your application needs?

This discussion (about water surface temperature models for non-flowing water bodies) probably needs its own issue.

@cwhanse SST models are quite complicated and usually require solving turbulence equations etc. (I actually had a discussion with an oceanographer about this...). Regarding lakes, if you found a paper with a suitable model, please mention it in an issue (I will also take another look), and I can take it from there! ;-)

@adriesse
Copy link
Member

I'm not yet convinced that this is a good idea. Whether we like it or not, inclusion in pvlib imparts a certain credibility and also increases visibility. This means that we have to be careful about what we include, whether we like it or not.

Building PV over running water seems to be a niche application, so strictly speaking this model function would benefit few people. On the other hand there will be lots of people building PV over larger water bodies, and if this is the only model they find, they will likely use it despite it not having been validated for their application. I don't see that as a benefit to anyone. (The situation is similar with the wind speed height model that was recently merged.)

From the abstract, it appears that the empirical model was derived from measurements on 11 streams in one geographic area only, and ambient temperatures were measured between 0 and 144 miles from those streams. If someone has used it for a lake in India (one of the references), does that bolster the case for inclusion? Or does it rather bolster the case against inclusion?

One problem that is hinted at in the abstract is the thermal mass of the water body. From personal experience living near a large lake I can attest to the moderating effect on air temperature in early summer and early winter. I doubt that the size of the water body and the location of the temperature measurement in relation to it can be entirely ignored for modeling floating PV systems in general.

Finally, there is no hurry. Even if we don't know of a suitable alternative right now, there is a steady stream(!) of papers on floating PV and surely more suitable models will show up. Or perhaps someone will validate this one more broadly and put my concerns to rest.

@RDaxini
Copy link
Contributor

RDaxini commented Sep 12, 2024

Most models appear to be dynamic; basically, future temperature is a function of past temperature and exogenous variables. Are these models more complex that your application needs?

I did a brief review and found the same as @cwhanse --- so far I have only seen models for the rate of change of LWST.

Regarding lakes, if you found a paper with a suitable model, please mention it in an issue (I will also take another look), and I can take it from there! ;-)

@IoannisSifnaios the For example, the air2water model in Equation 1 of this paper is an option and it has in fact been implemented in another package here. The calculation of net heat flux to the surface (at least in the paper, I haven't reviewed the github package in detail) is non-trivial.
Calculations for heat flux are broken down in this paper, where another model (General Lake Model, GLM) is also presented. You can see that LSWT is required to be known to calculate the heat flux (e.g. see equation 14), which I guess makes sense from a thermodynamics perspective since the heat emitted from a body depends in part on the temperature of that body.
A modified (and somewhat simplified) version of the air2water model in the results of the first paper (equations 2 and 3) that I linked also exists.

Again, these are for the rate of change of LSWT.

I defer the determination of whether they are suitable or not to you; I am not an expert in floating PV by a long shot 😅

Co-authored-by: Cliff Hansen <cwhanse@sandia.gov>
@AdamRJensen
Copy link
Member

The discussion above certainly brings up a lot of good points, e.g., about the validation of the algorithm and whether its usage is justifiable. I'm leaning toward closing this PR and seeing how the modeling of floating PV develops.

For floating PV on the sea, I think using reanalysis data for water temperature from ERA5 or similar could be a good option.

@IoannisSifnaios
Copy link
Contributor Author

I think I will close this for now. Thank you for the interesting discussions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement GSoC Contributions related to Google Summer of Code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants