NREL / OpenStudio

OpenStudio is a cross-platform collection of software tools to support whole building energy modeling using EnergyPlus and advanced daylight analysis using Radiance.
https://www.openstudio.net/
Other
484 stars 185 forks source link

EpwFile .getTimeSeries method fails if the weather file contains a leap year but only 28 days are given for that February #5214

Open ckirney opened 1 month ago

ckirney commented 1 month ago

Issue overview

Related to #3801

The EpwFile .getTimeSeries method fails when retrieving information from a weather file that contains a leap year but for which only 28 days of February data are provided. Examples of such files are the CWEC 2020 weather files for Toronto and Vancouver.

In both of the above files, the data for February is from a leap year (2004 for Toronto, 2000 for Vancouver). However, only 28 days of weather data for February are provided (no data for Feb. 29).

When using the EpwFile .getTimeSeries method to get dry bulb temperatures with such a file, the following error is produced:

[utilities.time.Date] <2> Bad Date: year = 2009, month = Feb(2), day = 29. C:/Users/Chris/projects/weather_test/weather_test.rb:6:in `getTimeSeries': D:\OSN\Openstudio\src\utilities\time\Date.cpp@382 : Bad Date: year = 2009, month = Feb(2), day = 29. (RuntimeError)

The problem does not occur if the year in the weather file for February is replaced with one that is not a leap year. This issue is especially problematic in TMY weather files since it is not obvious if the February in the file will be from a leap year but will only include 28 days of data.

Current Behavior

The following error:

[utilities.time.Date] <2> Bad Date: year = 2009, month = Feb(2), day = 29. C:/Users/Chris/projects/weather_test/weather_test.rb:6:in `getTimeSeries': D:\OSN\Openstudio\src\utilities\time\Date.cpp@382 : Bad Date: year = 2009, month = Feb(2), day = 29. (RuntimeError)

Expected Behavior

Time series weather data should be returned.

Steps to Reproduce

weather_file = 'path/to/CAN_ON_Toronto.Intl.AP.716240_CWEC2020.epw' epw = OpenStudio::EpwFile.new(weather_file) epw.getTimeSeries('Dry Bulb Temperature')

Possible Solution

Details

Environment

Some additional details about your environment for this issue (if relevant):

Context

Using the method to retrieve weather data to calculate PHIUS information. This issue causes unpredictable errors when conducting analyses using a variety of TMY weather files as it is not always clear which weather file will contain leap years with only 28 days of data in February. A replacement method is being implemented in openstudio-standards to replace this method until this issue is resolved.

joseph-robertson commented 4 weeks ago

@ckirney Can you test the fix in #5217?