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

Addresses #5214, EpwFile getTimeSeries fails for leap year weather file w/no leap day #5217

Open joseph-robertson opened 1 month ago

joseph-robertson commented 1 month ago

Pull request overview

As far as I can tell, the Bad Date: year = 2009, month = Feb(2), day = 29. error is thrown for each of the following scenarios:

Possible solutions:

Pull Request Author

Labels:

Review Checklist

This will not be exhaustively relevant to every PR.

joseph-robertson commented 1 month ago

After a bit of digging, it appears that realYear (and therefore epw.isActual) gets set to false here since we have a delta greater than 1 day in the epw file. I'm assuming this works as intended for TMY where months jump years.

Therefore we fall into this block instead of this one.

If epw.isActual were set to true, is the issue resolved here? If so, perhaps we could provide some type of override on isActual (either in the epw ctor, or as a setter somewhere)?

joseph-robertson commented 1 month ago

Ah ha, here's the core issue. For all 3 of the above scenarios, m_data has dateTimes that look like:

2012-Feb-28 20:00:00
2012-Feb-28 21:00:00
2012-Feb-28 22:00:00
2012-Feb-28 23:00:00
2012-Feb-29 00:00:00 => Bad Date: year = 2009, month = Feb(2), day = 29.
2012-Mar-01 01:00:00
2012-Mar-01 02:00:00
2012-Mar-01 03:00:00
2012-Mar-01 04:00:00

This is the line that fails. The assumedYear in the Data ctor here is 2009, and so fails on the line above.

Why doesn't the EpwDataPoint have a dateTime of 2012-Mar-01 00:00:00 instead of 2012-Feb-29 00:00:00?

Answer:

pt = OpenStudio::EpwDataPoint.fromEpwStrings(2012, 2, 28, 24, 0, ["foo"] * 35)
pt.dateTime => 2012-Feb-29 00:00:00
ci-commercialbuildings commented 4 weeks ago

CI Results for 17d344f9327a96d078cc0a19ac0ac63ecc9f1c2c:

ckirney commented 3 weeks ago

The fix looks good. I tried it on Windows with a couple of different weather files that had the issue before and everything seems to work. Thanks for resolving this.