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<EpwDataPoint> 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].fieldByName("Dew Point Temperature").get()); EXPECT_EQ(11.7,data[8759].field(EpwDataField("Dew Point Temperature")).get()); // The last data point should not have a liquid precipitation depth EXPECT_FALSE(data[8759].fieldByName("Liquid Precipitation Depth")); // Get a time series boost::optional<openstudio::TimeSeries> 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); } }
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<EpwDataPoint> 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<openstudio::TimeSeries> 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); } }
TEST(Filetypes, EpwFile_Data) { try{ path p = resourcesPath() / toPath("runmanager/USA_CO_Golden-NREL.724666_TMY3.epw"); EpwFile epwFile(p); EXPECT_EQ(p, epwFile.path()); EXPECT_EQ("F188656D", 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<EpwDataPoint> data = epwFile.data(); EXPECT_EQ(8760,data.size()); // The last data point should be on 12/31/1996, with a dry bulb temp of 4C and presure 81100 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].fieldByName("Dew Point Temperature").get()); EXPECT_EQ(-1.0,data[8759].field(EpwDataField("Dew Point Temperature")).get()); // The last data point should not have a liquid precipitation depth EXPECT_FALSE(data[8759].fieldByName("Liquid Precipitation Depth")); // Get a time series boost::optional<openstudio::TimeSeries> 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("F188656D", 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()); }catch(...){ ASSERT_TRUE(false); } }
TEST_F(DataFixture,TimeSeries_DetailedConstructor_WrapAroundDates) { std::string units = "W"; Date startDate(MonthOfYear(MonthOfYear::Jan),1); // fill vector with 365 days of data Vector values(365); DateTimeVector dateTimes; for (unsigned i = 0; i < 365; ++i){ values(i) = i; dateTimes.push_back(startDate + Time(i+1,0,0,0)); } unsigned numValues = values.size(); ASSERT_EQ(365u, numValues); ASSERT_EQ(365u, dateTimes.size()); EXPECT_EQ(DateTime(Date(MonthOfYear(MonthOfYear::Jan), 1), Time(1,0,0,0)), dateTimes[0].date()); EXPECT_EQ(DateTime(Date(MonthOfYear(MonthOfYear::Dec), 31), Time(1,0,0,0)), dateTimes[364].date()); // create detailed timeSeries TimeSeries timeSeries(dateTimes, values, units); ASSERT_EQ(365u, timeSeries.values().size()); // check interval EXPECT_FALSE(timeSeries.intervalLength()); // check start date and time DateTime firstDateTime = timeSeries.firstReportDateTime(); EXPECT_EQ(DateTime(Date(MonthOfYear(MonthOfYear::Jan), 1), Time(1,0,0,0)), firstDateTime); // check values for (unsigned i = 0; i < numValues; ++i){ DateTime dateTime = dateTimes[i]; EXPECT_EQ(i, timeSeries.value(dateTime)) << dateTime; } Vector test = timeSeries.values(DateTime(Date(MonthOfYear(MonthOfYear::Apr), 1), Time(1,0,0,0)), DateTime(Date(MonthOfYear(MonthOfYear::Apr), 30), Time(1,0,0,0))); ASSERT_EQ(30, test.size()); for (unsigned i = 0; i < 30; ++i){ EXPECT_EQ(i + 90, test[i]); } // now rearrange date times to make a wrap around year Vector wrappedValues(365); DateTimeVector wrappedDateTimes; unsigned j = 0; for (unsigned i = 100; i < 365; ++i, ++j){ wrappedValues[j] = values[i]; wrappedDateTimes.push_back(dateTimes[i]); } for (unsigned i = 0; i < 100; ++i, ++j){ wrappedValues[j] = values[i]; wrappedDateTimes.push_back(dateTimes[i]); } ASSERT_EQ(365u, wrappedValues.size()); ASSERT_EQ(365u, wrappedDateTimes.size()); EXPECT_EQ(100, wrappedValues[0]); EXPECT_EQ(99, wrappedValues[364]); EXPECT_EQ(DateTime(Date(MonthOfYear(MonthOfYear::Apr), 11), Time(1,0,0,0)), wrappedDateTimes[0].date()); EXPECT_EQ(DateTime(Date(MonthOfYear(MonthOfYear::Apr), 10), Time(1,0,0,0)), wrappedDateTimes[364].date()); // create detailed timeSeries TimeSeries wrappedTimeSeries(wrappedDateTimes, wrappedValues, units); ASSERT_EQ(365u, wrappedTimeSeries.values().size()); // check interval EXPECT_FALSE(wrappedTimeSeries.intervalLength()); // check start date and time firstDateTime = wrappedTimeSeries.firstReportDateTime(); EXPECT_EQ(DateTime(Date(MonthOfYear(MonthOfYear::Apr), 11), Time(1,0,0,0)), firstDateTime); // check values for (unsigned i = 0; i < numValues; ++i){ DateTime dateTime = dateTimes[i]; EXPECT_EQ(i, wrappedTimeSeries.value(dateTime)) << dateTime; } test = timeSeries.values(DateTime(Date(MonthOfYear(MonthOfYear::Apr), 1), Time(1,0,0,0)), DateTime(Date(MonthOfYear(MonthOfYear::Apr), 30), Time(1,0,0,0))); ASSERT_EQ(30, test.size()); for (unsigned i = 0; i < 30; ++i){ EXPECT_EQ(i + 90, test[i]); } }