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

Always shift solar influx by 30 minutes #257

Merged
merged 3 commits into from
Oct 11, 2022

Conversation

zoltanmaric
Copy link
Contributor

@zoltanmaric zoltanmaric commented Oct 6, 2022

Always Shift Solar Influx by 30 Minutes

Description

Fixes a bug in solar position time shift for ERA5 influx data where for some cases the frequency of the data would be incorrectly inferred. The change always shifts by -30 minutes, regardless of the sampling of the data. See discussion in #256 (comment) for reasoning.

Motivation and Context

Closes #256

How Has This Been Tested?

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I tested my contribution locally and it seems to work fine.
  • I locally ran pytest inside the repository and no unexpected problems came up.
  • I have adjusted the docstrings in the code appropriately.
  • I have documented the effects of my code changes in the documentation doc/.
  • I have added newly introduced dependencies to environment.yaml file.
  • I have added a note to release notes doc/release_notes.rst.
  • I have used pre-commit run --all to lint/format/check my contribution

@zoltanmaric
Copy link
Contributor Author

FYI @euronion @FabianHofmann

Copy link
Contributor

@FabianHofmann FabianHofmann left a comment

Choose a reason for hiding this comment

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

@zoltanmaric this looks great! Thank you for raising and tackling this issue. One question: What would happen if the time resolution wasn't 1 hour but, let's say, 3 hours? This would still work right?

@zoltanmaric
Copy link
Contributor Author

zoltanmaric commented Oct 7, 2022

@zoltanmaric this looks great! Thank you for raising and tackling this issue. One question: What would happen if the time resolution wasn't 1 hour but, let's say, 3 hours? This would still work right?

Yes, it works at any time sampling. I can add a unit test for that to this PR if you like.

That said, there does seem to be a slight difference in the values returned from CDS between 1-hour sampling and all other samplings (I tried 2h, 3h, 4h, and 6h) - see my comment here: #256 (comment)

SARAH_DIR = os.getenv("SARAH_DIR", "/home/vres/climate-data/sarah_v2")
GEBCO_PATH = os.getenv("GEBCO_PATH", "/home/vres/climate-data/GEBCO_2014_2D.nc")


Copy link
Contributor Author

Choose a reason for hiding this comment

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

This section was just moved to the top of the file, because I added a reference to TIME in one of the methods above.

@zoltanmaric
Copy link
Contributor Author

zoltanmaric commented Oct 7, 2022

@FabianHofmann I added a test for 3h-sampling in zoltanmaric@17a0847. Let me know if you want to keep it or if I should remove it.

@FabianHofmann
Copy link
Contributor

@FabianHofmann I added a test for 3h-sampling in zoltanmaric@17a0847. Let me know if you want to keep it or if I should remove it.

Let's keep the test. As far as I see, only a release note is missing. Would you be so kind? Then we can merge it.

@zoltanmaric zoltanmaric force-pushed the time-shift-30min branch 2 times, most recently from da9eb14 to 9faef23 Compare October 7, 2022 11:25
@zoltanmaric
Copy link
Contributor Author

As far as I see, only a release note is missing. Would you be so kind? Then we can merge it.

I wasn't sure about the format - I added a new version heading (0.2.10) and added a note there (see here). Is that right?

Comment on lines 14 to 15
Version 0.2.10
=================
Copy link
Contributor

@FabianHofmann FabianHofmann Oct 7, 2022

Choose a reason for hiding this comment

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

Suggested change
Version 0.2.10
=================
Upcoming Release
================

Copy link
Contributor

Choose a reason for hiding this comment

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

(otherwise there will be a warning during the compilation)

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 also noticed in the meantime that the latest release is 0.2.8. Should I then add my note to version 0.2.9 instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

No, there was just the GH release missing (which is sort of secondary). But perhaps you can name the heading Upcoming Release?

Copy link
Contributor

Choose a reason for hiding this comment

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

See suggestion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

@FabianHofmann FabianHofmann merged commit bfcecc8 into PyPSA:master Oct 11, 2022
@FabianHofmann
Copy link
Contributor

Thanks @zoltanmaric

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

Successfully merging this pull request may close these issues.

ERA5 Solar Position Time Shift Broken for Certain Time Spans
2 participants