From 2e7710e8f70e09c462d1dcc6738ac26b37c13371 Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Wed, 30 Oct 2024 11:22:42 +0100 Subject: [PATCH] Remove try catch in test, use a lambda to dry up code, and don't wrap optional into optional for getters --- src/utilities/filetypes/EpwFile.cpp | 163 +- .../filetypes/test/EpwFile_GTest.cpp | 1615 ++++++++--------- 2 files changed, 844 insertions(+), 934 deletions(-) diff --git a/src/utilities/filetypes/EpwFile.cpp b/src/utilities/filetypes/EpwFile.cpp index 26ec009e11..a962757a75 100644 --- a/src/utilities/filetypes/EpwFile.cpp +++ b/src/utilities/filetypes/EpwFile.cpp @@ -1286,13 +1286,16 @@ boost::optional EpwDesignCondition::getFieldByName(const std::string& na } boost::optional EpwDesignCondition::getField(EpwDesignField id) { + auto optionaIntToOptionalDouble = [](boost::optional val_) -> boost::optional { + if (val_) { + return *val_; + } + return boost::none; + }; + switch (id.value()) { case EpwDesignField::HeatingColdestMonth: - if (boost::optional _heatingColdestMonth = heatingColdestMonth()) { - return _heatingColdestMonth.get(); - } else { - return boost::none; - } + return optionaIntToOptionalDouble(heatingColdestMonth()); break; case EpwDesignField::HeatingDryBulb99pt6: return heatingDryBulb99pt6(); @@ -1334,18 +1337,10 @@ boost::optional EpwDesignCondition::getField(EpwDesignField id) { return heatingMeanCoincidentWindSpeed99pt6(); break; case EpwDesignField::HeatingPrevailingCoincidentWindDirection99pt6: - if (boost::optional _heatingPrevailingCoincidentWindDirection99pt6 = heatingPrevailingCoincidentWindDirection99pt6()) { - return _heatingPrevailingCoincidentWindDirection99pt6.get(); - } else { - return boost::none; - } + return optionaIntToOptionalDouble(heatingPrevailingCoincidentWindDirection99pt6()); break; case EpwDesignField::CoolingHottestMonth: - if (boost::optional _coolingHottestMonth = coolingHottestMonth()) { - return _coolingHottestMonth.get(); - } else { - return boost::none; - } + return optionaIntToOptionalDouble(coolingHottestMonth()); break; case EpwDesignField::CoolingDryBulbRange: return coolingDryBulbRange(); @@ -1390,11 +1385,7 @@ boost::optional EpwDesignCondition::getField(EpwDesignField id) { return coolingMeanCoincidentWindSpeed0pt4(); break; case EpwDesignField::CoolingPrevailingCoincidentWindDirection0pt4: - if (boost::optional _coolingPrevailingCoincidentWindDirection0pt4 = coolingPrevailingCoincidentWindDirection0pt4()) { - return _coolingPrevailingCoincidentWindDirection0pt4.get(); - } else { - return boost::none; - } + return optionaIntToOptionalDouble(coolingPrevailingCoincidentWindDirection0pt4()); break; case EpwDesignField::CoolingDehumidificationDewPoint0pt4: return coolingDehumidificationDewPoint0pt4(); @@ -1442,11 +1433,7 @@ boost::optional EpwDesignCondition::getField(EpwDesignField id) { return coolingEnthalpyMeanCoincidentDryBulb2(); break; case EpwDesignField::CoolingHours8To4AndDryBulb12pt8To20pt6: - if (boost::optional _coolingHours8To4AndDryBulb12pt8To20pt6 = coolingHours8To4AndDryBulb12pt8To20pt6()) { - return _coolingHours8To4AndDryBulb12pt8To20pt6.get(); - } else { - return boost::none; - } + return optionaIntToOptionalDouble(coolingHours8To4AndDryBulb12pt8To20pt6()); break; case EpwDesignField::ExtremeWindSpeed1: return extremeWindSpeed1(); @@ -2681,255 +2668,255 @@ std::string EpwDesignCondition::titleOfDesignCondition() const { } boost::optional EpwDesignCondition::heatingColdestMonth() const { - return boost::optional(m_heatingColdestMonth); + return m_heatingColdestMonth; } boost::optional EpwDesignCondition::heatingDryBulb99pt6() const { - return boost::optional(m_heatingDryBulb99pt6); + return m_heatingDryBulb99pt6; } boost::optional EpwDesignCondition::heatingDryBulb99() const { - return boost::optional(m_heatingDryBulb99); + return m_heatingDryBulb99; } boost::optional EpwDesignCondition::heatingHumidificationDewPoint99pt6() const { - return boost::optional(m_heatingHumidificationDewPoint99pt6); + return m_heatingHumidificationDewPoint99pt6; } boost::optional EpwDesignCondition::heatingHumidificationHumidityRatio99pt6() const { - return boost::optional(m_heatingHumidificationHumidityRatio99pt6); + return m_heatingHumidificationHumidityRatio99pt6; } boost::optional EpwDesignCondition::heatingHumidificationMeanCoincidentDryBulb99pt6() const { - return boost::optional(m_heatingHumidificationMeanCoincidentDryBulb99pt6); + return m_heatingHumidificationMeanCoincidentDryBulb99pt6; } boost::optional EpwDesignCondition::heatingHumidificationDewPoint99() const { - return boost::optional(m_heatingHumidificationDewPoint99); + return m_heatingHumidificationDewPoint99; } boost::optional EpwDesignCondition::heatingHumidificationHumidityRatio99() const { - return boost::optional(m_heatingHumidificationHumidityRatio99); + return m_heatingHumidificationHumidityRatio99; } boost::optional EpwDesignCondition::heatingHumidificationMeanCoincidentDryBulb99() const { - return boost::optional(m_heatingHumidificationMeanCoincidentDryBulb99); + return m_heatingHumidificationMeanCoincidentDryBulb99; } boost::optional EpwDesignCondition::heatingColdestMonthWindSpeed0pt4() const { - return boost::optional(m_heatingColdestMonthWindSpeed0pt4); + return m_heatingColdestMonthWindSpeed0pt4; } boost::optional EpwDesignCondition::heatingColdestMonthMeanCoincidentDryBulb0pt4() const { - return boost::optional(m_heatingColdestMonthMeanCoincidentDryBulb0pt4); + return m_heatingColdestMonthMeanCoincidentDryBulb0pt4; } boost::optional EpwDesignCondition::heatingColdestMonthWindSpeed1() const { - return boost::optional(m_heatingColdestMonthWindSpeed1); + return m_heatingColdestMonthWindSpeed1; } boost::optional EpwDesignCondition::heatingColdestMonthMeanCoincidentDryBulb1() const { - return boost::optional(m_heatingColdestMonthMeanCoincidentDryBulb1); + return m_heatingColdestMonthMeanCoincidentDryBulb1; } boost::optional EpwDesignCondition::heatingMeanCoincidentWindSpeed99pt6() const { - return boost::optional(m_heatingMeanCoincidentWindSpeed99pt6); + return m_heatingMeanCoincidentWindSpeed99pt6; } boost::optional EpwDesignCondition::heatingPrevailingCoincidentWindDirection99pt6() const { - return boost::optional(m_heatingPrevailingCoincidentWindDirection99pt6); + return m_heatingPrevailingCoincidentWindDirection99pt6; } boost::optional EpwDesignCondition::coolingHottestMonth() const { - return boost::optional(m_coolingHottestMonth); + return m_coolingHottestMonth; } boost::optional EpwDesignCondition::coolingDryBulbRange() const { - return boost::optional(m_coolingDryBulbRange); + return m_coolingDryBulbRange; } boost::optional EpwDesignCondition::coolingDryBulb0pt4() const { - return boost::optional(m_coolingDryBulb0pt4); + return m_coolingDryBulb0pt4; } boost::optional EpwDesignCondition::coolingMeanCoincidentWetBulb0pt4() const { - return boost::optional(m_coolingMeanCoincidentWetBulb0pt4); + return m_coolingMeanCoincidentWetBulb0pt4; } boost::optional EpwDesignCondition::coolingDryBulb1() const { - return boost::optional(m_coolingDryBulb1); + return m_coolingDryBulb1; } boost::optional EpwDesignCondition::coolingMeanCoincidentWetBulb1() const { - return boost::optional(m_coolingMeanCoincidentWetBulb1); + return m_coolingMeanCoincidentWetBulb1; } boost::optional EpwDesignCondition::coolingDryBulb2() const { - return boost::optional(m_coolingDryBulb2); + return m_coolingDryBulb2; } boost::optional EpwDesignCondition::coolingMeanCoincidentWetBulb2() const { - return boost::optional(m_coolingMeanCoincidentWetBulb2); + return m_coolingMeanCoincidentWetBulb2; } boost::optional EpwDesignCondition::coolingEvaporationWetBulb0pt4() const { - return boost::optional(m_coolingEvaporationWetBulb0pt4); + return m_coolingEvaporationWetBulb0pt4; } boost::optional EpwDesignCondition::coolingEvaporationMeanCoincidentDryBulb0pt4() const { - return boost::optional(m_coolingEvaporationMeanCoincidentDryBulb0pt4); + return m_coolingEvaporationMeanCoincidentDryBulb0pt4; } boost::optional EpwDesignCondition::coolingEvaporationWetBulb1() const { - return boost::optional(m_coolingEvaporationWetBulb1); + return m_coolingEvaporationWetBulb1; } boost::optional EpwDesignCondition::coolingEvaporationMeanCoincidentDryBulb1() const { - return boost::optional(m_coolingEvaporationMeanCoincidentDryBulb1); + return m_coolingEvaporationMeanCoincidentDryBulb1; } boost::optional EpwDesignCondition::coolingEvaporationWetBulb2() const { - return boost::optional(m_coolingEvaporationWetBulb2); + return m_coolingEvaporationWetBulb2; } boost::optional EpwDesignCondition::coolingEvaporationMeanCoincidentDryBulb2() const { - return boost::optional(m_coolingEvaporationMeanCoincidentDryBulb2); + return m_coolingEvaporationMeanCoincidentDryBulb2; } boost::optional EpwDesignCondition::coolingMeanCoincidentWindSpeed0pt4() const { - return boost::optional(m_coolingMeanCoincidentWindSpeed0pt4); + return m_coolingMeanCoincidentWindSpeed0pt4; } boost::optional EpwDesignCondition::coolingPrevailingCoincidentWindDirection0pt4() const { - return boost::optional(m_coolingPrevailingCoincidentWindDirection0pt4); + return m_coolingPrevailingCoincidentWindDirection0pt4; } boost::optional EpwDesignCondition::coolingDehumidificationDewPoint0pt4() const { - return boost::optional(m_coolingDehumidificationDewPoint0pt4); + return m_coolingDehumidificationDewPoint0pt4; } boost::optional EpwDesignCondition::coolingDehumidificationHumidityRatio0pt4() const { - return boost::optional(m_coolingDehumidificationHumidityRatio0pt4); + return m_coolingDehumidificationHumidityRatio0pt4; } boost::optional EpwDesignCondition::coolingDehumidificationMeanCoincidentDryBulb0pt4() const { - return boost::optional(m_coolingDehumidificationMeanCoincidentDryBulb0pt4); + return m_coolingDehumidificationMeanCoincidentDryBulb0pt4; } boost::optional EpwDesignCondition::coolingDehumidificationDewPoint1() const { - return boost::optional(m_coolingDehumidificationDewPoint1); + return m_coolingDehumidificationDewPoint1; } boost::optional EpwDesignCondition::coolingDehumidificationHumidityRatio1() const { - return boost::optional(m_coolingDehumidificationHumidityRatio1); + return m_coolingDehumidificationHumidityRatio1; } boost::optional EpwDesignCondition::coolingDehumidificationMeanCoincidentDryBulb1() const { - return boost::optional(m_coolingDehumidificationMeanCoincidentDryBulb1); + return m_coolingDehumidificationMeanCoincidentDryBulb1; } boost::optional EpwDesignCondition::coolingDehumidificationDewPoint2() const { - return boost::optional(m_coolingDehumidificationDewPoint2); + return m_coolingDehumidificationDewPoint2; } boost::optional EpwDesignCondition::coolingDehumidificationHumidityRatio2() const { - return boost::optional(m_coolingDehumidificationHumidityRatio2); + return m_coolingDehumidificationHumidityRatio2; } boost::optional EpwDesignCondition::coolingDehumidificationMeanCoincidentDryBulb2() const { - return boost::optional(m_coolingDehumidificationMeanCoincidentDryBulb2); + return m_coolingDehumidificationMeanCoincidentDryBulb2; } boost::optional EpwDesignCondition::coolingEnthalpy0pt4() const { - return boost::optional(m_coolingEnthalpy0pt4); + return m_coolingEnthalpy0pt4; } boost::optional EpwDesignCondition::coolingEnthalpyMeanCoincidentDryBulb0pt4() const { - return boost::optional(m_coolingEnthalpyMeanCoincidentDryBulb0pt4); + return m_coolingEnthalpyMeanCoincidentDryBulb0pt4; } boost::optional EpwDesignCondition::coolingEnthalpy1() const { - return boost::optional(m_coolingEnthalpy1); + return m_coolingEnthalpy1; } boost::optional EpwDesignCondition::coolingEnthalpyMeanCoincidentDryBulb1() const { - return boost::optional(m_coolingEnthalpyMeanCoincidentDryBulb1); + return m_coolingEnthalpyMeanCoincidentDryBulb1; } boost::optional EpwDesignCondition::coolingEnthalpy2() const { - return boost::optional(m_coolingEnthalpy2); + return m_coolingEnthalpy2; } boost::optional EpwDesignCondition::coolingEnthalpyMeanCoincidentDryBulb2() const { - return boost::optional(m_coolingEnthalpyMeanCoincidentDryBulb2); + return m_coolingEnthalpyMeanCoincidentDryBulb2; } boost::optional EpwDesignCondition::coolingHours8To4AndDryBulb12pt8To20pt6() const { - return boost::optional(m_coolingHours8To4AndDryBulb12pt8To20pt6); + return m_coolingHours8To4AndDryBulb12pt8To20pt6; } boost::optional EpwDesignCondition::extremeWindSpeed1() const { - return boost::optional(m_extremeWindSpeed1); + return m_extremeWindSpeed1; } boost::optional EpwDesignCondition::extremeWindSpeed2pt5() const { - return boost::optional(m_extremeWindSpeed2pt5); + return m_extremeWindSpeed2pt5; } boost::optional EpwDesignCondition::extremeWindSpeed5() const { - return boost::optional(m_extremeWindSpeed5); + return m_extremeWindSpeed5; } boost::optional EpwDesignCondition::extremeMaxWetBulb() const { - return boost::optional(m_extremeMaxWetBulb); + return m_extremeMaxWetBulb; } boost::optional EpwDesignCondition::extremeMeanMinDryBulb() const { - return boost::optional(m_extremeMeanMinDryBulb); + return m_extremeMeanMinDryBulb; } boost::optional EpwDesignCondition::extremeMeanMaxDryBulb() const { - return boost::optional(m_extremeMeanMaxDryBulb); + return m_extremeMeanMaxDryBulb; } boost::optional EpwDesignCondition::extremeStdDevMinDryBulb() const { - return boost::optional(m_extremeStdDevMinDryBulb); + return m_extremeStdDevMinDryBulb; } boost::optional EpwDesignCondition::extremeStdDevMaxDryBulb() const { - return boost::optional(m_extremeStdDevMaxDryBulb); + return m_extremeStdDevMaxDryBulb; } boost::optional EpwDesignCondition::extremeN5YearsMinDryBulb() const { - return boost::optional(m_extremeN5YearsMinDryBulb); + return m_extremeN5YearsMinDryBulb; } boost::optional EpwDesignCondition::extremeN5YearsMaxDryBulb() const { - return boost::optional(m_extremeN5YearsMaxDryBulb); + return m_extremeN5YearsMaxDryBulb; } boost::optional EpwDesignCondition::extremeN10YearsMinDryBulb() const { - return boost::optional(m_extremeN10YearsMinDryBulb); + return m_extremeN10YearsMinDryBulb; } boost::optional EpwDesignCondition::extremeN10YearsMaxDryBulb() const { - return boost::optional(m_extremeN10YearsMaxDryBulb); + return m_extremeN10YearsMaxDryBulb; } boost::optional EpwDesignCondition::extremeN20YearsMinDryBulb() const { - return boost::optional(m_extremeN20YearsMinDryBulb); + return m_extremeN20YearsMinDryBulb; } boost::optional EpwDesignCondition::extremeN20YearsMaxDryBulb() const { - return boost::optional(m_extremeN20YearsMaxDryBulb); + return m_extremeN20YearsMaxDryBulb; } boost::optional EpwDesignCondition::extremeN50YearsMinDryBulb() const { - return boost::optional(m_extremeN50YearsMinDryBulb); + return m_extremeN50YearsMinDryBulb; } boost::optional EpwDesignCondition::extremeN50YearsMaxDryBulb() const { - return boost::optional(m_extremeN50YearsMaxDryBulb); + return m_extremeN50YearsMaxDryBulb; } void EpwDesignCondition::setTitleOfDesignCondition(const std::string& titleOfDesignCondition) { diff --git a/src/utilities/filetypes/test/EpwFile_GTest.cpp b/src/utilities/filetypes/test/EpwFile_GTest.cpp index 738ac7fc49..8b00ace08a 100644 --- a/src/utilities/filetypes/test/EpwFile_GTest.cpp +++ b/src/utilities/filetypes/test/EpwFile_GTest.cpp @@ -14,921 +14,844 @@ using namespace openstudio; TEST(Filetypes, EpwFile) { - try { - // LOCATION,Climate Zone 1,CA,USA,CTZRV2,725945,40.80,-124.20,-8.0,13.0 - // DESIGN CONDITIONS,1,Climate Design Data 2009 ASHRAE Handbook,,Heating,12,-0.6,0.6,-4.1,2.7,5.3,-2.2,3.2,3.8,11.1,12.3,9.7,11.3,2,90,Cooling,8,6.5,21.6,15.2,19.9,15.1,18.7,14.6,16.8,19.5,16.1,18.6,15.5,17.6,4.3,320,15.9,11.4,17.5,15.1,10.8,16.8,14.4,10.3,16.2,47.3,19.8,45,18.5,43.3,17.6,1804,Extremes,9,8.2,7.4,20.8,-2.5,28.3,1.7,2.2,-3.7,29.8,-4.6,31.1,-5.6,32.3,-6.8,33.9 - // TYPICAL/EXTREME PERIODS,6,Summer - Week Nearest Max Temperature For Period,Extreme,7/ 8,7/14,Summer - Week Nearest Average Temperature For Period,Typical,8/12,8/18,Winter - Week Nearest Min Temperature For Period,Extreme,1/15,1/21,Winter - Week Nearest Average Temperature For Period,Typical,1/22,1/28,Autumn - Week Nearest Average Temperature For Period,Typical,11/26,12/ 2,Spring - Week Nearest Average Temperature For Period,Typical,5/27,6/ 2 - // GROUND TEMPERATURES,3,.5,,,,9.66,10.10,10.96,11.78,13.32,14.13,14.35,13.94,12.99,11.81,10.64,9.87,2,,,,10.27,10.38,10.87,11.41,12.60,13.35,13.73,13.65,13.10,12.29,11.37,10.64,4,,,,10.90,10.82,11.04,11.35,12.13,12.72,13.10,13.19,12.95,12.47,11.85,11.28 - // HOLIDAYS/DAYLIGHT SAVINGS,No,0,0,0 - // COMMENTS 1,California Climate Zone 01 Version 2; - // COMMENTS 2, -- Ground temps produced with a standard soil diffusivity of 2.3225760E-03 {m**2/day} - // DATA PERIODS,1,1,Data,Sunday, 1/ 1,12/31 - path p = resourcesPath() / toPath("utilities/Filetypes/USA_CO_Golden-NREL.724666_TMY3.epw"); - EpwFile epwFile(p); - EXPECT_EQ(p, epwFile.path()); - EXPECT_EQ("BDF687C1", epwFile.checksum()); - EXPECT_EQ(openstudio::checksum(epwFile.path()), epwFile.checksum()); - EXPECT_EQ("Denver Centennial Golden Nr", epwFile.city()); - EXPECT_EQ("CO", epwFile.stateProvinceRegion()); - EXPECT_EQ("USA", epwFile.country()); - EXPECT_EQ("TMY3", epwFile.dataSource()); - EXPECT_EQ("724666", epwFile.wmoNumber()); - EXPECT_EQ(39.74, epwFile.latitude()); - EXPECT_EQ(-105.18, epwFile.longitude()); - EXPECT_EQ(-7, epwFile.timeZone()); - EXPECT_EQ(1829, epwFile.elevation()); - EXPECT_EQ(Time(0, 1, 0, 0), epwFile.timeStep()); - EXPECT_EQ(DayOfWeek(DayOfWeek::Sunday), epwFile.startDayOfWeek()); - EXPECT_EQ(Date(MonthOfYear::Jan, 1), epwFile.startDate()); - EXPECT_EQ(Date(MonthOfYear::Dec, 31), epwFile.endDate()); - EXPECT_FALSE(epwFile.isActual()); - } catch (...) { - ASSERT_TRUE(false); - } + // LOCATION,Climate Zone 1,CA,USA,CTZRV2,725945,40.80,-124.20,-8.0,13.0 + // DESIGN CONDITIONS,1,Climate Design Data 2009 ASHRAE Handbook,,Heating,12,-0.6,0.6,-4.1,2.7,5.3,-2.2,3.2,3.8,11.1,12.3,9.7,11.3,2,90,Cooling,8,6.5,21.6,15.2,19.9,15.1,18.7,14.6,16.8,19.5,16.1,18.6,15.5,17.6,4.3,320,15.9,11.4,17.5,15.1,10.8,16.8,14.4,10.3,16.2,47.3,19.8,45,18.5,43.3,17.6,1804,Extremes,9,8.2,7.4,20.8,-2.5,28.3,1.7,2.2,-3.7,29.8,-4.6,31.1,-5.6,32.3,-6.8,33.9 + // TYPICAL/EXTREME PERIODS,6,Summer - Week Nearest Max Temperature For Period,Extreme,7/ 8,7/14,Summer - Week Nearest Average Temperature For Period,Typical,8/12,8/18,Winter - Week Nearest Min Temperature For Period,Extreme,1/15,1/21,Winter - Week Nearest Average Temperature For Period,Typical,1/22,1/28,Autumn - Week Nearest Average Temperature For Period,Typical,11/26,12/ 2,Spring - Week Nearest Average Temperature For Period,Typical,5/27,6/ 2 + // GROUND TEMPERATURES,3,.5,,,,9.66,10.10,10.96,11.78,13.32,14.13,14.35,13.94,12.99,11.81,10.64,9.87,2,,,,10.27,10.38,10.87,11.41,12.60,13.35,13.73,13.65,13.10,12.29,11.37,10.64,4,,,,10.90,10.82,11.04,11.35,12.13,12.72,13.10,13.19,12.95,12.47,11.85,11.28 + // HOLIDAYS/DAYLIGHT SAVINGS,No,0,0,0 + // COMMENTS 1,California Climate Zone 01 Version 2; + // COMMENTS 2, -- Ground temps produced with a standard soil diffusivity of 2.3225760E-03 {m**2/day} + // DATA PERIODS,1,1,Data,Sunday, 1/ 1,12/31 + path p = resourcesPath() / toPath("utilities/Filetypes/USA_CO_Golden-NREL.724666_TMY3.epw"); + EpwFile epwFile(p); + EXPECT_EQ(p, epwFile.path()); + EXPECT_EQ("BDF687C1", epwFile.checksum()); + EXPECT_EQ(openstudio::checksum(epwFile.path()), epwFile.checksum()); + EXPECT_EQ("Denver Centennial Golden Nr", epwFile.city()); + EXPECT_EQ("CO", epwFile.stateProvinceRegion()); + EXPECT_EQ("USA", epwFile.country()); + EXPECT_EQ("TMY3", epwFile.dataSource()); + EXPECT_EQ("724666", epwFile.wmoNumber()); + EXPECT_EQ(39.74, epwFile.latitude()); + EXPECT_EQ(-105.18, epwFile.longitude()); + EXPECT_EQ(-7, epwFile.timeZone()); + EXPECT_EQ(1829, epwFile.elevation()); + EXPECT_EQ(Time(0, 1, 0, 0), epwFile.timeStep()); + EXPECT_EQ(DayOfWeek(DayOfWeek::Sunday), epwFile.startDayOfWeek()); + EXPECT_EQ(Date(MonthOfYear::Jan, 1), epwFile.startDate()); + EXPECT_EQ(Date(MonthOfYear::Dec, 31), epwFile.endDate()); + EXPECT_FALSE(epwFile.isActual()); } TEST(Filetypes, EpwFile_Data) { - try { - path p = resourcesPath() / toPath("utilities/Filetypes/USA_CO_Golden-NREL.724666_TMY3.epw"); - EpwFile epwFile(p); - EXPECT_EQ(p, epwFile.path()); - EXPECT_EQ("BDF687C1", epwFile.checksum()); - EXPECT_EQ(openstudio::checksum(epwFile.path()), epwFile.checksum()); - EXPECT_EQ("Denver Centennial Golden Nr", epwFile.city()); - EXPECT_EQ("CO", epwFile.stateProvinceRegion()); - EXPECT_EQ("USA", epwFile.country()); - EXPECT_EQ("TMY3", epwFile.dataSource()); - EXPECT_EQ("724666", epwFile.wmoNumber()); - EXPECT_EQ(39.74, epwFile.latitude()); - EXPECT_EQ(-105.18, epwFile.longitude()); - EXPECT_EQ(-7, epwFile.timeZone()); - EXPECT_EQ(1829, epwFile.elevation()); - EXPECT_EQ(Time(0, 1, 0, 0), epwFile.timeStep()); - EXPECT_EQ(DayOfWeek(DayOfWeek::Sunday), epwFile.startDayOfWeek()); - EXPECT_EQ(Date(MonthOfYear::Jan, 1), epwFile.startDate()); - EXPECT_EQ(Date(MonthOfYear::Dec, 31), epwFile.endDate()); - // Up to here, everything should be the same as the first test. Now ask for the data - std::vector data = epwFile.data(); - EXPECT_EQ(8760, data.size()); - // The last data point should be for the last hour 12/31/1996, with a dry bulb temp of 4C and pressure 81100 - // Gets reported as "1997-Jan-01 00:00:00" - openstudio::DateTime dateTime = data[8759].dateTime(); - EXPECT_EQ(1, dateTime.date().monthOfYear().value()); - EXPECT_EQ(1, dateTime.date().dayOfMonth()); - EXPECT_EQ(1997, dateTime.date().year()); - EXPECT_EQ(0, dateTime.time().hours()); - EXPECT_EQ(0, dateTime.time().minutes()); - EXPECT_EQ(0, dateTime.time().seconds()); - EXPECT_EQ(4.0, data[8759].dryBulbTemperature().get()); - EXPECT_EQ(81100, data[8759].atmosphericStationPressure().get()); - // Try out the alternate access functions, dew point temperature should be -1C - EXPECT_EQ(-1.0, data[8759].getFieldByName("Dew Point Temperature").get()); - EXPECT_EQ(-1.0, data[8759].getField(EpwDataField("Dew Point Temperature")).get()); - // The last data point should not have a liquid precipitation depth - EXPECT_FALSE(data[8759].getFieldByName("Liquid Precipitation Depth")); - // Get the data as strings - std::vector epwStrings = data[8759].toEpwStrings(); - ASSERT_EQ(35, epwStrings.size()); - std::vector known = {"1996", "12", "31", "24", "0", "?9?9?9?9E0?9?9?9?9?9?9?9?9?9?9?9?9?9?9?9*9*9?9*9*9", - "4.0", "-1.0", "69", "81100", "0", "0", - "294", "0.000000", "0", "0", "0", "0", - "0", "0", "130", "6.200000", "9", "9", - "48.3", "7500", "9", "999999999", "60", "0.0310", - "0", "88", "0.210", "999", "99"}; - for (unsigned i = 0; i < 35; i++) { - EXPECT_EQ(known[i], epwStrings[i]); - } - // Get a time series - boost::optional series = epwFile.getTimeSeries("Wind Speed"); - ASSERT_TRUE(series); - ASSERT_EQ(8760, series->values().size()); - DateTimeVector seriesTimes = series->dateTimes(); - ASSERT_EQ(8760, seriesTimes.size()); - // Check the times in the data and the time series - DateTime current(Date(1, 1, 1999), Time(0, 1)); // Use 1999 to avoid leap years - Time delta(0, 1); - for (unsigned i = 0; i < 8760; i++) { - // This is a lot more complicated that it probably should be to avoid the year being a problem - DateTime datatime = data[i].dateTime(); - EXPECT_EQ(datatime.date().monthOfYear(), current.date().monthOfYear()); - EXPECT_EQ(datatime.date().dayOfMonth(), current.date().dayOfMonth()); - EXPECT_EQ(datatime.time().hours(), current.time().hours()); - EXPECT_EQ(datatime.time().minutes(), current.time().minutes()); - DateTime seriestime = seriesTimes[i]; - EXPECT_EQ(seriestime.date().monthOfYear(), current.date().monthOfYear()); - EXPECT_EQ(seriestime.date().dayOfMonth(), current.date().dayOfMonth()); - EXPECT_EQ(seriestime.time().hours(), current.time().hours()); - EXPECT_EQ(seriestime.time().minutes(), current.time().minutes()); - current += delta; - } - // We should redo the original tests because we have reparsed the entire file - EXPECT_EQ(p, epwFile.path()); - EXPECT_EQ("BDF687C1", epwFile.checksum()); - EXPECT_EQ(openstudio::checksum(epwFile.path()), epwFile.checksum()); - EXPECT_EQ("Denver Centennial Golden Nr", epwFile.city()); - EXPECT_EQ("CO", epwFile.stateProvinceRegion()); - EXPECT_EQ("USA", epwFile.country()); - EXPECT_EQ("TMY3", epwFile.dataSource()); - EXPECT_EQ("724666", epwFile.wmoNumber()); - EXPECT_EQ(39.74, epwFile.latitude()); - EXPECT_EQ(-105.18, epwFile.longitude()); - EXPECT_EQ(-7, epwFile.timeZone()); - EXPECT_EQ(1829, epwFile.elevation()); - EXPECT_EQ(Time(0, 1, 0, 0), epwFile.timeStep()); - EXPECT_EQ(DayOfWeek(DayOfWeek::Sunday), epwFile.startDayOfWeek()); - EXPECT_EQ(Date(MonthOfYear::Jan, 1), epwFile.startDate()); - EXPECT_EQ(Date(MonthOfYear::Dec, 31), epwFile.endDate()); - EXPECT_FALSE(epwFile.isActual()); - } catch (...) { - ASSERT_TRUE(false); + path p = resourcesPath() / toPath("utilities/Filetypes/USA_CO_Golden-NREL.724666_TMY3.epw"); + EpwFile epwFile(p); + EXPECT_EQ(p, epwFile.path()); + EXPECT_EQ("BDF687C1", epwFile.checksum()); + EXPECT_EQ(openstudio::checksum(epwFile.path()), epwFile.checksum()); + EXPECT_EQ("Denver Centennial Golden Nr", epwFile.city()); + EXPECT_EQ("CO", epwFile.stateProvinceRegion()); + EXPECT_EQ("USA", epwFile.country()); + EXPECT_EQ("TMY3", epwFile.dataSource()); + EXPECT_EQ("724666", epwFile.wmoNumber()); + EXPECT_EQ(39.74, epwFile.latitude()); + EXPECT_EQ(-105.18, epwFile.longitude()); + EXPECT_EQ(-7, epwFile.timeZone()); + EXPECT_EQ(1829, epwFile.elevation()); + EXPECT_EQ(Time(0, 1, 0, 0), epwFile.timeStep()); + EXPECT_EQ(DayOfWeek(DayOfWeek::Sunday), epwFile.startDayOfWeek()); + EXPECT_EQ(Date(MonthOfYear::Jan, 1), epwFile.startDate()); + EXPECT_EQ(Date(MonthOfYear::Dec, 31), epwFile.endDate()); + // Up to here, everything should be the same as the first test. Now ask for the data + std::vector data = epwFile.data(); + EXPECT_EQ(8760, data.size()); + // The last data point should be for the last hour 12/31/1996, with a dry bulb temp of 4C and pressure 81100 + // Gets reported as "1997-Jan-01 00:00:00" + openstudio::DateTime dateTime = data[8759].dateTime(); + EXPECT_EQ(1, dateTime.date().monthOfYear().value()); + EXPECT_EQ(1, dateTime.date().dayOfMonth()); + EXPECT_EQ(1997, dateTime.date().year()); + EXPECT_EQ(0, dateTime.time().hours()); + EXPECT_EQ(0, dateTime.time().minutes()); + EXPECT_EQ(0, dateTime.time().seconds()); + EXPECT_EQ(4.0, data[8759].dryBulbTemperature().get()); + EXPECT_EQ(81100, data[8759].atmosphericStationPressure().get()); + // Try out the alternate access functions, dew point temperature should be -1C + EXPECT_EQ(-1.0, data[8759].getFieldByName("Dew Point Temperature").get()); + EXPECT_EQ(-1.0, data[8759].getField(EpwDataField("Dew Point Temperature")).get()); + // The last data point should not have a liquid precipitation depth + EXPECT_FALSE(data[8759].getFieldByName("Liquid Precipitation Depth")); + // Get the data as strings + std::vector epwStrings = data[8759].toEpwStrings(); + ASSERT_EQ(35, epwStrings.size()); + std::vector known = {"1996", "12", "31", "24", "0", "?9?9?9?9E0?9?9?9?9?9?9?9?9?9?9?9?9?9?9?9*9*9?9*9*9", + "4.0", "-1.0", "69", "81100", "0", "0", + "294", "0.000000", "0", "0", "0", "0", + "0", "0", "130", "6.200000", "9", "9", + "48.3", "7500", "9", "999999999", "60", "0.0310", + "0", "88", "0.210", "999", "99"}; + for (unsigned i = 0; i < 35; i++) { + EXPECT_EQ(known[i], epwStrings[i]); + } + // Get a time series + boost::optional series = epwFile.getTimeSeries("Wind Speed"); + ASSERT_TRUE(series); + ASSERT_EQ(8760, series->values().size()); + DateTimeVector seriesTimes = series->dateTimes(); + ASSERT_EQ(8760, seriesTimes.size()); + // Check the times in the data and the time series + DateTime current(Date(1, 1, 1999), Time(0, 1)); // Use 1999 to avoid leap years + Time delta(0, 1); + for (unsigned i = 0; i < 8760; i++) { + // This is a lot more complicated that it probably should be to avoid the year being a problem + DateTime datatime = data[i].dateTime(); + EXPECT_EQ(datatime.date().monthOfYear(), current.date().monthOfYear()); + EXPECT_EQ(datatime.date().dayOfMonth(), current.date().dayOfMonth()); + EXPECT_EQ(datatime.time().hours(), current.time().hours()); + EXPECT_EQ(datatime.time().minutes(), current.time().minutes()); + DateTime seriestime = seriesTimes[i]; + EXPECT_EQ(seriestime.date().monthOfYear(), current.date().monthOfYear()); + EXPECT_EQ(seriestime.date().dayOfMonth(), current.date().dayOfMonth()); + EXPECT_EQ(seriestime.time().hours(), current.time().hours()); + EXPECT_EQ(seriestime.time().minutes(), current.time().minutes()); + current += delta; } + // We should redo the original tests because we have reparsed the entire file + EXPECT_EQ(p, epwFile.path()); + EXPECT_EQ("BDF687C1", epwFile.checksum()); + EXPECT_EQ(openstudio::checksum(epwFile.path()), epwFile.checksum()); + EXPECT_EQ("Denver Centennial Golden Nr", epwFile.city()); + EXPECT_EQ("CO", epwFile.stateProvinceRegion()); + EXPECT_EQ("USA", epwFile.country()); + EXPECT_EQ("TMY3", epwFile.dataSource()); + EXPECT_EQ("724666", epwFile.wmoNumber()); + EXPECT_EQ(39.74, epwFile.latitude()); + EXPECT_EQ(-105.18, epwFile.longitude()); + EXPECT_EQ(-7, epwFile.timeZone()); + EXPECT_EQ(1829, epwFile.elevation()); + EXPECT_EQ(Time(0, 1, 0, 0), epwFile.timeStep()); + EXPECT_EQ(DayOfWeek(DayOfWeek::Sunday), epwFile.startDayOfWeek()); + EXPECT_EQ(Date(MonthOfYear::Jan, 1), epwFile.startDate()); + EXPECT_EQ(Date(MonthOfYear::Dec, 31), epwFile.endDate()); + EXPECT_FALSE(epwFile.isActual()); } TEST(Filetypes, EpwFile_Design) { - try { - path p = resourcesPath() / toPath("utilities/Filetypes/USA_CO_Golden-NREL.724666_TMY3.epw"); - EpwFile epwFile(p); - EXPECT_EQ(p, epwFile.path()); - EXPECT_EQ("BDF687C1", epwFile.checksum()); - EXPECT_EQ(openstudio::checksum(epwFile.path()), epwFile.checksum()); - EXPECT_EQ("Denver Centennial Golden Nr", epwFile.city()); - EXPECT_EQ("CO", epwFile.stateProvinceRegion()); - EXPECT_EQ("USA", epwFile.country()); - EXPECT_EQ("TMY3", epwFile.dataSource()); - EXPECT_EQ("724666", epwFile.wmoNumber()); - EXPECT_EQ(39.74, epwFile.latitude()); - EXPECT_EQ(-105.18, epwFile.longitude()); - EXPECT_EQ(-7, epwFile.timeZone()); - EXPECT_EQ(1829, epwFile.elevation()); - EXPECT_EQ(Time(0, 1, 0, 0), epwFile.timeStep()); - EXPECT_EQ(DayOfWeek(DayOfWeek::Sunday), epwFile.startDayOfWeek()); - EXPECT_EQ(Date(MonthOfYear::Jan, 1), epwFile.startDate()); - EXPECT_EQ(Date(MonthOfYear::Dec, 31), epwFile.endDate()); - // Up to here, everything should be the same as the first test. Now ask for the design conditions - std::vector designs = epwFile.designConditions(); - EXPECT_EQ(1, designs.size()); - EXPECT_EQ("Climate Design Data 2009 ASHRAE Handbook", designs[0].titleOfDesignCondition()); - EXPECT_EQ(12, designs[0].heatingColdestMonth().get()); - EXPECT_EQ(-18.8, designs[0].heatingDryBulb99pt6().get()); - EXPECT_EQ(-18.8, designs[0].getFieldByName("Heating Dry Bulb Temperature 99.6%").get()); - EXPECT_EQ(-18.8, designs[0].getField(EpwDesignField("Heating Dry Bulb Temperature 99.6%")).get()); - EXPECT_EQ("C", designs[0].getUnitsByName("Heating Dry Bulb Temperature 99.6%").get()); - EXPECT_EQ("C", designs[0].getUnits(EpwDesignField("Heating Dry Bulb Temperature 99.6%"))); - EXPECT_EQ(-15.5, designs[0].heatingDryBulb99().get()); - EXPECT_EQ(-21.6, designs[0].heatingHumidificationDewPoint99pt6().get()); - EXPECT_EQ(0.7, designs[0].heatingHumidificationHumidityRatio99pt6().get()); - EXPECT_EQ(-10.9, designs[0].heatingHumidificationMeanCoincidentDryBulb99pt6().get()); - EXPECT_EQ(-18.8, designs[0].heatingHumidificationDewPoint99().get()); - EXPECT_EQ(0.9, designs[0].heatingHumidificationHumidityRatio99().get()); - EXPECT_EQ(-7.5, designs[0].heatingHumidificationMeanCoincidentDryBulb99().get()); - EXPECT_EQ(12.2, designs[0].heatingColdestMonthWindSpeed0pt4().get()); - EXPECT_EQ(3.9, designs[0].heatingColdestMonthMeanCoincidentDryBulb0pt4().get()); - EXPECT_EQ(10.9, designs[0].heatingColdestMonthWindSpeed1().get()); - EXPECT_EQ(3.8, designs[0].heatingColdestMonthMeanCoincidentDryBulb1().get()); - EXPECT_EQ(3.0, designs[0].heatingMeanCoincidentWindSpeed99pt6().get()); - EXPECT_EQ(340, designs[0].heatingPrevailingCoincidentWindDirection99pt6().get()); - EXPECT_EQ(7, designs[0].coolingHottestMonth().get()); - EXPECT_EQ(15.2, designs[0].coolingDryBulbRange().get()); - EXPECT_EQ(33.0, designs[0].coolingDryBulb0pt4().get()); - EXPECT_EQ(15.7, designs[0].coolingMeanCoincidentWetBulb0pt4().get()); - EXPECT_EQ(32.0, designs[0].coolingDryBulb1().get()); - EXPECT_EQ(15.5, designs[0].coolingMeanCoincidentWetBulb1().get()); - EXPECT_EQ(30.2, designs[0].coolingDryBulb2().get()); - EXPECT_EQ(15.3, designs[0].coolingMeanCoincidentWetBulb2().get()); - EXPECT_EQ(18.4, designs[0].coolingEvaporationWetBulb0pt4().get()); - EXPECT_EQ(27.3, designs[0].coolingEvaporationMeanCoincidentDryBulb0pt4().get()); - EXPECT_EQ(17.5, designs[0].coolingEvaporationWetBulb1().get()); - EXPECT_EQ(26.4, designs[0].coolingEvaporationMeanCoincidentDryBulb1().get()); - EXPECT_EQ(16.8, designs[0].coolingEvaporationWetBulb2().get()); - EXPECT_EQ(25.6, designs[0].coolingEvaporationMeanCoincidentDryBulb2().get()); - EXPECT_EQ(4.9, designs[0].coolingMeanCoincidentWindSpeed0pt4().get()); - EXPECT_EQ(0, designs[0].coolingPrevailingCoincidentWindDirection0pt4().get()); - EXPECT_EQ(16.1, designs[0].coolingDehumidificationDewPoint0pt4().get()); - EXPECT_EQ(14.3, designs[0].coolingDehumidificationHumidityRatio0pt4().get()); - EXPECT_EQ(20.2, designs[0].coolingDehumidificationMeanCoincidentDryBulb0pt4().get()); - EXPECT_EQ(14.9, designs[0].coolingDehumidificationDewPoint1().get()); - EXPECT_EQ(13.2, designs[0].coolingDehumidificationHumidityRatio1().get()); - EXPECT_EQ(19.9, designs[0].coolingDehumidificationMeanCoincidentDryBulb1().get()); - EXPECT_EQ(13.9, designs[0].coolingDehumidificationDewPoint2().get()); - EXPECT_EQ(12.3, designs[0].coolingDehumidificationHumidityRatio2().get()); - EXPECT_EQ(19.6, designs[0].coolingDehumidificationMeanCoincidentDryBulb2().get()); - EXPECT_EQ(59.7, designs[0].coolingEnthalpy0pt4().get()); - EXPECT_EQ(27.3, designs[0].coolingEnthalpyMeanCoincidentDryBulb0pt4().get()); - EXPECT_EQ(56.6, designs[0].coolingEnthalpy1().get()); - EXPECT_EQ(26.6, designs[0].coolingEnthalpyMeanCoincidentDryBulb1().get()); - EXPECT_EQ(54.0, designs[0].coolingEnthalpy2().get()); - EXPECT_EQ(25.7, designs[0].coolingEnthalpyMeanCoincidentDryBulb2().get()); - EXPECT_EQ(760, designs[0].coolingHours8To4AndDryBulb12pt8To20pt6().get()); - EXPECT_EQ(11.1, designs[0].extremeWindSpeed1().get()); - EXPECT_EQ(9.5, designs[0].extremeWindSpeed2pt5().get()); - EXPECT_EQ(8.4, designs[0].extremeWindSpeed5().get()); - EXPECT_EQ(22.9, designs[0].extremeMaxWetBulb().get()); - EXPECT_EQ(-22.9, designs[0].extremeMeanMinDryBulb().get()); - EXPECT_EQ(36.1, designs[0].extremeMeanMaxDryBulb().get()); - EXPECT_EQ(3.8, designs[0].extremeStdDevMinDryBulb().get()); - EXPECT_EQ(1.2, designs[0].extremeStdDevMaxDryBulb().get()); - EXPECT_EQ(-25.7, designs[0].extremeN5YearsMinDryBulb().get()); - EXPECT_EQ(37.0, designs[0].extremeN5YearsMaxDryBulb().get()); - EXPECT_EQ(-27.9, designs[0].extremeN10YearsMinDryBulb().get()); - EXPECT_EQ(37.7, designs[0].extremeN10YearsMaxDryBulb().get()); - EXPECT_EQ(-30.1, designs[0].extremeN20YearsMinDryBulb().get()); - EXPECT_EQ(38.3, designs[0].extremeN20YearsMaxDryBulb().get()); - EXPECT_EQ(-32.8, designs[0].extremeN50YearsMinDryBulb().get()); - EXPECT_EQ(39.2, designs[0].extremeN50YearsMaxDryBulb().get()); - } catch (...) { - ASSERT_TRUE(false); - } + path p = resourcesPath() / toPath("utilities/Filetypes/USA_CO_Golden-NREL.724666_TMY3.epw"); + EpwFile epwFile(p); + EXPECT_EQ(p, epwFile.path()); + EXPECT_EQ("BDF687C1", epwFile.checksum()); + EXPECT_EQ(openstudio::checksum(epwFile.path()), epwFile.checksum()); + EXPECT_EQ("Denver Centennial Golden Nr", epwFile.city()); + EXPECT_EQ("CO", epwFile.stateProvinceRegion()); + EXPECT_EQ("USA", epwFile.country()); + EXPECT_EQ("TMY3", epwFile.dataSource()); + EXPECT_EQ("724666", epwFile.wmoNumber()); + EXPECT_EQ(39.74, epwFile.latitude()); + EXPECT_EQ(-105.18, epwFile.longitude()); + EXPECT_EQ(-7, epwFile.timeZone()); + EXPECT_EQ(1829, epwFile.elevation()); + EXPECT_EQ(Time(0, 1, 0, 0), epwFile.timeStep()); + EXPECT_EQ(DayOfWeek(DayOfWeek::Sunday), epwFile.startDayOfWeek()); + EXPECT_EQ(Date(MonthOfYear::Jan, 1), epwFile.startDate()); + EXPECT_EQ(Date(MonthOfYear::Dec, 31), epwFile.endDate()); + // Up to here, everything should be the same as the first test. Now ask for the design conditions + std::vector designs = epwFile.designConditions(); + EXPECT_EQ(1, designs.size()); + EXPECT_EQ("Climate Design Data 2009 ASHRAE Handbook", designs[0].titleOfDesignCondition()); + EXPECT_EQ(12, designs[0].heatingColdestMonth().get()); + EXPECT_EQ(-18.8, designs[0].heatingDryBulb99pt6().get()); + EXPECT_EQ(-18.8, designs[0].getFieldByName("Heating Dry Bulb Temperature 99.6%").get()); + EXPECT_EQ(-18.8, designs[0].getField(EpwDesignField("Heating Dry Bulb Temperature 99.6%")).get()); + EXPECT_EQ("C", designs[0].getUnitsByName("Heating Dry Bulb Temperature 99.6%").get()); + EXPECT_EQ("C", designs[0].getUnits(EpwDesignField("Heating Dry Bulb Temperature 99.6%"))); + EXPECT_EQ(-15.5, designs[0].heatingDryBulb99().get()); + EXPECT_EQ(-21.6, designs[0].heatingHumidificationDewPoint99pt6().get()); + EXPECT_EQ(0.7, designs[0].heatingHumidificationHumidityRatio99pt6().get()); + EXPECT_EQ(-10.9, designs[0].heatingHumidificationMeanCoincidentDryBulb99pt6().get()); + EXPECT_EQ(-18.8, designs[0].heatingHumidificationDewPoint99().get()); + EXPECT_EQ(0.9, designs[0].heatingHumidificationHumidityRatio99().get()); + EXPECT_EQ(-7.5, designs[0].heatingHumidificationMeanCoincidentDryBulb99().get()); + EXPECT_EQ(12.2, designs[0].heatingColdestMonthWindSpeed0pt4().get()); + EXPECT_EQ(3.9, designs[0].heatingColdestMonthMeanCoincidentDryBulb0pt4().get()); + EXPECT_EQ(10.9, designs[0].heatingColdestMonthWindSpeed1().get()); + EXPECT_EQ(3.8, designs[0].heatingColdestMonthMeanCoincidentDryBulb1().get()); + EXPECT_EQ(3.0, designs[0].heatingMeanCoincidentWindSpeed99pt6().get()); + EXPECT_EQ(340, designs[0].heatingPrevailingCoincidentWindDirection99pt6().get()); + EXPECT_EQ(7, designs[0].coolingHottestMonth().get()); + EXPECT_EQ(15.2, designs[0].coolingDryBulbRange().get()); + EXPECT_EQ(33.0, designs[0].coolingDryBulb0pt4().get()); + EXPECT_EQ(15.7, designs[0].coolingMeanCoincidentWetBulb0pt4().get()); + EXPECT_EQ(32.0, designs[0].coolingDryBulb1().get()); + EXPECT_EQ(15.5, designs[0].coolingMeanCoincidentWetBulb1().get()); + EXPECT_EQ(30.2, designs[0].coolingDryBulb2().get()); + EXPECT_EQ(15.3, designs[0].coolingMeanCoincidentWetBulb2().get()); + EXPECT_EQ(18.4, designs[0].coolingEvaporationWetBulb0pt4().get()); + EXPECT_EQ(27.3, designs[0].coolingEvaporationMeanCoincidentDryBulb0pt4().get()); + EXPECT_EQ(17.5, designs[0].coolingEvaporationWetBulb1().get()); + EXPECT_EQ(26.4, designs[0].coolingEvaporationMeanCoincidentDryBulb1().get()); + EXPECT_EQ(16.8, designs[0].coolingEvaporationWetBulb2().get()); + EXPECT_EQ(25.6, designs[0].coolingEvaporationMeanCoincidentDryBulb2().get()); + EXPECT_EQ(4.9, designs[0].coolingMeanCoincidentWindSpeed0pt4().get()); + EXPECT_EQ(0, designs[0].coolingPrevailingCoincidentWindDirection0pt4().get()); + EXPECT_EQ(16.1, designs[0].coolingDehumidificationDewPoint0pt4().get()); + EXPECT_EQ(14.3, designs[0].coolingDehumidificationHumidityRatio0pt4().get()); + EXPECT_EQ(20.2, designs[0].coolingDehumidificationMeanCoincidentDryBulb0pt4().get()); + EXPECT_EQ(14.9, designs[0].coolingDehumidificationDewPoint1().get()); + EXPECT_EQ(13.2, designs[0].coolingDehumidificationHumidityRatio1().get()); + EXPECT_EQ(19.9, designs[0].coolingDehumidificationMeanCoincidentDryBulb1().get()); + EXPECT_EQ(13.9, designs[0].coolingDehumidificationDewPoint2().get()); + EXPECT_EQ(12.3, designs[0].coolingDehumidificationHumidityRatio2().get()); + EXPECT_EQ(19.6, designs[0].coolingDehumidificationMeanCoincidentDryBulb2().get()); + EXPECT_EQ(59.7, designs[0].coolingEnthalpy0pt4().get()); + EXPECT_EQ(27.3, designs[0].coolingEnthalpyMeanCoincidentDryBulb0pt4().get()); + EXPECT_EQ(56.6, designs[0].coolingEnthalpy1().get()); + EXPECT_EQ(26.6, designs[0].coolingEnthalpyMeanCoincidentDryBulb1().get()); + EXPECT_EQ(54.0, designs[0].coolingEnthalpy2().get()); + EXPECT_EQ(25.7, designs[0].coolingEnthalpyMeanCoincidentDryBulb2().get()); + EXPECT_EQ(760, designs[0].coolingHours8To4AndDryBulb12pt8To20pt6().get()); + EXPECT_EQ(11.1, designs[0].extremeWindSpeed1().get()); + EXPECT_EQ(9.5, designs[0].extremeWindSpeed2pt5().get()); + EXPECT_EQ(8.4, designs[0].extremeWindSpeed5().get()); + EXPECT_EQ(22.9, designs[0].extremeMaxWetBulb().get()); + EXPECT_EQ(-22.9, designs[0].extremeMeanMinDryBulb().get()); + EXPECT_EQ(36.1, designs[0].extremeMeanMaxDryBulb().get()); + EXPECT_EQ(3.8, designs[0].extremeStdDevMinDryBulb().get()); + EXPECT_EQ(1.2, designs[0].extremeStdDevMaxDryBulb().get()); + EXPECT_EQ(-25.7, designs[0].extremeN5YearsMinDryBulb().get()); + EXPECT_EQ(37.0, designs[0].extremeN5YearsMaxDryBulb().get()); + EXPECT_EQ(-27.9, designs[0].extremeN10YearsMinDryBulb().get()); + EXPECT_EQ(37.7, designs[0].extremeN10YearsMaxDryBulb().get()); + EXPECT_EQ(-30.1, designs[0].extremeN20YearsMinDryBulb().get()); + EXPECT_EQ(38.3, designs[0].extremeN20YearsMaxDryBulb().get()); + EXPECT_EQ(-32.8, designs[0].extremeN50YearsMinDryBulb().get()); + EXPECT_EQ(39.2, designs[0].extremeN50YearsMaxDryBulb().get()); } TEST(Filetypes, EpwFile_Design_DoubleRead) { - try { - path p = resourcesPath() / toPath("utilities/Filetypes/USA_CO_Golden-NREL.724666_TMY3.epw"); - EpwFile epwFile(p); - EXPECT_EQ(p, epwFile.path()); - EXPECT_EQ("BDF687C1", epwFile.checksum()); - EXPECT_EQ(openstudio::checksum(epwFile.path()), epwFile.checksum()); - EXPECT_EQ("Denver Centennial Golden Nr", epwFile.city()); - EXPECT_EQ("CO", epwFile.stateProvinceRegion()); - EXPECT_EQ("USA", epwFile.country()); - EXPECT_EQ("TMY3", epwFile.dataSource()); - EXPECT_EQ("724666", epwFile.wmoNumber()); - EXPECT_EQ(39.74, epwFile.latitude()); - EXPECT_EQ(-105.18, epwFile.longitude()); - EXPECT_EQ(-7, epwFile.timeZone()); - EXPECT_EQ(1829, epwFile.elevation()); - EXPECT_EQ(Time(0, 1, 0, 0), epwFile.timeStep()); - EXPECT_EQ(DayOfWeek(DayOfWeek::Sunday), epwFile.startDayOfWeek()); - EXPECT_EQ(Date(MonthOfYear::Jan, 1), epwFile.startDate()); - EXPECT_EQ(Date(MonthOfYear::Dec, 31), epwFile.endDate()); - // Ask for data - std::vector data = epwFile.data(); - EXPECT_EQ(8760, data.size()); - // The last data point should be for the last hour 12/31/1996, with a dry bulb temp of 4C and pressure 81100 - openstudio::DateTime dateTime = data[8759].dateTime(); - EXPECT_EQ(1, dateTime.date().monthOfYear().value()); - EXPECT_EQ(1, dateTime.date().dayOfMonth()); - EXPECT_EQ(1997, dateTime.date().year()); - EXPECT_EQ(0, dateTime.time().hours()); - EXPECT_EQ(0, dateTime.time().minutes()); - EXPECT_EQ(0, dateTime.time().seconds()); - EXPECT_EQ(4.0, data[8759].dryBulbTemperature().get()); - EXPECT_EQ(81100, data[8759].atmosphericStationPressure().get()); - // Try out the alternate access functions, dew point temperature should be -1C - EXPECT_EQ(-1.0, data[8759].getFieldByName("Dew Point Temperature").get()); - EXPECT_EQ(-1.0, data[8759].getField(EpwDataField("Dew Point Temperature")).get()); - // The last data point should not have a liquid precipitation depth - EXPECT_FALSE(data[8759].getFieldByName("Liquid Precipitation Depth")); - // Ask for the design conditions - std::vector designs = epwFile.designConditions(); - EXPECT_EQ(1, designs.size()); - EXPECT_EQ("Climate Design Data 2009 ASHRAE Handbook", designs[0].titleOfDesignCondition()); - EXPECT_EQ(12, designs[0].heatingColdestMonth().get()); - EXPECT_EQ(-18.8, designs[0].heatingDryBulb99pt6().get()); - EXPECT_EQ(-18.8, designs[0].getFieldByName("Heating Dry Bulb Temperature 99.6%").get()); - EXPECT_EQ(-18.8, designs[0].getField(EpwDesignField("Heating Dry Bulb Temperature 99.6%")).get()); - EXPECT_EQ("C", designs[0].getUnitsByName("Heating Dry Bulb Temperature 99.6%").get()); - EXPECT_EQ("C", designs[0].getUnits(EpwDesignField("Heating Dry Bulb Temperature 99.6%"))); - ASSERT_TRUE(designs[0].heatingDryBulb99().get()); - EXPECT_EQ(-15.5, designs[0].heatingDryBulb99().get()); - EXPECT_EQ(-21.6, designs[0].heatingHumidificationDewPoint99pt6().get()); - EXPECT_EQ(0.7, designs[0].heatingHumidificationHumidityRatio99pt6().get()); - EXPECT_EQ(-10.9, designs[0].heatingHumidificationMeanCoincidentDryBulb99pt6().get()); - EXPECT_EQ(-18.8, designs[0].heatingHumidificationDewPoint99().get()); - EXPECT_EQ(0.9, designs[0].heatingHumidificationHumidityRatio99().get()); - EXPECT_EQ(-7.5, designs[0].heatingHumidificationMeanCoincidentDryBulb99().get()); - EXPECT_EQ(12.2, designs[0].heatingColdestMonthWindSpeed0pt4().get()); - EXPECT_EQ(3.9, designs[0].heatingColdestMonthMeanCoincidentDryBulb0pt4().get()); - EXPECT_EQ(10.9, designs[0].heatingColdestMonthWindSpeed1().get()); - EXPECT_EQ(3.8, designs[0].heatingColdestMonthMeanCoincidentDryBulb1().get()); - EXPECT_EQ(3.0, designs[0].heatingMeanCoincidentWindSpeed99pt6().get()); - EXPECT_EQ(340, designs[0].heatingPrevailingCoincidentWindDirection99pt6().get()); - EXPECT_EQ(7, designs[0].coolingHottestMonth().get()); - EXPECT_EQ(15.2, designs[0].coolingDryBulbRange().get()); - EXPECT_EQ(33.0, designs[0].coolingDryBulb0pt4().get()); - EXPECT_EQ(15.7, designs[0].coolingMeanCoincidentWetBulb0pt4().get()); - EXPECT_EQ(32.0, designs[0].coolingDryBulb1().get()); - EXPECT_EQ(15.5, designs[0].coolingMeanCoincidentWetBulb1().get()); - EXPECT_EQ(30.2, designs[0].coolingDryBulb2().get()); - EXPECT_EQ(15.3, designs[0].coolingMeanCoincidentWetBulb2().get()); - EXPECT_EQ(18.4, designs[0].coolingEvaporationWetBulb0pt4().get()); - EXPECT_EQ(27.3, designs[0].coolingEvaporationMeanCoincidentDryBulb0pt4().get()); - EXPECT_EQ(17.5, designs[0].coolingEvaporationWetBulb1().get()); - EXPECT_EQ(26.4, designs[0].coolingEvaporationMeanCoincidentDryBulb1().get()); - EXPECT_EQ(16.8, designs[0].coolingEvaporationWetBulb2().get()); - EXPECT_EQ(25.6, designs[0].coolingEvaporationMeanCoincidentDryBulb2().get()); - EXPECT_EQ(4.9, designs[0].coolingMeanCoincidentWindSpeed0pt4().get()); - EXPECT_EQ(0, designs[0].coolingPrevailingCoincidentWindDirection0pt4().get()); - EXPECT_EQ(16.1, designs[0].coolingDehumidificationDewPoint0pt4().get()); - EXPECT_EQ(14.3, designs[0].coolingDehumidificationHumidityRatio0pt4().get()); - EXPECT_EQ(20.2, designs[0].coolingDehumidificationMeanCoincidentDryBulb0pt4().get()); - EXPECT_EQ(14.9, designs[0].coolingDehumidificationDewPoint1().get()); - EXPECT_EQ(13.2, designs[0].coolingDehumidificationHumidityRatio1().get()); - EXPECT_EQ(19.9, designs[0].coolingDehumidificationMeanCoincidentDryBulb1().get()); - EXPECT_EQ(13.9, designs[0].coolingDehumidificationDewPoint2().get()); - EXPECT_EQ(12.3, designs[0].coolingDehumidificationHumidityRatio2().get()); - EXPECT_EQ(19.6, designs[0].coolingDehumidificationMeanCoincidentDryBulb2().get()); - EXPECT_EQ(59.7, designs[0].coolingEnthalpy0pt4().get()); - EXPECT_EQ(27.3, designs[0].coolingEnthalpyMeanCoincidentDryBulb0pt4().get()); - EXPECT_EQ(56.6, designs[0].coolingEnthalpy1().get()); - EXPECT_EQ(26.6, designs[0].coolingEnthalpyMeanCoincidentDryBulb1().get()); - EXPECT_EQ(54.0, designs[0].coolingEnthalpy2().get()); - EXPECT_EQ(25.7, designs[0].coolingEnthalpyMeanCoincidentDryBulb2().get()); - EXPECT_EQ(760, designs[0].coolingHours8To4AndDryBulb12pt8To20pt6().get()); - EXPECT_EQ(11.1, designs[0].extremeWindSpeed1().get()); - EXPECT_EQ(9.5, designs[0].extremeWindSpeed2pt5().get()); - EXPECT_EQ(8.4, designs[0].extremeWindSpeed5().get()); - EXPECT_EQ(22.9, designs[0].extremeMaxWetBulb().get()); - EXPECT_EQ(-22.9, designs[0].extremeMeanMinDryBulb().get()); - EXPECT_EQ(36.1, designs[0].extremeMeanMaxDryBulb().get()); - EXPECT_EQ(3.8, designs[0].extremeStdDevMinDryBulb().get()); - EXPECT_EQ(1.2, designs[0].extremeStdDevMaxDryBulb().get()); - EXPECT_EQ(-25.7, designs[0].extremeN5YearsMinDryBulb().get()); - EXPECT_EQ(37.0, designs[0].extremeN5YearsMaxDryBulb().get()); - EXPECT_EQ(-27.9, designs[0].extremeN10YearsMinDryBulb().get()); - EXPECT_EQ(37.7, designs[0].extremeN10YearsMaxDryBulb().get()); - EXPECT_EQ(-30.1, designs[0].extremeN20YearsMinDryBulb().get()); - EXPECT_EQ(38.3, designs[0].extremeN20YearsMaxDryBulb().get()); - EXPECT_EQ(-32.8, designs[0].extremeN50YearsMinDryBulb().get()); - EXPECT_EQ(39.2, designs[0].extremeN50YearsMaxDryBulb().get()); - // Check that the data is the right size - data = epwFile.data(); - EXPECT_EQ(8760, data.size()); - } catch (...) { - ASSERT_TRUE(false); - } + path p = resourcesPath() / toPath("utilities/Filetypes/USA_CO_Golden-NREL.724666_TMY3.epw"); + EpwFile epwFile(p); + EXPECT_EQ(p, epwFile.path()); + EXPECT_EQ("BDF687C1", epwFile.checksum()); + EXPECT_EQ(openstudio::checksum(epwFile.path()), epwFile.checksum()); + EXPECT_EQ("Denver Centennial Golden Nr", epwFile.city()); + EXPECT_EQ("CO", epwFile.stateProvinceRegion()); + EXPECT_EQ("USA", epwFile.country()); + EXPECT_EQ("TMY3", epwFile.dataSource()); + EXPECT_EQ("724666", epwFile.wmoNumber()); + EXPECT_EQ(39.74, epwFile.latitude()); + EXPECT_EQ(-105.18, epwFile.longitude()); + EXPECT_EQ(-7, epwFile.timeZone()); + EXPECT_EQ(1829, epwFile.elevation()); + EXPECT_EQ(Time(0, 1, 0, 0), epwFile.timeStep()); + EXPECT_EQ(DayOfWeek(DayOfWeek::Sunday), epwFile.startDayOfWeek()); + EXPECT_EQ(Date(MonthOfYear::Jan, 1), epwFile.startDate()); + EXPECT_EQ(Date(MonthOfYear::Dec, 31), epwFile.endDate()); + // Ask for data + std::vector data = epwFile.data(); + EXPECT_EQ(8760, data.size()); + // The last data point should be for the last hour 12/31/1996, with a dry bulb temp of 4C and pressure 81100 + openstudio::DateTime dateTime = data[8759].dateTime(); + EXPECT_EQ(1, dateTime.date().monthOfYear().value()); + EXPECT_EQ(1, dateTime.date().dayOfMonth()); + EXPECT_EQ(1997, dateTime.date().year()); + EXPECT_EQ(0, dateTime.time().hours()); + EXPECT_EQ(0, dateTime.time().minutes()); + EXPECT_EQ(0, dateTime.time().seconds()); + EXPECT_EQ(4.0, data[8759].dryBulbTemperature().get()); + EXPECT_EQ(81100, data[8759].atmosphericStationPressure().get()); + // Try out the alternate access functions, dew point temperature should be -1C + EXPECT_EQ(-1.0, data[8759].getFieldByName("Dew Point Temperature").get()); + EXPECT_EQ(-1.0, data[8759].getField(EpwDataField("Dew Point Temperature")).get()); + // The last data point should not have a liquid precipitation depth + EXPECT_FALSE(data[8759].getFieldByName("Liquid Precipitation Depth")); + // Ask for the design conditions + std::vector designs = epwFile.designConditions(); + EXPECT_EQ(1, designs.size()); + EXPECT_EQ("Climate Design Data 2009 ASHRAE Handbook", designs[0].titleOfDesignCondition()); + EXPECT_EQ(12, designs[0].heatingColdestMonth().get()); + EXPECT_EQ(-18.8, designs[0].heatingDryBulb99pt6().get()); + EXPECT_EQ(-18.8, designs[0].getFieldByName("Heating Dry Bulb Temperature 99.6%").get()); + EXPECT_EQ(-18.8, designs[0].getField(EpwDesignField("Heating Dry Bulb Temperature 99.6%")).get()); + EXPECT_EQ("C", designs[0].getUnitsByName("Heating Dry Bulb Temperature 99.6%").get()); + EXPECT_EQ("C", designs[0].getUnits(EpwDesignField("Heating Dry Bulb Temperature 99.6%"))); + ASSERT_TRUE(designs[0].heatingDryBulb99().get()); + EXPECT_EQ(-15.5, designs[0].heatingDryBulb99().get()); + EXPECT_EQ(-21.6, designs[0].heatingHumidificationDewPoint99pt6().get()); + EXPECT_EQ(0.7, designs[0].heatingHumidificationHumidityRatio99pt6().get()); + EXPECT_EQ(-10.9, designs[0].heatingHumidificationMeanCoincidentDryBulb99pt6().get()); + EXPECT_EQ(-18.8, designs[0].heatingHumidificationDewPoint99().get()); + EXPECT_EQ(0.9, designs[0].heatingHumidificationHumidityRatio99().get()); + EXPECT_EQ(-7.5, designs[0].heatingHumidificationMeanCoincidentDryBulb99().get()); + EXPECT_EQ(12.2, designs[0].heatingColdestMonthWindSpeed0pt4().get()); + EXPECT_EQ(3.9, designs[0].heatingColdestMonthMeanCoincidentDryBulb0pt4().get()); + EXPECT_EQ(10.9, designs[0].heatingColdestMonthWindSpeed1().get()); + EXPECT_EQ(3.8, designs[0].heatingColdestMonthMeanCoincidentDryBulb1().get()); + EXPECT_EQ(3.0, designs[0].heatingMeanCoincidentWindSpeed99pt6().get()); + EXPECT_EQ(340, designs[0].heatingPrevailingCoincidentWindDirection99pt6().get()); + EXPECT_EQ(7, designs[0].coolingHottestMonth().get()); + EXPECT_EQ(15.2, designs[0].coolingDryBulbRange().get()); + EXPECT_EQ(33.0, designs[0].coolingDryBulb0pt4().get()); + EXPECT_EQ(15.7, designs[0].coolingMeanCoincidentWetBulb0pt4().get()); + EXPECT_EQ(32.0, designs[0].coolingDryBulb1().get()); + EXPECT_EQ(15.5, designs[0].coolingMeanCoincidentWetBulb1().get()); + EXPECT_EQ(30.2, designs[0].coolingDryBulb2().get()); + EXPECT_EQ(15.3, designs[0].coolingMeanCoincidentWetBulb2().get()); + EXPECT_EQ(18.4, designs[0].coolingEvaporationWetBulb0pt4().get()); + EXPECT_EQ(27.3, designs[0].coolingEvaporationMeanCoincidentDryBulb0pt4().get()); + EXPECT_EQ(17.5, designs[0].coolingEvaporationWetBulb1().get()); + EXPECT_EQ(26.4, designs[0].coolingEvaporationMeanCoincidentDryBulb1().get()); + EXPECT_EQ(16.8, designs[0].coolingEvaporationWetBulb2().get()); + EXPECT_EQ(25.6, designs[0].coolingEvaporationMeanCoincidentDryBulb2().get()); + EXPECT_EQ(4.9, designs[0].coolingMeanCoincidentWindSpeed0pt4().get()); + EXPECT_EQ(0, designs[0].coolingPrevailingCoincidentWindDirection0pt4().get()); + EXPECT_EQ(16.1, designs[0].coolingDehumidificationDewPoint0pt4().get()); + EXPECT_EQ(14.3, designs[0].coolingDehumidificationHumidityRatio0pt4().get()); + EXPECT_EQ(20.2, designs[0].coolingDehumidificationMeanCoincidentDryBulb0pt4().get()); + EXPECT_EQ(14.9, designs[0].coolingDehumidificationDewPoint1().get()); + EXPECT_EQ(13.2, designs[0].coolingDehumidificationHumidityRatio1().get()); + EXPECT_EQ(19.9, designs[0].coolingDehumidificationMeanCoincidentDryBulb1().get()); + EXPECT_EQ(13.9, designs[0].coolingDehumidificationDewPoint2().get()); + EXPECT_EQ(12.3, designs[0].coolingDehumidificationHumidityRatio2().get()); + EXPECT_EQ(19.6, designs[0].coolingDehumidificationMeanCoincidentDryBulb2().get()); + EXPECT_EQ(59.7, designs[0].coolingEnthalpy0pt4().get()); + EXPECT_EQ(27.3, designs[0].coolingEnthalpyMeanCoincidentDryBulb0pt4().get()); + EXPECT_EQ(56.6, designs[0].coolingEnthalpy1().get()); + EXPECT_EQ(26.6, designs[0].coolingEnthalpyMeanCoincidentDryBulb1().get()); + EXPECT_EQ(54.0, designs[0].coolingEnthalpy2().get()); + EXPECT_EQ(25.7, designs[0].coolingEnthalpyMeanCoincidentDryBulb2().get()); + EXPECT_EQ(760, designs[0].coolingHours8To4AndDryBulb12pt8To20pt6().get()); + EXPECT_EQ(11.1, designs[0].extremeWindSpeed1().get()); + EXPECT_EQ(9.5, designs[0].extremeWindSpeed2pt5().get()); + EXPECT_EQ(8.4, designs[0].extremeWindSpeed5().get()); + EXPECT_EQ(22.9, designs[0].extremeMaxWetBulb().get()); + EXPECT_EQ(-22.9, designs[0].extremeMeanMinDryBulb().get()); + EXPECT_EQ(36.1, designs[0].extremeMeanMaxDryBulb().get()); + EXPECT_EQ(3.8, designs[0].extremeStdDevMinDryBulb().get()); + EXPECT_EQ(1.2, designs[0].extremeStdDevMaxDryBulb().get()); + EXPECT_EQ(-25.7, designs[0].extremeN5YearsMinDryBulb().get()); + EXPECT_EQ(37.0, designs[0].extremeN5YearsMaxDryBulb().get()); + EXPECT_EQ(-27.9, designs[0].extremeN10YearsMinDryBulb().get()); + EXPECT_EQ(37.7, designs[0].extremeN10YearsMaxDryBulb().get()); + EXPECT_EQ(-30.1, designs[0].extremeN20YearsMinDryBulb().get()); + EXPECT_EQ(38.3, designs[0].extremeN20YearsMaxDryBulb().get()); + EXPECT_EQ(-32.8, designs[0].extremeN50YearsMinDryBulb().get()); + EXPECT_EQ(39.2, designs[0].extremeN50YearsMaxDryBulb().get()); + // Check that the data is the right size + data = epwFile.data(); + EXPECT_EQ(8760, data.size()); } TEST(Filetypes, EpwFile_Data_DoubleRead) { - try { - path p = resourcesPath() / toPath("utilities/Filetypes/USA_CO_Golden-NREL.724666_TMY3.epw"); - EpwFile epwFile(p); - EXPECT_EQ(p, epwFile.path()); - EXPECT_EQ("BDF687C1", epwFile.checksum()); - EXPECT_EQ(openstudio::checksum(epwFile.path()), epwFile.checksum()); - EXPECT_EQ("Denver Centennial Golden Nr", epwFile.city()); - EXPECT_EQ("CO", epwFile.stateProvinceRegion()); - EXPECT_EQ("USA", epwFile.country()); - EXPECT_EQ("TMY3", epwFile.dataSource()); - EXPECT_EQ("724666", epwFile.wmoNumber()); - EXPECT_EQ(39.74, epwFile.latitude()); - EXPECT_EQ(-105.18, epwFile.longitude()); - EXPECT_EQ(-7, epwFile.timeZone()); - EXPECT_EQ(1829, epwFile.elevation()); - EXPECT_EQ(Time(0, 1, 0, 0), epwFile.timeStep()); - EXPECT_EQ(DayOfWeek(DayOfWeek::Sunday), epwFile.startDayOfWeek()); - EXPECT_EQ(Date(MonthOfYear::Jan, 1), epwFile.startDate()); - EXPECT_EQ(Date(MonthOfYear::Dec, 31), epwFile.endDate()); - // Ask for the design conditions - std::vector designs = epwFile.designConditions(); - EXPECT_EQ(1, designs.size()); - EXPECT_EQ("Climate Design Data 2009 ASHRAE Handbook", designs[0].titleOfDesignCondition()); - EXPECT_EQ(12, designs[0].heatingColdestMonth().get()); - EXPECT_EQ(-18.8, designs[0].heatingDryBulb99pt6().get()); - EXPECT_EQ(-18.8, designs[0].getFieldByName("Heating Dry Bulb Temperature 99.6%").get()); - EXPECT_EQ(-18.8, designs[0].getField(EpwDesignField("Heating Dry Bulb Temperature 99.6%")).get()); - EXPECT_EQ("C", designs[0].getUnitsByName("Heating Dry Bulb Temperature 99.6%").get()); - EXPECT_EQ("C", designs[0].getUnits(EpwDesignField("Heating Dry Bulb Temperature 99.6%"))); - ASSERT_TRUE(designs[0].heatingDryBulb99().get()); - EXPECT_EQ(-15.5, designs[0].heatingDryBulb99().get()); - EXPECT_EQ(-21.6, designs[0].heatingHumidificationDewPoint99pt6().get()); - EXPECT_EQ(0.7, designs[0].heatingHumidificationHumidityRatio99pt6().get()); - EXPECT_EQ(-10.9, designs[0].heatingHumidificationMeanCoincidentDryBulb99pt6().get()); - EXPECT_EQ(-18.8, designs[0].heatingHumidificationDewPoint99().get()); - EXPECT_EQ(0.9, designs[0].heatingHumidificationHumidityRatio99().get()); - EXPECT_EQ(-7.5, designs[0].heatingHumidificationMeanCoincidentDryBulb99().get()); - EXPECT_EQ(12.2, designs[0].heatingColdestMonthWindSpeed0pt4().get()); - EXPECT_EQ(3.9, designs[0].heatingColdestMonthMeanCoincidentDryBulb0pt4().get()); - EXPECT_EQ(10.9, designs[0].heatingColdestMonthWindSpeed1().get()); - EXPECT_EQ(3.8, designs[0].heatingColdestMonthMeanCoincidentDryBulb1().get()); - EXPECT_EQ(3.0, designs[0].heatingMeanCoincidentWindSpeed99pt6().get()); - EXPECT_EQ(340, designs[0].heatingPrevailingCoincidentWindDirection99pt6().get()); - EXPECT_EQ(7, designs[0].coolingHottestMonth().get()); - EXPECT_EQ(15.2, designs[0].coolingDryBulbRange().get()); - EXPECT_EQ(33.0, designs[0].coolingDryBulb0pt4().get()); - EXPECT_EQ(15.7, designs[0].coolingMeanCoincidentWetBulb0pt4().get()); - EXPECT_EQ(32.0, designs[0].coolingDryBulb1().get()); - EXPECT_EQ(15.5, designs[0].coolingMeanCoincidentWetBulb1().get()); - EXPECT_EQ(30.2, designs[0].coolingDryBulb2().get()); - EXPECT_EQ(15.3, designs[0].coolingMeanCoincidentWetBulb2().get()); - EXPECT_EQ(18.4, designs[0].coolingEvaporationWetBulb0pt4().get()); - EXPECT_EQ(27.3, designs[0].coolingEvaporationMeanCoincidentDryBulb0pt4().get()); - EXPECT_EQ(17.5, designs[0].coolingEvaporationWetBulb1().get()); - EXPECT_EQ(26.4, designs[0].coolingEvaporationMeanCoincidentDryBulb1().get()); - EXPECT_EQ(16.8, designs[0].coolingEvaporationWetBulb2().get()); - EXPECT_EQ(25.6, designs[0].coolingEvaporationMeanCoincidentDryBulb2().get()); - EXPECT_EQ(4.9, designs[0].coolingMeanCoincidentWindSpeed0pt4().get()); - EXPECT_EQ(0, designs[0].coolingPrevailingCoincidentWindDirection0pt4().get()); - EXPECT_EQ(16.1, designs[0].coolingDehumidificationDewPoint0pt4().get()); - EXPECT_EQ(14.3, designs[0].coolingDehumidificationHumidityRatio0pt4().get()); - EXPECT_EQ(20.2, designs[0].coolingDehumidificationMeanCoincidentDryBulb0pt4().get()); - EXPECT_EQ(14.9, designs[0].coolingDehumidificationDewPoint1().get()); - EXPECT_EQ(13.2, designs[0].coolingDehumidificationHumidityRatio1().get()); - EXPECT_EQ(19.9, designs[0].coolingDehumidificationMeanCoincidentDryBulb1().get()); - EXPECT_EQ(13.9, designs[0].coolingDehumidificationDewPoint2().get()); - EXPECT_EQ(12.3, designs[0].coolingDehumidificationHumidityRatio2().get()); - EXPECT_EQ(19.6, designs[0].coolingDehumidificationMeanCoincidentDryBulb2().get()); - EXPECT_EQ(59.7, designs[0].coolingEnthalpy0pt4().get()); - EXPECT_EQ(27.3, designs[0].coolingEnthalpyMeanCoincidentDryBulb0pt4().get()); - EXPECT_EQ(56.6, designs[0].coolingEnthalpy1().get()); - EXPECT_EQ(26.6, designs[0].coolingEnthalpyMeanCoincidentDryBulb1().get()); - EXPECT_EQ(54.0, designs[0].coolingEnthalpy2().get()); - EXPECT_EQ(25.7, designs[0].coolingEnthalpyMeanCoincidentDryBulb2().get()); - EXPECT_EQ(760, designs[0].coolingHours8To4AndDryBulb12pt8To20pt6().get()); - EXPECT_EQ(11.1, designs[0].extremeWindSpeed1().get()); - EXPECT_EQ(9.5, designs[0].extremeWindSpeed2pt5().get()); - EXPECT_EQ(8.4, designs[0].extremeWindSpeed5().get()); - EXPECT_EQ(22.9, designs[0].extremeMaxWetBulb().get()); - EXPECT_EQ(-22.9, designs[0].extremeMeanMinDryBulb().get()); - EXPECT_EQ(36.1, designs[0].extremeMeanMaxDryBulb().get()); - EXPECT_EQ(3.8, designs[0].extremeStdDevMinDryBulb().get()); - EXPECT_EQ(1.2, designs[0].extremeStdDevMaxDryBulb().get()); - EXPECT_EQ(-25.7, designs[0].extremeN5YearsMinDryBulb().get()); - EXPECT_EQ(37.0, designs[0].extremeN5YearsMaxDryBulb().get()); - EXPECT_EQ(-27.9, designs[0].extremeN10YearsMinDryBulb().get()); - EXPECT_EQ(37.7, designs[0].extremeN10YearsMaxDryBulb().get()); - EXPECT_EQ(-30.1, designs[0].extremeN20YearsMinDryBulb().get()); - EXPECT_EQ(38.3, designs[0].extremeN20YearsMaxDryBulb().get()); - EXPECT_EQ(-32.8, designs[0].extremeN50YearsMinDryBulb().get()); - EXPECT_EQ(39.2, designs[0].extremeN50YearsMaxDryBulb().get()); - // Ask for data - std::vector data = epwFile.data(); - EXPECT_EQ(8760, data.size()); - // The last data point should be for the last hour 12/31/1996, with a dry bulb temp of 4C and pressure 81100 - openstudio::DateTime dateTime = data[8759].dateTime(); - EXPECT_EQ(1, dateTime.date().monthOfYear().value()); - EXPECT_EQ(1, dateTime.date().dayOfMonth()); - EXPECT_EQ(1997, dateTime.date().year()); - EXPECT_EQ(0, dateTime.time().hours()); - EXPECT_EQ(0, dateTime.time().minutes()); - EXPECT_EQ(0, dateTime.time().seconds()); - EXPECT_EQ(4.0, data[8759].dryBulbTemperature().get()); - EXPECT_EQ(81100, data[8759].atmosphericStationPressure().get()); - // Try out the alternate access functions, dew point temperature should be -1C - EXPECT_EQ(-1.0, data[8759].getFieldByName("Dew Point Temperature").get()); - EXPECT_EQ(-1.0, data[8759].getField(EpwDataField("Dew Point Temperature")).get()); - // The last data point should not have a liquid precipitation depth - EXPECT_FALSE(data[8759].getFieldByName("Liquid Precipitation Depth")); - // Check that the design data is the right size - designs = epwFile.designConditions(); - EXPECT_EQ(1, designs.size()); - } catch (...) { - ASSERT_TRUE(false); - } + path p = resourcesPath() / toPath("utilities/Filetypes/USA_CO_Golden-NREL.724666_TMY3.epw"); + EpwFile epwFile(p); + EXPECT_EQ(p, epwFile.path()); + EXPECT_EQ("BDF687C1", epwFile.checksum()); + EXPECT_EQ(openstudio::checksum(epwFile.path()), epwFile.checksum()); + EXPECT_EQ("Denver Centennial Golden Nr", epwFile.city()); + EXPECT_EQ("CO", epwFile.stateProvinceRegion()); + EXPECT_EQ("USA", epwFile.country()); + EXPECT_EQ("TMY3", epwFile.dataSource()); + EXPECT_EQ("724666", epwFile.wmoNumber()); + EXPECT_EQ(39.74, epwFile.latitude()); + EXPECT_EQ(-105.18, epwFile.longitude()); + EXPECT_EQ(-7, epwFile.timeZone()); + EXPECT_EQ(1829, epwFile.elevation()); + EXPECT_EQ(Time(0, 1, 0, 0), epwFile.timeStep()); + EXPECT_EQ(DayOfWeek(DayOfWeek::Sunday), epwFile.startDayOfWeek()); + EXPECT_EQ(Date(MonthOfYear::Jan, 1), epwFile.startDate()); + EXPECT_EQ(Date(MonthOfYear::Dec, 31), epwFile.endDate()); + // Ask for the design conditions + std::vector designs = epwFile.designConditions(); + EXPECT_EQ(1, designs.size()); + EXPECT_EQ("Climate Design Data 2009 ASHRAE Handbook", designs[0].titleOfDesignCondition()); + EXPECT_EQ(12, designs[0].heatingColdestMonth().get()); + EXPECT_EQ(-18.8, designs[0].heatingDryBulb99pt6().get()); + EXPECT_EQ(-18.8, designs[0].getFieldByName("Heating Dry Bulb Temperature 99.6%").get()); + EXPECT_EQ(-18.8, designs[0].getField(EpwDesignField("Heating Dry Bulb Temperature 99.6%")).get()); + EXPECT_EQ("C", designs[0].getUnitsByName("Heating Dry Bulb Temperature 99.6%").get()); + EXPECT_EQ("C", designs[0].getUnits(EpwDesignField("Heating Dry Bulb Temperature 99.6%"))); + ASSERT_TRUE(designs[0].heatingDryBulb99().get()); + EXPECT_EQ(-15.5, designs[0].heatingDryBulb99().get()); + EXPECT_EQ(-21.6, designs[0].heatingHumidificationDewPoint99pt6().get()); + EXPECT_EQ(0.7, designs[0].heatingHumidificationHumidityRatio99pt6().get()); + EXPECT_EQ(-10.9, designs[0].heatingHumidificationMeanCoincidentDryBulb99pt6().get()); + EXPECT_EQ(-18.8, designs[0].heatingHumidificationDewPoint99().get()); + EXPECT_EQ(0.9, designs[0].heatingHumidificationHumidityRatio99().get()); + EXPECT_EQ(-7.5, designs[0].heatingHumidificationMeanCoincidentDryBulb99().get()); + EXPECT_EQ(12.2, designs[0].heatingColdestMonthWindSpeed0pt4().get()); + EXPECT_EQ(3.9, designs[0].heatingColdestMonthMeanCoincidentDryBulb0pt4().get()); + EXPECT_EQ(10.9, designs[0].heatingColdestMonthWindSpeed1().get()); + EXPECT_EQ(3.8, designs[0].heatingColdestMonthMeanCoincidentDryBulb1().get()); + EXPECT_EQ(3.0, designs[0].heatingMeanCoincidentWindSpeed99pt6().get()); + EXPECT_EQ(340, designs[0].heatingPrevailingCoincidentWindDirection99pt6().get()); + EXPECT_EQ(7, designs[0].coolingHottestMonth().get()); + EXPECT_EQ(15.2, designs[0].coolingDryBulbRange().get()); + EXPECT_EQ(33.0, designs[0].coolingDryBulb0pt4().get()); + EXPECT_EQ(15.7, designs[0].coolingMeanCoincidentWetBulb0pt4().get()); + EXPECT_EQ(32.0, designs[0].coolingDryBulb1().get()); + EXPECT_EQ(15.5, designs[0].coolingMeanCoincidentWetBulb1().get()); + EXPECT_EQ(30.2, designs[0].coolingDryBulb2().get()); + EXPECT_EQ(15.3, designs[0].coolingMeanCoincidentWetBulb2().get()); + EXPECT_EQ(18.4, designs[0].coolingEvaporationWetBulb0pt4().get()); + EXPECT_EQ(27.3, designs[0].coolingEvaporationMeanCoincidentDryBulb0pt4().get()); + EXPECT_EQ(17.5, designs[0].coolingEvaporationWetBulb1().get()); + EXPECT_EQ(26.4, designs[0].coolingEvaporationMeanCoincidentDryBulb1().get()); + EXPECT_EQ(16.8, designs[0].coolingEvaporationWetBulb2().get()); + EXPECT_EQ(25.6, designs[0].coolingEvaporationMeanCoincidentDryBulb2().get()); + EXPECT_EQ(4.9, designs[0].coolingMeanCoincidentWindSpeed0pt4().get()); + EXPECT_EQ(0, designs[0].coolingPrevailingCoincidentWindDirection0pt4().get()); + EXPECT_EQ(16.1, designs[0].coolingDehumidificationDewPoint0pt4().get()); + EXPECT_EQ(14.3, designs[0].coolingDehumidificationHumidityRatio0pt4().get()); + EXPECT_EQ(20.2, designs[0].coolingDehumidificationMeanCoincidentDryBulb0pt4().get()); + EXPECT_EQ(14.9, designs[0].coolingDehumidificationDewPoint1().get()); + EXPECT_EQ(13.2, designs[0].coolingDehumidificationHumidityRatio1().get()); + EXPECT_EQ(19.9, designs[0].coolingDehumidificationMeanCoincidentDryBulb1().get()); + EXPECT_EQ(13.9, designs[0].coolingDehumidificationDewPoint2().get()); + EXPECT_EQ(12.3, designs[0].coolingDehumidificationHumidityRatio2().get()); + EXPECT_EQ(19.6, designs[0].coolingDehumidificationMeanCoincidentDryBulb2().get()); + EXPECT_EQ(59.7, designs[0].coolingEnthalpy0pt4().get()); + EXPECT_EQ(27.3, designs[0].coolingEnthalpyMeanCoincidentDryBulb0pt4().get()); + EXPECT_EQ(56.6, designs[0].coolingEnthalpy1().get()); + EXPECT_EQ(26.6, designs[0].coolingEnthalpyMeanCoincidentDryBulb1().get()); + EXPECT_EQ(54.0, designs[0].coolingEnthalpy2().get()); + EXPECT_EQ(25.7, designs[0].coolingEnthalpyMeanCoincidentDryBulb2().get()); + EXPECT_EQ(760, designs[0].coolingHours8To4AndDryBulb12pt8To20pt6().get()); + EXPECT_EQ(11.1, designs[0].extremeWindSpeed1().get()); + EXPECT_EQ(9.5, designs[0].extremeWindSpeed2pt5().get()); + EXPECT_EQ(8.4, designs[0].extremeWindSpeed5().get()); + EXPECT_EQ(22.9, designs[0].extremeMaxWetBulb().get()); + EXPECT_EQ(-22.9, designs[0].extremeMeanMinDryBulb().get()); + EXPECT_EQ(36.1, designs[0].extremeMeanMaxDryBulb().get()); + EXPECT_EQ(3.8, designs[0].extremeStdDevMinDryBulb().get()); + EXPECT_EQ(1.2, designs[0].extremeStdDevMaxDryBulb().get()); + EXPECT_EQ(-25.7, designs[0].extremeN5YearsMinDryBulb().get()); + EXPECT_EQ(37.0, designs[0].extremeN5YearsMaxDryBulb().get()); + EXPECT_EQ(-27.9, designs[0].extremeN10YearsMinDryBulb().get()); + EXPECT_EQ(37.7, designs[0].extremeN10YearsMaxDryBulb().get()); + EXPECT_EQ(-30.1, designs[0].extremeN20YearsMinDryBulb().get()); + EXPECT_EQ(38.3, designs[0].extremeN20YearsMaxDryBulb().get()); + EXPECT_EQ(-32.8, designs[0].extremeN50YearsMinDryBulb().get()); + EXPECT_EQ(39.2, designs[0].extremeN50YearsMaxDryBulb().get()); + // Ask for data + std::vector data = epwFile.data(); + EXPECT_EQ(8760, data.size()); + // The last data point should be for the last hour 12/31/1996, with a dry bulb temp of 4C and pressure 81100 + openstudio::DateTime dateTime = data[8759].dateTime(); + EXPECT_EQ(1, dateTime.date().monthOfYear().value()); + EXPECT_EQ(1, dateTime.date().dayOfMonth()); + EXPECT_EQ(1997, dateTime.date().year()); + EXPECT_EQ(0, dateTime.time().hours()); + EXPECT_EQ(0, dateTime.time().minutes()); + EXPECT_EQ(0, dateTime.time().seconds()); + EXPECT_EQ(4.0, data[8759].dryBulbTemperature().get()); + EXPECT_EQ(81100, data[8759].atmosphericStationPressure().get()); + // Try out the alternate access functions, dew point temperature should be -1C + EXPECT_EQ(-1.0, data[8759].getFieldByName("Dew Point Temperature").get()); + EXPECT_EQ(-1.0, data[8759].getField(EpwDataField("Dew Point Temperature")).get()); + // The last data point should not have a liquid precipitation depth + EXPECT_FALSE(data[8759].getFieldByName("Liquid Precipitation Depth")); + // Check that the design data is the right size + designs = epwFile.designConditions(); + EXPECT_EQ(1, designs.size()); } TEST(Filetypes, EpwFile_NoDesign) { - try { - path p = resourcesPath() / toPath("utilities/Filetypes/leapday-test.epw"); - EpwFile epwFile(p); - EXPECT_EQ(p, epwFile.path()); - // Ask for data - std::vector data = epwFile.data(); - EXPECT_EQ(8784, data.size()); - // Ask for the design conditions, but there aren't any - std::vector designs = epwFile.designConditions(); - EXPECT_EQ(0, designs.size()); - data = epwFile.data(); - EXPECT_EQ(8784, data.size()); - } catch (...) { - ASSERT_TRUE(false); - } + path p = resourcesPath() / toPath("utilities/Filetypes/leapday-test.epw"); + EpwFile epwFile(p); + EXPECT_EQ(p, epwFile.path()); + // Ask for data + std::vector data = epwFile.data(); + EXPECT_EQ(8784, data.size()); + // Ask for the design conditions, but there aren't any + std::vector designs = epwFile.designConditions(); + EXPECT_EQ(0, designs.size()); + data = epwFile.data(); + EXPECT_EQ(8784, data.size()); } TEST(Filetypes, EpwFile_IncompleteDesign) { - try { - path p = resourcesPath() / toPath("utilities/Filetypes/USA_CO_Golden-NREL.724666_TMY3_IncompleteDesign.epw"); - EpwFile epwFile(p); - EXPECT_EQ(p, epwFile.path()); - EXPECT_EQ("ECC55BA2", epwFile.checksum()); - EXPECT_EQ(openstudio::checksum(epwFile.path()), epwFile.checksum()); - EXPECT_EQ("Denver Centennial Golden Nr", epwFile.city()); - EXPECT_EQ("CO", epwFile.stateProvinceRegion()); - EXPECT_EQ("USA", epwFile.country()); - EXPECT_EQ("TMY3", epwFile.dataSource()); - EXPECT_EQ("724666", epwFile.wmoNumber()); - EXPECT_EQ(39.74, epwFile.latitude()); - EXPECT_EQ(-105.18, epwFile.longitude()); - EXPECT_EQ(-7, epwFile.timeZone()); - EXPECT_EQ(1829, epwFile.elevation()); - EXPECT_EQ(Time(0, 1, 0, 0), epwFile.timeStep()); - EXPECT_EQ(DayOfWeek(DayOfWeek::Sunday), epwFile.startDayOfWeek()); - EXPECT_EQ(Date(MonthOfYear::Jan, 1), epwFile.startDate()); - EXPECT_EQ(Date(MonthOfYear::Dec, 31), epwFile.endDate()); - // Up to here, everything should be the same as the first test. Now ask for the design conditions - std::vector designs = epwFile.designConditions(); - EXPECT_EQ(1, designs.size()); - EXPECT_EQ("Climate Design Data 2013 ASHRAE Handbook", designs[0].titleOfDesignCondition()); - ASSERT_FALSE(designs[0].heatingColdestMonth()); - ASSERT_FALSE(designs[0].heatingDryBulb99pt6()); - ASSERT_FALSE(designs[0].getFieldByName("Heating Dry Bulb Temperature 99.6%")); - ASSERT_FALSE(designs[0].getField(EpwDesignField("Heating Dry Bulb Temperature 99.6%"))); - EXPECT_EQ("C", designs[0].getUnitsByName("Heating Dry Bulb Temperature 99.6%").get()); - EXPECT_EQ("C", designs[0].getUnits(EpwDesignField("Heating Dry Bulb Temperature 99.6%"))); - ASSERT_FALSE(designs[0].heatingDryBulb99()); - ASSERT_FALSE(designs[0].heatingHumidificationDewPoint99pt6()); - ASSERT_FALSE(designs[0].heatingHumidificationHumidityRatio99pt6()); - ASSERT_FALSE(designs[0].heatingHumidificationMeanCoincidentDryBulb99pt6()); - ASSERT_FALSE(designs[0].heatingHumidificationDewPoint99()); - ASSERT_FALSE(designs[0].heatingHumidificationHumidityRatio99()); - ASSERT_FALSE(designs[0].heatingHumidificationMeanCoincidentDryBulb99()); - ASSERT_FALSE(designs[0].heatingColdestMonthWindSpeed0pt4()); - ASSERT_FALSE(designs[0].heatingColdestMonthMeanCoincidentDryBulb0pt4()); - ASSERT_TRUE(designs[0].heatingColdestMonthWindSpeed1()); - EXPECT_EQ(13.4, designs[0].heatingColdestMonthWindSpeed1().get()); - ASSERT_FALSE(designs[0].heatingColdestMonthMeanCoincidentDryBulb1()); - ASSERT_FALSE(designs[0].heatingMeanCoincidentWindSpeed99pt6()); - ASSERT_FALSE(designs[0].heatingPrevailingCoincidentWindDirection99pt6()); - ASSERT_FALSE(designs[0].coolingHottestMonth()); - ASSERT_TRUE(designs[0].coolingDryBulbRange()); - EXPECT_EQ(9.8, designs[0].coolingDryBulbRange().get()); - ASSERT_FALSE(designs[0].coolingDryBulb0pt4()); - ASSERT_FALSE(designs[0].coolingMeanCoincidentWetBulb0pt4()); - ASSERT_TRUE(designs[0].coolingDryBulb1()); - EXPECT_EQ(28.0, designs[0].coolingDryBulb1().get()); - ASSERT_TRUE(designs[0].coolingMeanCoincidentWetBulb1()); - EXPECT_EQ(19.5, designs[0].coolingMeanCoincidentWetBulb1().get()); - ASSERT_FALSE(designs[0].coolingDryBulb2()); - ASSERT_FALSE(designs[0].coolingMeanCoincidentWetBulb2()); - ASSERT_FALSE(designs[0].coolingEvaporationWetBulb0pt4()); - ASSERT_FALSE(designs[0].coolingEvaporationMeanCoincidentDryBulb0pt4()); - ASSERT_FALSE(designs[0].coolingEvaporationWetBulb1()); - ASSERT_FALSE(designs[0].coolingEvaporationMeanCoincidentDryBulb1()); - ASSERT_FALSE(designs[0].coolingEvaporationWetBulb2()); - ASSERT_FALSE(designs[0].coolingEvaporationMeanCoincidentDryBulb2()); - ASSERT_TRUE(designs[0].coolingMeanCoincidentWindSpeed0pt4()); - EXPECT_EQ(5.5, designs[0].coolingMeanCoincidentWindSpeed0pt4().get()); - ASSERT_FALSE(designs[0].coolingPrevailingCoincidentWindDirection0pt4()); - ASSERT_FALSE(designs[0].coolingDehumidificationDewPoint0pt4()); - ASSERT_FALSE(designs[0].coolingDehumidificationHumidityRatio0pt4()); - ASSERT_FALSE(designs[0].coolingDehumidificationMeanCoincidentDryBulb0pt4()); - ASSERT_FALSE(designs[0].coolingDehumidificationDewPoint1()); - ASSERT_FALSE(designs[0].coolingDehumidificationHumidityRatio1()); - ASSERT_FALSE(designs[0].coolingDehumidificationMeanCoincidentDryBulb1()); - ASSERT_TRUE(designs[0].coolingDehumidificationDewPoint2()); - EXPECT_EQ(17.7, designs[0].coolingDehumidificationDewPoint2().get()); - ASSERT_FALSE(designs[0].coolingDehumidificationHumidityRatio2()); - ASSERT_TRUE(designs[0].coolingDehumidificationMeanCoincidentDryBulb2()); - EXPECT_EQ(23.2, designs[0].coolingDehumidificationMeanCoincidentDryBulb2().get()); - ASSERT_FALSE(designs[0].coolingEnthalpy0pt4()); - ASSERT_FALSE(designs[0].coolingEnthalpyMeanCoincidentDryBulb0pt4()); - ASSERT_FALSE(designs[0].coolingEnthalpy1()); - ASSERT_FALSE(designs[0].coolingEnthalpyMeanCoincidentDryBulb1()); - ASSERT_FALSE(designs[0].coolingEnthalpy2()); - ASSERT_FALSE(designs[0].coolingEnthalpyMeanCoincidentDryBulb2()); - ASSERT_FALSE(designs[0].coolingHours8To4AndDryBulb12pt8To20pt6()); - ASSERT_FALSE(designs[0].extremeWindSpeed1()); - ASSERT_FALSE(designs[0].extremeWindSpeed2pt5()); - ASSERT_FALSE(designs[0].extremeWindSpeed5()); - ASSERT_FALSE(designs[0].extremeMaxWetBulb()); - ASSERT_FALSE(designs[0].extremeMeanMinDryBulb()); - ASSERT_FALSE(designs[0].extremeMeanMaxDryBulb()); - ASSERT_FALSE(designs[0].extremeStdDevMinDryBulb()); - ASSERT_FALSE(designs[0].extremeStdDevMaxDryBulb()); - ASSERT_FALSE(designs[0].extremeN5YearsMinDryBulb()); - ASSERT_FALSE(designs[0].extremeN5YearsMaxDryBulb()); - ASSERT_FALSE(designs[0].extremeN10YearsMinDryBulb()); - ASSERT_FALSE(designs[0].extremeN10YearsMaxDryBulb()); - ASSERT_FALSE(designs[0].extremeN20YearsMinDryBulb()); - ASSERT_FALSE(designs[0].extremeN20YearsMaxDryBulb()); - ASSERT_FALSE(designs[0].extremeN50YearsMinDryBulb()); - ASSERT_FALSE(designs[0].extremeN50YearsMaxDryBulb()); - } catch (...) { - ASSERT_TRUE(false); - } + path p = resourcesPath() / toPath("utilities/Filetypes/USA_CO_Golden-NREL.724666_TMY3_IncompleteDesign.epw"); + EpwFile epwFile(p); + EXPECT_EQ(p, epwFile.path()); + EXPECT_EQ("ECC55BA2", epwFile.checksum()); + EXPECT_EQ(openstudio::checksum(epwFile.path()), epwFile.checksum()); + EXPECT_EQ("Denver Centennial Golden Nr", epwFile.city()); + EXPECT_EQ("CO", epwFile.stateProvinceRegion()); + EXPECT_EQ("USA", epwFile.country()); + EXPECT_EQ("TMY3", epwFile.dataSource()); + EXPECT_EQ("724666", epwFile.wmoNumber()); + EXPECT_EQ(39.74, epwFile.latitude()); + EXPECT_EQ(-105.18, epwFile.longitude()); + EXPECT_EQ(-7, epwFile.timeZone()); + EXPECT_EQ(1829, epwFile.elevation()); + EXPECT_EQ(Time(0, 1, 0, 0), epwFile.timeStep()); + EXPECT_EQ(DayOfWeek(DayOfWeek::Sunday), epwFile.startDayOfWeek()); + EXPECT_EQ(Date(MonthOfYear::Jan, 1), epwFile.startDate()); + EXPECT_EQ(Date(MonthOfYear::Dec, 31), epwFile.endDate()); + // Up to here, everything should be the same as the first test. Now ask for the design conditions + std::vector designs = epwFile.designConditions(); + EXPECT_EQ(1, designs.size()); + EXPECT_EQ("Climate Design Data 2013 ASHRAE Handbook", designs[0].titleOfDesignCondition()); + EXPECT_FALSE(designs[0].heatingColdestMonth()); + EXPECT_FALSE(designs[0].heatingDryBulb99pt6()); + EXPECT_FALSE(designs[0].getFieldByName("Heating Dry Bulb Temperature 99.6%")); + EXPECT_FALSE(designs[0].getField(EpwDesignField("Heating Dry Bulb Temperature 99.6%"))); + EXPECT_EQ("C", designs[0].getUnitsByName("Heating Dry Bulb Temperature 99.6%").get()); + EXPECT_EQ("C", designs[0].getUnits(EpwDesignField("Heating Dry Bulb Temperature 99.6%"))); + EXPECT_FALSE(designs[0].heatingDryBulb99()); + EXPECT_FALSE(designs[0].heatingHumidificationDewPoint99pt6()); + EXPECT_FALSE(designs[0].heatingHumidificationHumidityRatio99pt6()); + EXPECT_FALSE(designs[0].heatingHumidificationMeanCoincidentDryBulb99pt6()); + EXPECT_FALSE(designs[0].heatingHumidificationDewPoint99()); + EXPECT_FALSE(designs[0].heatingHumidificationHumidityRatio99()); + EXPECT_FALSE(designs[0].heatingHumidificationMeanCoincidentDryBulb99()); + EXPECT_FALSE(designs[0].heatingColdestMonthWindSpeed0pt4()); + EXPECT_FALSE(designs[0].heatingColdestMonthMeanCoincidentDryBulb0pt4()); + ASSERT_TRUE(designs[0].heatingColdestMonthWindSpeed1()); + EXPECT_EQ(13.4, designs[0].heatingColdestMonthWindSpeed1().get()); + EXPECT_FALSE(designs[0].heatingColdestMonthMeanCoincidentDryBulb1()); + EXPECT_FALSE(designs[0].heatingMeanCoincidentWindSpeed99pt6()); + EXPECT_FALSE(designs[0].heatingPrevailingCoincidentWindDirection99pt6()); + EXPECT_FALSE(designs[0].coolingHottestMonth()); + ASSERT_TRUE(designs[0].coolingDryBulbRange()); + EXPECT_EQ(9.8, designs[0].coolingDryBulbRange().get()); + EXPECT_FALSE(designs[0].coolingDryBulb0pt4()); + EXPECT_FALSE(designs[0].coolingMeanCoincidentWetBulb0pt4()); + ASSERT_TRUE(designs[0].coolingDryBulb1()); + EXPECT_EQ(28.0, designs[0].coolingDryBulb1().get()); + ASSERT_TRUE(designs[0].coolingMeanCoincidentWetBulb1()); + EXPECT_EQ(19.5, designs[0].coolingMeanCoincidentWetBulb1().get()); + EXPECT_FALSE(designs[0].coolingDryBulb2()); + EXPECT_FALSE(designs[0].coolingMeanCoincidentWetBulb2()); + EXPECT_FALSE(designs[0].coolingEvaporationWetBulb0pt4()); + EXPECT_FALSE(designs[0].coolingEvaporationMeanCoincidentDryBulb0pt4()); + EXPECT_FALSE(designs[0].coolingEvaporationWetBulb1()); + EXPECT_FALSE(designs[0].coolingEvaporationMeanCoincidentDryBulb1()); + EXPECT_FALSE(designs[0].coolingEvaporationWetBulb2()); + EXPECT_FALSE(designs[0].coolingEvaporationMeanCoincidentDryBulb2()); + ASSERT_TRUE(designs[0].coolingMeanCoincidentWindSpeed0pt4()); + EXPECT_EQ(5.5, designs[0].coolingMeanCoincidentWindSpeed0pt4().get()); + EXPECT_FALSE(designs[0].coolingPrevailingCoincidentWindDirection0pt4()); + EXPECT_FALSE(designs[0].coolingDehumidificationDewPoint0pt4()); + EXPECT_FALSE(designs[0].coolingDehumidificationHumidityRatio0pt4()); + EXPECT_FALSE(designs[0].coolingDehumidificationMeanCoincidentDryBulb0pt4()); + EXPECT_FALSE(designs[0].coolingDehumidificationDewPoint1()); + EXPECT_FALSE(designs[0].coolingDehumidificationHumidityRatio1()); + EXPECT_FALSE(designs[0].coolingDehumidificationMeanCoincidentDryBulb1()); + ASSERT_TRUE(designs[0].coolingDehumidificationDewPoint2()); + EXPECT_EQ(17.7, designs[0].coolingDehumidificationDewPoint2().get()); + EXPECT_FALSE(designs[0].coolingDehumidificationHumidityRatio2()); + ASSERT_TRUE(designs[0].coolingDehumidificationMeanCoincidentDryBulb2()); + EXPECT_EQ(23.2, designs[0].coolingDehumidificationMeanCoincidentDryBulb2().get()); + EXPECT_FALSE(designs[0].coolingEnthalpy0pt4()); + EXPECT_FALSE(designs[0].coolingEnthalpyMeanCoincidentDryBulb0pt4()); + EXPECT_FALSE(designs[0].coolingEnthalpy1()); + EXPECT_FALSE(designs[0].coolingEnthalpyMeanCoincidentDryBulb1()); + EXPECT_FALSE(designs[0].coolingEnthalpy2()); + EXPECT_FALSE(designs[0].coolingEnthalpyMeanCoincidentDryBulb2()); + EXPECT_FALSE(designs[0].coolingHours8To4AndDryBulb12pt8To20pt6()); + EXPECT_FALSE(designs[0].extremeWindSpeed1()); + EXPECT_FALSE(designs[0].extremeWindSpeed2pt5()); + EXPECT_FALSE(designs[0].extremeWindSpeed5()); + EXPECT_FALSE(designs[0].extremeMaxWetBulb()); + EXPECT_FALSE(designs[0].extremeMeanMinDryBulb()); + EXPECT_FALSE(designs[0].extremeMeanMaxDryBulb()); + EXPECT_FALSE(designs[0].extremeStdDevMinDryBulb()); + EXPECT_FALSE(designs[0].extremeStdDevMaxDryBulb()); + EXPECT_FALSE(designs[0].extremeN5YearsMinDryBulb()); + EXPECT_FALSE(designs[0].extremeN5YearsMaxDryBulb()); + EXPECT_FALSE(designs[0].extremeN10YearsMinDryBulb()); + EXPECT_FALSE(designs[0].extremeN10YearsMaxDryBulb()); + EXPECT_FALSE(designs[0].extremeN20YearsMinDryBulb()); + EXPECT_FALSE(designs[0].extremeN20YearsMaxDryBulb()); + EXPECT_FALSE(designs[0].extremeN50YearsMinDryBulb()); + EXPECT_FALSE(designs[0].extremeN50YearsMaxDryBulb()); } TEST(Filetypes, EpwFile_LeapTimeSeries) { - try { - path p = resourcesPath() / toPath("utilities/Filetypes/leapday-test.epw"); - EpwFile epwFile(p); - EXPECT_EQ(p, epwFile.path()); - // Ask for data - std::vector data = epwFile.data(); - EXPECT_EQ(8784, data.size()); - // Ask for the design conditions, but there aren't any - std::vector designs = epwFile.designConditions(); - EXPECT_EQ(0, designs.size()); - data = epwFile.data(); - EXPECT_EQ(8784, data.size()); + path p = resourcesPath() / toPath("utilities/Filetypes/leapday-test.epw"); + EpwFile epwFile(p); + EXPECT_EQ(p, epwFile.path()); + // Ask for data + std::vector data = epwFile.data(); + EXPECT_EQ(8784, data.size()); + // Ask for the design conditions, but there aren't any + std::vector designs = epwFile.designConditions(); + EXPECT_EQ(0, designs.size()); + data = epwFile.data(); + EXPECT_EQ(8784, data.size()); - EXPECT_TRUE(epwFile.isActual()); + EXPECT_TRUE(epwFile.isActual()); - boost::optional _epwDataPointBaseYear = data[0].date().baseYear(); - ASSERT_TRUE(_epwDataPointBaseYear); - EXPECT_EQ(2012, _epwDataPointBaseYear.get()); + boost::optional _epwDataPointBaseYear = data[0].date().baseYear(); + ASSERT_TRUE(_epwDataPointBaseYear); + EXPECT_EQ(2012, _epwDataPointBaseYear.get()); - boost::optional _t; - ASSERT_NO_THROW(_t = epwFile.getTimeSeries("Dry Bulb Temperature")); - ASSERT_TRUE(_t); - // isActual is true, so it should be a timeSeries with the actual year - boost::optional _timeSeriesBaseYear = _t->firstReportDateTime().date().baseYear(); - ASSERT_TRUE(_timeSeriesBaseYear); - EXPECT_EQ(2012, _timeSeriesBaseYear.get()); - } catch (...) { - ASSERT_TRUE(false); - } + boost::optional _t; + ASSERT_NO_THROW(_t = epwFile.getTimeSeries("Dry Bulb Temperature")); + ASSERT_TRUE(_t); + // isActual is true, so it should be a timeSeries with the actual year + boost::optional _timeSeriesBaseYear = _t->firstReportDateTime().date().baseYear(); + ASSERT_TRUE(_timeSeriesBaseYear); + EXPECT_EQ(2012, _timeSeriesBaseYear.get()); } TEST(Filetypes, EpwFile_LeapTimeSeries_AMYNoLeapDay) { // Tests for #5214 - try { - path p = resourcesPath() / toPath("utilities/Filetypes/leapday-test-noleapday.epw"); - EpwFile epwFile(p); - boost::optional _t; - ASSERT_NO_THROW(_t = epwFile.getTimeSeries("Dry Bulb Temperature")); - ASSERT_TRUE(_t); - // even though this is AMY, the lack of Feb 29 causes it to be TMY (i.e., successive datapoints greater than 1 day) - boost::optional _timeSeriesBaseYear = _t->firstReportDateTime().date().baseYear(); - EXPECT_FALSE(_timeSeriesBaseYear); - } catch (...) { - ASSERT_TRUE(false); - } + path p = resourcesPath() / toPath("utilities/Filetypes/leapday-test-noleapday.epw"); + EpwFile epwFile(p); + boost::optional _t; + ASSERT_NO_THROW(_t = epwFile.getTimeSeries("Dry Bulb Temperature")); + ASSERT_TRUE(_t); + // even though this is AMY, the lack of Feb 29 causes it to be TMY (i.e., successive datapoints greater than 1 day) + boost::optional _timeSeriesBaseYear = _t->firstReportDateTime().date().baseYear(); + EXPECT_FALSE(_timeSeriesBaseYear); } TEST(Filetypes, EpwFile_LeapTimeSeries_TMYLeapFebNoLeapDay) { // Tests for #5214 - try { - path p = resourcesPath() / toPath("utilities/Filetypes/USA_CO_Golden-NREL.724666_TMY3-noleapday.epw"); - EpwFile epwFile(p); - boost::optional _t; - ASSERT_NO_THROW(_t = epwFile.getTimeSeries("Dry Bulb Temperature")); - ASSERT_TRUE(_t); - boost::optional _timeSeriesBaseYear = _t->firstReportDateTime().date().baseYear(); - EXPECT_FALSE(_timeSeriesBaseYear); - } catch (...) { - ASSERT_TRUE(false); - } + path p = resourcesPath() / toPath("utilities/Filetypes/USA_CO_Golden-NREL.724666_TMY3-noleapday.epw"); + EpwFile epwFile(p); + boost::optional _t; + ASSERT_NO_THROW(_t = epwFile.getTimeSeries("Dry Bulb Temperature")); + ASSERT_TRUE(_t); + boost::optional _timeSeriesBaseYear = _t->firstReportDateTime().date().baseYear(); + EXPECT_FALSE(_timeSeriesBaseYear); } TEST(Filetypes, EpwFile_LeapTimeSeries_TMYLeapFebLeapDay) { // Tests for #5214 - try { - path p = resourcesPath() / toPath("utilities/Filetypes/USA_CO_Golden-NREL.724666_TMY3-leapday.epw"); - EpwFile epwFile(p); - boost::optional _t; - _t = epwFile.getTimeSeries("Dry Bulb Temperature"); - ASSERT_TRUE(false); // we don't hit this because we expect getTimeSeries to fail - } catch (...) { - ASSERT_TRUE(true); - } + path p = resourcesPath() / toPath("utilities/Filetypes/USA_CO_Golden-NREL.724666_TMY3-leapday.epw"); + EpwFile epwFile(p); + // [utilities.time.Date] <2> Bad Date: year = 2009, month = Feb(2), day = 29. + EXPECT_ANY_THROW(epwFile.getTimeSeries("Dry Bulb Temperature")); } TEST(Filetypes, EpwFile_NonActualTimeSeries) { - try { - path p = resourcesPath() / toPath("utilities/Filetypes/USA_CO_Golden-NREL.724666_TMY3.epw"); - EpwFile epwFile(p); - EXPECT_EQ(p, epwFile.path()); - // Ask for data - std::vector data = epwFile.data(); - EXPECT_EQ(8760, data.size()); + path p = resourcesPath() / toPath("utilities/Filetypes/USA_CO_Golden-NREL.724666_TMY3.epw"); + EpwFile epwFile(p); + EXPECT_EQ(p, epwFile.path()); + // Ask for data + std::vector data = epwFile.data(); + EXPECT_EQ(8760, data.size()); - EXPECT_FALSE(epwFile.isActual()); + EXPECT_FALSE(epwFile.isActual()); - // It should have a baseYear as a DataPoint - boost::optional _epwDataPointBaseYear = data[0].date().baseYear(); - ASSERT_TRUE(_epwDataPointBaseYear); - EXPECT_EQ(1999, _epwDataPointBaseYear.get()); + // It should have a baseYear as a DataPoint + boost::optional _epwDataPointBaseYear = data[0].date().baseYear(); + ASSERT_TRUE(_epwDataPointBaseYear); + EXPECT_EQ(1999, _epwDataPointBaseYear.get()); - boost::optional _t; - ASSERT_NO_THROW(_t = epwFile.getTimeSeries("Dry Bulb Temperature")); - ASSERT_TRUE(_t); - // But it shouldn't when getting a TimeSeries, since it's a TMY file - boost::optional _timeSeriesBaseYear = _t->firstReportDateTime().date().baseYear(); - EXPECT_FALSE(_timeSeriesBaseYear); - } catch (...) { - ASSERT_TRUE(false); - } + boost::optional _t; + ASSERT_NO_THROW(_t = epwFile.getTimeSeries("Dry Bulb Temperature")); + ASSERT_TRUE(_t); + // But it shouldn't when getting a TimeSeries, since it's a TMY file + boost::optional _timeSeriesBaseYear = _t->firstReportDateTime().date().baseYear(); + EXPECT_FALSE(_timeSeriesBaseYear); } TEST(Filetypes, EpwFile_International_Data) { - try { - path p = resourcesPath() / toPath("utilities/Filetypes/CHN_Guangdong.Shaoguan.590820_CSWD.epw"); - EpwFile epwFile(p, true); - EXPECT_EQ(p, epwFile.path()); - EXPECT_EQ("B68C068B", epwFile.checksum()); - EXPECT_EQ("Shaoguan", epwFile.city()); - EXPECT_EQ("Guangdong", epwFile.stateProvinceRegion()); - EXPECT_EQ("CHN", epwFile.country()); - EXPECT_EQ("CSWD", epwFile.dataSource()); - EXPECT_EQ("590820", epwFile.wmoNumber()); - EXPECT_EQ(24.68, epwFile.latitude()); - EXPECT_EQ(113.6, epwFile.longitude()); - EXPECT_EQ(8, epwFile.timeZone()); - EXPECT_EQ(61, epwFile.elevation()); - EXPECT_EQ(Time(0, 1, 0, 0), epwFile.timeStep()); - EXPECT_EQ(DayOfWeek(DayOfWeek::Sunday), epwFile.startDayOfWeek()); - EXPECT_EQ(Date(MonthOfYear::Jan, 1), epwFile.startDate()); - EXPECT_EQ(Date(MonthOfYear::Dec, 31), epwFile.endDate()); - // Up to here, everything should be the same as the first test. Now ask for the data - std::vector data = epwFile.data(); - EXPECT_EQ(8760, data.size()); - // The last data point check - EXPECT_EQ(14.7, data[8759].dryBulbTemperature().get()); - EXPECT_EQ(101100, data[8759].atmosphericStationPressure().get()); - // Try out the alternate access functions, dew point temperature should be -1C - EXPECT_EQ(11.7, data[8759].getFieldByName("Dew Point Temperature").get()); - EXPECT_EQ(11.7, data[8759].getField(EpwDataField("Dew Point Temperature")).get()); - // The last data point should not have a liquid precipitation depth - EXPECT_FALSE(data[8759].getFieldByName("Liquid Precipitation Depth")); - // Get a time series - boost::optional series = epwFile.getTimeSeries("Wind Speed"); - ASSERT_TRUE(series); - ASSERT_EQ(8760, series->values().size()); - DateTimeVector seriesTimes = series->dateTimes(); - ASSERT_EQ(8760, seriesTimes.size()); - // Check the times in the data and the time series - DateTime current(Date(1, 1, 1999), Time(0, 1)); // Use 1999 to avoid leap years - Time delta(0, 1); - for (unsigned i = 0; i < 8760; i++) { - // This is a lot more complicated that it probably should be to avoid the year being a problem - DateTime datatime = data[i].dateTime(); - EXPECT_EQ(datatime.date().monthOfYear(), current.date().monthOfYear()); - EXPECT_EQ(datatime.date().dayOfMonth(), current.date().dayOfMonth()); - EXPECT_EQ(datatime.time().hours(), current.time().hours()); - EXPECT_EQ(datatime.time().minutes(), current.time().minutes()); - DateTime seriestime = seriesTimes[i]; - EXPECT_EQ(seriestime.date().monthOfYear(), current.date().monthOfYear()); - EXPECT_EQ(seriestime.date().dayOfMonth(), current.date().dayOfMonth()); - EXPECT_EQ(seriestime.time().hours(), current.time().hours()); - EXPECT_EQ(seriestime.time().minutes(), current.time().minutes()); - current += delta; - } - // No need to redo the original tests here since the data should have been loaded in the constructor - } catch (...) { - ASSERT_TRUE(false); + path p = resourcesPath() / toPath("utilities/Filetypes/CHN_Guangdong.Shaoguan.590820_CSWD.epw"); + EpwFile epwFile(p, true); + EXPECT_EQ(p, epwFile.path()); + EXPECT_EQ("B68C068B", epwFile.checksum()); + EXPECT_EQ("Shaoguan", epwFile.city()); + EXPECT_EQ("Guangdong", epwFile.stateProvinceRegion()); + EXPECT_EQ("CHN", epwFile.country()); + EXPECT_EQ("CSWD", epwFile.dataSource()); + EXPECT_EQ("590820", epwFile.wmoNumber()); + EXPECT_EQ(24.68, epwFile.latitude()); + EXPECT_EQ(113.6, epwFile.longitude()); + EXPECT_EQ(8, epwFile.timeZone()); + EXPECT_EQ(61, epwFile.elevation()); + EXPECT_EQ(Time(0, 1, 0, 0), epwFile.timeStep()); + EXPECT_EQ(DayOfWeek(DayOfWeek::Sunday), epwFile.startDayOfWeek()); + EXPECT_EQ(Date(MonthOfYear::Jan, 1), epwFile.startDate()); + EXPECT_EQ(Date(MonthOfYear::Dec, 31), epwFile.endDate()); + // Up to here, everything should be the same as the first test. Now ask for the data + std::vector data = epwFile.data(); + EXPECT_EQ(8760, data.size()); + // The last data point check + EXPECT_EQ(14.7, data[8759].dryBulbTemperature().get()); + EXPECT_EQ(101100, data[8759].atmosphericStationPressure().get()); + // Try out the alternate access functions, dew point temperature should be -1C + EXPECT_EQ(11.7, data[8759].getFieldByName("Dew Point Temperature").get()); + EXPECT_EQ(11.7, data[8759].getField(EpwDataField("Dew Point Temperature")).get()); + // The last data point should not have a liquid precipitation depth + EXPECT_FALSE(data[8759].getFieldByName("Liquid Precipitation Depth")); + // Get a time series + boost::optional series = epwFile.getTimeSeries("Wind Speed"); + ASSERT_TRUE(series); + ASSERT_EQ(8760, series->values().size()); + DateTimeVector seriesTimes = series->dateTimes(); + ASSERT_EQ(8760, seriesTimes.size()); + // Check the times in the data and the time series + DateTime current(Date(1, 1, 1999), Time(0, 1)); // Use 1999 to avoid leap years + Time delta(0, 1); + for (unsigned i = 0; i < 8760; i++) { + // This is a lot more complicated that it probably should be to avoid the year being a problem + DateTime datatime = data[i].dateTime(); + EXPECT_EQ(datatime.date().monthOfYear(), current.date().monthOfYear()); + EXPECT_EQ(datatime.date().dayOfMonth(), current.date().dayOfMonth()); + EXPECT_EQ(datatime.time().hours(), current.time().hours()); + EXPECT_EQ(datatime.time().minutes(), current.time().minutes()); + DateTime seriestime = seriesTimes[i]; + EXPECT_EQ(seriestime.date().monthOfYear(), current.date().monthOfYear()); + EXPECT_EQ(seriestime.date().dayOfMonth(), current.date().dayOfMonth()); + EXPECT_EQ(seriestime.time().hours(), current.time().hours()); + EXPECT_EQ(seriestime.time().minutes(), current.time().minutes()); + current += delta; } + // No need to redo the original tests here since the data should have been loaded in the constructor } TEST(Filetypes, EpwFile_IWEC_Data) { - try { - path p = resourcesPath() / toPath("utilities/Filetypes/TUN_Tunis.607150_IWEC.epw"); - EpwFile epwFile(p, true); - EXPECT_EQ(p, epwFile.path()); - EXPECT_EQ("FEAB878E", epwFile.checksum()); - EXPECT_EQ("TUNIS", epwFile.city()); - EXPECT_EQ("-", epwFile.stateProvinceRegion()); - EXPECT_EQ("TUN", epwFile.country()); - EXPECT_EQ("IWEC Data", epwFile.dataSource()); - EXPECT_EQ("607150", epwFile.wmoNumber()); - EXPECT_EQ(36.83, epwFile.latitude()); - EXPECT_EQ(10.23, epwFile.longitude()); - EXPECT_EQ(1, epwFile.timeZone()); - EXPECT_EQ(4, epwFile.elevation()); - EXPECT_EQ(Time(0, 1, 0, 0), epwFile.timeStep()); - EXPECT_EQ(DayOfWeek(DayOfWeek::Sunday), epwFile.startDayOfWeek()); - EXPECT_EQ(Date(MonthOfYear::Jan, 1), epwFile.startDate()); - EXPECT_EQ(Date(MonthOfYear::Dec, 31), epwFile.endDate()); - // Up to here, everything should be the same as the first test. Now ask for the data - std::vector data = epwFile.data(); - EXPECT_EQ(8760, data.size()); - // The last data point check - EXPECT_EQ(11.3, data[8759].dryBulbTemperature().get()); - EXPECT_EQ(102400, data[8759].atmosphericStationPressure().get()); - // Try out the alternate access functions - EXPECT_EQ(9.8, data[8759].getFieldByName("Dew Point Temperature").get()); - EXPECT_EQ(9.8, data[8759].getField(EpwDataField("Dew Point Temperature")).get()); - // Get a time series - boost::optional series = epwFile.getTimeSeries("Wind Speed"); - ASSERT_TRUE(series); - ASSERT_EQ(8760, series->values().size()); - DateTimeVector seriesTimes = series->dateTimes(); - ASSERT_EQ(8760, seriesTimes.size()); - // Check the times in the data and the time series - DateTime current(Date(1, 1, 1999), Time(0, 1)); // Use 1999 to avoid leap years - Time delta(0, 1); - for (unsigned i = 0; i < 8760; i++) { - // This is a lot more complicated that it probably should be to avoid the year being a problem - DateTime datatime = data[i].dateTime(); - EXPECT_EQ(datatime.date().monthOfYear(), current.date().monthOfYear()); - EXPECT_EQ(datatime.date().dayOfMonth(), current.date().dayOfMonth()); - EXPECT_EQ(datatime.time().hours(), current.time().hours()); - EXPECT_EQ(datatime.time().minutes(), current.time().minutes()); - DateTime seriestime = seriesTimes[i]; - EXPECT_EQ(seriestime.date().monthOfYear(), current.date().monthOfYear()); - EXPECT_EQ(seriestime.date().dayOfMonth(), current.date().dayOfMonth()); - EXPECT_EQ(seriestime.time().hours(), current.time().hours()); - EXPECT_EQ(seriestime.time().minutes(), current.time().minutes()); - current += delta; - } - // No need to redo the original tests here since the data should have been loaded in the constructor - } catch (...) { - ASSERT_TRUE(false); + path p = resourcesPath() / toPath("utilities/Filetypes/TUN_Tunis.607150_IWEC.epw"); + EpwFile epwFile(p, true); + EXPECT_EQ(p, epwFile.path()); + EXPECT_EQ("FEAB878E", epwFile.checksum()); + EXPECT_EQ("TUNIS", epwFile.city()); + EXPECT_EQ("-", epwFile.stateProvinceRegion()); + EXPECT_EQ("TUN", epwFile.country()); + EXPECT_EQ("IWEC Data", epwFile.dataSource()); + EXPECT_EQ("607150", epwFile.wmoNumber()); + EXPECT_EQ(36.83, epwFile.latitude()); + EXPECT_EQ(10.23, epwFile.longitude()); + EXPECT_EQ(1, epwFile.timeZone()); + EXPECT_EQ(4, epwFile.elevation()); + EXPECT_EQ(Time(0, 1, 0, 0), epwFile.timeStep()); + EXPECT_EQ(DayOfWeek(DayOfWeek::Sunday), epwFile.startDayOfWeek()); + EXPECT_EQ(Date(MonthOfYear::Jan, 1), epwFile.startDate()); + EXPECT_EQ(Date(MonthOfYear::Dec, 31), epwFile.endDate()); + // Up to here, everything should be the same as the first test. Now ask for the data + std::vector data = epwFile.data(); + EXPECT_EQ(8760, data.size()); + // The last data point check + EXPECT_EQ(11.3, data[8759].dryBulbTemperature().get()); + EXPECT_EQ(102400, data[8759].atmosphericStationPressure().get()); + // Try out the alternate access functions + EXPECT_EQ(9.8, data[8759].getFieldByName("Dew Point Temperature").get()); + EXPECT_EQ(9.8, data[8759].getField(EpwDataField("Dew Point Temperature")).get()); + // Get a time series + boost::optional series = epwFile.getTimeSeries("Wind Speed"); + ASSERT_TRUE(series); + ASSERT_EQ(8760, series->values().size()); + DateTimeVector seriesTimes = series->dateTimes(); + ASSERT_EQ(8760, seriesTimes.size()); + // Check the times in the data and the time series + DateTime current(Date(1, 1, 1999), Time(0, 1)); // Use 1999 to avoid leap years + Time delta(0, 1); + for (unsigned i = 0; i < 8760; i++) { + // This is a lot more complicated that it probably should be to avoid the year being a problem + DateTime datatime = data[i].dateTime(); + EXPECT_EQ(datatime.date().monthOfYear(), current.date().monthOfYear()); + EXPECT_EQ(datatime.date().dayOfMonth(), current.date().dayOfMonth()); + EXPECT_EQ(datatime.time().hours(), current.time().hours()); + EXPECT_EQ(datatime.time().minutes(), current.time().minutes()); + DateTime seriestime = seriesTimes[i]; + EXPECT_EQ(seriestime.date().monthOfYear(), current.date().monthOfYear()); + EXPECT_EQ(seriestime.date().dayOfMonth(), current.date().dayOfMonth()); + EXPECT_EQ(seriestime.time().hours(), current.time().hours()); + EXPECT_EQ(seriestime.time().minutes(), current.time().minutes()); + current += delta; } + // No need to redo the original tests here since the data should have been loaded in the constructor } TEST(Filetypes, EpwFile_TMY) { - try { - path p = resourcesPath() / toPath("utilities/Filetypes/USA_CO_Golden-NREL.724666_TMY3.epw"); - EpwFile epwFile(p); - EXPECT_EQ(p, epwFile.path()); - EXPECT_EQ("BDF687C1", epwFile.checksum()); - EXPECT_EQ("Denver Centennial Golden Nr", epwFile.city()); - EXPECT_EQ("CO", epwFile.stateProvinceRegion()); - EXPECT_EQ("USA", epwFile.country()); - EXPECT_EQ("TMY3", epwFile.dataSource()); - EXPECT_EQ("724666", epwFile.wmoNumber()); - EXPECT_EQ(39.74, epwFile.latitude()); - EXPECT_EQ(-105.18, epwFile.longitude()); - EXPECT_EQ(-7, epwFile.timeZone()); - EXPECT_EQ(1829, epwFile.elevation()); - EXPECT_EQ(Time(0, 1, 0, 0), epwFile.timeStep()); - EXPECT_EQ(DayOfWeek(DayOfWeek::Sunday), epwFile.startDayOfWeek()); - EXPECT_FALSE(epwFile.startDateActualYear()); - EXPECT_FALSE(epwFile.endDateActualYear()); - EXPECT_EQ(Date(MonthOfYear::Jan, 1), epwFile.startDate()); - EXPECT_EQ(Date(MonthOfYear::Dec, 31), epwFile.endDate()); - EXPECT_EQ(365, (epwFile.endDate() - epwFile.startDate()).totalDays() + 1); - EXPECT_FALSE(epwFile.isActual()); - } catch (...) { - ASSERT_TRUE(false); - } + path p = resourcesPath() / toPath("utilities/Filetypes/USA_CO_Golden-NREL.724666_TMY3.epw"); + EpwFile epwFile(p); + EXPECT_EQ(p, epwFile.path()); + EXPECT_EQ("BDF687C1", epwFile.checksum()); + EXPECT_EQ("Denver Centennial Golden Nr", epwFile.city()); + EXPECT_EQ("CO", epwFile.stateProvinceRegion()); + EXPECT_EQ("USA", epwFile.country()); + EXPECT_EQ("TMY3", epwFile.dataSource()); + EXPECT_EQ("724666", epwFile.wmoNumber()); + EXPECT_EQ(39.74, epwFile.latitude()); + EXPECT_EQ(-105.18, epwFile.longitude()); + EXPECT_EQ(-7, epwFile.timeZone()); + EXPECT_EQ(1829, epwFile.elevation()); + EXPECT_EQ(Time(0, 1, 0, 0), epwFile.timeStep()); + EXPECT_EQ(DayOfWeek(DayOfWeek::Sunday), epwFile.startDayOfWeek()); + EXPECT_FALSE(epwFile.startDateActualYear()); + EXPECT_FALSE(epwFile.endDateActualYear()); + EXPECT_EQ(Date(MonthOfYear::Jan, 1), epwFile.startDate()); + EXPECT_EQ(Date(MonthOfYear::Dec, 31), epwFile.endDate()); + EXPECT_EQ(365, (epwFile.endDate() - epwFile.startDate()).totalDays() + 1); + EXPECT_FALSE(epwFile.isActual()); } TEST(Filetypes, EpwFile_Wrap_TMY) { - try { - path p = resourcesPath() / toPath("utilities/Filetypes/USA_CO_Golden-NREL.wrap.epw"); - EpwFile epwFile(p); - EXPECT_TRUE(false); - } catch (...) { - EXPECT_TRUE(true); - } + path p = resourcesPath() / toPath("utilities/Filetypes/USA_CO_Golden-NREL.wrap.epw"); + // Wrap around years not supported for TMY data, EPW file + EXPECT_ANY_THROW(EpwFile{p}); } TEST(Filetypes, EpwFile_AMY) { - try { - path p = resourcesPath() / toPath("utilities/Filetypes/USA_CO_Golden-NREL.amy"); - EpwFile epwFile(p); - EXPECT_EQ(p, epwFile.path()); - EXPECT_EQ("521A957C", epwFile.checksum()); - EXPECT_EQ("Denver Centennial Golden Nr", epwFile.city()); - EXPECT_EQ("CO", epwFile.stateProvinceRegion()); - EXPECT_EQ("USA", epwFile.country()); - EXPECT_EQ("TMY3", epwFile.dataSource()); - EXPECT_EQ("724666", epwFile.wmoNumber()); - EXPECT_EQ(39.74, epwFile.latitude()); - EXPECT_EQ(-105.18, epwFile.longitude()); - EXPECT_EQ(-7, epwFile.timeZone()); - EXPECT_EQ(1829, epwFile.elevation()); - EXPECT_EQ(Time(0, 1, 0, 0), epwFile.timeStep()); - EXPECT_EQ(DayOfWeek(DayOfWeek::Friday), epwFile.startDayOfWeek()); - ASSERT_TRUE(epwFile.startDateActualYear()); - EXPECT_EQ(1999, epwFile.startDateActualYear().get()); - ASSERT_TRUE(epwFile.endDateActualYear()); - EXPECT_EQ(1999, epwFile.endDateActualYear().get()); - EXPECT_EQ(Date(MonthOfYear::Jan, 1, 1999), epwFile.startDate()); - EXPECT_EQ(Date(MonthOfYear::Dec, 31, 1999), epwFile.endDate()); - EXPECT_EQ(365, (epwFile.endDate() - epwFile.startDate()).totalDays() + 1); - EXPECT_TRUE(epwFile.isActual()); - } catch (...) { - ASSERT_TRUE(false); - } + path p = resourcesPath() / toPath("utilities/Filetypes/USA_CO_Golden-NREL.amy"); + EpwFile epwFile(p); + EXPECT_EQ(p, epwFile.path()); + EXPECT_EQ("521A957C", epwFile.checksum()); + EXPECT_EQ("Denver Centennial Golden Nr", epwFile.city()); + EXPECT_EQ("CO", epwFile.stateProvinceRegion()); + EXPECT_EQ("USA", epwFile.country()); + EXPECT_EQ("TMY3", epwFile.dataSource()); + EXPECT_EQ("724666", epwFile.wmoNumber()); + EXPECT_EQ(39.74, epwFile.latitude()); + EXPECT_EQ(-105.18, epwFile.longitude()); + EXPECT_EQ(-7, epwFile.timeZone()); + EXPECT_EQ(1829, epwFile.elevation()); + EXPECT_EQ(Time(0, 1, 0, 0), epwFile.timeStep()); + EXPECT_EQ(DayOfWeek(DayOfWeek::Friday), epwFile.startDayOfWeek()); + ASSERT_TRUE(epwFile.startDateActualYear()); + EXPECT_EQ(1999, epwFile.startDateActualYear().get()); + ASSERT_TRUE(epwFile.endDateActualYear()); + EXPECT_EQ(1999, epwFile.endDateActualYear().get()); + EXPECT_EQ(Date(MonthOfYear::Jan, 1, 1999), epwFile.startDate()); + EXPECT_EQ(Date(MonthOfYear::Dec, 31, 1999), epwFile.endDate()); + EXPECT_EQ(365, (epwFile.endDate() - epwFile.startDate()).totalDays() + 1); + EXPECT_TRUE(epwFile.isActual()); } TEST(Filetypes, EpwFile_Wrap_AMY) { - try { - path p = resourcesPath() / toPath("utilities/Filetypes/USA_CO_Golden-NREL.wrap.amy"); - EpwFile epwFile(p); - EXPECT_EQ(p, epwFile.path()); - EXPECT_EQ("8F74A20B", epwFile.checksum()); - EXPECT_EQ("Denver Centennial Golden Nr", epwFile.city()); - EXPECT_EQ("CO", epwFile.stateProvinceRegion()); - EXPECT_EQ("USA", epwFile.country()); - EXPECT_EQ("TMY3", epwFile.dataSource()); - EXPECT_EQ("724666", epwFile.wmoNumber()); - EXPECT_EQ(39.74, epwFile.latitude()); - EXPECT_EQ(-105.18, epwFile.longitude()); - EXPECT_EQ(-7, epwFile.timeZone()); - EXPECT_EQ(1829, epwFile.elevation()); - EXPECT_EQ(Time(0, 1, 0, 0), epwFile.timeStep()); - EXPECT_EQ(DayOfWeek(DayOfWeek::Saturday), epwFile.startDayOfWeek()); - ASSERT_TRUE(epwFile.startDateActualYear()); - EXPECT_EQ(1999, epwFile.startDateActualYear().get()); - ASSERT_TRUE(epwFile.endDateActualYear()); - EXPECT_EQ(2000, epwFile.endDateActualYear().get()); - EXPECT_EQ(Date(MonthOfYear::Apr, 10, 1999), epwFile.startDate()); - EXPECT_EQ(Date(MonthOfYear::Apr, 8, 2000), epwFile.endDate()); // 2000 is a leap year - EXPECT_EQ(365, (epwFile.endDate() - epwFile.startDate()).totalDays() + 1); - EXPECT_TRUE(epwFile.isActual()); - } catch (...) { - ASSERT_TRUE(false); - } + path p = resourcesPath() / toPath("utilities/Filetypes/USA_CO_Golden-NREL.wrap.amy"); + EpwFile epwFile(p); + EXPECT_EQ(p, epwFile.path()); + EXPECT_EQ("8F74A20B", epwFile.checksum()); + EXPECT_EQ("Denver Centennial Golden Nr", epwFile.city()); + EXPECT_EQ("CO", epwFile.stateProvinceRegion()); + EXPECT_EQ("USA", epwFile.country()); + EXPECT_EQ("TMY3", epwFile.dataSource()); + EXPECT_EQ("724666", epwFile.wmoNumber()); + EXPECT_EQ(39.74, epwFile.latitude()); + EXPECT_EQ(-105.18, epwFile.longitude()); + EXPECT_EQ(-7, epwFile.timeZone()); + EXPECT_EQ(1829, epwFile.elevation()); + EXPECT_EQ(Time(0, 1, 0, 0), epwFile.timeStep()); + EXPECT_EQ(DayOfWeek(DayOfWeek::Saturday), epwFile.startDayOfWeek()); + ASSERT_TRUE(epwFile.startDateActualYear()); + EXPECT_EQ(1999, epwFile.startDateActualYear().get()); + ASSERT_TRUE(epwFile.endDateActualYear()); + EXPECT_EQ(2000, epwFile.endDateActualYear().get()); + EXPECT_EQ(Date(MonthOfYear::Apr, 10, 1999), epwFile.startDate()); + EXPECT_EQ(Date(MonthOfYear::Apr, 8, 2000), epwFile.endDate()); // 2000 is a leap year + EXPECT_EQ(365, (epwFile.endDate() - epwFile.startDate()).totalDays() + 1); + EXPECT_TRUE(epwFile.isActual()); } TEST(Filetypes, EpwFile_DataPoint) { - try { - // Check that we can read all timeseries wind speed values, even if they are extreme - path p = resourcesPath() / toPath("utilities/Filetypes/USA_CT_New.Haven-Tweed.AP.725045_TMY3.epw"); - EpwFile epwFile(p); - EXPECT_EQ(p, epwFile.path()); - for (const EpwDataPoint& dataPoint : epwFile.data()) { - EXPECT_TRUE(dataPoint.windSpeed()); - //EXPECT_NO_THROW(dataPoint.windSpeed().get()); - } - } catch (...) { - ASSERT_TRUE(false); + // Check that we can read all timeseries wind speed values, even if they are extreme + path p = resourcesPath() / toPath("utilities/Filetypes/USA_CT_New.Haven-Tweed.AP.725045_TMY3.epw"); + EpwFile epwFile(p); + EXPECT_EQ(p, epwFile.path()); + for (const EpwDataPoint& dataPoint : epwFile.data()) { + EXPECT_TRUE(dataPoint.windSpeed()); + //EXPECT_NO_THROW(dataPoint.windSpeed().get()); } }