Skip to content

Handling Leap Years in OpenMeteo Resource Data#633

Open
elenya-grant wants to merge 4 commits intoNatLabRockies:developfrom
elenya-grant:resource/leap_days
Open

Handling Leap Years in OpenMeteo Resource Data#633
elenya-grant wants to merge 4 commits intoNatLabRockies:developfrom
elenya-grant:resource/leap_days

Conversation

@elenya-grant
Copy link
Copy Markdown
Collaborator

Handling Leap Years in OpenMeteo Resource Data

The NLR API calls handle leap years by removing them. The PySAM solar function SAM_CSV_to_solar_data (from PySAM.ResourceTools) also has logic to remove leap days (although it's hard-coded for hourly data and assumes UTC timezone). If we were to run the floris wind plant model using openmeteo wind resource data from 2024, we would get an error on the line power_farm = self.fi.get_farm_power().reshape(self.n_timesteps) because n_timesteps is 8760 but the resource data (and therefore the wind farm timeseries) is length 8784 (includes a leap day).

This PR adds the ability to remove resource data for a leap day data in the OpenMeteo resource models. This option is user-controlled with the new configuration parameter for the openmeteo resource models include_leap_day (which defaults to False).

Section 1: Type of Contribution

  • Feature Enhancement
    • Framework
    • New Model
    • Updated Model
    • Tools/Utilities
    • Other (please describe):
  • Bug Fix
  • Documentation Update
  • CI Changes
  • Other (please describe):

Section 2: Draft PR Checklist

  • [-] Open draft PR
  • [-] Describe the feature that will be added
  • [-] Fill out TODO list steps
  • [-] Describe requested feedback from reviewers on draft PR
  • [-] Complete Section 7: New Model Checklist (if applicable)

Type of Reviewer Feedback Requested (on Draft PR)

Structural feedback:

Implementation feedback:

Other feedback:

Section 3: General PR Checklist

  • PR description thoroughly describes the new feature, bug fix, etc.
  • Added tests for new functionality or bug fixes
  • Tests pass (If not, and this is expected, please elaborate in the Section 6: Test Results)
  • Documentation
    • Docstrings are up-to-date
    • Related docs/ files are up-to-date, or added when necessary
    • Documentation has been rebuilt successfully
    • Examples have been updated (if applicable)
  • CHANGELOG.md
    • At least one complete sentence has been provided to describe the changes made in this PR
    • After the above, a hyperlink has been provided to the PR using the following format:
      "A complete thought. [PR XYZ]((https://github.com/NatLabRockies/H2Integrate/pull/XYZ)", where
      XYZ should be replaced with the actual number.

Section 3: Related Issues

Section 4: Impacted Areas of the Software

Section 4.1: New Files

  • resource_files/wind/-28.454864_114.551749_2024_openmeteo_archive_60min_local_tz.csv
  • resource_files/solar/-28.454864_114.551749_2024_openmeteo_archive_solar_60min_local_tz.csv

Section 4.2: Modified Files

  • h2integrate/resource/resource_base.py:
    • ResourceBaseAPIModel.setup(): added n_timesteps as an attribute of the class
  • h2integrate/resource/wind/openmeteo_wind.py
    • OpenMeteoHistoricalWindAPIConfig: added include_leap_day attribute
    • OpenMeteoHistoricalWindResource
      • load_data(): updated to remove leap day if specified and needed. Added error message if resource data is not the same length as n_timesteps.
      • format_timeseries_data: updated units for is_day to be unitless (bugfix)
  • h2integrate/resource/solar/openmeteo_solar.py
    • OpenMeteoHistoricalSolarAPIConfig: added include_leap_day attribute
    • OpenMeteoHistoricalSolarResource
      • load_data(): updated to remove leap day if specified and needed. Added error message if resource data is not the same length as n_timesteps.

Tests

  • h2integrate/resource/wind/test/test_openmeteo_wind_api.py: added test for leap-year data
  • h2integrate/resource/solar/test/test_resource_models.py: added test for leap-year data
  • h2integrate/resource/solar/test/test_pvwatts_integration.py: added test for leap-year data

Section 5: Additional Supporting Information

Section 6: Test Results, if applicable

Section 7 (Optional): New Model Checklist

  • Model Structure:
    • Follows established naming conventions outlined in docs/developer_guide/coding_guidelines.md
    • Used attrs class to define the Config to load in attributes for the model
      • If applicable: inherit from BaseConfig or CostModelBaseConfig
    • Added: initialize() method, setup() method, compute() method
      • If applicable: inherit from CostModelBaseClass
  • Integration: Model has been properly integrated into H2Integrate
    • Added to supported_models.py
    • If a new commodity_type is added, update create_financial_model in h2integrate_model.py
  • Tests: Unit tests have been added for the new model
    • Pytest-style unit tests
    • Unit tests are in a "test" folder within the folder a new model was added to
    • If applicable add integration tests
  • Example: If applicable, a working example demonstrating the new model has been created
    • Input file comments
    • Run file comments
    • Example has been tested and runs successfully in test_all_examples.py
  • Documentation:
    • Write docstrings using the Google style
    • Model added to the main models list in docs/user_guide/model_overview.md
      • Model documentation page added to the appropriate docs/ section
      • <model_name>.md is added to the _toc.yml

@elenya-grant elenya-grant requested a review from johnjasa March 27, 2026 23:07
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.

1 participant