GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 49.9% 1793 / 0 / 3591
Functions: 75.4% 347 / 0 / 460
Branches: 36.6% 1470 / 0 / 4016

src/utilities/filetypes/EpwFile.cpp
Line Branch Exec Source
1 /***********************************************************************************************************************
2 * OpenStudio(R), Copyright (c) Alliance for Energy Innovation, LLC.
3 * See also https://openstudio.net/license
4 ***********************************************************************************************************************/
5
6 #include "EpwFile.hpp"
7 #include "../idf/IdfObject.hpp"
8 #include "../idd/IddEnums.hpp"
9 #include <utilities/idd/IddEnums.hxx>
10 #include "../core/Assert.hpp"
11 #include "../core/Checksum.hpp"
12 #include "../core/Compare.hpp"
13 #include "../core/StringHelpers.hpp"
14
15 #include <fmt/format.h>
16 #include <array>
17 #include <cmath>
18 #include <string_view>
19
20 namespace openstudio {
21
22 constexpr std::string_view UTF8_BOM{"\xEF\xBB\xBF", 3};
23
24 ✗ static double psat(double T) {
25 // Compute water vapor saturation pressure, eqns 5 and 6 from ASHRAE Fundamentals 2009 Ch. 1
26 // This version takes T in C rather than Kelvin since most of the other eqns use C
27 ✗ T += 273.15;
28 ✗ constexpr double C1 = -5.6745359e+03;
29 ✗ constexpr double C2 = 6.3925247e+00;
30 ✗ constexpr double C3 = -9.6778430e-03;
31 ✗ constexpr double C4 = 6.2215701e-07;
32 ✗ constexpr double C5 = 2.0747825e-09;
33 ✗ constexpr double C6 = -9.4840240e-13;
34 ✗ constexpr double C7 = 4.1635019e+00;
35 ✗ constexpr double C8 = -5.8002206e+03;
36 ✗ constexpr double C9 = 1.3914993e+00;
37 ✗ constexpr double C10 = -4.8640239e-02;
38 ✗ constexpr double C11 = 4.1764768e-05;
39 ✗ constexpr double C12 = -1.4452093e-08;
40 ✗ constexpr double C13 = 6.5459673e+00;
41 ✗ double rhs = 0.0;
42 ✗ if (T < 273.15) {
43 ✗ rhs = C1 / T + C2 + T * (C3 + T * (C4 + T * (C5 + T * C6))) + C7 * std::log(T);
44 } else {
45 ✗ rhs = C8 / T + C9 + T * (C10 + T * (C11 + T * C12)) + C13 * std::log(T);
46 }
47 ✗ return std::exp(rhs);
48 }
49
50 ✗ static double psatp(double T, double psat) {
51 // Compute the derivative of the water vapor saturation pressure function (eqns 5 and 6 from
52 // ASHRAE Fundamentals 2009 Ch. 1)
53 // This version takes T in C rather than Kelvin since most of the other eqns use C
54 ✗ T += 273.15;
55 ✗ constexpr double C1 = -5.6745359e+03;
56 ✗ constexpr double C3 = -9.6778430e-03;
57 ✗ constexpr double C4 = 6.2215701e-07;
58 ✗ constexpr double C5 = 2.0747825e-09;
59 ✗ constexpr double C6 = -9.4840240e-13;
60 ✗ constexpr double C7 = 4.1635019e+00;
61 ✗ constexpr double C8 = -5.8002206e+03;
62 ✗ constexpr double C10 = -4.8640239e-02;
63 ✗ constexpr double C11 = 4.1764768e-05;
64 ✗ constexpr double C12 = -1.4452093e-08;
65 ✗ constexpr double C13 = 6.5459673e+00;
66 ✗ const double T2 = T * T;
67 ✗ const double T3 = T * T2;
68 ✗ double fp = 0.0;
69 ✗ if (T < 273.15) {
70 ✗ fp = -C1 / T2 + C3 + 2 * T * C4 + 3 * T2 * C5 + 4 * T3 * C6 + C7 / T;
71 } else {
72 ✗ fp = -C8 / T2 + C10 + 2 * T * C11 + 3 * T2 * C12 + C13 / T;
73 }
74 //std::cout << "psatp: " << T - 273.15 << " " << fp << " " << fp*psat << '\n';
75 ✗ return fp * psat;
76 }
77
78 // Note JM 2019-01-03: suppress -Wunused-function warning for this API function
79 ✗ [[maybe_unused]] static double enthalpy(double T, double p, double phi) {
80 // Compute moist air enthalpy, eqns 5, 6, 22, 24, and 32 from ASHRAE Fundamentals 2009 Ch. 1
81 ✗ const double pw = phi * psat(T); // Partial pressure of water vapor, eqn 24 (uses eqns 5 and 6)
82 ✗ const double W = 0.621945 * pw / (p - pw); // Humidity ratio, eqn 22
83 ✗ return 1.006 * T + W * (2501 + 1.86 * T); // Moist air specific enthalpy, eqn 32
84 }
85
86 ✗ [[maybe_unused]] static double enthalpyFromDewPoint(double T, double p, double Tdewpoint) {
87 // Compute moist air enthalpy, eqns 5, 6, 22, 32, and 38 from ASHRAE Fundamentals 2009 Ch. 1
88 ✗ const double pw = openstudio::psat(Tdewpoint); // Partial pressure of water vapor, eqn 38 (uses eqns 5 and 6)
89 ✗ const double W = 0.621945 * pw / (p - pw); // Humidity ratio, eqn 22
90 ✗ return 1.006 * T + W * (2501 + 1.86 * T); // Moist air specific enthalpy, eqn 32
91 }
92
93 // Using equation 35/37 in ASHRAE Fundamentals 2009 Ch. 1:
94 //
95 // W = (A W*_s - B)/C
96 //
97 // where A, B, C, and W*_s are all function of wet bulb t*
98 // Solve for the root of
99 //
100 // f = W C - A W*_s + B
101 //
102 // To make things even more opaque, lets use
103 //
104 // A = a0 + a1 t*
105 // B = b (t - t*)
106 // C = c0 + c1 t + c2 t*
107 //
108 ✗ static boost::optional<double> solveForWetBulb(double drybulb, double p, double W, double deltaLimit, int itermax) {
109 ✗ const double Bp = -1.006;
110 ✗ const double b = 1.006;
111 ✗ const double c1t = 1.86 * drybulb;
112 ✗ double a0 = 2501;
113 ✗ double a1 = -2.326;
114 ✗ double c0 = 2501;
115 ✗ double c2 = -4.186;
116 ✗ double Ap = -2.326;
117 ✗ double Cp = -4.186;
118 ✗ if (drybulb < 0) {
119 ✗ a0 = 2830;
120 ✗ a1 = -0.24;
121 ✗ c0 = 2830;
122 ✗ c2 = -2.1;
123 ✗ Ap = -0.24;
124 ✗ Cp = -2.1;
125 }
126
127 ✗ int i = 0;
128 ✗ double tstar = drybulb;
129 ✗ while (i < itermax) {
130 ✗ i++;
131 ✗ const double A = a0 + a1 * tstar;
132 ✗ const double B = b * (drybulb - tstar);
133 ✗ const double C = c0 + c1t + c2 * tstar;
134 ✗ const double pwsstar = psat(tstar);
135 ✗ const double pwsstarp = psatp(tstar, pwsstar);
136 ✗ const double deltap = p - pwsstar;
137 ✗ const double Wsstar = 0.621945 * pwsstar / deltap;
138 ✗ const double Wsstarp = (0.621945 * pwsstarp * deltap + 0.621945 * pwsstar * pwsstarp) / (deltap * deltap);
139 ✗ const double f = W * C - A * Wsstar + B;
140 ✗ const double fp = W * Cp - A * Wsstarp - Ap * Wsstar + Bp;
141 ✗ const double delta = -f / fp;
142 ✗ tstar += delta;
143 // std::cout << i << " " << tstar << " " << delta / (273.15 + tstar) << '\n';
144 ✗ if (std::fabs(delta / (273.15 + tstar)) <= deltaLimit) {
145 ✗ return {tstar};
146 }
147 }
148 ✗ return boost::none;
149 }
150
151 // Using equation 38 in ASHRAE Fundamentals 2009 Ch. 1:
152 //
153 // psat(td) = pw
154 //
155 ✗ static boost::optional<double> solveForDewPoint(double drybulb, double pw, double deltaLimit, int itermax) {
156 //double deltaLimit = percentChange*0.01;
157 ✗ double tdew = drybulb;
158 ✗ int i = 0;
159
160 ✗ while (i < itermax) {
161 ✗ i++;
162 ✗ const double pws = psat(tdew);
163 ✗ const double f = pws - pw;
164 ✗ const double fp = psatp(tdew, pws);
165 ✗ const double delta = -f / fp;
166 ✗ tdew += delta;
167 // std::cout << i << " " << tdew << " " << delta / (273.15 + tdew) << '\n';
168 ✗ if (std::fabs(delta / (273.15 + tdew)) <= deltaLimit) {
169 ✗ return {tdew};
170 }
171 }
172 ✗ return boost::none;
173 }
174
175 ✗ AirState::AirState()
176 : // Set parameters
177 ✗ m_drybulb(20.0),
178 ✗ m_pressure(101325.0),
179 ✗ m_psat(psat(m_drybulb)),
180 ✗ m_phi(0.5) {
181 // Compute moist air properties, eqns from ASHRAE Fundamentals 2009 Ch. 1, should probably just set all of these
182 // Water vapor saturation pressure (uses eqns 5 and 6)
183 ✗ double pw = m_phi * m_psat; // Relative humidity, eqn 24
184 ✗ m_W = 0.621945 * pw / (m_pressure - pw); // Humidity ratio, eqn 22
185 // TODO: Use the function above
186 ✗ m_h = 1.006 * m_drybulb + m_W * (2501 + 1.86 * m_drybulb); // Moist air specific enthalpy, eqn 32
187 ✗ m_v = 0.287042 * (m_drybulb + 273.15) * (1 + 1.607858 * m_W) / m_pressure; // Specific volume, eqn 28
188 // Compute the dew point temperature here
189 ✗ boost::optional<double> dewpoint = solveForDewPoint(m_drybulb, pw, 1e-4, 100);
190 ✗ OS_ASSERT(dewpoint);
191 ✗ m_dewpoint = dewpoint.get();
192 // Compute the wet bulb temperature here
193 ✗ boost::optional<double> wetbulb = solveForWetBulb(m_drybulb, m_pressure, m_W, 1e-4, 100);
194 ✗ OS_ASSERT(wetbulb);
195 ✗ m_wetbulb = wetbulb.get();
196 ✗ }
197
198 ✗ boost::optional<AirState> AirState::fromDryBulbDewPointPressure(double drybulb, double dewpoint, double pressure) {
199 ✗ AirState state;
200 ✗ if (drybulb < -100.0 || drybulb > 200.0) {
201 // Out of the range of our current psat function
202 ✗ return boost::none;
203 }
204 ✗ if (dewpoint < -100.0 || dewpoint > 200.0) {
205 // Out of the range of our current psat function
206 ✗ return boost::none;
207 }
208 ✗ state.m_drybulb = drybulb;
209 ✗ state.m_dewpoint = dewpoint;
210 ✗ state.m_pressure = pressure;
211 // Compute moist air properties, eqns from ASHRAE Fundamentals 2009 Ch. 1
212 ✗ double pw = psat(dewpoint); // // Partial pressure of water vapor, eqn 38 (uses eqns 5 and 6)
213 ✗ state.m_W = 0.621945 * pw / (pressure - pw); // Humidity ratio, eqn 22
214 ✗ state.m_psat = psat(drybulb); // Water vapor saturation pressure (uses eqns 5 and 6)
215 //double Ws = 0.621945 * state.m_psat / (pressure - state.m_psat);
216 ✗ state.m_phi = pw / state.m_psat; // Relative humidity, eqn 24
217 ✗ state.m_h = 1.006 * drybulb + state.m_W * (2501 + 1.86 * drybulb); // Moist air specific enthalpy, eqn 32
218 ✗ state.m_v = 0.287042 * (drybulb + 273.15) * (1 + 1.607858 * state.m_W) / pressure; // Specific volume, eqn 28
219 // Compute the wet bulb temperature here
220 ✗ boost::optional<double> wetbulb = solveForWetBulb(drybulb, pressure, state.m_W, 1e-4, 100);
221 ✗ if (!wetbulb) {
222 ✗ return boost::none;
223 }
224 ✗ state.m_wetbulb = wetbulb.get();
225 ✗ return boost::optional<AirState>(state);
226 }
227
228 ✗ boost::optional<AirState> AirState::fromDryBulbRelativeHumidityPressure(double drybulb, double RH, double pressure) {
229 ✗ AirState state;
230 ✗ if (drybulb < -100.0 || drybulb > 200.0) {
231 // Out of the range of our current psat function
232 ✗ return boost::none;
233 }
234 ✗ if (RH > 100.0 || RH < 0.0) {
235 // Out of the range
236 ✗ return boost::none;
237 }
238 ✗ state.m_drybulb = drybulb;
239 ✗ state.m_phi = 0.01 * RH;
240 ✗ state.m_pressure = pressure;
241 // Compute moist air properties, eqns from ASHRAE Fundamentals 2009 Ch. 1
242 ✗ state.m_psat = psat(drybulb); // Water vapor saturation pressure (uses eqns 5 and 6)
243 ✗ double pw = state.m_phi * state.m_psat; // Relative humidity, eqn 24
244 ✗ state.m_W = 0.621945 * pw / (pressure - pw); // Humidity ratio, eqn 22
245 ✗ state.m_h = 1.006 * drybulb + state.m_W * (2501 + 1.86 * drybulb); // Moist air specific enthalpy, eqn 32
246 ✗ state.m_v = 0.287042 * (drybulb + 273.15) * (1 + 1.607858 * state.m_W) / pressure; // Specific volume, eqn 28
247 // Compute the dew point temperature here
248 ✗ boost::optional<double> dewpoint = solveForDewPoint(drybulb, pw, 1e-4, 100);
249 ✗ if (!dewpoint) {
250 ✗ return boost::none;
251 }
252 ✗ state.m_dewpoint = dewpoint.get();
253 // Compute the wet bulb temperature here
254 ✗ boost::optional<double> wetbulb = solveForWetBulb(drybulb, pressure, state.m_W, 1e-4, 100);
255 ✗ if (!wetbulb) {
256 ✗ return boost::none;
257 }
258 ✗ state.m_wetbulb = wetbulb.get();
259 ✗ return boost::optional<AirState>(state);
260 }
261
262 ✗ double AirState::drybulb() const {
263 ✗ return m_drybulb;
264 }
265
266 ✗ double AirState::dewpoint() const {
267 ✗ return m_dewpoint;
268 }
269
270 ✗ double AirState::wetbulb() const {
271 ✗ return m_wetbulb;
272 }
273
274 ✗ double AirState::relativeHumidity() const {
275 ✗ return 100.0 * m_phi;
276 }
277
278 ✗ double AirState::pressure() const {
279 ✗ return m_pressure;
280 }
281
282 ✗ double AirState::enthalpy() const {
283 ✗ return m_h;
284 }
285
286 ✗ double AirState::saturationPressure() const {
287 ✗ return m_psat;
288 }
289
290 ✗ double AirState::density() const {
291 ✗ return 1.0 / m_v;
292 }
293
294 ✗ double AirState::specificVolume() const {
295 ✗ return m_v;
296 }
297
298 ✗ double AirState::humidityRatio() const {
299 ✗ return m_W;
300 }
301
302 ✗ double AirState::R() {
303 ✗ return 8314.472 / 28.966; // eqn 1 from ASHRAE Fundamentals 2009 Ch. 1
304 }
305
306 ✗ EpwDataPoint::EpwDataPoint(int year, int month, int day, int hour, int minute, const std::string& dataSourceandUncertaintyFlags,
307 double dryBulbTemperature, double dewPointTemperature, double relativeHumidity, double atmosphericStationPressure,
308 double extraterrestrialHorizontalRadiation, double extraterrestrialDirectNormalRadiation,
309 double horizontalInfraredRadiationIntensity, double globalHorizontalRadiation, double directNormalRadiation,
310 double diffuseHorizontalRadiation, double globalHorizontalIlluminance, double directNormalIlluminance,
311 double diffuseHorizontalIlluminance, double zenithLuminance, double windDirection, double windSpeed, int totalSkyCover,
312 int opaqueSkyCover, double visibility, double ceilingHeight, int presentWeatherObservation, int presentWeatherCodes,
313 double precipitableWater, double aerosolOpticalDepth, double snowDepth, double daysSinceLastSnowfall, double albedo,
314 ✗ double liquidPrecipitationDepth, double liquidPrecipitationQuantity) {
315 ✗ setYear(year);
316 ✗ setMonth(month);
317 ✗ setDay(day);
318 ✗ setHour(hour);
319 ✗ setMinute(minute);
320 ✗ setDataSourceandUncertaintyFlags(dataSourceandUncertaintyFlags);
321 ✗ setDryBulbTemperature(dryBulbTemperature);
322 ✗ setDewPointTemperature(dewPointTemperature);
323 ✗ setRelativeHumidity(relativeHumidity);
324 ✗ setAtmosphericStationPressure(atmosphericStationPressure);
325 ✗ setExtraterrestrialHorizontalRadiation(extraterrestrialHorizontalRadiation);
326 ✗ setExtraterrestrialDirectNormalRadiation(extraterrestrialDirectNormalRadiation);
327 ✗ setHorizontalInfraredRadiationIntensity(horizontalInfraredRadiationIntensity);
328 ✗ setGlobalHorizontalRadiation(globalHorizontalRadiation);
329 ✗ setDirectNormalRadiation(directNormalRadiation);
330 ✗ setDiffuseHorizontalRadiation(diffuseHorizontalRadiation);
331 ✗ setGlobalHorizontalIlluminance(globalHorizontalIlluminance);
332 ✗ setDirectNormalIlluminance(directNormalIlluminance);
333 ✗ setDiffuseHorizontalIlluminance(diffuseHorizontalIlluminance);
334 ✗ setZenithLuminance(zenithLuminance);
335 ✗ setWindDirection(windDirection);
336 ✗ setWindSpeed(windSpeed);
337 ✗ setTotalSkyCover(totalSkyCover);
338 ✗ setOpaqueSkyCover(opaqueSkyCover);
339 ✗ setVisibility(visibility);
340 ✗ setCeilingHeight(ceilingHeight);
341 ✗ setPresentWeatherObservation(presentWeatherObservation);
342 ✗ setPresentWeatherCodes(presentWeatherCodes);
343 ✗ setPrecipitableWater(precipitableWater);
344 ✗ setAerosolOpticalDepth(aerosolOpticalDepth);
345 ✗ setSnowDepth(snowDepth);
346 ✗ setDaysSinceLastSnowfall(daysSinceLastSnowfall);
347 ✗ setAlbedo(albedo);
348 ✗ setLiquidPrecipitationDepth(liquidPrecipitationDepth);
349 ✗ setLiquidPrecipitationQuantity(liquidPrecipitationQuantity);
350 ✗ }
351
352 ✗ EpwDesignCondition::EpwDesignCondition(
353 const std::string& titleOfDesignCondition, int heatingColdestMonth, double heatingDryBulb99pt6, double heatingDryBulb99,
354 double heatingHumidificationDewPoint99pt6, double heatingHumidificationHumidityRatio99pt6, double heatingHumidificationMeanCoincidentDryBulb99pt6,
355 double heatingHumidificationDewPoint99, double heatingHumidificationHumidityRatio99, double heatingHumidificationMeanCoincidentDryBulb99,
356 double heatingColdestMonthWindSpeed0pt4, double heatingColdestMonthMeanCoincidentDryBulb0pt4, double heatingColdestMonthWindSpeed1,
357 double heatingColdestMonthMeanCoincidentDryBulb1, double heatingMeanCoincidentWindSpeed99pt6, int heatingPrevailingCoincidentWindDirection99pt6,
358 int coolingHottestMonth, double coolingDryBulbRange, double coolingDryBulb0pt4, double coolingMeanCoincidentWetBulb0pt4, double coolingDryBulb1,
359 double coolingMeanCoincidentWetBulb1, double coolingDryBulb2, double coolingMeanCoincidentWetBulb2, double coolingEvaporationWetBulb0pt4,
360 double coolingEvaporationMeanCoincidentDryBulb0pt4, double coolingEvaporationWetBulb1, double coolingEvaporationMeanCoincidentDryBulb1,
361 double coolingEvaporationWetBulb2, double coolingEvaporationMeanCoincidentDryBulb2, double coolingMeanCoincidentWindSpeed0pt4,
362 int coolingPrevailingCoincidentWindDirection0pt4, double coolingDehumidificationDewPoint0pt4, double coolingDehumidificationHumidityRatio0pt4,
363 double coolingDehumidificationMeanCoincidentDryBulb0pt4, double coolingDehumidificationDewPoint1, double coolingDehumidificationHumidityRatio1,
364 double coolingDehumidificationMeanCoincidentDryBulb1, double coolingDehumidificationDewPoint2, double coolingDehumidificationHumidityRatio2,
365 double coolingDehumidificationMeanCoincidentDryBulb2, double coolingEnthalpy0pt4, double coolingEnthalpyMeanCoincidentDryBulb0pt4,
366 double coolingEnthalpy1, double coolingEnthalpyMeanCoincidentDryBulb1, double coolingEnthalpy2, double coolingEnthalpyMeanCoincidentDryBulb2,
367 int coolingHours8To4AndDryBulb12pt8To20pt6, double extremeWindSpeed1, double extremeWindSpeed2pt5, double extremeWindSpeed5,
368 double extremeMaxWetBulb, double extremeMeanMinDryBulb, double extremeMeanMaxDryBulb, double extremeStdDevMinDryBulb,
369 double extremeStdDevMaxDryBulb, double extremeN5YearsMinDryBulb, double extremeN5YearsMaxDryBulb, double extremeN10YearsMinDryBulb,
370 double extremeN10YearsMaxDryBulb, double extremeN20YearsMinDryBulb, double extremeN20YearsMaxDryBulb, double extremeN50YearsMinDryBulb,
371 ✗ double extremeN50YearsMaxDryBulb) {
372 ✗ setTitleOfDesignCondition(titleOfDesignCondition);
373 ✗ setHeatingColdestMonth(heatingColdestMonth);
374 ✗ setHeatingDryBulb99pt6(heatingDryBulb99pt6);
375 ✗ setHeatingDryBulb99(heatingDryBulb99);
376 ✗ setHeatingHumidificationDewPoint99pt6(heatingHumidificationDewPoint99pt6);
377 ✗ setHeatingHumidificationHumidityRatio99pt6(heatingHumidificationHumidityRatio99pt6);
378 ✗ setHeatingHumidificationMeanCoincidentDryBulb99pt6(heatingHumidificationMeanCoincidentDryBulb99pt6);
379 ✗ setHeatingHumidificationDewPoint99(heatingHumidificationDewPoint99);
380 ✗ setHeatingHumidificationHumidityRatio99(heatingHumidificationHumidityRatio99);
381 ✗ setHeatingHumidificationMeanCoincidentDryBulb99(heatingHumidificationMeanCoincidentDryBulb99);
382 ✗ setHeatingColdestMonthWindSpeed0pt4(heatingColdestMonthWindSpeed0pt4);
383 ✗ setHeatingColdestMonthMeanCoincidentDryBulb0pt4(heatingColdestMonthMeanCoincidentDryBulb0pt4);
384 ✗ setHeatingColdestMonthWindSpeed1(heatingColdestMonthWindSpeed1);
385 ✗ setHeatingColdestMonthMeanCoincidentDryBulb1(heatingColdestMonthMeanCoincidentDryBulb1);
386 ✗ setHeatingMeanCoincidentWindSpeed99pt6(heatingMeanCoincidentWindSpeed99pt6);
387 ✗ setHeatingPrevailingCoincidentWindDirection99pt6(heatingPrevailingCoincidentWindDirection99pt6);
388 ✗ setCoolingHottestMonth(coolingHottestMonth);
389 ✗ setCoolingDryBulbRange(coolingDryBulbRange);
390 ✗ setCoolingDryBulb0pt4(coolingDryBulb0pt4);
391 ✗ setCoolingMeanCoincidentWetBulb0pt4(coolingMeanCoincidentWetBulb0pt4);
392 ✗ setCoolingDryBulb1(coolingDryBulb1);
393 ✗ setCoolingMeanCoincidentWetBulb1(coolingMeanCoincidentWetBulb1);
394 ✗ setCoolingDryBulb2(coolingDryBulb2);
395 ✗ setCoolingMeanCoincidentWetBulb2(coolingMeanCoincidentWetBulb2);
396 ✗ setCoolingEvaporationWetBulb0pt4(coolingEvaporationWetBulb0pt4);
397 ✗ setCoolingEvaporationMeanCoincidentDryBulb0pt4(coolingEvaporationMeanCoincidentDryBulb0pt4);
398 ✗ setCoolingEvaporationWetBulb1(coolingEvaporationWetBulb1);
399 ✗ setCoolingEvaporationMeanCoincidentDryBulb1(coolingEvaporationMeanCoincidentDryBulb1);
400 ✗ setCoolingEvaporationWetBulb2(coolingEvaporationWetBulb2);
401 ✗ setCoolingEvaporationMeanCoincidentDryBulb2(coolingEvaporationMeanCoincidentDryBulb2);
402 ✗ setCoolingMeanCoincidentWindSpeed0pt4(coolingMeanCoincidentWindSpeed0pt4);
403 ✗ setCoolingPrevailingCoincidentWindDirection0pt4(coolingPrevailingCoincidentWindDirection0pt4);
404 ✗ setCoolingDehumidificationDewPoint0pt4(coolingDehumidificationDewPoint0pt4);
405 ✗ setCoolingDehumidificationHumidityRatio0pt4(coolingDehumidificationHumidityRatio0pt4);
406 ✗ setCoolingDehumidificationMeanCoincidentDryBulb0pt4(coolingDehumidificationMeanCoincidentDryBulb0pt4);
407 ✗ setCoolingDehumidificationDewPoint1(coolingDehumidificationDewPoint1);
408 ✗ setCoolingDehumidificationHumidityRatio1(coolingDehumidificationHumidityRatio1);
409 ✗ setCoolingDehumidificationMeanCoincidentDryBulb1(coolingDehumidificationMeanCoincidentDryBulb1);
410 ✗ setCoolingDehumidificationDewPoint2(coolingDehumidificationDewPoint2);
411 ✗ setCoolingDehumidificationHumidityRatio2(coolingDehumidificationHumidityRatio2);
412 ✗ setCoolingDehumidificationMeanCoincidentDryBulb2(coolingDehumidificationMeanCoincidentDryBulb2);
413 ✗ setCoolingEnthalpy0pt4(coolingEnthalpy0pt4);
414 ✗ setCoolingEnthalpyMeanCoincidentDryBulb0pt4(coolingEnthalpyMeanCoincidentDryBulb0pt4);
415 ✗ setCoolingEnthalpy1(coolingEnthalpy1);
416 ✗ setCoolingEnthalpyMeanCoincidentDryBulb1(coolingEnthalpyMeanCoincidentDryBulb1);
417 ✗ setCoolingEnthalpy2(coolingEnthalpy2);
418 ✗ setCoolingEnthalpyMeanCoincidentDryBulb2(coolingEnthalpyMeanCoincidentDryBulb2);
419 ✗ setCoolingHours8To4AndDryBulb12pt8To20pt6(coolingHours8To4AndDryBulb12pt8To20pt6);
420 ✗ setExtremeWindSpeed1(extremeWindSpeed1);
421 ✗ setExtremeWindSpeed2pt5(extremeWindSpeed2pt5);
422 ✗ setExtremeWindSpeed5(extremeWindSpeed5);
423 ✗ setExtremeMaxWetBulb(extremeMaxWetBulb);
424 ✗ setExtremeMeanMinDryBulb(extremeMeanMinDryBulb);
425 ✗ setExtremeMeanMaxDryBulb(extremeMeanMaxDryBulb);
426 ✗ setExtremeStdDevMinDryBulb(extremeStdDevMinDryBulb);
427 ✗ setExtremeStdDevMaxDryBulb(extremeStdDevMaxDryBulb);
428 ✗ setExtremeN5YearsMinDryBulb(extremeN5YearsMinDryBulb);
429 ✗ setExtremeN5YearsMaxDryBulb(extremeN5YearsMaxDryBulb);
430 ✗ setExtremeN10YearsMinDryBulb(extremeN10YearsMinDryBulb);
431 ✗ setExtremeN10YearsMaxDryBulb(extremeN10YearsMaxDryBulb);
432 ✗ setExtremeN20YearsMinDryBulb(extremeN20YearsMinDryBulb);
433 ✗ setExtremeN20YearsMaxDryBulb(extremeN20YearsMaxDryBulb);
434 ✗ setExtremeN50YearsMinDryBulb(extremeN50YearsMinDryBulb);
435 ✗ setExtremeN50YearsMaxDryBulb(extremeN50YearsMaxDryBulb);
436 ✗ }
437
438 ✗ boost::optional<EpwDataPoint> EpwDataPoint::fromEpwString(const std::string& line) {
439 ✗ std::vector<std::string> strings = splitString(line, ',');
440 ✗ return fromEpwStrings(strings);
441 ✗ }
442
443 ✗ boost::optional<EpwDataPoint> EpwDataPoint::fromEpwStrings(const std::vector<std::string>& strings, bool pedantic) {
444 ✗ EpwDataPoint pt;
445 // Expect 35 items in the strings
446 ✗ if (strings.size() < 35) {
447 ✗ if (pedantic) {
448 ✗ LOG_FREE(Error, "openstudio.EpwFile", "Expected 35 fields in EPW data instead of the " << strings.size() << " received");
449 ✗ return boost::none;
450 } else {
451 ✗ LOG_FREE(Warn, "openstudio.EpwFile",
452 "Expected 35 fields in EPW data instead of the " << strings.size() << " received. The remaining fields will not be available");
453 }
454 ✗ } else if (strings.size() > 35) {
455 ✗ LOG_FREE(Warn, "openstudio.EpwFile",
456 "Expected 35 fields in EPW data instead of the " << strings.size() << " received. The additional data will be ignored");
457 }
458 // Use the appropriate setter on each field
459 ✗ if (!pt.setYear(strings[EpwDataField::Year])) {
460 ✗ return boost::none;
461 }
462 ✗ if (!pt.setMonth(strings[EpwDataField::Month])) {
463 ✗ return boost::none;
464 }
465 ✗ if (!pt.setDay(strings[EpwDataField::Day])) {
466 ✗ return boost::none;
467 }
468 ✗ if (!pt.setHour(strings[EpwDataField::Hour])) {
469 ✗ return boost::none;
470 }
471 ✗ if (!pt.setMinute(strings[EpwDataField::Minute])) {
472 ✗ return boost::none;
473 }
474 ✗ pt.setDataSourceandUncertaintyFlags(strings[EpwDataField::DataSourceandUncertaintyFlags]);
475 ✗ pt.setDryBulbTemperature(strings[EpwDataField::DryBulbTemperature]);
476 ✗ pt.setDewPointTemperature(strings[EpwDataField::DewPointTemperature]);
477 ✗ pt.setRelativeHumidity(strings[EpwDataField::RelativeHumidity]);
478 ✗ pt.setAtmosphericStationPressure(strings[EpwDataField::AtmosphericStationPressure]);
479 ✗ pt.setExtraterrestrialHorizontalRadiation(strings[EpwDataField::ExtraterrestrialHorizontalRadiation]);
480 ✗ pt.setExtraterrestrialDirectNormalRadiation(strings[EpwDataField::ExtraterrestrialDirectNormalRadiation]);
481 ✗ pt.setHorizontalInfraredRadiationIntensity(strings[EpwDataField::HorizontalInfraredRadiationIntensity]);
482 ✗ pt.setGlobalHorizontalRadiation(strings[EpwDataField::GlobalHorizontalRadiation]);
483 ✗ pt.setDirectNormalRadiation(strings[EpwDataField::DirectNormalRadiation]);
484 ✗ pt.setDiffuseHorizontalRadiation(strings[EpwDataField::DiffuseHorizontalRadiation]);
485 ✗ pt.setGlobalHorizontalIlluminance(strings[EpwDataField::GlobalHorizontalIlluminance]);
486 ✗ pt.setDirectNormalIlluminance(strings[EpwDataField::DirectNormalIlluminance]);
487 ✗ pt.setDiffuseHorizontalIlluminance(strings[EpwDataField::DiffuseHorizontalIlluminance]);
488 ✗ pt.setZenithLuminance(strings[EpwDataField::ZenithLuminance]);
489 ✗ pt.setWindDirection(strings[EpwDataField::WindDirection]);
490 ✗ pt.setWindSpeed(strings[EpwDataField::WindSpeed]);
491 ✗ pt.setTotalSkyCover(strings[EpwDataField::TotalSkyCover]);
492 ✗ pt.setOpaqueSkyCover(strings[EpwDataField::OpaqueSkyCover]);
493 ✗ pt.setVisibility(strings[EpwDataField::Visibility]);
494 ✗ pt.setCeilingHeight(strings[EpwDataField::CeilingHeight]);
495 ✗ pt.setPresentWeatherObservation(strings[EpwDataField::PresentWeatherObservation]);
496 ✗ pt.setPresentWeatherCodes(strings[EpwDataField::PresentWeatherCodes]);
497 ✗ pt.setPrecipitableWater(strings[EpwDataField::PrecipitableWater]);
498 ✗ pt.setAerosolOpticalDepth(strings[EpwDataField::AerosolOpticalDepth]);
499 ✗ pt.setSnowDepth(strings[EpwDataField::SnowDepth]);
500 ✗ pt.setDaysSinceLastSnowfall(strings[EpwDataField::DaysSinceLastSnowfall]);
501 ✗ pt.setAlbedo(strings[EpwDataField::Albedo]);
502 ✗ pt.setLiquidPrecipitationDepth(strings[EpwDataField::LiquidPrecipitationDepth]);
503 ✗ pt.setLiquidPrecipitationQuantity(strings[EpwDataField::LiquidPrecipitationQuantity]);
504 ✗ return boost::optional<EpwDataPoint>(pt);
505 ✗ }
506
507 140232 boost::optional<EpwDataPoint> EpwDataPoint::fromEpwStrings(int year, int month, int day, int hour, int minute,
508 const std::vector<std::string>& strings, bool pedantic) {
509
1/1
✓ Branch 1 taken 140232 times.
140232 EpwDataPoint pt;
510 // Expect 30 items in the strings
511
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 140232 times.
140232 if (strings.size() < 35) {
512 ✗ if (pedantic) {
513 ✗ LOG_FREE(Error, "openstudio.EpwFile", "Expected 35 fields in EPW data instead of the " << strings.size() << " received");
514 ✗ return boost::none;
515 } else {
516 ✗ LOG_FREE(Warn, "openstudio.EpwFile",
517 "Expected 35 fields in EPW data instead of the " << strings.size() << " received. The remaining fields will not be available");
518 }
519
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 140232 times.
140232 } else if (strings.size() > 35) {
520 ✗ LOG_FREE(Warn, "openstudio.EpwFile",
521 "Expected 35 fields in EPW data instead of the " << strings.size() << " received. The additional data will be ignored");
522 }
523 // Use the appropriate setter on each field
524
1/1
✓ Branch 1 taken 140232 times.
140232 pt.setYear(year);
525
2/3
✓ Branch 1 taken 140232 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 140232 times.
140232 if (!pt.setMonth(month)) {
526 ✗ return boost::none;
527 }
528
2/3
✓ Branch 1 taken 140232 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 140232 times.
140232 if (!pt.setDay(day)) {
529 ✗ return boost::none;
530 }
531
2/3
✓ Branch 1 taken 140232 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 140232 times.
140232 if (!pt.setHour(hour)) {
532 ✗ return boost::none;
533 }
534
2/3
✓ Branch 1 taken 140232 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 140232 times.
140232 if (!pt.setMinute(minute)) {
535 ✗ return boost::none;
536 }
537
1/1
✓ Branch 2 taken 140232 times.
140232 pt.setDataSourceandUncertaintyFlags(strings[EpwDataField::DataSourceandUncertaintyFlags]);
538
1/1
✓ Branch 2 taken 140232 times.
140232 pt.setDryBulbTemperature(strings[EpwDataField::DryBulbTemperature]);
539
1/1
✓ Branch 2 taken 140232 times.
140232 pt.setDewPointTemperature(strings[EpwDataField::DewPointTemperature]);
540
1/1
✓ Branch 2 taken 140232 times.
140232 pt.setRelativeHumidity(strings[EpwDataField::RelativeHumidity]);
541
1/1
✓ Branch 2 taken 140232 times.
140232 pt.setAtmosphericStationPressure(strings[EpwDataField::AtmosphericStationPressure]);
542
1/1
✓ Branch 2 taken 140232 times.
140232 pt.setExtraterrestrialHorizontalRadiation(strings[EpwDataField::ExtraterrestrialHorizontalRadiation]);
543
1/1
✓ Branch 2 taken 140232 times.
140232 pt.setExtraterrestrialDirectNormalRadiation(strings[EpwDataField::ExtraterrestrialDirectNormalRadiation]);
544
1/1
✓ Branch 2 taken 140232 times.
140232 pt.setHorizontalInfraredRadiationIntensity(strings[EpwDataField::HorizontalInfraredRadiationIntensity]);
545
1/1
✓ Branch 2 taken 140232 times.
140232 pt.setGlobalHorizontalRadiation(strings[EpwDataField::GlobalHorizontalRadiation]);
546
1/1
✓ Branch 2 taken 140232 times.
140232 pt.setDirectNormalRadiation(strings[EpwDataField::DirectNormalRadiation]);
547
1/1
✓ Branch 2 taken 140232 times.
140232 pt.setDiffuseHorizontalRadiation(strings[EpwDataField::DiffuseHorizontalRadiation]);
548
1/1
✓ Branch 2 taken 140232 times.
140232 pt.setGlobalHorizontalIlluminance(strings[EpwDataField::GlobalHorizontalIlluminance]);
549
1/1
✓ Branch 2 taken 140232 times.
140232 pt.setDirectNormalIlluminance(strings[EpwDataField::DirectNormalIlluminance]);
550
1/1
✓ Branch 2 taken 140232 times.
140232 pt.setDiffuseHorizontalIlluminance(strings[EpwDataField::DiffuseHorizontalIlluminance]);
551
1/1
✓ Branch 2 taken 140232 times.
140232 pt.setZenithLuminance(strings[EpwDataField::ZenithLuminance]);
552
1/1
✓ Branch 2 taken 140232 times.
140232 pt.setWindDirection(strings[EpwDataField::WindDirection]);
553
1/1
✓ Branch 2 taken 140232 times.
140232 pt.setWindSpeed(strings[EpwDataField::WindSpeed]);
554
1/1
✓ Branch 2 taken 140232 times.
140232 pt.setTotalSkyCover(strings[EpwDataField::TotalSkyCover]);
555
1/1
✓ Branch 2 taken 140232 times.
140232 pt.setOpaqueSkyCover(strings[EpwDataField::OpaqueSkyCover]);
556
1/1
✓ Branch 2 taken 140232 times.
140232 pt.setVisibility(strings[EpwDataField::Visibility]);
557
1/1
✓ Branch 2 taken 140232 times.
140232 pt.setCeilingHeight(strings[EpwDataField::CeilingHeight]);
558
1/1
✓ Branch 2 taken 140232 times.
140232 pt.setPresentWeatherObservation(strings[EpwDataField::PresentWeatherObservation]);
559
1/1
✓ Branch 2 taken 140232 times.
140232 pt.setPresentWeatherCodes(strings[EpwDataField::PresentWeatherCodes]);
560
1/1
✓ Branch 2 taken 140232 times.
140232 pt.setPrecipitableWater(strings[EpwDataField::PrecipitableWater]);
561
1/1
✓ Branch 2 taken 140232 times.
140232 pt.setAerosolOpticalDepth(strings[EpwDataField::AerosolOpticalDepth]);
562
1/1
✓ Branch 2 taken 140232 times.
140232 pt.setSnowDepth(strings[EpwDataField::SnowDepth]);
563
1/1
✓ Branch 2 taken 140232 times.
140232 pt.setDaysSinceLastSnowfall(strings[EpwDataField::DaysSinceLastSnowfall]);
564
1/1
✓ Branch 2 taken 140232 times.
140232 pt.setAlbedo(strings[EpwDataField::Albedo]);
565
1/1
✓ Branch 2 taken 140232 times.
140232 pt.setLiquidPrecipitationDepth(strings[EpwDataField::LiquidPrecipitationDepth]);
566
1/1
✓ Branch 2 taken 140232 times.
140232 pt.setLiquidPrecipitationQuantity(strings[EpwDataField::LiquidPrecipitationQuantity]);
567
1/1
✓ Branch 1 taken 140232 times.
140232 return boost::optional<EpwDataPoint>(pt);
568 140232 }
569
570 8 boost::optional<EpwDesignCondition> EpwDesignCondition::fromDesignConditionsString(const std::string& line) {
571
1/1
✓ Branch 1 taken 8 times.
8 std::vector<std::string> strings = splitString(line, ',');
572
1/1
✓ Branch 1 taken 8 times.
16 return fromDesignConditionsStrings(strings);
573 8 }
574
575 7 ASHRAEHoFVintage EpwDesignCondition::ashraeHoFVersion() const {
576 7 return m_ashraeHoFVersion;
577 }
578
579 57 void EpwDesignCondition::assignHeatingData(std::span<const std::string> stringValues) {
580 916 auto index = [base_field = static_cast<size_t>(EpwDesignField::Heating)](EpwDesignField field) -> size_t {
581 859 return static_cast<size_t>(field.value()) - base_field - 1;
582 };
583
584
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setHeatingColdestMonth(stringValues[index(EpwDesignField::HeatingColdestMonth)]);
585
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setHeatingDryBulb99pt6(stringValues[index(EpwDesignField::HeatingDryBulb99pt6)]);
586
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setHeatingDryBulb99(stringValues[index(EpwDesignField::HeatingDryBulb99)]);
587
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setHeatingHumidificationDewPoint99pt6(stringValues[index(EpwDesignField::HeatingHumidificationDewPoint99pt6)]);
588
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setHeatingHumidificationHumidityRatio99pt6(stringValues[index(EpwDesignField::HeatingHumidificationHumidityRatio99pt6)]);
589
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setHeatingHumidificationMeanCoincidentDryBulb99pt6(stringValues[index(EpwDesignField::HeatingHumidificationMeanCoincidentDryBulb99pt6)]);
590
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setHeatingHumidificationDewPoint99(stringValues[index(EpwDesignField::HeatingHumidificationDewPoint99)]);
591
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setHeatingHumidificationHumidityRatio99(stringValues[index(EpwDesignField::HeatingHumidificationHumidityRatio99)]);
592
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setHeatingHumidificationMeanCoincidentDryBulb99(stringValues[index(EpwDesignField::HeatingHumidificationMeanCoincidentDryBulb99)]);
593
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setHeatingColdestMonthWindSpeed0pt4(stringValues[index(EpwDesignField::HeatingColdestMonthWindSpeed0pt4)]);
594
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setHeatingColdestMonthMeanCoincidentDryBulb0pt4(stringValues[index(EpwDesignField::HeatingColdestMonthMeanCoincidentDryBulb0pt4)]);
595
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setHeatingColdestMonthWindSpeed1(stringValues[index(EpwDesignField::HeatingColdestMonthWindSpeed1)]);
596
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setHeatingColdestMonthMeanCoincidentDryBulb1(stringValues[index(EpwDesignField::HeatingColdestMonthMeanCoincidentDryBulb1)]);
597
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setHeatingMeanCoincidentWindSpeed99pt6(stringValues[index(EpwDesignField::HeatingMeanCoincidentWindSpeed99pt6)]);
598
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setHeatingPrevailingCoincidentWindDirection99pt6(stringValues[index(EpwDesignField::HeatingPrevailingCoincidentWindDirection99pt6)]);
599
600
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 53 times.
57 if (m_ashraeHoFVersion >= ASHRAEHoFVintage::ASHRAE_2021) {
601
3/3
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 8 taken 4 times.
4 setHeatingWindShelterFactor(stringValues[index(EpwDesignField::HeatingWindShelterFactor)]);
602 }
603 57 }
604
605 57 void EpwDesignCondition::assignCoolingData(std::span<const std::string> stringValues) {
606 1881 auto index = [base_field = static_cast<size_t>(EpwDesignField::Cooling)](EpwDesignField field) -> size_t {
607 1824 return static_cast<size_t>(field.value()) - base_field - 1;
608 };
609
610
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setCoolingHottestMonth(stringValues[index(EpwDesignField::CoolingHottestMonth)]);
611
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setCoolingDryBulbRange(stringValues[index(EpwDesignField::CoolingDryBulbRange)]);
612
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setCoolingDryBulb0pt4(stringValues[index(EpwDesignField::CoolingDryBulb0pt4)]);
613
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setCoolingMeanCoincidentWetBulb0pt4(stringValues[index(EpwDesignField::CoolingMeanCoincidentWetBulb0pt4)]);
614
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setCoolingDryBulb1(stringValues[index(EpwDesignField::CoolingDryBulb1)]);
615
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setCoolingMeanCoincidentWetBulb1(stringValues[index(EpwDesignField::CoolingMeanCoincidentWetBulb1)]);
616
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setCoolingDryBulb2(stringValues[index(EpwDesignField::CoolingDryBulb2)]);
617
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setCoolingMeanCoincidentWetBulb2(stringValues[index(EpwDesignField::CoolingMeanCoincidentWetBulb2)]);
618
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setCoolingEvaporationWetBulb0pt4(stringValues[index(EpwDesignField::CoolingEvaporationWetBulb0pt4)]);
619
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setCoolingEvaporationMeanCoincidentDryBulb0pt4(stringValues[index(EpwDesignField::CoolingEvaporationMeanCoincidentDryBulb0pt4)]);
620
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setCoolingEvaporationWetBulb1(stringValues[index(EpwDesignField::CoolingEvaporationWetBulb1)]);
621
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setCoolingEvaporationMeanCoincidentDryBulb1(stringValues[index(EpwDesignField::CoolingEvaporationMeanCoincidentDryBulb1)]);
622
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setCoolingEvaporationWetBulb2(stringValues[index(EpwDesignField::CoolingEvaporationWetBulb2)]);
623
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setCoolingEvaporationMeanCoincidentDryBulb2(stringValues[index(EpwDesignField::CoolingEvaporationMeanCoincidentDryBulb2)]);
624
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setCoolingMeanCoincidentWindSpeed0pt4(stringValues[index(EpwDesignField::CoolingMeanCoincidentWindSpeed0pt4)]);
625
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setCoolingPrevailingCoincidentWindDirection0pt4(stringValues[index(EpwDesignField::CoolingPrevailingCoincidentWindDirection0pt4)]);
626
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setCoolingDehumidificationDewPoint0pt4(stringValues[index(EpwDesignField::CoolingDehumidificationDewPoint0pt4)]);
627
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setCoolingDehumidificationHumidityRatio0pt4(stringValues[index(EpwDesignField::CoolingDehumidificationHumidityRatio0pt4)]);
628
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setCoolingDehumidificationMeanCoincidentDryBulb0pt4(stringValues[index(EpwDesignField::CoolingDehumidificationMeanCoincidentDryBulb0pt4)]);
629
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setCoolingDehumidificationDewPoint1(stringValues[index(EpwDesignField::CoolingDehumidificationDewPoint1)]);
630
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setCoolingDehumidificationHumidityRatio1(stringValues[index(EpwDesignField::CoolingDehumidificationHumidityRatio1)]);
631
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setCoolingDehumidificationMeanCoincidentDryBulb1(stringValues[index(EpwDesignField::CoolingDehumidificationMeanCoincidentDryBulb1)]);
632
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setCoolingDehumidificationDewPoint2(stringValues[index(EpwDesignField::CoolingDehumidificationDewPoint2)]);
633
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setCoolingDehumidificationHumidityRatio2(stringValues[index(EpwDesignField::CoolingDehumidificationHumidityRatio2)]);
634
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setCoolingDehumidificationMeanCoincidentDryBulb2(stringValues[index(EpwDesignField::CoolingDehumidificationMeanCoincidentDryBulb2)]);
635
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setCoolingEnthalpy0pt4(stringValues[index(EpwDesignField::CoolingEnthalpy0pt4)]);
636
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setCoolingEnthalpyMeanCoincidentDryBulb0pt4(stringValues[index(EpwDesignField::CoolingEnthalpyMeanCoincidentDryBulb0pt4)]);
637
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setCoolingEnthalpy1(stringValues[index(EpwDesignField::CoolingEnthalpy1)]);
638
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setCoolingEnthalpyMeanCoincidentDryBulb1(stringValues[index(EpwDesignField::CoolingEnthalpyMeanCoincidentDryBulb1)]);
639
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setCoolingEnthalpy2(stringValues[index(EpwDesignField::CoolingEnthalpy2)]);
640
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setCoolingEnthalpyMeanCoincidentDryBulb2(stringValues[index(EpwDesignField::CoolingEnthalpyMeanCoincidentDryBulb2)]);
641
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 52 times.
✓ Branch 5 taken 5 times.
57 if (m_ashraeHoFVersion <= ASHRAEHoFVintage::ASHRAE_2013) {
642
3/3
✓ Branch 1 taken 52 times.
✓ Branch 4 taken 52 times.
✓ Branch 8 taken 52 times.
52 setCoolingHours8To4AndDryBulb12pt8To20pt6(stringValues[index(EpwDesignField::CoolingHours8To4AndDryBulb12pt8To20pt6)]);
643 } else {
644
3/3
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 8 taken 5 times.
5 setExtremeMaxWetBulb(stringValues[index(EpwDesignField::CoolingExtremeMaxWetBulb) - 1]);
645 }
646 57 }
647
648 57 void EpwDesignCondition::assignExtremesData(std::span<const std::string> stringValues) {
649 57 size_t offset = 1;
650 964 auto index = [&offset, base_field = static_cast<size_t>(EpwDesignField::Extremes)](EpwDesignField field) -> size_t {
651 907 return static_cast<size_t>(field.value()) - base_field - offset;
652 57 };
653
654
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setExtremeWindSpeed1(stringValues[index(EpwDesignField::ExtremeWindSpeed1)]);
655
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setExtremeWindSpeed2pt5(stringValues[index(EpwDesignField::ExtremeWindSpeed2pt5)]);
656
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setExtremeWindSpeed5(stringValues[index(EpwDesignField::ExtremeWindSpeed5)]);
657
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 52 times.
✓ Branch 5 taken 5 times.
57 if (m_ashraeHoFVersion <= ASHRAEHoFVintage::ASHRAE_2013) {
658
3/3
✓ Branch 1 taken 52 times.
✓ Branch 4 taken 52 times.
✓ Branch 8 taken 52 times.
52 setExtremeMaxWetBulb(stringValues[index(EpwDesignField::ExtremeMaxWetBulb)]);
659 } else {
660 5 ++offset;
661 }
662
663
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setExtremeMeanMinDryBulb(stringValues[index(EpwDesignField::ExtremeMeanMinDryBulb)]);
664
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setExtremeMeanMaxDryBulb(stringValues[index(EpwDesignField::ExtremeMeanMaxDryBulb)]);
665
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setExtremeStdDevMinDryBulb(stringValues[index(EpwDesignField::ExtremeStdDevMinDryBulb)]);
666
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setExtremeStdDevMaxDryBulb(stringValues[index(EpwDesignField::ExtremeStdDevMaxDryBulb)]);
667
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setExtremeN5YearsMinDryBulb(stringValues[index(EpwDesignField::ExtremeN5YearsMinDryBulb)]);
668
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setExtremeN5YearsMaxDryBulb(stringValues[index(EpwDesignField::ExtremeN5YearsMaxDryBulb)]);
669
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setExtremeN10YearsMinDryBulb(stringValues[index(EpwDesignField::ExtremeN10YearsMinDryBulb)]);
670
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setExtremeN10YearsMaxDryBulb(stringValues[index(EpwDesignField::ExtremeN10YearsMaxDryBulb)]);
671
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setExtremeN20YearsMinDryBulb(stringValues[index(EpwDesignField::ExtremeN20YearsMinDryBulb)]);
672
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setExtremeN20YearsMaxDryBulb(stringValues[index(EpwDesignField::ExtremeN20YearsMaxDryBulb)]);
673
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setExtremeN50YearsMinDryBulb(stringValues[index(EpwDesignField::ExtremeN50YearsMinDryBulb)]);
674
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 8 taken 57 times.
57 setExtremeN50YearsMaxDryBulb(stringValues[index(EpwDesignField::ExtremeN50YearsMaxDryBulb)]);
675 57 }
676
677 60 boost::optional<EpwDesignCondition> EpwDesignCondition::fromDesignConditionsStrings(const std::vector<std::string>& strings) {
678
1/1
✓ Branch 1 taken 60 times.
60 EpwDesignCondition dc;
679
680 60 const size_t num_strings = strings.size();
681 // Expect 68 items in the strings
682
3/4
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
✓ Branch 3 taken 59 times.
60 if (num_strings < 67 || num_strings > 68) {
683
7/7
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 8 taken 1 time.
✓ Branch 11 taken 1 time.
✓ Branch 14 taken 1 time.
✓ Branch 17 taken 1 time.
✓ Branch 20 taken 1 time.
3 LOG_FREE(Error, "openstudio.EpwFile", "Expected 68 fields in EPW design condition instead of the " << strings.size() << " received");
684 1 return boost::none;
685 }
686
687 // Use the appropriate setter on each field
688
1/1
✓ Branch 2 taken 59 times.
59 dc.setTitleOfDesignCondition(strings[EpwDesignField::TitleOfDesignCondition]);
689 59 const auto& title = strings[EpwDesignField::TitleOfDesignCondition];
690
4/7
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 57 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 57 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
59 static const boost::regex yearRegex(R"(\b(20\d{2})\b)"); // Matches 20xx
691 59 boost::optional<ASHRAEHoFVintage> assumedVersion;
692
1/1
✓ Branch 1 taken 59 times.
59 boost::smatch m;
693
3/3
✓ Branch 1 taken 59 times.
✓ Branch 3 taken 57 times.
✓ Branch 4 taken 2 times.
59 if (boost::regex_search(title, m, yearRegex)) {
694
3/3
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 7 taken 57 times.
57 int year = std::stoi(m[1]);
695
2/4
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57 times.
✗ Branch 3 not taken.
57 if (year >= 2009 && (year - 2009) % 4 == 0) {
696 // Valid ASHRAE design year: 2009, 2013, 2017, 2021, 2025, etc.
697
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 23 times.
57 if (year == 2009) {
698
1/1
✓ Branch 1 taken 34 times.
34 assumedVersion = ASHRAEHoFVintage::ASHRAE_2009;
699
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 5 times.
23 } else if (year == 2013) {
700
1/1
✓ Branch 1 taken 18 times.
18 assumedVersion = ASHRAEHoFVintage::ASHRAE_2013;
701
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 4 times.
5 } else if (year == 2017) {
702
1/1
✓ Branch 1 taken 1 time.
1 assumedVersion = ASHRAEHoFVintage::ASHRAE_2017;
703
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 } else if (year == 2021) {
704
1/1
✓ Branch 1 taken 4 times.
4 assumedVersion = ASHRAEHoFVintage::ASHRAE_2021;
705 ✗ } else if (year == 2025) {
706 ✗ assumedVersion = ASHRAEHoFVintage::ASHRAE_2025;
707 } else {
708 // Assume future version is the same as 2025
709 ✗ LOG_FREE(Debug, "openstudio.EpwFile",
710 "Unrecognized ASHRAE design year (" << year << ") in EPW design condition title. Assuming 2025 vintage for parsing.");
711 ✗ assumedVersion = ASHRAEHoFVintage::ASHRAE_2025;
712 }
713 57 } else {
714 ✗ LOG_FREE(Debug, "openstudio.EpwFile", "Did not detect a valid ASHRAE design year in EPW design condition title.");
715 }
716 }
717
718
3/3
✓ Branch 1 taken 177 times.
✓ Branch 4 taken 177 times.
✓ Branch 11 taken 59 times.
590 auto itHeating = std::find_if(strings.cbegin(), strings.cend(), [](const auto& s) { return openstudio::istringEqual(s, "Heating"); });
719
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 59 times.
59 if (itHeating == strings.cend()) {
720 ✗ LOG_FREE(Error, "openstudio.EpwFile", "Could not find 'Heating' design condition in EPW design condition string");
721 ✗ return boost::none;
722 }
723 // Heating Must be in position 2 (Title, Blank, Heating, ...)
724
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
118 if (std::distance(strings.cbegin(), itHeating) != 2) {
725 ✗ LOG_FREE(Error, "openstudio.EpwFile", "'Heating' design condition not in expected position in EPW design condition string");
726 ✗ return boost::none;
727 }
728
3/3
✓ Branch 1 taken 1127 times.
✓ Branch 4 taken 1127 times.
✓ Branch 11 taken 59 times.
3440 auto itCooling = std::find_if(strings.cbegin(), strings.cend(), [](const auto& s) { return openstudio::istringEqual(s, "Cooling"); });
729
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 59 times.
59 if (itCooling == strings.cend()) {
730 ✗ LOG_FREE(Error, "openstudio.EpwFile", "Could not find 'Cooling' design condition in EPW design condition string");
731 ✗ return boost::none;
732 }
733
3/3
✓ Branch 1 taken 3075 times.
✓ Branch 4 taken 3075 times.
✓ Branch 11 taken 59 times.
9284 auto itExtreme = std::find_if(strings.cbegin(), strings.cend(), [](const auto& s) { return openstudio::istringEqual(s, "Extremes"); });
734
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 59 times.
59 if (itExtreme == strings.cend()) {
735 ✗ LOG_FREE(Error, "openstudio.EpwFile", "Could not find 'Extremes' design condition in EPW design condition string");
736 ✗ return boost::none;
737 }
738
739 59 std::span<const std::string> heatingStrings(std::next(itHeating, 1), itCooling);
740 59 std::span<const std::string> coolingStrings(std::next(itCooling, 1), itExtreme);
741 118 std::span<const std::string> extremesStrings(std::next(itExtreme, 1), strings.cend());
742
743 59 const auto numHeatingFields = heatingStrings.size();
744 59 const auto numCoolingFields = coolingStrings.size();
745 59 const auto numExtremeFields = extremesStrings.size();
746
747 // Default to 2009 for now
748 // constexpr size_t numOtherFields = 5; // Title, Blank, Heating, Cooling, Extreme
749 59 size_t expectedNumHeatingFields = 15;
750 59 const size_t expectedNumCoolingFields = 32;
751 59 size_t expectedNumExtremeFields = 16;
752
753 59 bool needHeuristics = false;
754
755
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 2 times.
59 if (assumedVersion) {
756
4/4
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 7 taken 4 times.
✓ Branch 8 taken 53 times.
57 if (*assumedVersion <= ASHRAEHoFVintage::ASHRAE_2017) {
757 } else {
758 4 expectedNumHeatingFields = 16;
759 }
760
4/4
✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
✓ Branch 7 taken 52 times.
✓ Branch 8 taken 5 times.
57 if (*assumedVersion <= ASHRAEHoFVintage::ASHRAE_2013) {
761 52 expectedNumHeatingFields = 15;
762 52 expectedNumExtremeFields = 16;
763
4/4
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 1 time.
✓ Branch 8 taken 4 times.
5 } else if (*assumedVersion <= ASHRAEHoFVintage::ASHRAE_2017) {
764 1 expectedNumExtremeFields = 15;
765 1 expectedNumExtremeFields = 15;
766 } else {
767 4 expectedNumExtremeFields = 16;
768 4 expectedNumExtremeFields = 15;
769 }
770 // Check that the field counts match the assumed version, we'll fall back to heuristics if not
771
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 54 times.
57 if (numHeatingFields != expectedNumHeatingFields) {
772
13/13
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
✓ Branch 19 taken 3 times.
✓ Branch 22 taken 3 times.
✓ Branch 25 taken 3 times.
✓ Branch 28 taken 3 times.
✓ Branch 32 taken 3 times.
✓ Branch 35 taken 3 times.
✓ Branch 38 taken 3 times.
9 LOG_FREE(Warn, "openstudio.EpwFile",
773 "Based on the assumed vintage parsed in the title string of " << assumedVersion->valueDescription() << ", we expected "
774 << expectedNumHeatingFields << " Heating fields but got "
775 << numHeatingFields << ", falling to back to heuristics.");
776 3 needHeuristics = true;
777 }
778
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 55 times.
57 if (numExtremeFields != expectedNumExtremeFields) {
779
13/13
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
✓ Branch 16 taken 2 times.
✓ Branch 19 taken 2 times.
✓ Branch 22 taken 2 times.
✓ Branch 25 taken 2 times.
✓ Branch 28 taken 2 times.
✓ Branch 32 taken 2 times.
✓ Branch 35 taken 2 times.
✓ Branch 38 taken 2 times.
6 LOG_FREE(Warn, "openstudio.EpwFile",
780 "Based on the assumed vintage parsed in the title string of " << assumedVersion->valueDescription() << ", we expected "
781 << expectedNumExtremeFields << " Extreme fields but got "
782 << numExtremeFields << ", falling to back to heuristics.");
783 2 needHeuristics = true;
784 }
785 } else {
786 2 needHeuristics = true;
787 }
788
789
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 54 times.
59 if (needHeuristics) {
790
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3 times.
5 if (numHeatingFields == 15) {
791 // Wind Shelter Factor is not present yet, so this must be between 2009 and 2017 included
792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (num_strings == 67) {
793 ✗ assumedVersion = ASHRAEHoFVintage::ASHRAE_2017;
794 ✗ expectedNumHeatingFields = 15;
795 ✗ expectedNumExtremeFields = 15;
796 } else {
797
1/1
✓ Branch 1 taken 2 times.
2 assumedVersion = ASHRAEHoFVintage::ASHRAE_2009;
798 2 expectedNumHeatingFields = 15;
799 2 expectedNumExtremeFields = 16;
800 }
801
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 time.
3 } else if (numHeatingFields == 16) {
802 // This has to be 2021 or 2025
803
1/1
✓ Branch 1 taken 2 times.
2 assumedVersion = ASHRAEHoFVintage::ASHRAE_2021;
804 2 expectedNumHeatingFields = 16;
805 2 expectedNumExtremeFields = 15;
806 } else {
807
7/7
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
✓ Branch 16 taken 1 time.
✓ Branch 19 taken 1 time.
3 LOG_FREE(Error, "openstudio.EpwFile",
808 "Unexpected number of heating design condition fields (" << numHeatingFields << ", expected 15 or 16) in EPW design condition string");
809 1 return boost::none;
810 }
811 }
812
813
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if (numHeatingFields != expectedNumHeatingFields) {
814 ✗ LOG_FREE(Error, "openstudio.EpwFile",
815 "Based on the assumed vintage of " << assumedVersion->valueDescription() << ", we expected " << expectedNumHeatingFields
816 << " Heating fields but got " << numHeatingFields << ".");
817 ✗ return boost::none;
818 }
819
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 57 times.
58 if (numCoolingFields != expectedNumCoolingFields) {
820
13/13
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
✓ Branch 16 taken 1 time.
✓ Branch 19 taken 1 time.
✓ Branch 22 taken 1 time.
✓ Branch 25 taken 1 time.
✓ Branch 28 taken 1 time.
✓ Branch 32 taken 1 time.
✓ Branch 35 taken 1 time.
✓ Branch 38 taken 1 time.
3 LOG_FREE(Error, "openstudio.EpwFile",
821 "Based on the assumed vintage of " << assumedVersion->valueDescription() << ", we expected " << expectedNumCoolingFields
822 << " Cooling fields but got " << numCoolingFields << ".");
823 1 return boost::none;
824 }
825
826
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
57 if (numExtremeFields != expectedNumExtremeFields) {
827 ✗ LOG_FREE(Error, "openstudio.EpwFile",
828 "Based on the assumed vintage of " << assumedVersion->valueDescription() << ", we expected " << expectedNumExtremeFields
829 << " Extreme fields but got " << numExtremeFields << ".");
830 ✗ return boost::none;
831 }
832
833
1/1
✓ Branch 1 taken 57 times.
57 dc.m_ashraeHoFVersion = *assumedVersion;
834
835
1/1
✓ Branch 1 taken 57 times.
57 dc.assignHeatingData(heatingStrings);
836
1/1
✓ Branch 1 taken 57 times.
57 dc.assignCoolingData(coolingStrings);
837
1/1
✓ Branch 1 taken 57 times.
57 dc.assignExtremesData(extremesStrings);
838
839
1/1
✓ Branch 1 taken 57 times.
57 return dc;
840 60 }
841
842 3 std::vector<std::string> EpwDataPoint::toEpwStrings() const {
843 3 std::vector<std::string> strings;
844
1/1
✓ Branch 1 taken 3 times.
3 strings.reserve(35);
845
1/1
✓ Branch 2 taken 3 times.
3 strings.push_back(std::to_string(m_year));
846
1/1
✓ Branch 2 taken 3 times.
3 strings.push_back(std::to_string(m_month));
847
1/1
✓ Branch 2 taken 3 times.
3 strings.push_back(std::to_string(m_day));
848
1/1
✓ Branch 2 taken 3 times.
3 strings.push_back(std::to_string(m_hour));
849
1/1
✓ Branch 2 taken 3 times.
3 strings.push_back(std::to_string(m_minute));
850
1/1
✓ Branch 1 taken 3 times.
3 strings.push_back(m_dataSourceandUncertaintyFlags);
851
1/1
✓ Branch 1 taken 3 times.
3 strings.push_back(m_dryBulbTemperature);
852
1/1
✓ Branch 1 taken 3 times.
3 strings.push_back(m_dewPointTemperature);
853
1/1
✓ Branch 1 taken 3 times.
3 strings.push_back(m_relativeHumidity);
854
1/1
✓ Branch 1 taken 3 times.
3 strings.push_back(m_atmosphericStationPressure);
855
1/1
✓ Branch 1 taken 3 times.
3 strings.push_back(m_extraterrestrialHorizontalRadiation);
856
1/1
✓ Branch 1 taken 3 times.
3 strings.push_back(m_extraterrestrialDirectNormalRadiation);
857
1/1
✓ Branch 1 taken 3 times.
3 strings.push_back(m_horizontalInfraredRadiationIntensity);
858
1/1
✓ Branch 1 taken 3 times.
3 strings.push_back(m_globalHorizontalRadiation);
859
1/1
✓ Branch 1 taken 3 times.
3 strings.push_back(m_directNormalRadiation);
860
1/1
✓ Branch 1 taken 3 times.
3 strings.push_back(m_diffuseHorizontalRadiation);
861
1/1
✓ Branch 1 taken 3 times.
3 strings.push_back(m_globalHorizontalIlluminance);
862
1/1
✓ Branch 1 taken 3 times.
3 strings.push_back(m_directNormalIlluminance);
863
1/1
✓ Branch 1 taken 3 times.
3 strings.push_back(m_diffuseHorizontalIlluminance);
864
1/1
✓ Branch 1 taken 3 times.
3 strings.push_back(m_zenithLuminance);
865
1/1
✓ Branch 1 taken 3 times.
3 strings.push_back(m_windDirection);
866
1/1
✓ Branch 1 taken 3 times.
3 strings.push_back(m_windSpeed);
867
1/1
✓ Branch 2 taken 3 times.
3 strings.push_back(std::to_string(m_totalSkyCover));
868
1/1
✓ Branch 2 taken 3 times.
3 strings.push_back(std::to_string(m_opaqueSkyCover));
869
1/1
✓ Branch 1 taken 3 times.
3 strings.push_back(m_visibility);
870
1/1
✓ Branch 1 taken 3 times.
3 strings.push_back(m_ceilingHeight);
871
1/1
✓ Branch 2 taken 3 times.
3 strings.push_back(std::to_string(m_presentWeatherObservation));
872
1/1
✓ Branch 2 taken 3 times.
3 strings.push_back(std::to_string(m_presentWeatherCodes));
873
1/1
✓ Branch 1 taken 3 times.
3 strings.push_back(m_precipitableWater);
874
1/1
✓ Branch 1 taken 3 times.
3 strings.push_back(m_aerosolOpticalDepth);
875
1/1
✓ Branch 1 taken 3 times.
3 strings.push_back(m_snowDepth);
876
1/1
✓ Branch 1 taken 3 times.
3 strings.push_back(m_daysSinceLastSnowfall);
877
1/1
✓ Branch 1 taken 3 times.
3 strings.push_back(m_albedo);
878
1/1
✓ Branch 1 taken 3 times.
3 strings.push_back(m_liquidPrecipitationDepth);
879
1/1
✓ Branch 1 taken 3 times.
3 strings.push_back(m_liquidPrecipitationQuantity);
880 3 return strings;
881 ✗ }
882
883 ✗ boost::optional<std::string> EpwDataPoint::getUnitsByName(const std::string& name) {
884 ✗ EpwDataField id;
885 try {
886 ✗ id = EpwDataField(name);
887 ✗ } catch (...) {
888 // Could do a warning message here
889 ✗ return boost::none;
890 ✗ }
891 ✗ return boost::optional<std::string>(getUnits(id));
892 }
893
894 10 std::string EpwDataPoint::getUnits(EpwDataField field) {
895 10 std::string string;
896
3/37
✓ Branch 1 taken 10 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 5 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 5 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
10 switch (field.value()) {
897 ✗ case EpwDataField::Year:
898 //string = "None";
899 ✗ break;
900 ✗ case EpwDataField::Month:
901 //string = "None";
902 ✗ break;
903 ✗ case EpwDataField::Day:
904 //string = "None";
905 ✗ break;
906 ✗ case EpwDataField::Hour:
907 //string = "None";
908 ✗ break;
909 ✗ case EpwDataField::Minute:
910 //string = "None";
911 ✗ break;
912 ✗ case EpwDataField::DataSourceandUncertaintyFlags:
913 //string = "None";
914 ✗ break;
915 5 case EpwDataField::DryBulbTemperature:
916
1/1
✓ Branch 1 taken 5 times.
5 string = "C";
917 5 break;
918 ✗ case EpwDataField::DewPointTemperature:
919 ✗ string = "C";
920 ✗ break;
921 ✗ case EpwDataField::RelativeHumidity:
922 //string = "None";
923 ✗ break;
924 ✗ case EpwDataField::AtmosphericStationPressure:
925 ✗ string = "Pa";
926 ✗ break;
927 ✗ case EpwDataField::ExtraterrestrialHorizontalRadiation:
928 ✗ string = "Wh/m2";
929 ✗ break;
930 ✗ case EpwDataField::ExtraterrestrialDirectNormalRadiation:
931 ✗ string = "Wh/m2";
932 ✗ break;
933 ✗ case EpwDataField::HorizontalInfraredRadiationIntensity:
934 ✗ string = "Wh/m2";
935 ✗ break;
936 ✗ case EpwDataField::GlobalHorizontalRadiation:
937 ✗ string = "Wh/m2";
938 ✗ break;
939 ✗ case EpwDataField::DirectNormalRadiation:
940 ✗ string = "Wh/m2";
941 ✗ break;
942 ✗ case EpwDataField::DiffuseHorizontalRadiation:
943 ✗ string = "Wh/m2";
944 ✗ break;
945 ✗ case EpwDataField::GlobalHorizontalIlluminance:
946 ✗ string = "lux";
947 ✗ break;
948 ✗ case EpwDataField::DirectNormalIlluminance:
949 ✗ string = "lux";
950 ✗ break;
951 ✗ case EpwDataField::DiffuseHorizontalIlluminance:
952 ✗ string = "lux";
953 ✗ break;
954 ✗ case EpwDataField::ZenithLuminance:
955 ✗ string = "Cd/m2";
956 ✗ break;
957 ✗ case EpwDataField::WindDirection:
958 ✗ string = "degrees";
959 ✗ break;
960 5 case EpwDataField::WindSpeed:
961
1/1
✓ Branch 1 taken 5 times.
5 string = "m/s";
962 5 break;
963 ✗ case EpwDataField::TotalSkyCover:
964 //string = "None";
965 ✗ break;
966 ✗ case EpwDataField::OpaqueSkyCover:
967 //string = "None";
968 ✗ break;
969 ✗ case EpwDataField::Visibility:
970 ✗ string = "km";
971 ✗ break;
972 ✗ case EpwDataField::CeilingHeight:
973 ✗ string = "m";
974 ✗ break;
975 ✗ case EpwDataField::PresentWeatherObservation:
976 //string = "None";
977 ✗ break;
978 ✗ case EpwDataField::PresentWeatherCodes:
979 //string = "None";
980 ✗ break;
981 ✗ case EpwDataField::PrecipitableWater:
982 ✗ string = "mm";
983 ✗ break;
984 ✗ case EpwDataField::AerosolOpticalDepth:
985 ✗ string = "thousandths";
986 ✗ break;
987 ✗ case EpwDataField::SnowDepth:
988 ✗ string = "cm";
989 ✗ break;
990 ✗ case EpwDataField::DaysSinceLastSnowfall:
991 //string = "None";
992 ✗ break;
993 ✗ case EpwDataField::Albedo:
994 //string = "None";
995 ✗ break;
996 ✗ case EpwDataField::LiquidPrecipitationDepth:
997 ✗ string = "mm";
998 ✗ break;
999 ✗ case EpwDataField::LiquidPrecipitationQuantity:
1000 ✗ string = "hr";
1001 ✗ break;
1002 ✗ default:
1003 //string = "None";
1004 ✗ break;
1005 }
1006 10 return string;
1007 ✗ }
1008
1009 11 boost::optional<std::string> EpwDesignCondition::getUnitsByName(const std::string& name) {
1010
1/1
✓ Branch 1 taken 11 times.
11 EpwDesignField id;
1011 try {
1012
1/1
✓ Branch 1 taken 11 times.
11 id = EpwDesignField(name);
1013 ✗ } catch (...) {
1014 // Could do a warning message here
1015 ✗ return boost::none;
1016 ✗ }
1017
2/2
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
11 return getUnits(id);
1018 }
1019
1020 22 std::string EpwDesignCondition::getUnits(EpwDesignField field) {
1021 22 std::string string;
1022
2/68
✓ Branch 1 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✗ Branch 49 not taken.
✗ Branch 50 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 53 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
✗ Branch 56 not taken.
✗ Branch 57 not taken.
✗ Branch 58 not taken.
✗ Branch 59 not taken.
✗ Branch 60 not taken.
✗ Branch 61 not taken.
✗ Branch 62 not taken.
✗ Branch 63 not taken.
✗ Branch 64 not taken.
✗ Branch 65 not taken.
✗ Branch 66 not taken.
✗ Branch 67 not taken.
✗ Branch 68 not taken.
✗ Branch 69 not taken.
22 switch (field.value()) {
1023 ✗ case EpwDesignField::TitleOfDesignCondition:
1024 //string = "None";
1025 ✗ break;
1026 ✗ case EpwDesignField::HeatingColdestMonth:
1027 //string = "None";
1028 ✗ break;
1029 22 case EpwDesignField::HeatingDryBulb99pt6:
1030
1/1
✓ Branch 1 taken 22 times.
22 string = "C";
1031 22 break;
1032 ✗ case EpwDesignField::HeatingDryBulb99:
1033 ✗ string = "C";
1034 ✗ break;
1035 ✗ case EpwDesignField::HeatingHumidificationDewPoint99pt6:
1036 ✗ string = "C";
1037 ✗ break;
1038 ✗ case EpwDesignField::HeatingHumidificationHumidityRatio99pt6:
1039 ✗ string = "g/kg";
1040 ✗ break;
1041 ✗ case EpwDesignField::HeatingHumidificationMeanCoincidentDryBulb99pt6:
1042 ✗ string = "C";
1043 ✗ break;
1044 ✗ case EpwDesignField::HeatingHumidificationDewPoint99:
1045 ✗ string = "C";
1046 ✗ break;
1047 ✗ case EpwDesignField::HeatingHumidificationHumidityRatio99:
1048 ✗ string = "g/kg";
1049 ✗ break;
1050 ✗ case EpwDesignField::HeatingHumidificationMeanCoincidentDryBulb99:
1051 ✗ string = "C";
1052 ✗ break;
1053 ✗ case EpwDesignField::HeatingColdestMonthWindSpeed0pt4:
1054 ✗ string = "m/s";
1055 ✗ break;
1056 ✗ case EpwDesignField::HeatingColdestMonthMeanCoincidentDryBulb0pt4:
1057 ✗ string = "C";
1058 ✗ break;
1059 ✗ case EpwDesignField::HeatingColdestMonthWindSpeed1:
1060 ✗ string = "m/s";
1061 ✗ break;
1062 ✗ case EpwDesignField::HeatingColdestMonthMeanCoincidentDryBulb1:
1063 ✗ string = "C";
1064 ✗ break;
1065 ✗ case EpwDesignField::HeatingMeanCoincidentWindSpeed99pt6:
1066 ✗ string = "m/s";
1067 ✗ break;
1068 ✗ case EpwDesignField::HeatingPrevailingCoincidentWindDirection99pt6:
1069 ✗ string = "degrees";
1070 ✗ break;
1071 ✗ case EpwDesignField::HeatingWindShelterFactor:
1072 //string = "None";
1073 ✗ break;
1074 ✗ case EpwDesignField::CoolingHottestMonth:
1075 //string = "None";
1076 ✗ break;
1077 ✗ case EpwDesignField::CoolingDryBulbRange:
1078 ✗ string = "C";
1079 ✗ break;
1080 ✗ case EpwDesignField::CoolingDryBulb0pt4:
1081 ✗ string = "C";
1082 ✗ break;
1083 ✗ case EpwDesignField::CoolingMeanCoincidentWetBulb0pt4:
1084 ✗ string = "C";
1085 ✗ break;
1086 ✗ case EpwDesignField::CoolingDryBulb1:
1087 ✗ string = "C";
1088 ✗ break;
1089 ✗ case EpwDesignField::CoolingMeanCoincidentWetBulb1:
1090 ✗ string = "C";
1091 ✗ break;
1092 ✗ case EpwDesignField::CoolingDryBulb2:
1093 ✗ string = "C";
1094 ✗ break;
1095 ✗ case EpwDesignField::CoolingMeanCoincidentWetBulb2:
1096 ✗ string = "C";
1097 ✗ break;
1098 ✗ case EpwDesignField::CoolingEvaporationWetBulb0pt4:
1099 ✗ string = "C";
1100 ✗ break;
1101 ✗ case EpwDesignField::CoolingEvaporationMeanCoincidentDryBulb0pt4:
1102 ✗ string = "C";
1103 ✗ break;
1104 ✗ case EpwDesignField::CoolingEvaporationWetBulb1:
1105 ✗ string = "C";
1106 ✗ break;
1107 ✗ case EpwDesignField::CoolingEvaporationMeanCoincidentDryBulb1:
1108 ✗ string = "C";
1109 ✗ break;
1110 ✗ case EpwDesignField::CoolingEvaporationWetBulb2:
1111 ✗ string = "C";
1112 ✗ break;
1113 ✗ case EpwDesignField::CoolingEvaporationMeanCoincidentDryBulb2:
1114 ✗ string = "C";
1115 ✗ break;
1116 ✗ case EpwDesignField::CoolingMeanCoincidentWindSpeed0pt4:
1117 ✗ string = "m/s";
1118 ✗ break;
1119 ✗ case EpwDesignField::CoolingPrevailingCoincidentWindDirection0pt4:
1120 ✗ string = "degrees";
1121 ✗ break;
1122 ✗ case EpwDesignField::CoolingDehumidificationDewPoint0pt4:
1123 ✗ string = "C";
1124 ✗ break;
1125 ✗ case EpwDesignField::CoolingDehumidificationHumidityRatio0pt4:
1126 ✗ string = "g/kg";
1127 ✗ break;
1128 ✗ case EpwDesignField::CoolingDehumidificationMeanCoincidentDryBulb0pt4:
1129 ✗ string = "C";
1130 ✗ break;
1131 ✗ case EpwDesignField::CoolingDehumidificationDewPoint1:
1132 ✗ string = "C";
1133 ✗ break;
1134 ✗ case EpwDesignField::CoolingDehumidificationHumidityRatio1:
1135 ✗ string = "g/kg";
1136 ✗ break;
1137 ✗ case EpwDesignField::CoolingDehumidificationMeanCoincidentDryBulb1:
1138 ✗ string = "C";
1139 ✗ break;
1140 ✗ case EpwDesignField::CoolingDehumidificationDewPoint2:
1141 ✗ string = "C";
1142 ✗ break;
1143 ✗ case EpwDesignField::CoolingDehumidificationHumidityRatio2:
1144 ✗ string = "g/kg";
1145 ✗ break;
1146 ✗ case EpwDesignField::CoolingDehumidificationMeanCoincidentDryBulb2:
1147 ✗ string = "C";
1148 ✗ break;
1149 ✗ case EpwDesignField::CoolingEnthalpy0pt4:
1150 ✗ string = "kJ/kg";
1151 ✗ break;
1152 ✗ case EpwDesignField::CoolingEnthalpyMeanCoincidentDryBulb0pt4:
1153 ✗ string = "C";
1154 ✗ break;
1155 ✗ case EpwDesignField::CoolingEnthalpy1:
1156 ✗ string = "kJ/kg";
1157 ✗ break;
1158 ✗ case EpwDesignField::CoolingEnthalpyMeanCoincidentDryBulb1:
1159 ✗ string = "C";
1160 ✗ break;
1161 ✗ case EpwDesignField::CoolingEnthalpy2:
1162 ✗ string = "kJ/kg";
1163 ✗ break;
1164 ✗ case EpwDesignField::CoolingEnthalpyMeanCoincidentDryBulb2:
1165 ✗ string = "C";
1166 ✗ break;
1167 ✗ case EpwDesignField::CoolingHours8To4AndDryBulb12pt8To20pt6:
1168 ✗ string = "hr";
1169 ✗ break;
1170 ✗ case EpwDesignField::CoolingExtremeMaxWetBulb:
1171 ✗ string = "C";
1172 ✗ break;
1173 ✗ case EpwDesignField::ExtremeWindSpeed1:
1174 ✗ string = "m/s";
1175 ✗ break;
1176 ✗ case EpwDesignField::ExtremeWindSpeed2pt5:
1177 ✗ string = "m/s";
1178 ✗ break;
1179 ✗ case EpwDesignField::ExtremeWindSpeed5:
1180 ✗ string = "m/s";
1181 ✗ break;
1182 ✗ case EpwDesignField::ExtremeMaxWetBulb:
1183 ✗ string = "C";
1184 ✗ break;
1185 ✗ case EpwDesignField::ExtremeMeanMinDryBulb:
1186 ✗ string = "C";
1187 ✗ break;
1188 ✗ case EpwDesignField::ExtremeMeanMaxDryBulb:
1189 ✗ string = "C";
1190 ✗ break;
1191 ✗ case EpwDesignField::ExtremeStdDevMinDryBulb:
1192 ✗ string = "C";
1193 ✗ break;
1194 ✗ case EpwDesignField::ExtremeStdDevMaxDryBulb:
1195 ✗ string = "C";
1196 ✗ break;
1197 ✗ case EpwDesignField::ExtremeN5YearsMinDryBulb:
1198 ✗ string = "C";
1199 ✗ break;
1200 ✗ case EpwDesignField::ExtremeN5YearsMaxDryBulb:
1201 ✗ string = "C";
1202 ✗ break;
1203 ✗ case EpwDesignField::ExtremeN10YearsMinDryBulb:
1204 ✗ string = "C";
1205 ✗ break;
1206 ✗ case EpwDesignField::ExtremeN10YearsMaxDryBulb:
1207 ✗ string = "C";
1208 ✗ break;
1209 ✗ case EpwDesignField::ExtremeN20YearsMinDryBulb:
1210 ✗ string = "C";
1211 ✗ break;
1212 ✗ case EpwDesignField::ExtremeN20YearsMaxDryBulb:
1213 ✗ string = "C";
1214 ✗ break;
1215 ✗ case EpwDesignField::ExtremeN50YearsMinDryBulb:
1216 ✗ string = "C";
1217 ✗ break;
1218 ✗ case EpwDesignField::ExtremeN50YearsMaxDryBulb:
1219 ✗ string = "C";
1220 ✗ break;
1221 ✗ default:
1222 //string = "None";
1223 ✗ break;
1224 }
1225 22 return string;
1226 ✗ }
1227
1228 ✗ std::string EpwDataPoint::getUnits(EpwComputedField field) {
1229 ✗ std::string string;
1230 ✗ switch (field.value()) {
1231 ✗ case EpwComputedField::SaturationPressure:
1232 ✗ string = "Pa";
1233 ✗ break;
1234 ✗ case EpwComputedField::Enthalpy:
1235 ✗ string = "kJ/kg";
1236 ✗ break;
1237 ✗ case EpwComputedField::HumidityRatio:
1238 ✗ break;
1239 ✗ case EpwComputedField::WetBulbTemperature:
1240 ✗ string = "C";
1241 ✗ break;
1242 ✗ default:
1243 ✗ break;
1244 }
1245 ✗ return string;
1246 ✗ }
1247
1248 11 boost::optional<double> EpwDataPoint::getFieldByName(const std::string& name) const {
1249
1/1
✓ Branch 1 taken 11 times.
11 EpwDataField id;
1250 try {
1251
1/1
✓ Branch 1 taken 11 times.
11 id = EpwDataField(name);
1252 ✗ } catch (...) {
1253 // Could do a warning message here
1254 ✗ return boost::none;
1255 ✗ }
1256
1/1
✓ Branch 1 taken 11 times.
11 return getField(id);
1257 }
1258
1259 80299 boost::optional<double> EpwDataPoint::getField(EpwDataField id) const {
1260 80299 boost::optional<int> ivalue;
1261
5/31
✓ Branch 1 taken 80299 times.
✓ Branch 3 taken 36481 times.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✓ Branch 18 taken 43800 times.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✓ Branch 30 taken 4 times.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
80299 switch (id.value()) {
1262 36481 case EpwDataField::DryBulbTemperature:
1263
1/1
✓ Branch 1 taken 36481 times.
36481 return dryBulbTemperature();
1264 break;
1265 14 case EpwDataField::DewPointTemperature:
1266
1/1
✓ Branch 1 taken 14 times.
14 return dewPointTemperature();
1267 break;
1268 ✗ case EpwDataField::RelativeHumidity:
1269 ✗ return relativeHumidity();
1270 break;
1271 ✗ case EpwDataField::AtmosphericStationPressure:
1272 ✗ return atmosphericStationPressure();
1273 break;
1274 ✗ case EpwDataField::ExtraterrestrialHorizontalRadiation:
1275 ✗ return extraterrestrialHorizontalRadiation();
1276 break;
1277 ✗ case EpwDataField::ExtraterrestrialDirectNormalRadiation:
1278 ✗ return extraterrestrialDirectNormalRadiation();
1279 break;
1280 ✗ case EpwDataField::HorizontalInfraredRadiationIntensity:
1281 ✗ return horizontalInfraredRadiationIntensity();
1282 break;
1283 ✗ case EpwDataField::GlobalHorizontalRadiation:
1284 ✗ return globalHorizontalRadiation();
1285 break;
1286 ✗ case EpwDataField::DirectNormalRadiation:
1287 ✗ return directNormalRadiation();
1288 break;
1289 ✗ case EpwDataField::DiffuseHorizontalRadiation:
1290 ✗ return diffuseHorizontalRadiation();
1291 break;
1292 ✗ case EpwDataField::GlobalHorizontalIlluminance:
1293 ✗ return globalHorizontalIlluminance();
1294 break;
1295 ✗ case EpwDataField::DirectNormalIlluminance:
1296 ✗ return directNormalIlluminance();
1297 break;
1298 ✗ case EpwDataField::DiffuseHorizontalIlluminance:
1299 ✗ return diffuseHorizontalIlluminance();
1300 break;
1301 ✗ case EpwDataField::ZenithLuminance:
1302 ✗ return zenithLuminance();
1303 break;
1304 ✗ case EpwDataField::WindDirection:
1305 ✗ return windDirection();
1306 break;
1307 43800 case EpwDataField::WindSpeed:
1308
1/1
✓ Branch 1 taken 43800 times.
43800 return windSpeed();
1309 break;
1310 ✗ case EpwDataField::TotalSkyCover:
1311 ✗ ivalue = totalSkyCover();
1312 ✗ if (ivalue) {
1313 ✗ return boost::optional<double>((double)ivalue.get());
1314 }
1315 ✗ break;
1316 ✗ case EpwDataField::OpaqueSkyCover:
1317 ✗ ivalue = opaqueSkyCover();
1318 ✗ if (ivalue) {
1319 ✗ return boost::optional<double>((double)ivalue.get());
1320 }
1321 ✗ break;
1322 ✗ case EpwDataField::Visibility:
1323 ✗ return visibility();
1324 break;
1325 ✗ case EpwDataField::CeilingHeight:
1326 ✗ return ceilingHeight();
1327 break;
1328 ✗ case EpwDataField::PresentWeatherObservation:
1329 ✗ ivalue = presentWeatherObservation();
1330 ✗ if (ivalue) {
1331 ✗ return boost::optional<double>((double)ivalue.get());
1332 }
1333 ✗ break;
1334 ✗ case EpwDataField::PresentWeatherCodes:
1335 ✗ ivalue = presentWeatherCodes();
1336 ✗ if (ivalue) {
1337 ✗ return boost::optional<double>((double)ivalue.get());
1338 }
1339 ✗ break;
1340 ✗ case EpwDataField::PrecipitableWater:
1341 ✗ return precipitableWater();
1342 break;
1343 ✗ case EpwDataField::AerosolOpticalDepth:
1344 ✗ return aerosolOpticalDepth();
1345 break;
1346 ✗ case EpwDataField::SnowDepth:
1347 ✗ return snowDepth();
1348 break;
1349 ✗ case EpwDataField::DaysSinceLastSnowfall:
1350 ✗ return daysSinceLastSnowfall();
1351 break;
1352 ✗ case EpwDataField::Albedo:
1353 ✗ return albedo();
1354 break;
1355 4 case EpwDataField::LiquidPrecipitationDepth:
1356
1/1
✓ Branch 1 taken 4 times.
4 return liquidPrecipitationDepth();
1357 break;
1358 ✗ case EpwDataField::LiquidPrecipitationQuantity:
1359 ✗ return liquidPrecipitationQuantity();
1360 break;
1361 ✗ default:
1362 // Could do a warning message here
1363 ✗ return boost::none;
1364 break;
1365 }
1366 ✗ return boost::none;
1367 }
1368
1369 11 boost::optional<double> EpwDesignCondition::getFieldByName(const std::string& name) const {
1370
1/1
✓ Branch 1 taken 11 times.
11 EpwDesignField id;
1371 try {
1372
1/1
✓ Branch 1 taken 11 times.
11 id = EpwDesignField(name);
1373 ✗ } catch (...) {
1374 // Could do a warning message here
1375 ✗ return boost::none;
1376 ✗ }
1377
1/1
✓ Branch 1 taken 11 times.
11 return getField(id);
1378 }
1379
1380 22 boost::optional<double> EpwDesignCondition::getField(EpwDesignField id) const {
1381 ✗ auto optionaIntToOptionalDouble = [](boost::optional<int> val_) -> boost::optional<double> {
1382 ✗ if (val_) {
1383 ✗ return *val_;
1384 }
1385 ✗ return boost::none;
1386 };
1387
1388
2/67
✓ Branch 1 taken 22 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 22 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✗ Branch 49 not taken.
✗ Branch 50 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 53 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
✗ Branch 56 not taken.
✗ Branch 57 not taken.
✗ Branch 58 not taken.
✗ Branch 59 not taken.
✗ Branch 60 not taken.
✗ Branch 61 not taken.
✗ Branch 62 not taken.
✗ Branch 63 not taken.
✗ Branch 64 not taken.
✗ Branch 65 not taken.
✗ Branch 66 not taken.
✗ Branch 67 not taken.
✗ Branch 68 not taken.
22 switch (id.value()) {
1389 ✗ case EpwDesignField::HeatingColdestMonth:
1390 ✗ return optionaIntToOptionalDouble(heatingColdestMonth());
1391 break;
1392 22 case EpwDesignField::HeatingDryBulb99pt6:
1393
1/1
✓ Branch 1 taken 22 times.
22 return heatingDryBulb99pt6();
1394 break;
1395 ✗ case EpwDesignField::HeatingDryBulb99:
1396 ✗ return heatingDryBulb99();
1397 break;
1398 ✗ case EpwDesignField::HeatingHumidificationDewPoint99pt6:
1399 ✗ return heatingHumidificationDewPoint99pt6();
1400 break;
1401 ✗ case EpwDesignField::HeatingHumidificationHumidityRatio99pt6:
1402 ✗ return heatingHumidificationHumidityRatio99pt6();
1403 break;
1404 ✗ case EpwDesignField::HeatingHumidificationMeanCoincidentDryBulb99pt6:
1405 ✗ return heatingHumidificationMeanCoincidentDryBulb99pt6();
1406 break;
1407 ✗ case EpwDesignField::HeatingHumidificationDewPoint99:
1408 ✗ return heatingHumidificationDewPoint99();
1409 break;
1410 ✗ case EpwDesignField::HeatingHumidificationHumidityRatio99:
1411 ✗ return heatingHumidificationHumidityRatio99();
1412 break;
1413 ✗ case EpwDesignField::HeatingHumidificationMeanCoincidentDryBulb99:
1414 ✗ return heatingHumidificationMeanCoincidentDryBulb99();
1415 break;
1416 ✗ case EpwDesignField::HeatingColdestMonthWindSpeed0pt4:
1417 ✗ return heatingColdestMonthWindSpeed0pt4();
1418 break;
1419 ✗ case EpwDesignField::HeatingColdestMonthMeanCoincidentDryBulb0pt4:
1420 ✗ return heatingColdestMonthMeanCoincidentDryBulb0pt4();
1421 break;
1422 ✗ case EpwDesignField::HeatingColdestMonthWindSpeed1:
1423 ✗ return heatingColdestMonthWindSpeed1();
1424 break;
1425 ✗ case EpwDesignField::HeatingColdestMonthMeanCoincidentDryBulb1:
1426 ✗ return heatingColdestMonthMeanCoincidentDryBulb1();
1427 break;
1428 ✗ case EpwDesignField::HeatingMeanCoincidentWindSpeed99pt6:
1429 ✗ return heatingMeanCoincidentWindSpeed99pt6();
1430 break;
1431 ✗ case EpwDesignField::HeatingPrevailingCoincidentWindDirection99pt6:
1432 ✗ return optionaIntToOptionalDouble(heatingPrevailingCoincidentWindDirection99pt6());
1433 break;
1434 ✗ case EpwDesignField::HeatingWindShelterFactor:
1435 ✗ return heatingWindShelterFactor();
1436 break;
1437 ✗ case EpwDesignField::CoolingHottestMonth:
1438 ✗ return optionaIntToOptionalDouble(coolingHottestMonth());
1439 break;
1440 ✗ case EpwDesignField::CoolingDryBulbRange:
1441 ✗ return coolingDryBulbRange();
1442 break;
1443 ✗ case EpwDesignField::CoolingDryBulb0pt4:
1444 ✗ return coolingDryBulb0pt4();
1445 break;
1446 ✗ case EpwDesignField::CoolingMeanCoincidentWetBulb0pt4:
1447 ✗ return coolingMeanCoincidentWetBulb0pt4();
1448 break;
1449 ✗ case EpwDesignField::CoolingDryBulb1:
1450 ✗ return coolingDryBulb1();
1451 break;
1452 ✗ case EpwDesignField::CoolingMeanCoincidentWetBulb1:
1453 ✗ return coolingMeanCoincidentWetBulb1();
1454 break;
1455 ✗ case EpwDesignField::CoolingDryBulb2:
1456 ✗ return coolingDryBulb2();
1457 break;
1458 ✗ case EpwDesignField::CoolingMeanCoincidentWetBulb2:
1459 ✗ return coolingMeanCoincidentWetBulb2();
1460 break;
1461 ✗ case EpwDesignField::CoolingEvaporationWetBulb0pt4:
1462 ✗ return coolingEvaporationWetBulb0pt4();
1463 break;
1464 ✗ case EpwDesignField::CoolingEvaporationMeanCoincidentDryBulb0pt4:
1465 ✗ return coolingEvaporationMeanCoincidentDryBulb0pt4();
1466 break;
1467 ✗ case EpwDesignField::CoolingEvaporationWetBulb1:
1468 ✗ return coolingEvaporationWetBulb1();
1469 break;
1470 ✗ case EpwDesignField::CoolingEvaporationMeanCoincidentDryBulb1:
1471 ✗ return coolingEvaporationMeanCoincidentDryBulb1();
1472 break;
1473 ✗ case EpwDesignField::CoolingEvaporationWetBulb2:
1474 ✗ return coolingEvaporationWetBulb2();
1475 break;
1476 ✗ case EpwDesignField::CoolingEvaporationMeanCoincidentDryBulb2:
1477 ✗ return coolingEvaporationMeanCoincidentDryBulb2();
1478 break;
1479 ✗ case EpwDesignField::CoolingMeanCoincidentWindSpeed0pt4:
1480 ✗ return coolingMeanCoincidentWindSpeed0pt4();
1481 break;
1482 ✗ case EpwDesignField::CoolingPrevailingCoincidentWindDirection0pt4:
1483 ✗ return optionaIntToOptionalDouble(coolingPrevailingCoincidentWindDirection0pt4());
1484 break;
1485 ✗ case EpwDesignField::CoolingDehumidificationDewPoint0pt4:
1486 ✗ return coolingDehumidificationDewPoint0pt4();
1487 break;
1488 ✗ case EpwDesignField::CoolingDehumidificationHumidityRatio0pt4:
1489 ✗ return coolingDehumidificationHumidityRatio0pt4();
1490 break;
1491 ✗ case EpwDesignField::CoolingDehumidificationMeanCoincidentDryBulb0pt4:
1492 ✗ return coolingDehumidificationMeanCoincidentDryBulb0pt4();
1493 break;
1494 ✗ case EpwDesignField::CoolingDehumidificationDewPoint1:
1495 ✗ return coolingDehumidificationDewPoint1();
1496 break;
1497 ✗ case EpwDesignField::CoolingDehumidificationHumidityRatio1:
1498 ✗ return coolingDehumidificationHumidityRatio1();
1499 break;
1500 ✗ case EpwDesignField::CoolingDehumidificationMeanCoincidentDryBulb1:
1501 ✗ return coolingDehumidificationMeanCoincidentDryBulb1();
1502 break;
1503 ✗ case EpwDesignField::CoolingDehumidificationDewPoint2:
1504 ✗ return coolingDehumidificationDewPoint2();
1505 break;
1506 ✗ case EpwDesignField::CoolingDehumidificationHumidityRatio2:
1507 ✗ return coolingDehumidificationHumidityRatio2();
1508 break;
1509 ✗ case EpwDesignField::CoolingDehumidificationMeanCoincidentDryBulb2:
1510 ✗ return coolingDehumidificationMeanCoincidentDryBulb2();
1511 break;
1512 ✗ case EpwDesignField::CoolingEnthalpy0pt4:
1513 ✗ return coolingEnthalpy0pt4();
1514 break;
1515 ✗ case EpwDesignField::CoolingEnthalpyMeanCoincidentDryBulb0pt4:
1516 ✗ return coolingEnthalpyMeanCoincidentDryBulb0pt4();
1517 break;
1518 ✗ case EpwDesignField::CoolingEnthalpy1:
1519 ✗ return coolingEnthalpy1();
1520 break;
1521 ✗ case EpwDesignField::CoolingEnthalpyMeanCoincidentDryBulb1:
1522 ✗ return coolingEnthalpyMeanCoincidentDryBulb1();
1523 break;
1524 ✗ case EpwDesignField::CoolingEnthalpy2:
1525 ✗ return coolingEnthalpy2();
1526 break;
1527 ✗ case EpwDesignField::CoolingEnthalpyMeanCoincidentDryBulb2:
1528 ✗ return coolingEnthalpyMeanCoincidentDryBulb2();
1529 break;
1530 ✗ case EpwDesignField::CoolingHours8To4AndDryBulb12pt8To20pt6:
1531 ✗ return optionaIntToOptionalDouble(coolingHours8To4AndDryBulb12pt8To20pt6());
1532 break;
1533 ✗ case EpwDesignField::CoolingExtremeMaxWetBulb:
1534 ✗ return coolingExtremeMaxWetBulb();
1535 break;
1536 ✗ case EpwDesignField::ExtremeWindSpeed1:
1537 ✗ return extremeWindSpeed1();
1538 break;
1539 ✗ case EpwDesignField::ExtremeWindSpeed2pt5:
1540 ✗ return extremeWindSpeed2pt5();
1541 break;
1542 ✗ case EpwDesignField::ExtremeWindSpeed5:
1543 ✗ return extremeWindSpeed5();
1544 break;
1545 ✗ case EpwDesignField::ExtremeMaxWetBulb:
1546 ✗ return extremeMaxWetBulb();
1547 break;
1548 ✗ case EpwDesignField::ExtremeMeanMinDryBulb:
1549 ✗ return extremeMeanMinDryBulb();
1550 break;
1551 ✗ case EpwDesignField::ExtremeMeanMaxDryBulb:
1552 ✗ return extremeMeanMaxDryBulb();
1553 break;
1554 ✗ case EpwDesignField::ExtremeStdDevMinDryBulb:
1555 ✗ return extremeStdDevMinDryBulb();
1556 break;
1557 ✗ case EpwDesignField::ExtremeStdDevMaxDryBulb:
1558 ✗ return extremeStdDevMaxDryBulb();
1559 break;
1560 ✗ case EpwDesignField::ExtremeN5YearsMinDryBulb:
1561 ✗ return extremeN5YearsMinDryBulb();
1562 break;
1563 ✗ case EpwDesignField::ExtremeN5YearsMaxDryBulb:
1564 ✗ return extremeN5YearsMaxDryBulb();
1565 break;
1566 ✗ case EpwDesignField::ExtremeN10YearsMinDryBulb:
1567 ✗ return extremeN10YearsMinDryBulb();
1568 break;
1569 ✗ case EpwDesignField::ExtremeN10YearsMaxDryBulb:
1570 ✗ return extremeN10YearsMaxDryBulb();
1571 break;
1572 ✗ case EpwDesignField::ExtremeN20YearsMinDryBulb:
1573 ✗ return extremeN20YearsMinDryBulb();
1574 break;
1575 ✗ case EpwDesignField::ExtremeN20YearsMaxDryBulb:
1576 ✗ return extremeN20YearsMaxDryBulb();
1577 break;
1578 ✗ case EpwDesignField::ExtremeN50YearsMinDryBulb:
1579 ✗ return extremeN50YearsMinDryBulb();
1580 break;
1581 ✗ case EpwDesignField::ExtremeN50YearsMaxDryBulb:
1582 ✗ return extremeN50YearsMaxDryBulb();
1583 break;
1584 ✗ default:
1585 // Could do a warning message here
1586 ✗ return boost::none;
1587 break;
1588 }
1589 return boost::none;
1590 }
1591
1592 ✗ boost::optional<std::string> EpwDataPoint::toWthString() const {
1593 ✗ std::string date = fmt::format("{}/{}", m_month, m_day);
1594 ✗ std::string string = date;
1595 ✗ std::string hms = fmt::format("{:02d}:{:02d}:00", m_hour, m_minute);
1596 ✗ string += '\t' + hms;
1597 ✗ boost::optional<double> value = dryBulbTemperature();
1598 ✗ if (!value) {
1599 ✗ LOG_FREE(Error, "openstudio.EpwFile", "Missing dry bulb temperature on " << date << " at " << hms)
1600 ✗ return boost::none;
1601 }
1602 //boost::optional<double> optdrybulb = openstudio::convert(value.get(), "C", "K");
1603 //OS_ASSERT(optdrybulb);
1604 ✗ double drybulb = value.get();
1605 ✗ string += '\t' + std::to_string(drybulb + 273.15);
1606 ✗ value = atmosphericStationPressure();
1607 ✗ if (!value) {
1608 ✗ LOG_FREE(Error, "openstudio.EpwFile", "Missing atmospheric station pressure on " << date << " at " << hms);
1609 ✗ return boost::none;
1610 }
1611 ✗ double p = value.get();
1612 ✗ string += '\t' + m_atmosphericStationPressure;
1613 ✗ if (!windSpeed()) {
1614 ✗ LOG_FREE(Error, "openstudio.EpwFile", "Missing wind speed on " << date << " at " << hms);
1615 ✗ return boost::none;
1616 }
1617 ✗ string += '\t' + m_windSpeed;
1618 ✗ if (!windDirection()) {
1619 ✗ LOG_FREE(Error, "openstudio.EpwFile", "Missing wind direction on " << date << " at " << hms);
1620 ✗ return boost::none;
1621 }
1622 ✗ string += '\t' + m_windDirection;
1623 double pw;
1624 ✗ value = relativeHumidity();
1625 ✗ if (!value) { // Don't have relative humidity - this has not been tested
1626 ✗ value = dewPointTemperature();
1627 ✗ if (!value) {
1628 ✗ LOG_FREE(Error, "openstudio.EpwFile", "Cannot compute humidity ratio on " << date << " at " << hms);
1629 ✗ return boost::none;
1630 }
1631 //boost::optional<double> optdewpoint = openstudio::convert(value.get(), "C", "K");
1632 //OS_ASSERT(optdewpoint);
1633 ✗ double dewpoint = value.get();
1634 ✗ pw = openstudio::psat(dewpoint);
1635 } else { // Have relative humidity
1636 ✗ double pws = openstudio::psat(drybulb);
1637 ✗ pw = 0.01 * value.get() * pws;
1638 }
1639 ✗ double W = 0.621945 * pw / (p - pw);
1640 ✗ string += "\t" + std::to_string(W * 1000); // need g/kg
1641 // Pass on solar flux quantities
1642 ✗ string += "\t0\t0";
1643 // Pass on Tsky
1644 ✗ string += "\t0";
1645 // Pass on snow and rain
1646 ✗ string += "\t0\t0";
1647 ✗ return boost::optional<std::string>(string);
1648 ✗ }
1649
1650 // Local convenience functions
1651 561208 static int stringToInteger(const std::string& string, bool* ok) {
1652 561208 int value = 0;
1653 561208 *ok = true;
1654 try {
1655
1/1
✓ Branch 1 taken 561203 times.
561208 value = std::stoi(string);
1656
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 } catch (const std::invalid_argument&) {
1657 5 *ok = false;
1658 5 } catch (const std::out_of_range&) {
1659 ✗ *ok = false;
1660 ✗ }
1661 561208 return value;
1662 }
1663
1664 3511654 static double stringToDouble(const std::string& string, bool* ok) {
1665 3511654 double value = 0;
1666 3511654 *ok = true;
1667 try {
1668
1/1
✓ Branch 1 taken 3511126 times.
3511654 value = std::stod(string);
1669
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 528 times.
✗ Branch 2 not taken.
528 } catch (const std::invalid_argument&) {
1670 528 *ok = false;
1671 528 } catch (const std::out_of_range&) {
1672 ✗ *ok = false;
1673 ✗ }
1674 3511654 return value;
1675 }
1676
1677 106566 Date EpwDataPoint::date() const {
1678
2/2
✓ Branch 1 taken 106566 times.
✓ Branch 4 taken 106566 times.
106566 return {MonthOfYear(m_month), static_cast<unsigned int>(m_day), m_year};
1679 }
1680
1681 ✗ void EpwDataPoint::setDate(Date date) {
1682 ✗ m_month = openstudio::month(date.monthOfYear());
1683 ✗ m_day = date.dayOfMonth();
1684 ✗ m_year = date.year();
1685 ✗ }
1686
1687 106564 Time EpwDataPoint::time() const {
1688 106564 return {0, m_hour, m_minute};
1689 }
1690
1691 ✗ void EpwDataPoint::setTime(Time time) {
1692 ✗ m_hour = time.hours();
1693 ✗ m_minute = time.minutes();
1694 ✗ }
1695
1696 106564 DateTime EpwDataPoint::dateTime() const {
1697
3/3
✓ Branch 1 taken 106564 times.
✓ Branch 4 taken 106564 times.
✓ Branch 7 taken 106564 times.
106564 return DateTime(date(), time());
1698 }
1699
1700 ✗ void EpwDataPoint::setDateTime(DateTime dateTime) {
1701 ✗ setDate(dateTime.date());
1702 ✗ setTime(dateTime.time());
1703 ✗ }
1704
1705 ✗ int EpwDataPoint::year() const {
1706 ✗ return m_year;
1707 }
1708
1709 140232 void EpwDataPoint::setYear(int year) {
1710 140232 m_year = year;
1711 140232 }
1712
1713 ✗ bool EpwDataPoint::setYear(const std::string& year) {
1714 bool ok;
1715 ✗ int value = stringToInteger(year, &ok);
1716 ✗ if (!ok) {
1717 ✗ return false;
1718 }
1719 ✗ m_year = value;
1720 ✗ return true;
1721 }
1722
1723 ✗ int EpwDataPoint::month() const {
1724 ✗ return m_month;
1725 }
1726
1727 140232 bool EpwDataPoint::setMonth(int month) {
1728
2/4
✓ Branch 0 taken 140232 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 140232 times.
140232 if (1 > month || 12 < month) {
1729 ✗ LOG_FREE(Error, "openstudio.EpwFile", "Month value " << month << " out of range");
1730 ✗ return false;
1731 }
1732 140232 m_month = month;
1733 140232 return true;
1734 }
1735
1736 ✗ bool EpwDataPoint::setMonth(const std::string& month) {
1737 bool ok;
1738 ✗ int value = stringToInteger(month, &ok);
1739 ✗ if (!ok) {
1740 ✗ LOG_FREE(Error, "openstudio.EpwFile", "Month value '" << month << "' cannot be converted into an integer");
1741 ✗ return false;
1742 }
1743 ✗ return setMonth(value);
1744 }
1745
1746 ✗ int EpwDataPoint::day() const {
1747 ✗ return m_day;
1748 }
1749
1750 140232 bool EpwDataPoint::setDay(int day) {
1751
2/4
✓ Branch 0 taken 140232 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 140232 times.
140232 if (1 > day || 31 < day) {
1752 ✗ LOG_FREE(Error, "openstudio.EpwFile", "Day value " << day << " out of range");
1753 ✗ return false;
1754 }
1755 140232 m_day = day;
1756 140232 return true;
1757 }
1758
1759 ✗ bool EpwDataPoint::setDay(const std::string& day) {
1760 bool ok;
1761 ✗ int value = stringToInteger(day, &ok);
1762 ✗ if (!ok) {
1763 ✗ LOG_FREE(Error, "openstudio.EpwFile", "Day value '" << day << "' cannot be converted into an integer");
1764 ✗ return false;
1765 }
1766 ✗ return setDay(value);
1767 }
1768
1769 ✗ int EpwDataPoint::hour() const {
1770 ✗ return m_hour;
1771 }
1772
1773 140232 bool EpwDataPoint::setHour(int hour) {
1774
2/4
✓ Branch 0 taken 140232 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 140232 times.
140232 if (1 > hour || 24 < hour) {
1775 ✗ LOG_FREE(Error, "openstudio.EpwFile", "Hour value " << hour << " out of range");
1776 ✗ return false;
1777 }
1778 140232 m_hour = hour;
1779 140232 return true;
1780 }
1781
1782 ✗ bool EpwDataPoint::setHour(const std::string& hour) {
1783 bool ok;
1784 ✗ int value = stringToInteger(hour, &ok);
1785 ✗ if (!ok) {
1786 ✗ LOG_FREE(Error, "openstudio.EpwFile", "Hour value '" << hour << "' cannot be converted into an integer");
1787 ✗ return false;
1788 }
1789 ✗ return setHour(value);
1790 }
1791
1792 ✗ int EpwDataPoint::minute() const {
1793 ✗ return m_minute;
1794 }
1795
1796 140232 bool EpwDataPoint::setMinute(int minute) {
1797
2/4
✓ Branch 0 taken 140232 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 140232 times.
140232 if (0 > minute || 59 < minute) {
1798 ✗ LOG_FREE(Error, "openstudio.EpwFile", "Minute value " << minute << " out of range");
1799 ✗ return false;
1800 }
1801 140232 m_minute = minute;
1802 140232 return true;
1803 }
1804
1805 ✗ bool EpwDataPoint::setMinute(const std::string& minute) {
1806 bool ok;
1807 ✗ int value = stringToInteger(minute, &ok);
1808 ✗ if (!ok) {
1809 ✗ LOG_FREE(Error, "openstudio.EpwFile", "Minute value '" << minute << "' cannot be converted into an integer");
1810 ✗ return false;
1811 }
1812 ✗ return setMinute(value);
1813 }
1814
1815 ✗ std::string EpwDataPoint::dataSourceandUncertaintyFlags() const {
1816 ✗ return m_dataSourceandUncertaintyFlags;
1817 }
1818
1819 140232 void EpwDataPoint::setDataSourceandUncertaintyFlags(const std::string& dataSourceandUncertaintyFlags) {
1820 140232 m_dataSourceandUncertaintyFlags = dataSourceandUncertaintyFlags;
1821 140232 }
1822
1823 36488 boost::optional<double> EpwDataPoint::dryBulbTemperature() const {
1824
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 36488 times.
36488 if (m_dryBulbTemperature == "99.9") {
1825 ✗ return boost::none;
1826 }
1827
2/2
✓ Branch 1 taken 36488 times.
✓ Branch 4 taken 36488 times.
36488 return boost::optional<double>(std::stod(m_dryBulbTemperature));
1828 }
1829
1830 ✗ bool EpwDataPoint::setDryBulbTemperature(double value) {
1831 ✗ if (-70 >= value || 70 <= value) {
1832 ✗ LOG_FREE(Warn, "openstudio.EpwFile", "DryBulbTemperature value '" << value << "' not within the expected limits");
1833 }
1834 ✗ m_dryBulbTemperature = std::to_string(value);
1835 ✗ return true;
1836 }
1837
1838 140232 bool EpwDataPoint::setDryBulbTemperature(const std::string& dryBulbTemperature) {
1839 bool ok;
1840
1/1
✓ Branch 1 taken 140232 times.
140232 double value = stringToDouble(dryBulbTemperature, &ok);
1841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140232 times.
140232 if (!ok) {
1842 ✗ m_dryBulbTemperature = "99.9";
1843 ✗ return false;
1844
2/4
✓ Branch 0 taken 140232 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 140232 times.
140232 } else if (-70 >= value || 70 <= value) {
1845 ✗ LOG_FREE(Warn, "openstudio.EpwFile", "DryBulbTemperature value '" << value << "' not within the expected limits");
1846 }
1847
1/1
✓ Branch 1 taken 140232 times.
140232 m_dryBulbTemperature = dryBulbTemperature;
1848 140232 return true;
1849 }
1850
1851 14 boost::optional<double> EpwDataPoint::dewPointTemperature() const {
1852
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
14 if (m_dewPointTemperature == "99.9") {
1853 ✗ return boost::none;
1854 }
1855
2/2
✓ Branch 1 taken 14 times.
✓ Branch 4 taken 14 times.
14 return boost::optional<double>(std::stod(m_dewPointTemperature));
1856 }
1857
1858 ✗ bool EpwDataPoint::setDewPointTemperature(double value) {
1859 ✗ if (-70 >= value || 70 <= value) {
1860 ✗ LOG_FREE(Warn, "openstudio.EpwFile", "DewPointTemperature value '" << value << "' not within the expected limits");
1861 }
1862 ✗ m_dewPointTemperature = std::to_string(value);
1863 ✗ return true;
1864 }
1865
1866 140232 bool EpwDataPoint::setDewPointTemperature(const std::string& dewPointTemperature) {
1867 bool ok;
1868
1/1
✓ Branch 1 taken 140232 times.
140232 double value = stringToDouble(dewPointTemperature, &ok);
1869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140232 times.
140232 if (!ok) {
1870 ✗ m_dewPointTemperature = "99.9";
1871 ✗ return false;
1872
2/4
✓ Branch 0 taken 140232 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 140232 times.
140232 } else if (-70 >= value || 70 <= value) {
1873 ✗ LOG_FREE(Warn, "openstudio.EpwFile", "DewPointTemperature value '" << value << "' not within the expected limits");
1874 }
1875
1/1
✓ Branch 1 taken 140232 times.
140232 m_dewPointTemperature = dewPointTemperature;
1876 140232 return true;
1877 }
1878
1879 ✗ boost::optional<double> EpwDataPoint::relativeHumidity() const {
1880 ✗ if (m_relativeHumidity == "999") {
1881 ✗ return boost::none;
1882 }
1883 ✗ return boost::optional<double>(std::stod(m_relativeHumidity));
1884 }
1885
1886 ✗ bool EpwDataPoint::setRelativeHumidity(double value) {
1887 ✗ if (0 > value) {
1888 ✗ m_relativeHumidity = "999";
1889 ✗ return false;
1890 ✗ } else if (110 < value) {
1891 ✗ LOG_FREE(Warn, "openstudio.EpwFile", "RelativeHumidity value '" << value << "' not within the expected limits");
1892 }
1893 ✗ m_relativeHumidity = std::to_string(value);
1894 ✗ return true;
1895 }
1896
1897 140232 bool EpwDataPoint::setRelativeHumidity(const std::string& relativeHumidity) {
1898 bool ok;
1899
1/1
✓ Branch 1 taken 140232 times.
140232 double value = stringToDouble(relativeHumidity, &ok);
1900
2/4
✓ Branch 0 taken 140232 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 140232 times.
140232 if (!ok || 0 > value) {
1901 ✗ m_relativeHumidity = "999";
1902 ✗ return false;
1903
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140232 times.
140232 } else if (110 < value) {
1904 ✗ LOG_FREE(Warn, "openstudio.EpwFile", "RelativeHumidity value '" << value << "' not within the expected limits");
1905 }
1906
1/1
✓ Branch 1 taken 140232 times.
140232 m_relativeHumidity = relativeHumidity;
1907 140232 return true;
1908 }
1909
1910 7 boost::optional<double> EpwDataPoint::atmosphericStationPressure() const {
1911
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
7 if (m_atmosphericStationPressure == "999999") {
1912 ✗ return boost::none;
1913 }
1914
2/2
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
7 return boost::optional<double>(std::stod(m_atmosphericStationPressure));
1915 }
1916
1917 ✗ bool EpwDataPoint::setAtmosphericStationPressure(double value) {
1918 ✗ if (31000 >= value || 120000 <= value) {
1919 ✗ LOG_FREE(Warn, "openstudio.EpwFile", "AtmosphericStationPressure value '" << value << "' not within the expected limits");
1920 }
1921 ✗ m_atmosphericStationPressure = std::to_string(value);
1922 ✗ return true;
1923 }
1924
1925 140232 bool EpwDataPoint::setAtmosphericStationPressure(const std::string& atmosphericStationPressure) {
1926 bool ok;
1927
1/1
✓ Branch 1 taken 140232 times.
140232 double value = stringToDouble(atmosphericStationPressure, &ok);
1928
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140232 times.
140232 if (!ok) {
1929 ✗ m_atmosphericStationPressure = "999999";
1930 ✗ return false;
1931
2/4
✓ Branch 0 taken 140232 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 140232 times.
140232 } else if (31000 >= value || 120000 <= value) {
1932 ✗ LOG_FREE(Warn, "openstudio.EpwFile", "AtmosphericStationPressure value '" << value << "' not within the expected limits");
1933 }
1934
1/1
✓ Branch 1 taken 140232 times.
140232 m_atmosphericStationPressure = atmosphericStationPressure;
1935 140232 return true;
1936 }
1937
1938 ✗ boost::optional<double> EpwDataPoint::extraterrestrialHorizontalRadiation() const {
1939 ✗ if (m_extraterrestrialHorizontalRadiation == "9999") {
1940 ✗ return boost::none;
1941 }
1942 ✗ return boost::optional<double>(std::stod(m_extraterrestrialHorizontalRadiation));
1943 }
1944
1945 ✗ bool EpwDataPoint::setExtraterrestrialHorizontalRadiation(double value) {
1946 ✗ if (0 > value || value == 9999) {
1947 ✗ m_extraterrestrialHorizontalRadiation = "9999";
1948 ✗ return false;
1949 }
1950 ✗ m_extraterrestrialHorizontalRadiation = std::to_string(value);
1951 ✗ return true;
1952 }
1953
1954 140232 bool EpwDataPoint::setExtraterrestrialHorizontalRadiation(const std::string& extraterrestrialHorizontalRadiation) {
1955 bool ok;
1956
1/1
✓ Branch 1 taken 140232 times.
140232 double value = stringToDouble(extraterrestrialHorizontalRadiation, &ok);
1957
4/6
✓ Branch 0 taken 140232 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 140232 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 35088 times.
✓ Branch 5 taken 105144 times.
140232 if (!ok || 0 > value || value == 9999) {
1958
1/1
✓ Branch 1 taken 35088 times.
35088 m_extraterrestrialHorizontalRadiation = "9999";
1959 35088 return false;
1960 }
1961
1/1
✓ Branch 1 taken 105144 times.
105144 m_extraterrestrialHorizontalRadiation = extraterrestrialHorizontalRadiation;
1962 105144 return true;
1963 }
1964
1965 ✗ boost::optional<double> EpwDataPoint::extraterrestrialDirectNormalRadiation() const {
1966 ✗ if (m_extraterrestrialDirectNormalRadiation == "9999") {
1967 ✗ return boost::none;
1968 }
1969 ✗ return boost::optional<double>(std::stod(m_extraterrestrialDirectNormalRadiation));
1970 }
1971
1972 ✗ bool EpwDataPoint::setExtraterrestrialDirectNormalRadiation(double value) {
1973 ✗ if (0 > value || value == 9999) {
1974 ✗ m_extraterrestrialDirectNormalRadiation = "9999";
1975 ✗ return false;
1976 }
1977 ✗ m_extraterrestrialDirectNormalRadiation = std::to_string(value);
1978 ✗ return true;
1979 }
1980
1981 140232 bool EpwDataPoint::setExtraterrestrialDirectNormalRadiation(const std::string& extraterrestrialDirectNormalRadiation) {
1982 bool ok;
1983
1/1
✓ Branch 1 taken 140232 times.
140232 double value = stringToDouble(extraterrestrialDirectNormalRadiation, &ok);
1984
4/6
✓ Branch 0 taken 140232 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 140232 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 35088 times.
✓ Branch 5 taken 105144 times.
140232 if (!ok || 0 > value || value == 9999) {
1985
1/1
✓ Branch 1 taken 35088 times.
35088 m_extraterrestrialDirectNormalRadiation = "9999";
1986 35088 return false;
1987 }
1988
1/1
✓ Branch 1 taken 105144 times.
105144 m_extraterrestrialDirectNormalRadiation = extraterrestrialDirectNormalRadiation;
1989 105144 return true;
1990 }
1991
1992 ✗ boost::optional<double> EpwDataPoint::horizontalInfraredRadiationIntensity() const {
1993 ✗ if (m_horizontalInfraredRadiationIntensity == "9999") {
1994 ✗ return boost::none;
1995 }
1996 ✗ return boost::optional<double>(std::stod(m_horizontalInfraredRadiationIntensity));
1997 }
1998
1999 ✗ bool EpwDataPoint::setHorizontalInfraredRadiationIntensity(double value) {
2000 ✗ if (0 > value || value == 9999) {
2001 ✗ m_horizontalInfraredRadiationIntensity = "9999";
2002 ✗ return false;
2003 }
2004 ✗ m_horizontalInfraredRadiationIntensity = std::to_string(value);
2005 ✗ return true;
2006 }
2007
2008 140232 bool EpwDataPoint::setHorizontalInfraredRadiationIntensity(const std::string& horizontalInfraredRadiationIntensity) {
2009 bool ok;
2010
1/1
✓ Branch 1 taken 140232 times.
140232 double value = stringToDouble(horizontalInfraredRadiationIntensity, &ok);
2011
4/6
✓ Branch 0 taken 140232 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 140232 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26328 times.
✓ Branch 5 taken 113904 times.
140232 if (!ok || 0 > value || value == 9999) {
2012
1/1
✓ Branch 1 taken 26328 times.
26328 m_horizontalInfraredRadiationIntensity = "9999";
2013 26328 return false;
2014 }
2015
1/1
✓ Branch 1 taken 113904 times.
113904 m_horizontalInfraredRadiationIntensity = horizontalInfraredRadiationIntensity;
2016 113904 return true;
2017 }
2018
2019 ✗ boost::optional<double> EpwDataPoint::globalHorizontalRadiation() const {
2020 ✗ if (m_globalHorizontalRadiation == "9999") {
2021 ✗ return boost::none;
2022 }
2023 ✗ return boost::optional<double>(std::stod(m_globalHorizontalRadiation));
2024 }
2025
2026 140232 bool EpwDataPoint::setGlobalHorizontalRadiation(double value) {
2027
2/4
✓ Branch 0 taken 140232 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 140232 times.
140232 if (0 > value || value == 9999) {
2028 ✗ m_globalHorizontalRadiation = "9999";
2029 ✗ return false;
2030 }
2031
1/1
✓ Branch 1 taken 140232 times.
140232 m_globalHorizontalRadiation = std::to_string(value);
2032 140232 return true;
2033 }
2034
2035 140232 bool EpwDataPoint::setGlobalHorizontalRadiation(const std::string& globalHorizontalRadiation) {
2036 bool ok;
2037
1/1
✓ Branch 1 taken 140232 times.
140232 double value = stringToDouble(globalHorizontalRadiation, &ok);
2038
3/6
✓ Branch 0 taken 140232 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 140232 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 140232 times.
140232 if (!ok || 0 > value || value == 9999) {
2039 ✗ m_globalHorizontalRadiation = "9999";
2040 ✗ return false;
2041 }
2042
1/1
✓ Branch 1 taken 140232 times.
140232 return setGlobalHorizontalRadiation(value);
2043 }
2044
2045 ✗ boost::optional<double> EpwDataPoint::directNormalRadiation() const {
2046 ✗ if (m_directNormalRadiation == "9999") {
2047 ✗ return boost::none;
2048 }
2049 ✗ return boost::optional<double>(std::stod(m_directNormalRadiation));
2050 }
2051
2052 ✗ bool EpwDataPoint::setDirectNormalRadiation(double value) {
2053 ✗ if (0 > value || value == 9999) {
2054 ✗ m_directNormalRadiation = "9999";
2055 ✗ return false;
2056 }
2057 ✗ m_directNormalRadiation = std::to_string(value);
2058 ✗ return true;
2059 }
2060
2061 140232 bool EpwDataPoint::setDirectNormalRadiation(const std::string& directNormalRadiation) {
2062 bool ok;
2063
1/1
✓ Branch 1 taken 140232 times.
140232 double value = stringToDouble(directNormalRadiation, &ok);
2064
3/6
✓ Branch 0 taken 140232 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 140232 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 140232 times.
140232 if (!ok || 0 > value || value == 9999) {
2065 ✗ m_directNormalRadiation = "9999";
2066 ✗ return false;
2067 }
2068
1/1
✓ Branch 1 taken 140232 times.
140232 m_directNormalRadiation = directNormalRadiation;
2069 140232 return true;
2070 }
2071
2072 ✗ boost::optional<double> EpwDataPoint::diffuseHorizontalRadiation() const {
2073 ✗ if (m_diffuseHorizontalRadiation == "9999") {
2074 ✗ return boost::none;
2075 }
2076 ✗ return boost::optional<double>(std::stod(m_diffuseHorizontalRadiation));
2077 }
2078
2079 ✗ bool EpwDataPoint::setDiffuseHorizontalRadiation(double value) {
2080 ✗ if (0 > value || value == 9999) {
2081 ✗ m_diffuseHorizontalRadiation = "9999";
2082 ✗ return false;
2083 }
2084 ✗ m_diffuseHorizontalRadiation = std::to_string(value);
2085 ✗ return true;
2086 }
2087
2088 140232 bool EpwDataPoint::setDiffuseHorizontalRadiation(const std::string& diffuseHorizontalRadiation) {
2089 bool ok;
2090
1/1
✓ Branch 1 taken 140232 times.
140232 double value = stringToDouble(diffuseHorizontalRadiation, &ok);
2091
3/6
✓ Branch 0 taken 140232 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 140232 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 140232 times.
140232 if (!ok || 0 > value || value == 9999) {
2092 ✗ m_diffuseHorizontalRadiation = "9999";
2093 ✗ return false;
2094 }
2095
1/1
✓ Branch 1 taken 140232 times.
140232 m_diffuseHorizontalRadiation = diffuseHorizontalRadiation;
2096 140232 return true;
2097 }
2098
2099 ✗ boost::optional<double> EpwDataPoint::globalHorizontalIlluminance() const {
2100 ✗ if (m_globalHorizontalIlluminance == "999999") {
2101 ✗ return boost::none;
2102 }
2103 ✗ return boost::optional<double>(std::stod(m_globalHorizontalIlluminance));
2104 }
2105
2106 ✗ bool EpwDataPoint::setGlobalHorizontalIlluminance(double value) {
2107 ✗ if (0 > value || 999900 < value) {
2108 ✗ m_globalHorizontalIlluminance = "999999";
2109 ✗ return false;
2110 }
2111 ✗ m_globalHorizontalIlluminance = std::to_string(value);
2112 ✗ return true;
2113 }
2114
2115 140232 bool EpwDataPoint::setGlobalHorizontalIlluminance(const std::string& globalHorizontalIlluminance) {
2116 bool ok;
2117
1/1
✓ Branch 1 taken 140232 times.
140232 double value = stringToDouble(globalHorizontalIlluminance, &ok);
2118
4/6
✓ Branch 0 taken 140232 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 140232 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26328 times.
✓ Branch 5 taken 113904 times.
140232 if (!ok || 0 > value || 999900 < value) {
2119
1/1
✓ Branch 1 taken 26328 times.
26328 m_globalHorizontalIlluminance = "999999";
2120 26328 return false;
2121 }
2122
1/1
✓ Branch 1 taken 113904 times.
113904 m_globalHorizontalIlluminance = globalHorizontalIlluminance;
2123 113904 return true;
2124 }
2125
2126 ✗ boost::optional<double> EpwDataPoint::directNormalIlluminance() const {
2127 ✗ if (m_directNormalIlluminance == "999999") {
2128 ✗ return boost::none;
2129 }
2130 ✗ return boost::optional<double>(std::stod(m_directNormalIlluminance));
2131 }
2132
2133 ✗ bool EpwDataPoint::setDirectNormalIlluminance(double value) {
2134 ✗ if (0 > value || 999900 < value) {
2135 ✗ m_directNormalIlluminance = "999999";
2136 ✗ return false;
2137 }
2138 ✗ m_directNormalIlluminance = std::to_string(value);
2139 ✗ return true;
2140 }
2141
2142 140232 bool EpwDataPoint::setDirectNormalIlluminance(const std::string& directNormalIlluminance) {
2143 bool ok;
2144
1/1
✓ Branch 1 taken 140232 times.
140232 double value = stringToDouble(directNormalIlluminance, &ok);
2145
4/6
✓ Branch 0 taken 140232 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 140232 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26328 times.
✓ Branch 5 taken 113904 times.
140232 if (!ok || 0 > value || 999900 < value) {
2146
1/1
✓ Branch 1 taken 26328 times.
26328 m_directNormalIlluminance = "999999";
2147 26328 return false;
2148 }
2149
1/1
✓ Branch 1 taken 113904 times.
113904 m_directNormalIlluminance = directNormalIlluminance;
2150 113904 return true;
2151 }
2152
2153 ✗ boost::optional<double> EpwDataPoint::diffuseHorizontalIlluminance() const {
2154 ✗ if (m_diffuseHorizontalIlluminance == "999999") {
2155 ✗ return boost::none;
2156 }
2157 ✗ return boost::optional<double>(std::stod(m_diffuseHorizontalIlluminance));
2158 }
2159
2160 ✗ bool EpwDataPoint::setDiffuseHorizontalIlluminance(double value) {
2161 ✗ if (0 > value || 999900 < value) {
2162 ✗ m_diffuseHorizontalIlluminance = "999999";
2163 ✗ return false;
2164 }
2165 ✗ m_diffuseHorizontalIlluminance = std::to_string(value);
2166 ✗ return true;
2167 }
2168
2169 140232 bool EpwDataPoint::setDiffuseHorizontalIlluminance(const std::string& diffuseHorizontalIlluminance) {
2170 bool ok;
2171
1/1
✓ Branch 1 taken 140232 times.
140232 double value = stringToDouble(diffuseHorizontalIlluminance, &ok);
2172
4/6
✓ Branch 0 taken 140232 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 140232 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26328 times.
✓ Branch 5 taken 113904 times.
140232 if (!ok || 0 > value || 999900 < value) {
2173
1/1
✓ Branch 1 taken 26328 times.
26328 m_diffuseHorizontalIlluminance = "999999";
2174 26328 return false;
2175 }
2176
1/1
✓ Branch 1 taken 113904 times.
113904 m_diffuseHorizontalIlluminance = diffuseHorizontalIlluminance;
2177 113904 return true;
2178 }
2179
2180 ✗ boost::optional<double> EpwDataPoint::zenithLuminance() const {
2181 ✗ if (m_zenithLuminance == "9999") {
2182 ✗ return boost::none;
2183 }
2184 ✗ return boost::optional<double>(std::stod(m_zenithLuminance));
2185 }
2186
2187 ✗ bool EpwDataPoint::setZenithLuminance(double value) {
2188 ✗ if (0 > value || 9999 <= value) {
2189 ✗ m_zenithLuminance = "9999";
2190 ✗ return false;
2191 }
2192 ✗ m_zenithLuminance = std::to_string(value);
2193 ✗ return true;
2194 }
2195
2196 140232 bool EpwDataPoint::setZenithLuminance(const std::string& zenithLuminance) {
2197 bool ok;
2198
1/1
✓ Branch 1 taken 140232 times.
140232 double value = stringToDouble(zenithLuminance, &ok);
2199
4/6
✓ Branch 0 taken 140232 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 140232 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 41577 times.
✓ Branch 5 taken 98655 times.
140232 if (!ok || 0 > value || 9999 <= value) {
2200
1/1
✓ Branch 1 taken 41577 times.
41577 m_zenithLuminance = "9999";
2201 41577 return false;
2202 }
2203
1/1
✓ Branch 1 taken 98655 times.
98655 m_zenithLuminance = zenithLuminance;
2204 98655 return true;
2205 }
2206
2207 ✗ boost::optional<double> EpwDataPoint::windDirection() const {
2208 ✗ if (m_windDirection == "999") {
2209 ✗ return boost::none;
2210 }
2211 ✗ return boost::optional<double>(std::stod(m_windDirection));
2212 }
2213
2214 ✗ bool EpwDataPoint::setWindDirection(double value) {
2215 ✗ if (0 > value || 360 < value) {
2216 ✗ m_windDirection = "999";
2217 ✗ return false;
2218 }
2219 ✗ m_windDirection = std::to_string(value);
2220 ✗ return true;
2221 }
2222
2223 140232 bool EpwDataPoint::setWindDirection(const std::string& windDirection) {
2224 bool ok;
2225
1/1
✓ Branch 1 taken 140232 times.
140232 double value = stringToDouble(windDirection, &ok);
2226
3/6
✓ Branch 0 taken 140232 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 140232 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 140232 times.
140232 if (!ok || 0 > value || 360 < value) {
2227 ✗ m_windDirection = "999";
2228 ✗ return false;
2229 }
2230
1/1
✓ Branch 1 taken 140232 times.
140232 m_windDirection = windDirection;
2231 140232 return true;
2232 }
2233
2234 52560 boost::optional<double> EpwDataPoint::windSpeed() const {
2235
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 52560 times.
52560 if (m_windSpeed == "999") {
2236 ✗ return boost::none;
2237 }
2238
2/2
✓ Branch 1 taken 52560 times.
✓ Branch 4 taken 52560 times.
52560 return boost::optional<double>(std::stod(m_windSpeed));
2239 }
2240
2241 140232 bool EpwDataPoint::setWindSpeed(double value) {
2242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140232 times.
140232 if (0 > value) {
2243 ✗ m_windSpeed = "999";
2244 ✗ return false;
2245
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 140229 times.
140232 } else if (40 < value) {
2246
7/7
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
✓ Branch 19 taken 3 times.
9 LOG_FREE(Warn, "openstudio.EpwFile", "WindSpeed value '" << value << "' not within the expected limits");
2247 }
2248
1/1
✓ Branch 1 taken 140232 times.
140232 m_windSpeed = std::to_string(value);
2249 140232 return true;
2250 }
2251
2252 140232 bool EpwDataPoint::setWindSpeed(const std::string& windSpeed) {
2253 bool ok;
2254
1/1
✓ Branch 1 taken 140232 times.
140232 double value = stringToDouble(windSpeed, &ok);
2255
2/4
✓ Branch 0 taken 140232 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 140232 times.
140232 if (!ok || 0 > value) {
2256 ✗ m_windSpeed = "999";
2257 ✗ return false;
2258
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 140229 times.
140232 } else if (40 < value) {
2259
7/7
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
✓ Branch 19 taken 3 times.
9 LOG_FREE(Warn, "openstudio.EpwFile", "WindSpeed value '" << value << "' not within the expected limits");
2260 }
2261
1/1
✓ Branch 1 taken 140232 times.
140232 return setWindSpeed(value);
2262 }
2263
2264 ✗ int EpwDataPoint::totalSkyCover() const {
2265 ✗ return m_totalSkyCover;
2266 }
2267
2268 113904 bool EpwDataPoint::setTotalSkyCover(int value) {
2269
2/4
✓ Branch 0 taken 113904 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 113904 times.
113904 if (0 > value || 10 < value) {
2270 ✗ m_totalSkyCover = 99;
2271 ✗ return false;
2272 }
2273 113904 m_totalSkyCover = value;
2274 113904 return true;
2275 }
2276
2277 140232 bool EpwDataPoint::setTotalSkyCover(const std::string& totalSkyCover) {
2278 bool ok;
2279
1/1
✓ Branch 1 taken 140232 times.
140232 int value = stringToInteger(totalSkyCover, &ok);
2280
4/6
✓ Branch 0 taken 140232 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 140232 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26328 times.
✓ Branch 5 taken 113904 times.
140232 if (!ok || 0 > value || 10 < value) {
2281 26328 m_totalSkyCover = 99;
2282 26328 return false;
2283 }
2284
1/1
✓ Branch 1 taken 113904 times.
113904 return setTotalSkyCover(value);
2285 }
2286
2287 ✗ int EpwDataPoint::opaqueSkyCover() const {
2288 ✗ return m_opaqueSkyCover;
2289 }
2290
2291 140232 bool EpwDataPoint::setOpaqueSkyCover(int value) {
2292
2/4
✓ Branch 0 taken 140232 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 140232 times.
140232 if (0 > value || 10 < value) {
2293 ✗ m_opaqueSkyCover = 99;
2294 ✗ return false;
2295 }
2296 140232 m_opaqueSkyCover = value;
2297 140232 return true;
2298 }
2299
2300 140232 bool EpwDataPoint::setOpaqueSkyCover(const std::string& opaqueSkyCover) {
2301 bool ok;
2302
1/1
✓ Branch 1 taken 140232 times.
140232 int value = stringToInteger(opaqueSkyCover, &ok);
2303
3/6
✓ Branch 0 taken 140232 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 140232 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 140232 times.
140232 if (!ok || 0 > value || 10 < value) {
2304 ✗ m_opaqueSkyCover = 99;
2305 ✗ return false;
2306 }
2307
1/1
✓ Branch 1 taken 140232 times.
140232 return setOpaqueSkyCover(value);
2308 }
2309
2310 ✗ boost::optional<double> EpwDataPoint::visibility() const {
2311 ✗ if (m_visibility == "9999") {
2312 ✗ return boost::none;
2313 }
2314 ✗ return boost::optional<double>(std::stod(m_visibility));
2315 }
2316
2317 ✗ bool EpwDataPoint::setVisibility(double value) {
2318 ✗ if (value == 9999) {
2319 ✗ m_visibility = "9999";
2320 ✗ return false;
2321 }
2322 ✗ m_visibility = std::to_string(value);
2323 ✗ return true;
2324 }
2325
2326 140232 bool EpwDataPoint::setVisibility(const std::string& visibility) {
2327 bool ok;
2328
1/1
✓ Branch 1 taken 140232 times.
140232 double value = stringToDouble(visibility, &ok);
2329
3/4
✓ Branch 0 taken 140232 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26328 times.
✓ Branch 3 taken 113904 times.
140232 if (!ok || value == 9999) {
2330
1/1
✓ Branch 1 taken 26328 times.
26328 m_visibility = "9999";
2331 26328 return false;
2332 }
2333
1/1
✓ Branch 1 taken 113904 times.
113904 m_visibility = visibility;
2334 113904 return true;
2335 }
2336
2337 ✗ boost::optional<double> EpwDataPoint::ceilingHeight() const {
2338 ✗ if (m_ceilingHeight == "99999") {
2339 ✗ return boost::none;
2340 }
2341 ✗ return boost::optional<double>(std::stod(m_ceilingHeight));
2342 }
2343
2344 ✗ void EpwDataPoint::setCeilingHeight(double ceilingHeight) {
2345 ✗ m_ceilingHeight = std::to_string(ceilingHeight);
2346 ✗ }
2347
2348 140232 bool EpwDataPoint::setCeilingHeight(const std::string& ceilingHeight) {
2349 bool ok;
2350
1/1
✓ Branch 1 taken 140232 times.
140232 double value = stringToDouble(ceilingHeight, &ok);
2351
3/4
✓ Branch 0 taken 140232 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26328 times.
✓ Branch 3 taken 113904 times.
140232 if (!ok || value == 99999) {
2352
1/1
✓ Branch 1 taken 26328 times.
26328 m_ceilingHeight = "99999";
2353 26328 return false;
2354 }
2355
1/1
✓ Branch 1 taken 113904 times.
113904 m_ceilingHeight = ceilingHeight;
2356 113904 return true;
2357 }
2358
2359 ✗ int EpwDataPoint::presentWeatherObservation() const {
2360 ✗ return m_presentWeatherObservation;
2361 }
2362
2363 ✗ void EpwDataPoint::setPresentWeatherObservation(int presentWeatherObservation) {
2364 ✗ m_presentWeatherObservation = presentWeatherObservation;
2365 ✗ }
2366
2367 140232 bool EpwDataPoint::setPresentWeatherObservation(const std::string& presentWeatherObservation) {
2368 bool ok;
2369
1/1
✓ Branch 1 taken 140232 times.
140232 int value = stringToInteger(presentWeatherObservation, &ok);
2370
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140232 times.
140232 if (!ok) {
2371 ✗ return false;
2372 }
2373 140232 m_presentWeatherObservation = value;
2374 140232 return true;
2375 }
2376
2377 ✗ int EpwDataPoint::presentWeatherCodes() const {
2378 ✗ return m_presentWeatherCodes;
2379 }
2380
2381 ✗ void EpwDataPoint::setPresentWeatherCodes(int presentWeatherCodes) {
2382 ✗ m_presentWeatherCodes = presentWeatherCodes;
2383 ✗ }
2384
2385 140232 bool EpwDataPoint::setPresentWeatherCodes(const std::string& presentWeatherCodes) {
2386 bool ok;
2387
1/1
✓ Branch 1 taken 140232 times.
140232 int value = stringToInteger(presentWeatherCodes, &ok);
2388
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140232 times.
140232 if (!ok) {
2389 ✗ return false;
2390 }
2391 140232 m_presentWeatherCodes = value;
2392 140232 return true;
2393 }
2394
2395 ✗ boost::optional<double> EpwDataPoint::precipitableWater() const {
2396 ✗ if (m_precipitableWater == "999") {
2397 ✗ return boost::none;
2398 }
2399 ✗ return boost::optional<double>(std::stod(m_precipitableWater));
2400 }
2401
2402 ✗ void EpwDataPoint::setPrecipitableWater(double precipitableWater) {
2403 ✗ m_precipitableWater = std::to_string(precipitableWater);
2404 ✗ }
2405
2406 140232 bool EpwDataPoint::setPrecipitableWater(const std::string& precipitableWater) {
2407 bool ok;
2408
1/1
✓ Branch 1 taken 140232 times.
140232 double value = stringToDouble(precipitableWater, &ok);
2409
2/4
✓ Branch 0 taken 140232 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 140232 times.
140232 if (!ok || value == 999) {
2410 ✗ m_precipitableWater = "999";
2411 ✗ return false;
2412 }
2413
1/1
✓ Branch 1 taken 140232 times.
140232 m_precipitableWater = precipitableWater;
2414 140232 return true;
2415 }
2416
2417 ✗ boost::optional<double> EpwDataPoint::aerosolOpticalDepth() const {
2418 ✗ if (m_aerosolOpticalDepth == ".999") {
2419 ✗ return boost::none;
2420 }
2421 ✗ return boost::optional<double>(std::stod(m_aerosolOpticalDepth));
2422 }
2423
2424 ✗ void EpwDataPoint::setAerosolOpticalDepth(double aerosolOpticalDepth) {
2425 ✗ m_aerosolOpticalDepth = std::to_string(aerosolOpticalDepth);
2426 ✗ }
2427
2428 140232 bool EpwDataPoint::setAerosolOpticalDepth(const std::string& aerosolOpticalDepth) {
2429 bool ok;
2430
1/1
✓ Branch 1 taken 140232 times.
140232 double value = stringToDouble(aerosolOpticalDepth, &ok);
2431
3/4
✓ Branch 0 taken 140232 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26328 times.
✓ Branch 3 taken 113904 times.
140232 if (!ok || value == 0.999) {
2432
1/1
✓ Branch 1 taken 26328 times.
26328 m_aerosolOpticalDepth = ".999";
2433 26328 return false;
2434 }
2435
1/1
✓ Branch 1 taken 113904 times.
113904 m_aerosolOpticalDepth = aerosolOpticalDepth;
2436 113904 return true;
2437 }
2438
2439 ✗ boost::optional<double> EpwDataPoint::snowDepth() const {
2440 ✗ if (m_snowDepth == "999") {
2441 ✗ return boost::none;
2442 }
2443 ✗ return boost::optional<double>(std::stod(m_snowDepth));
2444 }
2445
2446 ✗ void EpwDataPoint::setSnowDepth(double snowDepth) {
2447 ✗ m_snowDepth = std::to_string(snowDepth);
2448 ✗ }
2449
2450 140232 bool EpwDataPoint::setSnowDepth(const std::string& snowDepth) {
2451 bool ok;
2452
1/1
✓ Branch 1 taken 140232 times.
140232 double value = stringToDouble(snowDepth, &ok);
2453
2/4
✓ Branch 0 taken 140232 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 140232 times.
140232 if (!ok || value == 999) {
2454 ✗ m_snowDepth = "999";
2455 ✗ return false;
2456 }
2457
1/1
✓ Branch 1 taken 140232 times.
140232 m_snowDepth = snowDepth;
2458 140232 return true;
2459 }
2460
2461 ✗ boost::optional<double> EpwDataPoint::daysSinceLastSnowfall() const {
2462 ✗ if (m_daysSinceLastSnowfall == "99") {
2463 ✗ return boost::none;
2464 }
2465 ✗ return boost::optional<double>(std::stod(m_daysSinceLastSnowfall));
2466 }
2467
2468 ✗ void EpwDataPoint::setDaysSinceLastSnowfall(double daysSinceLastSnowfall) {
2469 ✗ m_daysSinceLastSnowfall = std::to_string(daysSinceLastSnowfall);
2470 ✗ }
2471
2472 140232 bool EpwDataPoint::setDaysSinceLastSnowfall(const std::string& daysSinceLastSnowfall) {
2473 bool ok;
2474
1/1
✓ Branch 1 taken 140232 times.
140232 double value = stringToDouble(daysSinceLastSnowfall, &ok);
2475
3/4
✓ Branch 0 taken 140232 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26328 times.
✓ Branch 3 taken 113904 times.
140232 if (!ok || value == 99) {
2476
1/1
✓ Branch 1 taken 26328 times.
26328 m_daysSinceLastSnowfall = "99";
2477 26328 return false;
2478 }
2479
1/1
✓ Branch 1 taken 113904 times.
113904 m_daysSinceLastSnowfall = daysSinceLastSnowfall;
2480 113904 return true;
2481 }
2482
2483 ✗ boost::optional<double> EpwDataPoint::albedo() const {
2484 ✗ if (m_albedo == "999") {
2485 ✗ return boost::none;
2486 }
2487 ✗ return boost::optional<double>(std::stod(m_albedo));
2488 }
2489
2490 ✗ void EpwDataPoint::setAlbedo(double albedo) {
2491 ✗ m_albedo = std::to_string(albedo);
2492 ✗ }
2493
2494 140232 bool EpwDataPoint::setAlbedo(const std::string& albedo) {
2495 bool ok;
2496
1/1
✓ Branch 1 taken 140232 times.
140232 double value = stringToDouble(albedo, &ok);
2497
3/4
✓ Branch 0 taken 140232 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35088 times.
✓ Branch 3 taken 105144 times.
140232 if (!ok || value == 999) {
2498
1/1
✓ Branch 1 taken 35088 times.
35088 m_albedo = "999";
2499 35088 return false;
2500 }
2501
1/1
✓ Branch 1 taken 105144 times.
105144 m_albedo = albedo;
2502 105144 return true;
2503 }
2504
2505 4 boost::optional<double> EpwDataPoint::liquidPrecipitationDepth() const {
2506
1/2
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
4 if (m_liquidPrecipitationDepth == "999") {
2507 4 return boost::none;
2508 }
2509 ✗ return boost::optional<double>(std::stod(m_liquidPrecipitationDepth));
2510 }
2511
2512 ✗ void EpwDataPoint::setLiquidPrecipitationDepth(double liquidPrecipitationDepth) {
2513 ✗ m_liquidPrecipitationDepth = std::to_string(liquidPrecipitationDepth);
2514 ✗ }
2515
2516 140232 bool EpwDataPoint::setLiquidPrecipitationDepth(const std::string& liquidPrecipitationDepth) {
2517 bool ok;
2518
1/1
✓ Branch 1 taken 140232 times.
140232 double value = stringToDouble(liquidPrecipitationDepth, &ok);
2519
3/4
✓ Branch 0 taken 140232 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115542 times.
✓ Branch 3 taken 24690 times.
140232 if (!ok || value == 999) {
2520
1/1
✓ Branch 1 taken 115542 times.
115542 m_liquidPrecipitationDepth = "999";
2521 115542 return false;
2522 }
2523
1/1
✓ Branch 1 taken 24690 times.
24690 m_liquidPrecipitationDepth = liquidPrecipitationDepth;
2524 24690 return true;
2525 }
2526
2527 ✗ boost::optional<double> EpwDataPoint::liquidPrecipitationQuantity() const {
2528 ✗ if (m_liquidPrecipitationQuantity == "99") {
2529 ✗ return boost::none;
2530 }
2531 ✗ return boost::optional<double>(std::stod(m_liquidPrecipitationQuantity));
2532 }
2533
2534 ✗ void EpwDataPoint::setLiquidPrecipitationQuantity(double liquidPrecipitationQuantity) {
2535 ✗ m_liquidPrecipitationQuantity = std::to_string(liquidPrecipitationQuantity);
2536 ✗ }
2537
2538 140232 bool EpwDataPoint::setLiquidPrecipitationQuantity(const std::string& liquidPrecipitationQuantity) {
2539 bool ok;
2540
1/1
✓ Branch 1 taken 140232 times.
140232 double value = stringToDouble(liquidPrecipitationQuantity, &ok);
2541
3/4
✓ Branch 0 taken 140232 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115542 times.
✓ Branch 3 taken 24690 times.
140232 if (!ok || value == 99) {
2542
1/1
✓ Branch 1 taken 115542 times.
115542 m_liquidPrecipitationQuantity = "99";
2543 115542 return false;
2544 }
2545
1/1
✓ Branch 1 taken 24690 times.
24690 m_liquidPrecipitationQuantity = liquidPrecipitationQuantity;
2546 24690 return true;
2547 }
2548
2549 ✗ boost::optional<AirState> EpwDataPoint::airState() const {
2550 ✗ boost::optional<double> value = dryBulbTemperature();
2551 ✗ if (!value) {
2552 ✗ return boost::none; // Have to have dry bulb
2553 }
2554 ✗ double drybulb = value.get();
2555
2556 ✗ value = atmosphericStationPressure();
2557 ✗ if (!value) {
2558 ✗ return boost::none; // Have to have pressure
2559 }
2560 ✗ double pressure = value.get();
2561
2562 ✗ value = relativeHumidity();
2563 ✗ if (!value) { // Don't have relative humidity
2564 ✗ value = dewPointTemperature();
2565 ✗ if (value) {
2566 ✗ double dewpoint = value.get();
2567 ✗ return AirState::fromDryBulbDewPointPressure(drybulb, dewpoint, pressure);
2568 }
2569 } else { // Have relative humidity
2570 ✗ double RH = value.get();
2571 ✗ return AirState::fromDryBulbRelativeHumidityPressure(drybulb, RH, pressure);
2572 }
2573
2574 ✗ return boost::none;
2575 }
2576
2577 ✗ boost::optional<double> EpwDataPoint::saturationPressure() const {
2578 ✗ boost::optional<double> optdrybulb = dryBulbTemperature();
2579 ✗ if (optdrybulb) {
2580 ✗ double drybulb = optdrybulb.get();
2581 ✗ if (drybulb >= -100.0 && drybulb <= 200.0) {
2582 ✗ return boost::optional<double>(openstudio::psat(drybulb));
2583 }
2584 }
2585 ✗ return boost::none;
2586 }
2587
2588 ✗ boost::optional<double> EpwDataPoint::enthalpy() const {
2589 ✗ boost::optional<AirState> state = airState();
2590 ✗ if (state) {
2591 ✗ return boost::optional<double>(state.get().enthalpy());
2592 }
2593 ✗ return boost::none;
2594 ✗ }
2595
2596 ✗ boost::optional<double> EpwDataPoint::humidityRatio() const {
2597 ✗ boost::optional<AirState> state = airState();
2598 ✗ if (state) {
2599 ✗ return boost::optional<double>(state.get().humidityRatio());
2600 }
2601 ✗ return boost::none;
2602 ✗ }
2603
2604 ✗ boost::optional<double> EpwDataPoint::density() const {
2605 ✗ boost::optional<AirState> state = airState();
2606 ✗ if (state) {
2607 ✗ return boost::optional<double>(state.get().density());
2608 }
2609 ✗ return boost::none;
2610 ✗ }
2611
2612 ✗ boost::optional<double> EpwDataPoint::specificVolume() const {
2613 ✗ boost::optional<AirState> state = airState();
2614 ✗ if (state) {
2615 ✗ return boost::optional<double>(state.get().specificVolume());
2616 }
2617 ✗ return boost::none;
2618 ✗ }
2619
2620 ✗ boost::optional<double> EpwDataPoint::wetbulb() const {
2621 ✗ boost::optional<AirState> state = airState();
2622 ✗ if (state) {
2623 ✗ return boost::optional<double>(state.get().wetbulb());
2624 }
2625 ✗ return boost::none;
2626 ✗ }
2627
2628 48 EpwFile::EpwFile(const openstudio::path& p, bool storeData)
2629
3/3
✓ Branch 8 taken 48 times.
✓ Branch 11 taken 48 times.
✓ Branch 14 taken 48 times.
48 : m_path(p), m_latitude(0), m_longitude(0), m_timeZone(0), m_elevation(0), m_isActual(false), m_minutesMatch(true) {
2630
5/8
✓ Branch 1 taken 48 times.
✓ Branch 3 taken 48 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 48 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 48 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 48 times.
48 if (!openstudio::filesystem::exists(m_path) || !openstudio::filesystem::is_regular_file(m_path)) {
2631 ✗ LOG_AND_THROW("Path '" << m_path << "' is not an EPW file");
2632 }
2633
2634 // set checksum
2635
1/1
✓ Branch 1 taken 48 times.
48 m_checksum = openstudio::checksum(m_path);
2636
2637 // open file
2638
2/2
✓ Branch 1 taken 48 times.
✓ Branch 4 taken 48 times.
48 std::ifstream ifs(openstudio::toSystemFilename(m_path));
2639
2640
3/3
✓ Branch 1 taken 48 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 47 times.
48 if (!parse(ifs, storeData)) {
2641
1/1
✓ Branch 1 taken 1 time.
1 ifs.close();
2642
19/19
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
✓ Branch 17 taken 1 time.
✓ Branch 20 taken 1 time.
✓ Branch 23 taken 1 time.
✓ Branch 29 taken 1 time.
✓ Branch 32 taken 1 time.
✓ Branch 35 taken 1 time.
✓ Branch 38 taken 1 time.
✓ Branch 41 taken 1 time.
✓ Branch 44 taken 1 time.
✓ Branch 47 taken 1 time.
✓ Branch 50 taken 1 time.
✓ Branch 53 taken 1 time.
✓ Branch 58 taken 1 time.
✓ Branch 61 taken 1 time.
1 LOG_AND_THROW("EpwFile '" << toString(p) << "' cannot be processed");
2643 }
2644
1/1
✓ Branch 1 taken 47 times.
47 ifs.close();
2645 61 }
2646
2647
3/3
✓ Branch 8 taken 8 times.
✓ Branch 11 taken 8 times.
✓ Branch 14 taken 8 times.
8 EpwFile::EpwFile() : m_latitude(0), m_longitude(0), m_timeZone(0), m_elevation(0), m_isActual(false), m_minutesMatch(true) {}
2648
2649 25 boost::optional<EpwFile> EpwFile::load(const openstudio::path& p, bool storeData) {
2650 25 boost::optional<EpwFile> result;
2651 try {
2652
2/2
✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
25 result = EpwFile(p, storeData);
2653 ✗ } catch (const std::exception&) {
2654 ✗ }
2655 25 return result;
2656 ✗ }
2657
2658 8 boost::optional<EpwFile> EpwFile::loadFromString(const std::string& str, bool storeData) {
2659
1/1
✓ Branch 1 taken 8 times.
8 EpwFile result;
2660
1/1
✓ Branch 2 taken 8 times.
8 std::stringstream ss(str);
2661
2/3
✓ Branch 1 taken 8 times.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
8 if (result.parse(ss, storeData)) {
2662
2/2
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
8 result.m_checksum = openstudio::checksum(str);
2663 } else {
2664 ✗ return boost::none;
2665 }
2666
1/1
✓ Branch 1 taken 8 times.
8 return result;
2667 8 }
2668
2669 47 openstudio::path EpwFile::path() const {
2670 47 return m_path;
2671 }
2672
2673 43 std::string EpwFile::checksum() const {
2674 43 return m_checksum;
2675 }
2676
2677 38 std::string EpwFile::city() const {
2678 38 return m_city;
2679 }
2680
2681 38 std::string EpwFile::stateProvinceRegion() const {
2682 38 return m_stateProvinceRegion;
2683 }
2684
2685 37 std::string EpwFile::country() const {
2686 37 return m_country;
2687 }
2688
2689 37 std::string EpwFile::dataSource() const {
2690 37 return m_dataSource;
2691 }
2692
2693 38 std::string EpwFile::wmoNumber() const {
2694 38 return m_wmoNumber;
2695 }
2696
2697 37 double EpwFile::latitude() const {
2698 37 return m_latitude;
2699 }
2700
2701 37 double EpwFile::longitude() const {
2702 37 return m_longitude;
2703 }
2704
2705 37 double EpwFile::timeZone() const {
2706 37 return m_timeZone;
2707 }
2708
2709 37 double EpwFile::elevation() const {
2710 37 return m_elevation;
2711 }
2712
2713 13 Time EpwFile::timeStep() const {
2714
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 OS_ASSERT((60 % m_recordsPerHour) == 0);
2715 13 return {0, 0, 60 / m_recordsPerHour};
2716 }
2717
2718 ✗ int EpwFile::recordsPerHour() const {
2719 ✗ return m_recordsPerHour;
2720 }
2721
2722 41 DayOfWeek EpwFile::startDayOfWeek() const {
2723 41 return m_startDayOfWeek;
2724 }
2725
2726 18 Date EpwFile::startDate() const {
2727 18 return m_startDate;
2728 }
2729
2730 18 Date EpwFile::endDate() const {
2731 18 return m_endDate;
2732 }
2733
2734 33 boost::optional<int> EpwFile::startDateActualYear() const {
2735 33 return m_startDateActualYear;
2736 }
2737
2738 5 boost::optional<int> EpwFile::endDateActualYear() const {
2739 5 return m_endDateActualYear;
2740 }
2741
2742 14 std::vector<EpwDataPoint> EpwFile::data() {
2743
2/2
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 5 times.
14 if (m_data.empty()) {
2744
5/8
✓ Branch 1 taken 9 times.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 9 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 9 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 9 times.
9 if (!openstudio::filesystem::exists(m_path) || !openstudio::filesystem::is_regular_file(m_path)) {
2745 ✗ LOG_AND_THROW("Path '" << m_path << "' is not an EPW file");
2746 }
2747
2748 // set checksum
2749
1/1
✓ Branch 1 taken 9 times.
9 m_checksum = openstudio::checksum(m_path);
2750
2751 // open file
2752
2/2
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
9 std::ifstream ifs(openstudio::toSystemFilename(m_path));
2753
2754
2/3
✓ Branch 1 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
9 if (!parse(ifs, true)) {
2755 ✗ ifs.close();
2756 ✗ LOG(Error, "EpwFile '" << toString(m_path) << "' cannot be processed");
2757 } else {
2758
1/1
✓ Branch 1 taken 9 times.
9 ifs.close();
2759 }
2760 9 }
2761 14 return m_data;
2762 }
2763
2764 11 std::string EpwDesignCondition::titleOfDesignCondition() const {
2765 11 return m_titleOfDesignCondition;
2766 }
2767
2768 11 boost::optional<int> EpwDesignCondition::heatingColdestMonth() const {
2769 11 return m_heatingColdestMonth;
2770 }
2771
2772 33 boost::optional<double> EpwDesignCondition::heatingDryBulb99pt6() const {
2773 33 return m_heatingDryBulb99pt6;
2774 }
2775
2776 13 boost::optional<double> EpwDesignCondition::heatingDryBulb99() const {
2777 13 return m_heatingDryBulb99;
2778 }
2779
2780 11 boost::optional<double> EpwDesignCondition::heatingHumidificationDewPoint99pt6() const {
2781 11 return m_heatingHumidificationDewPoint99pt6;
2782 }
2783
2784 11 boost::optional<double> EpwDesignCondition::heatingHumidificationHumidityRatio99pt6() const {
2785 11 return m_heatingHumidificationHumidityRatio99pt6;
2786 }
2787
2788 11 boost::optional<double> EpwDesignCondition::heatingHumidificationMeanCoincidentDryBulb99pt6() const {
2789 11 return m_heatingHumidificationMeanCoincidentDryBulb99pt6;
2790 }
2791
2792 11 boost::optional<double> EpwDesignCondition::heatingHumidificationDewPoint99() const {
2793 11 return m_heatingHumidificationDewPoint99;
2794 }
2795
2796 11 boost::optional<double> EpwDesignCondition::heatingHumidificationHumidityRatio99() const {
2797 11 return m_heatingHumidificationHumidityRatio99;
2798 }
2799
2800 11 boost::optional<double> EpwDesignCondition::heatingHumidificationMeanCoincidentDryBulb99() const {
2801 11 return m_heatingHumidificationMeanCoincidentDryBulb99;
2802 }
2803
2804 11 boost::optional<double> EpwDesignCondition::heatingColdestMonthWindSpeed0pt4() const {
2805 11 return m_heatingColdestMonthWindSpeed0pt4;
2806 }
2807
2808 11 boost::optional<double> EpwDesignCondition::heatingColdestMonthMeanCoincidentDryBulb0pt4() const {
2809 11 return m_heatingColdestMonthMeanCoincidentDryBulb0pt4;
2810 }
2811
2812 12 boost::optional<double> EpwDesignCondition::heatingColdestMonthWindSpeed1() const {
2813 12 return m_heatingColdestMonthWindSpeed1;
2814 }
2815
2816 11 boost::optional<double> EpwDesignCondition::heatingColdestMonthMeanCoincidentDryBulb1() const {
2817 11 return m_heatingColdestMonthMeanCoincidentDryBulb1;
2818 }
2819
2820 11 boost::optional<double> EpwDesignCondition::heatingMeanCoincidentWindSpeed99pt6() const {
2821 11 return m_heatingMeanCoincidentWindSpeed99pt6;
2822 }
2823
2824 11 boost::optional<int> EpwDesignCondition::heatingPrevailingCoincidentWindDirection99pt6() const {
2825 11 return m_heatingPrevailingCoincidentWindDirection99pt6;
2826 }
2827
2828 11 boost::optional<double> EpwDesignCondition::heatingWindShelterFactor() const {
2829 11 return m_heatingWindShelterFactor;
2830 }
2831
2832 11 boost::optional<int> EpwDesignCondition::coolingHottestMonth() const {
2833 11 return m_coolingHottestMonth;
2834 }
2835
2836 12 boost::optional<double> EpwDesignCondition::coolingDryBulbRange() const {
2837 12 return m_coolingDryBulbRange;
2838 }
2839
2840 11 boost::optional<double> EpwDesignCondition::coolingDryBulb0pt4() const {
2841 11 return m_coolingDryBulb0pt4;
2842 }
2843
2844 11 boost::optional<double> EpwDesignCondition::coolingMeanCoincidentWetBulb0pt4() const {
2845 11 return m_coolingMeanCoincidentWetBulb0pt4;
2846 }
2847
2848 12 boost::optional<double> EpwDesignCondition::coolingDryBulb1() const {
2849 12 return m_coolingDryBulb1;
2850 }
2851
2852 12 boost::optional<double> EpwDesignCondition::coolingMeanCoincidentWetBulb1() const {
2853 12 return m_coolingMeanCoincidentWetBulb1;
2854 }
2855
2856 11 boost::optional<double> EpwDesignCondition::coolingDryBulb2() const {
2857 11 return m_coolingDryBulb2;
2858 }
2859
2860 11 boost::optional<double> EpwDesignCondition::coolingMeanCoincidentWetBulb2() const {
2861 11 return m_coolingMeanCoincidentWetBulb2;
2862 }
2863
2864 11 boost::optional<double> EpwDesignCondition::coolingEvaporationWetBulb0pt4() const {
2865 11 return m_coolingEvaporationWetBulb0pt4;
2866 }
2867
2868 11 boost::optional<double> EpwDesignCondition::coolingEvaporationMeanCoincidentDryBulb0pt4() const {
2869 11 return m_coolingEvaporationMeanCoincidentDryBulb0pt4;
2870 }
2871
2872 11 boost::optional<double> EpwDesignCondition::coolingEvaporationWetBulb1() const {
2873 11 return m_coolingEvaporationWetBulb1;
2874 }
2875
2876 11 boost::optional<double> EpwDesignCondition::coolingEvaporationMeanCoincidentDryBulb1() const {
2877 11 return m_coolingEvaporationMeanCoincidentDryBulb1;
2878 }
2879
2880 11 boost::optional<double> EpwDesignCondition::coolingEvaporationWetBulb2() const {
2881 11 return m_coolingEvaporationWetBulb2;
2882 }
2883
2884 11 boost::optional<double> EpwDesignCondition::coolingEvaporationMeanCoincidentDryBulb2() const {
2885 11 return m_coolingEvaporationMeanCoincidentDryBulb2;
2886 }
2887
2888 12 boost::optional<double> EpwDesignCondition::coolingMeanCoincidentWindSpeed0pt4() const {
2889 12 return m_coolingMeanCoincidentWindSpeed0pt4;
2890 }
2891
2892 11 boost::optional<int> EpwDesignCondition::coolingPrevailingCoincidentWindDirection0pt4() const {
2893 11 return m_coolingPrevailingCoincidentWindDirection0pt4;
2894 }
2895
2896 11 boost::optional<double> EpwDesignCondition::coolingDehumidificationDewPoint0pt4() const {
2897 11 return m_coolingDehumidificationDewPoint0pt4;
2898 }
2899
2900 11 boost::optional<double> EpwDesignCondition::coolingDehumidificationHumidityRatio0pt4() const {
2901 11 return m_coolingDehumidificationHumidityRatio0pt4;
2902 }
2903
2904 11 boost::optional<double> EpwDesignCondition::coolingDehumidificationMeanCoincidentDryBulb0pt4() const {
2905 11 return m_coolingDehumidificationMeanCoincidentDryBulb0pt4;
2906 }
2907
2908 11 boost::optional<double> EpwDesignCondition::coolingDehumidificationDewPoint1() const {
2909 11 return m_coolingDehumidificationDewPoint1;
2910 }
2911
2912 11 boost::optional<double> EpwDesignCondition::coolingDehumidificationHumidityRatio1() const {
2913 11 return m_coolingDehumidificationHumidityRatio1;
2914 }
2915
2916 11 boost::optional<double> EpwDesignCondition::coolingDehumidificationMeanCoincidentDryBulb1() const {
2917 11 return m_coolingDehumidificationMeanCoincidentDryBulb1;
2918 }
2919
2920 12 boost::optional<double> EpwDesignCondition::coolingDehumidificationDewPoint2() const {
2921 12 return m_coolingDehumidificationDewPoint2;
2922 }
2923
2924 11 boost::optional<double> EpwDesignCondition::coolingDehumidificationHumidityRatio2() const {
2925 11 return m_coolingDehumidificationHumidityRatio2;
2926 }
2927
2928 12 boost::optional<double> EpwDesignCondition::coolingDehumidificationMeanCoincidentDryBulb2() const {
2929 12 return m_coolingDehumidificationMeanCoincidentDryBulb2;
2930 }
2931
2932 11 boost::optional<double> EpwDesignCondition::coolingEnthalpy0pt4() const {
2933 11 return m_coolingEnthalpy0pt4;
2934 }
2935
2936 11 boost::optional<double> EpwDesignCondition::coolingEnthalpyMeanCoincidentDryBulb0pt4() const {
2937 11 return m_coolingEnthalpyMeanCoincidentDryBulb0pt4;
2938 }
2939
2940 11 boost::optional<double> EpwDesignCondition::coolingEnthalpy1() const {
2941 11 return m_coolingEnthalpy1;
2942 }
2943
2944 11 boost::optional<double> EpwDesignCondition::coolingEnthalpyMeanCoincidentDryBulb1() const {
2945 11 return m_coolingEnthalpyMeanCoincidentDryBulb1;
2946 }
2947
2948 11 boost::optional<double> EpwDesignCondition::coolingEnthalpy2() const {
2949 11 return m_coolingEnthalpy2;
2950 }
2951
2952 11 boost::optional<double> EpwDesignCondition::coolingEnthalpyMeanCoincidentDryBulb2() const {
2953 11 return m_coolingEnthalpyMeanCoincidentDryBulb2;
2954 }
2955
2956 13 boost::optional<int> EpwDesignCondition::coolingHours8To4AndDryBulb12pt8To20pt6() const {
2957 13 return m_coolingHours8To4AndDryBulb12pt8To20pt6;
2958 }
2959
2960 14 boost::optional<double> EpwDesignCondition::coolingExtremeMaxWetBulb() const {
2961 14 return m_extremeMaxWetBulb;
2962 }
2963
2964 11 boost::optional<double> EpwDesignCondition::extremeWindSpeed1() const {
2965 11 return m_extremeWindSpeed1;
2966 }
2967
2968 11 boost::optional<double> EpwDesignCondition::extremeWindSpeed2pt5() const {
2969 11 return m_extremeWindSpeed2pt5;
2970 }
2971
2972 11 boost::optional<double> EpwDesignCondition::extremeWindSpeed5() const {
2973 11 return m_extremeWindSpeed5;
2974 }
2975
2976 18 boost::optional<double> EpwDesignCondition::extremeMaxWetBulb() const {
2977 18 return m_extremeMaxWetBulb;
2978 }
2979
2980 11 boost::optional<double> EpwDesignCondition::extremeMeanMinDryBulb() const {
2981 11 return m_extremeMeanMinDryBulb;
2982 }
2983
2984 11 boost::optional<double> EpwDesignCondition::extremeMeanMaxDryBulb() const {
2985 11 return m_extremeMeanMaxDryBulb;
2986 }
2987
2988 11 boost::optional<double> EpwDesignCondition::extremeStdDevMinDryBulb() const {
2989 11 return m_extremeStdDevMinDryBulb;
2990 }
2991
2992 11 boost::optional<double> EpwDesignCondition::extremeStdDevMaxDryBulb() const {
2993 11 return m_extremeStdDevMaxDryBulb;
2994 }
2995
2996 11 boost::optional<double> EpwDesignCondition::extremeN5YearsMinDryBulb() const {
2997 11 return m_extremeN5YearsMinDryBulb;
2998 }
2999
3000 11 boost::optional<double> EpwDesignCondition::extremeN5YearsMaxDryBulb() const {
3001 11 return m_extremeN5YearsMaxDryBulb;
3002 }
3003
3004 11 boost::optional<double> EpwDesignCondition::extremeN10YearsMinDryBulb() const {
3005 11 return m_extremeN10YearsMinDryBulb;
3006 }
3007
3008 11 boost::optional<double> EpwDesignCondition::extremeN10YearsMaxDryBulb() const {
3009 11 return m_extremeN10YearsMaxDryBulb;
3010 }
3011
3012 11 boost::optional<double> EpwDesignCondition::extremeN20YearsMinDryBulb() const {
3013 11 return m_extremeN20YearsMinDryBulb;
3014 }
3015
3016 11 boost::optional<double> EpwDesignCondition::extremeN20YearsMaxDryBulb() const {
3017 11 return m_extremeN20YearsMaxDryBulb;
3018 }
3019
3020 11 boost::optional<double> EpwDesignCondition::extremeN50YearsMinDryBulb() const {
3021 11 return m_extremeN50YearsMinDryBulb;
3022 }
3023
3024 11 boost::optional<double> EpwDesignCondition::extremeN50YearsMaxDryBulb() const {
3025 11 return m_extremeN50YearsMaxDryBulb;
3026 }
3027
3028 59 void EpwDesignCondition::setTitleOfDesignCondition(const std::string& titleOfDesignCondition) {
3029 59 m_titleOfDesignCondition = titleOfDesignCondition;
3030 59 }
3031
3032 57 bool EpwDesignCondition::setHeatingColdestMonth(const std::string& heatingColdestMonth) {
3033 bool ok;
3034
1/1
✓ Branch 1 taken 57 times.
57 int value = stringToInteger(heatingColdestMonth, &ok);
3035
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3036 1 m_heatingColdestMonth = boost::none;
3037 } else {
3038
1/1
✓ Branch 1 taken 56 times.
56 setHeatingColdestMonth(value);
3039 }
3040 57 return ok;
3041 }
3042
3043 56 void EpwDesignCondition::setHeatingColdestMonth(int heatingColdestMonth) {
3044 56 m_heatingColdestMonth = heatingColdestMonth;
3045 56 }
3046
3047 57 bool EpwDesignCondition::setHeatingDryBulb99pt6(const std::string& heatingDryBulb99pt6) {
3048 bool ok;
3049
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(heatingDryBulb99pt6, &ok);
3050
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3051 1 m_heatingDryBulb99pt6 = boost::none;
3052 } else {
3053
1/1
✓ Branch 1 taken 56 times.
56 setHeatingDryBulb99pt6(value);
3054 }
3055 57 return ok;
3056 }
3057
3058 56 void EpwDesignCondition::setHeatingDryBulb99pt6(double heatingDryBulb99pt6) {
3059 56 m_heatingDryBulb99pt6 = heatingDryBulb99pt6;
3060 56 }
3061
3062 57 bool EpwDesignCondition::setHeatingDryBulb99(const std::string& heatingDryBulb99) {
3063 bool ok;
3064
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(heatingDryBulb99, &ok);
3065
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3066 1 m_heatingDryBulb99 = boost::none;
3067 } else {
3068
1/1
✓ Branch 1 taken 56 times.
56 setHeatingDryBulb99(value);
3069 }
3070 57 return ok;
3071 }
3072
3073 56 void EpwDesignCondition::setHeatingDryBulb99(double heatingDryBulb99) {
3074 56 m_heatingDryBulb99 = heatingDryBulb99;
3075 56 }
3076
3077 57 bool EpwDesignCondition::setHeatingHumidificationDewPoint99pt6(const std::string& heatingHumidificationDewPoint99pt6) {
3078 bool ok;
3079
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(heatingHumidificationDewPoint99pt6, &ok);
3080
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3081 1 m_heatingHumidificationDewPoint99pt6 = boost::none;
3082 } else {
3083
1/1
✓ Branch 1 taken 56 times.
56 setHeatingHumidificationDewPoint99pt6(value);
3084 }
3085 57 return ok;
3086 }
3087
3088 56 void EpwDesignCondition::setHeatingHumidificationDewPoint99pt6(double heatingHumidificationDewPoint99pt6) {
3089 56 m_heatingHumidificationDewPoint99pt6 = heatingHumidificationDewPoint99pt6;
3090 56 }
3091
3092 57 bool EpwDesignCondition::setHeatingHumidificationHumidityRatio99pt6(const std::string& heatingHumidificationHumidityRatio99pt6) {
3093 bool ok;
3094
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(heatingHumidificationHumidityRatio99pt6, &ok);
3095
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3096 1 m_heatingHumidificationHumidityRatio99pt6 = boost::none;
3097 } else {
3098
1/1
✓ Branch 1 taken 56 times.
56 setHeatingHumidificationHumidityRatio99pt6(value);
3099 }
3100 57 return ok;
3101 }
3102
3103 56 void EpwDesignCondition::setHeatingHumidificationHumidityRatio99pt6(double heatingHumidificationHumidityRatio99pt6) {
3104 56 m_heatingHumidificationHumidityRatio99pt6 = heatingHumidificationHumidityRatio99pt6;
3105 56 }
3106
3107 57 bool EpwDesignCondition::setHeatingHumidificationMeanCoincidentDryBulb99pt6(const std::string& heatingHumidificationMeanCoincidentDryBulb99pt6) {
3108 bool ok;
3109
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(heatingHumidificationMeanCoincidentDryBulb99pt6, &ok);
3110
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3111 1 m_heatingHumidificationMeanCoincidentDryBulb99pt6 = boost::none;
3112 } else {
3113
1/1
✓ Branch 1 taken 56 times.
56 setHeatingHumidificationMeanCoincidentDryBulb99pt6(value);
3114 }
3115 57 return ok;
3116 }
3117
3118 56 void EpwDesignCondition::setHeatingHumidificationMeanCoincidentDryBulb99pt6(double heatingHumidificationMeanCoincidentDryBulb99pt6) {
3119 56 m_heatingHumidificationMeanCoincidentDryBulb99pt6 = heatingHumidificationMeanCoincidentDryBulb99pt6;
3120 56 }
3121
3122 57 bool EpwDesignCondition::setHeatingHumidificationDewPoint99(const std::string& heatingHumidificationDewPoint99) {
3123 bool ok;
3124
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(heatingHumidificationDewPoint99, &ok);
3125
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3126 1 m_heatingHumidificationDewPoint99 = boost::none;
3127 } else {
3128
1/1
✓ Branch 1 taken 56 times.
56 setHeatingHumidificationDewPoint99(value);
3129 }
3130 57 return ok;
3131 }
3132
3133 56 void EpwDesignCondition::setHeatingHumidificationDewPoint99(double heatingHumidificationDewPoint99) {
3134 56 m_heatingHumidificationDewPoint99 = heatingHumidificationDewPoint99;
3135 56 }
3136
3137 57 bool EpwDesignCondition::setHeatingHumidificationHumidityRatio99(const std::string& heatingHumidificationHumidityRatio99) {
3138 bool ok;
3139
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(heatingHumidificationHumidityRatio99, &ok);
3140
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3141 1 m_heatingHumidificationHumidityRatio99 = boost::none;
3142 } else {
3143
1/1
✓ Branch 1 taken 56 times.
56 setHeatingHumidificationHumidityRatio99(value);
3144 }
3145 57 return ok;
3146 }
3147
3148 56 void EpwDesignCondition::setHeatingHumidificationHumidityRatio99(double heatingHumidificationHumidityRatio99) {
3149 56 m_heatingHumidificationHumidityRatio99 = heatingHumidificationHumidityRatio99;
3150 56 }
3151
3152 57 bool EpwDesignCondition::setHeatingHumidificationMeanCoincidentDryBulb99(const std::string& heatingHumidificationMeanCoincidentDryBulb99) {
3153 bool ok;
3154
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(heatingHumidificationMeanCoincidentDryBulb99, &ok);
3155
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3156 1 m_heatingHumidificationMeanCoincidentDryBulb99 = boost::none;
3157 } else {
3158
1/1
✓ Branch 1 taken 56 times.
56 setHeatingHumidificationMeanCoincidentDryBulb99(value);
3159 }
3160 57 return ok;
3161 }
3162
3163 56 void EpwDesignCondition::setHeatingHumidificationMeanCoincidentDryBulb99(double heatingHumidificationMeanCoincidentDryBulb99) {
3164 56 m_heatingHumidificationMeanCoincidentDryBulb99 = heatingHumidificationMeanCoincidentDryBulb99;
3165 56 }
3166
3167 57 bool EpwDesignCondition::setHeatingColdestMonthWindSpeed0pt4(const std::string& heatingColdestMonthWindSpeed0pt4) {
3168 bool ok;
3169
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(heatingColdestMonthWindSpeed0pt4, &ok);
3170
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3171 1 m_heatingColdestMonthWindSpeed0pt4 = boost::none;
3172 } else {
3173
1/1
✓ Branch 1 taken 56 times.
56 setHeatingColdestMonthWindSpeed0pt4(value);
3174 }
3175 57 return ok;
3176 }
3177
3178 56 void EpwDesignCondition::setHeatingColdestMonthWindSpeed0pt4(double heatingColdestMonthWindSpeed0pt4) {
3179 56 m_heatingColdestMonthWindSpeed0pt4 = heatingColdestMonthWindSpeed0pt4;
3180 56 }
3181
3182 57 bool EpwDesignCondition::setHeatingColdestMonthMeanCoincidentDryBulb0pt4(const std::string& heatingColdestMonthMeanCoincidentDryBulb0pt4) {
3183 bool ok;
3184
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(heatingColdestMonthMeanCoincidentDryBulb0pt4, &ok);
3185
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3186 1 m_heatingColdestMonthMeanCoincidentDryBulb0pt4 = boost::none;
3187 } else {
3188
1/1
✓ Branch 1 taken 56 times.
56 setHeatingColdestMonthMeanCoincidentDryBulb0pt4(value);
3189 }
3190 57 return ok;
3191 }
3192
3193 56 void EpwDesignCondition::setHeatingColdestMonthMeanCoincidentDryBulb0pt4(double heatingColdestMonthMeanCoincidentDryBulb0pt4) {
3194 56 m_heatingColdestMonthMeanCoincidentDryBulb0pt4 = heatingColdestMonthMeanCoincidentDryBulb0pt4;
3195 56 }
3196
3197 57 bool EpwDesignCondition::setHeatingColdestMonthWindSpeed1(const std::string& heatingColdestMonthWindSpeed1) {
3198 bool ok;
3199
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(heatingColdestMonthWindSpeed1, &ok);
3200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
57 if (!ok) {
3201 ✗ m_heatingColdestMonthWindSpeed1 = boost::none;
3202 } else {
3203
1/1
✓ Branch 1 taken 57 times.
57 setHeatingColdestMonthWindSpeed1(value);
3204 }
3205 57 return ok;
3206 }
3207
3208 57 void EpwDesignCondition::setHeatingColdestMonthWindSpeed1(double heatingColdestMonthWindSpeed1) {
3209 57 m_heatingColdestMonthWindSpeed1 = heatingColdestMonthWindSpeed1;
3210 57 }
3211
3212 57 bool EpwDesignCondition::setHeatingColdestMonthMeanCoincidentDryBulb1(const std::string& heatingColdestMonthMeanCoincidentDryBulb1) {
3213 bool ok;
3214
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(heatingColdestMonthMeanCoincidentDryBulb1, &ok);
3215
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3216 1 m_heatingColdestMonthMeanCoincidentDryBulb1 = boost::none;
3217 } else {
3218
1/1
✓ Branch 1 taken 56 times.
56 setHeatingColdestMonthMeanCoincidentDryBulb1(value);
3219 }
3220 57 return ok;
3221 }
3222
3223 56 void EpwDesignCondition::setHeatingColdestMonthMeanCoincidentDryBulb1(double heatingColdestMonthMeanCoincidentDryBulb1) {
3224 56 m_heatingColdestMonthMeanCoincidentDryBulb1 = heatingColdestMonthMeanCoincidentDryBulb1;
3225 56 }
3226
3227 57 bool EpwDesignCondition::setHeatingMeanCoincidentWindSpeed99pt6(const std::string& heatingMeanCoincidentWindSpeed99pt6) {
3228 bool ok;
3229
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(heatingMeanCoincidentWindSpeed99pt6, &ok);
3230
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3231 1 m_heatingMeanCoincidentWindSpeed99pt6 = boost::none;
3232 } else {
3233
1/1
✓ Branch 1 taken 56 times.
56 setHeatingMeanCoincidentWindSpeed99pt6(value);
3234 }
3235 57 return ok;
3236 }
3237
3238 56 void EpwDesignCondition::setHeatingMeanCoincidentWindSpeed99pt6(double heatingMeanCoincidentWindSpeed99pt6) {
3239 56 m_heatingMeanCoincidentWindSpeed99pt6 = heatingMeanCoincidentWindSpeed99pt6;
3240 56 }
3241
3242 57 bool EpwDesignCondition::setHeatingPrevailingCoincidentWindDirection99pt6(const std::string& heatingPrevailingCoincidentWindDirection99pt6) {
3243 bool ok;
3244
1/1
✓ Branch 1 taken 57 times.
57 int value = stringToInteger(heatingPrevailingCoincidentWindDirection99pt6, &ok);
3245
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3246 1 m_heatingPrevailingCoincidentWindDirection99pt6 = boost::none;
3247 } else {
3248
1/1
✓ Branch 1 taken 56 times.
56 setHeatingPrevailingCoincidentWindDirection99pt6(value);
3249 }
3250 57 return ok;
3251 }
3252
3253 56 void EpwDesignCondition::setHeatingPrevailingCoincidentWindDirection99pt6(int heatingPrevailingCoincidentWindDirection99pt6) {
3254 56 m_heatingPrevailingCoincidentWindDirection99pt6 = heatingPrevailingCoincidentWindDirection99pt6;
3255 56 }
3256
3257 4 bool EpwDesignCondition::setHeatingWindShelterFactor(const std::string& heatingWindShelterFactor) {
3258 bool ok;
3259
1/1
✓ Branch 1 taken 4 times.
4 double value = stringToDouble(heatingWindShelterFactor, &ok);
3260
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!ok) {
3261 ✗ m_heatingWindShelterFactor = boost::none;
3262 } else {
3263
1/1
✓ Branch 1 taken 4 times.
4 setHeatingWindShelterFactor(value);
3264 }
3265 4 return ok;
3266 }
3267
3268 4 void EpwDesignCondition::setHeatingWindShelterFactor(double heatingWindShelterFactor) {
3269 4 m_heatingWindShelterFactor = heatingWindShelterFactor;
3270 4 }
3271
3272 57 bool EpwDesignCondition::setCoolingHottestMonth(const std::string& coolingHottestMonth) {
3273 bool ok;
3274
1/1
✓ Branch 1 taken 57 times.
57 int value = stringToInteger(coolingHottestMonth, &ok);
3275
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3276 1 m_coolingHottestMonth = boost::none;
3277 } else {
3278
1/1
✓ Branch 1 taken 56 times.
56 setCoolingHottestMonth(value);
3279 }
3280 57 return ok;
3281 }
3282
3283 56 void EpwDesignCondition::setCoolingHottestMonth(int coolingHottestMonth) {
3284 56 m_coolingHottestMonth = coolingHottestMonth;
3285 56 }
3286
3287 57 bool EpwDesignCondition::setCoolingDryBulbRange(const std::string& coolingDryBulbRange) {
3288 bool ok;
3289
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(coolingDryBulbRange, &ok);
3290
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
57 if (!ok) {
3291 ✗ m_coolingDryBulbRange = boost::none;
3292 } else {
3293
1/1
✓ Branch 1 taken 57 times.
57 setCoolingDryBulbRange(value);
3294 }
3295 57 return ok;
3296 }
3297
3298 57 void EpwDesignCondition::setCoolingDryBulbRange(double coolingDryBulbRange) {
3299 57 m_coolingDryBulbRange = coolingDryBulbRange;
3300 57 }
3301
3302 57 bool EpwDesignCondition::setCoolingDryBulb0pt4(const std::string& coolingDryBulb0pt4) {
3303 bool ok;
3304
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(coolingDryBulb0pt4, &ok);
3305
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3306 1 m_coolingDryBulb0pt4 = boost::none;
3307 } else {
3308
1/1
✓ Branch 1 taken 56 times.
56 setCoolingDryBulb0pt4(value);
3309 }
3310 57 return ok;
3311 }
3312
3313 56 void EpwDesignCondition::setCoolingDryBulb0pt4(double coolingDryBulb0pt4) {
3314 56 m_coolingDryBulb0pt4 = coolingDryBulb0pt4;
3315 56 }
3316
3317 57 bool EpwDesignCondition::setCoolingMeanCoincidentWetBulb0pt4(const std::string& coolingMeanCoincidentWetBulb0pt4) {
3318 bool ok;
3319
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(coolingMeanCoincidentWetBulb0pt4, &ok);
3320
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3321 1 m_coolingMeanCoincidentWetBulb0pt4 = boost::none;
3322 } else {
3323
1/1
✓ Branch 1 taken 56 times.
56 setCoolingMeanCoincidentWetBulb0pt4(value);
3324 }
3325 57 return ok;
3326 }
3327
3328 56 void EpwDesignCondition::setCoolingMeanCoincidentWetBulb0pt4(double coolingMeanCoincidentWetBulb0pt4) {
3329 56 m_coolingMeanCoincidentWetBulb0pt4 = coolingMeanCoincidentWetBulb0pt4;
3330 56 }
3331
3332 57 bool EpwDesignCondition::setCoolingDryBulb1(const std::string& coolingDryBulb1) {
3333 bool ok;
3334
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(coolingDryBulb1, &ok);
3335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
57 if (!ok) {
3336 ✗ m_coolingDryBulb1 = boost::none;
3337 } else {
3338
1/1
✓ Branch 1 taken 57 times.
57 setCoolingDryBulb1(value);
3339 }
3340 57 return ok;
3341 }
3342
3343 57 void EpwDesignCondition::setCoolingDryBulb1(double coolingDryBulb1) {
3344 57 m_coolingDryBulb1 = coolingDryBulb1;
3345 57 }
3346
3347 57 bool EpwDesignCondition::setCoolingMeanCoincidentWetBulb1(const std::string& coolingMeanCoincidentWetBulb1) {
3348 bool ok;
3349
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(coolingMeanCoincidentWetBulb1, &ok);
3350
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
57 if (!ok) {
3351 ✗ m_coolingMeanCoincidentWetBulb1 = boost::none;
3352 } else {
3353
1/1
✓ Branch 1 taken 57 times.
57 setCoolingMeanCoincidentWetBulb1(value);
3354 }
3355 57 return ok;
3356 }
3357
3358 57 void EpwDesignCondition::setCoolingMeanCoincidentWetBulb1(double coolingMeanCoincidentWetBulb1) {
3359 57 m_coolingMeanCoincidentWetBulb1 = coolingMeanCoincidentWetBulb1;
3360 57 }
3361
3362 57 bool EpwDesignCondition::setCoolingDryBulb2(const std::string& coolingDryBulb2) {
3363 bool ok;
3364
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(coolingDryBulb2, &ok);
3365
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3366 1 m_coolingDryBulb2 = boost::none;
3367 } else {
3368
1/1
✓ Branch 1 taken 56 times.
56 setCoolingDryBulb2(value);
3369 }
3370 57 return ok;
3371 }
3372
3373 56 void EpwDesignCondition::setCoolingDryBulb2(double coolingDryBulb2) {
3374 56 m_coolingDryBulb2 = coolingDryBulb2;
3375 56 }
3376
3377 57 bool EpwDesignCondition::setCoolingMeanCoincidentWetBulb2(const std::string& coolingMeanCoincidentWetBulb2) {
3378 bool ok;
3379
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(coolingMeanCoincidentWetBulb2, &ok);
3380
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3381 1 m_coolingMeanCoincidentWetBulb2 = boost::none;
3382 } else {
3383
1/1
✓ Branch 1 taken 56 times.
56 setCoolingMeanCoincidentWetBulb2(value);
3384 }
3385 57 return ok;
3386 }
3387
3388 56 void EpwDesignCondition::setCoolingMeanCoincidentWetBulb2(double coolingMeanCoincidentWetBulb2) {
3389 56 m_coolingMeanCoincidentWetBulb2 = coolingMeanCoincidentWetBulb2;
3390 56 }
3391
3392 57 bool EpwDesignCondition::setCoolingEvaporationWetBulb0pt4(const std::string& coolingEvaporationWetBulb0pt4) {
3393 bool ok;
3394
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(coolingEvaporationWetBulb0pt4, &ok);
3395
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3396 1 m_coolingEvaporationWetBulb0pt4 = boost::none;
3397 } else {
3398
1/1
✓ Branch 1 taken 56 times.
56 setCoolingEvaporationWetBulb0pt4(value);
3399 }
3400 57 return ok;
3401 }
3402
3403 56 void EpwDesignCondition::setCoolingEvaporationWetBulb0pt4(double coolingEvaporationWetBulb0pt4) {
3404 56 m_coolingEvaporationWetBulb0pt4 = coolingEvaporationWetBulb0pt4;
3405 56 }
3406
3407 57 bool EpwDesignCondition::setCoolingEvaporationMeanCoincidentDryBulb0pt4(const std::string& coolingEvaporationMeanCoincidentDryBulb0pt4) {
3408 bool ok;
3409
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(coolingEvaporationMeanCoincidentDryBulb0pt4, &ok);
3410
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3411 1 m_coolingEvaporationMeanCoincidentDryBulb0pt4 = boost::none;
3412 } else {
3413
1/1
✓ Branch 1 taken 56 times.
56 setCoolingEvaporationMeanCoincidentDryBulb0pt4(value);
3414 }
3415 57 return ok;
3416 }
3417
3418 56 void EpwDesignCondition::setCoolingEvaporationMeanCoincidentDryBulb0pt4(double coolingEvaporationMeanCoincidentDryBulb0pt4) {
3419 56 m_coolingEvaporationMeanCoincidentDryBulb0pt4 = coolingEvaporationMeanCoincidentDryBulb0pt4;
3420 56 }
3421
3422 57 bool EpwDesignCondition::setCoolingEvaporationWetBulb1(const std::string& coolingEvaporationWetBulb1) {
3423 bool ok;
3424
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(coolingEvaporationWetBulb1, &ok);
3425
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3426 1 m_coolingEvaporationWetBulb1 = boost::none;
3427 } else {
3428
1/1
✓ Branch 1 taken 56 times.
56 setCoolingEvaporationWetBulb1(value);
3429 }
3430 57 return ok;
3431 }
3432
3433 56 void EpwDesignCondition::setCoolingEvaporationWetBulb1(double coolingEvaporationWetBulb1) {
3434 56 m_coolingEvaporationWetBulb1 = coolingEvaporationWetBulb1;
3435 56 }
3436
3437 57 bool EpwDesignCondition::setCoolingEvaporationMeanCoincidentDryBulb1(const std::string& coolingEvaporationMeanCoincidentDryBulb1) {
3438 bool ok;
3439
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(coolingEvaporationMeanCoincidentDryBulb1, &ok);
3440
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3441 1 m_coolingEvaporationMeanCoincidentDryBulb1 = boost::none;
3442 } else {
3443
1/1
✓ Branch 1 taken 56 times.
56 setCoolingEvaporationMeanCoincidentDryBulb1(value);
3444 }
3445 57 return ok;
3446 }
3447
3448 56 void EpwDesignCondition::setCoolingEvaporationMeanCoincidentDryBulb1(double coolingEvaporationMeanCoincidentDryBulb1) {
3449 56 m_coolingEvaporationMeanCoincidentDryBulb1 = coolingEvaporationMeanCoincidentDryBulb1;
3450 56 }
3451
3452 57 bool EpwDesignCondition::setCoolingEvaporationWetBulb2(const std::string& coolingEvaporationWetBulb2) {
3453 bool ok;
3454
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(coolingEvaporationWetBulb2, &ok);
3455
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3456 1 m_coolingEvaporationWetBulb2 = boost::none;
3457 } else {
3458
1/1
✓ Branch 1 taken 56 times.
56 setCoolingEvaporationWetBulb2(value);
3459 }
3460 57 return ok;
3461 }
3462
3463 56 void EpwDesignCondition::setCoolingEvaporationWetBulb2(double coolingEvaporationWetBulb2) {
3464 56 m_coolingEvaporationWetBulb2 = coolingEvaporationWetBulb2;
3465 56 }
3466
3467 57 bool EpwDesignCondition::setCoolingEvaporationMeanCoincidentDryBulb2(const std::string& coolingEvaporationMeanCoincidentDryBulb2) {
3468 bool ok;
3469
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(coolingEvaporationMeanCoincidentDryBulb2, &ok);
3470
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3471 1 m_coolingEvaporationMeanCoincidentDryBulb2 = boost::none;
3472 } else {
3473
1/1
✓ Branch 1 taken 56 times.
56 setCoolingEvaporationMeanCoincidentDryBulb2(value);
3474 }
3475 57 return ok;
3476 }
3477
3478 56 void EpwDesignCondition::setCoolingEvaporationMeanCoincidentDryBulb2(double coolingEvaporationMeanCoincidentDryBulb2) {
3479 56 m_coolingEvaporationMeanCoincidentDryBulb2 = coolingEvaporationMeanCoincidentDryBulb2;
3480 56 }
3481
3482 57 bool EpwDesignCondition::setCoolingMeanCoincidentWindSpeed0pt4(const std::string& coolingMeanCoincidentWindSpeed0pt4) {
3483 bool ok;
3484
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(coolingMeanCoincidentWindSpeed0pt4, &ok);
3485
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
57 if (!ok) {
3486 ✗ m_coolingMeanCoincidentWindSpeed0pt4 = boost::none;
3487 } else {
3488
1/1
✓ Branch 1 taken 57 times.
57 setCoolingMeanCoincidentWindSpeed0pt4(value);
3489 }
3490 57 return ok;
3491 }
3492
3493 57 void EpwDesignCondition::setCoolingMeanCoincidentWindSpeed0pt4(double coolingMeanCoincidentWindSpeed0pt4) {
3494 57 m_coolingMeanCoincidentWindSpeed0pt4 = coolingMeanCoincidentWindSpeed0pt4;
3495 57 }
3496
3497 57 bool EpwDesignCondition::setCoolingPrevailingCoincidentWindDirection0pt4(const std::string& coolingPrevailingCoincidentWindDirection0pt4) {
3498 bool ok;
3499
1/1
✓ Branch 1 taken 57 times.
57 int value = stringToInteger(coolingPrevailingCoincidentWindDirection0pt4, &ok);
3500
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3501 1 m_coolingPrevailingCoincidentWindDirection0pt4 = boost::none;
3502 } else {
3503
1/1
✓ Branch 1 taken 56 times.
56 setCoolingPrevailingCoincidentWindDirection0pt4(value);
3504 }
3505 57 return ok;
3506 }
3507
3508 56 void EpwDesignCondition::setCoolingPrevailingCoincidentWindDirection0pt4(int coolingPrevailingCoincidentWindDirection0pt4) {
3509 56 m_coolingPrevailingCoincidentWindDirection0pt4 = coolingPrevailingCoincidentWindDirection0pt4;
3510 56 }
3511
3512 57 bool EpwDesignCondition::setCoolingDehumidificationDewPoint0pt4(const std::string& coolingDehumidificationDewPoint0pt4) {
3513 bool ok;
3514
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(coolingDehumidificationDewPoint0pt4, &ok);
3515
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3516 1 m_coolingDehumidificationDewPoint0pt4 = boost::none;
3517 } else {
3518
1/1
✓ Branch 1 taken 56 times.
56 setCoolingDehumidificationDewPoint0pt4(value);
3519 }
3520 57 return ok;
3521 }
3522
3523 56 void EpwDesignCondition::setCoolingDehumidificationDewPoint0pt4(double coolingDehumidificationDewPoint0pt4) {
3524 56 m_coolingDehumidificationDewPoint0pt4 = coolingDehumidificationDewPoint0pt4;
3525 56 }
3526
3527 57 bool EpwDesignCondition::setCoolingDehumidificationHumidityRatio0pt4(const std::string& coolingDehumidificationHumidityRatio0pt4) {
3528 bool ok;
3529
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(coolingDehumidificationHumidityRatio0pt4, &ok);
3530
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3531 1 m_coolingDehumidificationHumidityRatio0pt4 = boost::none;
3532 } else {
3533
1/1
✓ Branch 1 taken 56 times.
56 setCoolingDehumidificationHumidityRatio0pt4(value);
3534 }
3535 57 return ok;
3536 }
3537
3538 56 void EpwDesignCondition::setCoolingDehumidificationHumidityRatio0pt4(double coolingDehumidificationHumidityRatio0pt4) {
3539 56 m_coolingDehumidificationHumidityRatio0pt4 = coolingDehumidificationHumidityRatio0pt4;
3540 56 }
3541
3542 57 bool EpwDesignCondition::setCoolingDehumidificationMeanCoincidentDryBulb0pt4(const std::string& coolingDehumidificationMeanCoincidentDryBulb0pt4) {
3543 bool ok;
3544
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(coolingDehumidificationMeanCoincidentDryBulb0pt4, &ok);
3545
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3546 1 m_coolingDehumidificationMeanCoincidentDryBulb0pt4 = boost::none;
3547 } else {
3548
1/1
✓ Branch 1 taken 56 times.
56 setCoolingDehumidificationMeanCoincidentDryBulb0pt4(value);
3549 }
3550 57 return ok;
3551 }
3552
3553 56 void EpwDesignCondition::setCoolingDehumidificationMeanCoincidentDryBulb0pt4(double coolingDehumidificationMeanCoincidentDryBulb0pt4) {
3554 56 m_coolingDehumidificationMeanCoincidentDryBulb0pt4 = coolingDehumidificationMeanCoincidentDryBulb0pt4;
3555 56 }
3556
3557 57 bool EpwDesignCondition::setCoolingDehumidificationDewPoint1(const std::string& coolingDehumidificationDewPoint1) {
3558 bool ok;
3559
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(coolingDehumidificationDewPoint1, &ok);
3560
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3561 1 m_coolingDehumidificationDewPoint1 = boost::none;
3562 } else {
3563
1/1
✓ Branch 1 taken 56 times.
56 setCoolingDehumidificationDewPoint1(value);
3564 }
3565 57 return ok;
3566 }
3567
3568 56 void EpwDesignCondition::setCoolingDehumidificationDewPoint1(double coolingDehumidificationDewPoint1) {
3569 56 m_coolingDehumidificationDewPoint1 = coolingDehumidificationDewPoint1;
3570 56 }
3571
3572 57 bool EpwDesignCondition::setCoolingDehumidificationHumidityRatio1(const std::string& coolingDehumidificationHumidityRatio1) {
3573 bool ok;
3574
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(coolingDehumidificationHumidityRatio1, &ok);
3575
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3576 1 m_coolingDehumidificationHumidityRatio1 = boost::none;
3577 } else {
3578
1/1
✓ Branch 1 taken 56 times.
56 setCoolingDehumidificationHumidityRatio1(value);
3579 }
3580 57 return ok;
3581 }
3582
3583 56 void EpwDesignCondition::setCoolingDehumidificationHumidityRatio1(double coolingDehumidificationHumidityRatio1) {
3584 56 m_coolingDehumidificationHumidityRatio1 = coolingDehumidificationHumidityRatio1;
3585 56 }
3586
3587 57 bool EpwDesignCondition::setCoolingDehumidificationMeanCoincidentDryBulb1(const std::string& coolingDehumidificationMeanCoincidentDryBulb1) {
3588 bool ok;
3589
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(coolingDehumidificationMeanCoincidentDryBulb1, &ok);
3590
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3591 1 m_coolingDehumidificationMeanCoincidentDryBulb1 = boost::none;
3592 } else {
3593
1/1
✓ Branch 1 taken 56 times.
56 setCoolingDehumidificationMeanCoincidentDryBulb1(value);
3594 }
3595 57 return ok;
3596 }
3597
3598 56 void EpwDesignCondition::setCoolingDehumidificationMeanCoincidentDryBulb1(double coolingDehumidificationMeanCoincidentDryBulb1) {
3599 56 m_coolingDehumidificationMeanCoincidentDryBulb1 = coolingDehumidificationMeanCoincidentDryBulb1;
3600 56 }
3601
3602 57 bool EpwDesignCondition::setCoolingDehumidificationDewPoint2(const std::string& coolingDehumidificationDewPoint2) {
3603 bool ok;
3604
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(coolingDehumidificationDewPoint2, &ok);
3605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
57 if (!ok) {
3606 ✗ m_coolingDehumidificationDewPoint2 = boost::none;
3607 } else {
3608
1/1
✓ Branch 1 taken 57 times.
57 setCoolingDehumidificationDewPoint2(value);
3609 }
3610 57 return ok;
3611 }
3612
3613 57 void EpwDesignCondition::setCoolingDehumidificationDewPoint2(double coolingDehumidificationDewPoint2) {
3614 57 m_coolingDehumidificationDewPoint2 = coolingDehumidificationDewPoint2;
3615 57 }
3616
3617 57 bool EpwDesignCondition::setCoolingDehumidificationHumidityRatio2(const std::string& coolingDehumidificationHumidityRatio2) {
3618 bool ok;
3619
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(coolingDehumidificationHumidityRatio2, &ok);
3620
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3621 1 m_coolingDehumidificationHumidityRatio2 = boost::none;
3622 } else {
3623
1/1
✓ Branch 1 taken 56 times.
56 setCoolingDehumidificationHumidityRatio2(value);
3624 }
3625 57 return ok;
3626 }
3627
3628 56 void EpwDesignCondition::setCoolingDehumidificationHumidityRatio2(double coolingDehumidificationHumidityRatio2) {
3629 56 m_coolingDehumidificationHumidityRatio2 = coolingDehumidificationHumidityRatio2;
3630 56 }
3631
3632 57 bool EpwDesignCondition::setCoolingDehumidificationMeanCoincidentDryBulb2(const std::string& coolingDehumidificationMeanCoincidentDryBulb2) {
3633 bool ok;
3634
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(coolingDehumidificationMeanCoincidentDryBulb2, &ok);
3635
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
57 if (!ok) {
3636 ✗ m_coolingDehumidificationMeanCoincidentDryBulb2 = boost::none;
3637 } else {
3638
1/1
✓ Branch 1 taken 57 times.
57 setCoolingDehumidificationMeanCoincidentDryBulb2(value);
3639 }
3640 57 return ok;
3641 }
3642
3643 57 void EpwDesignCondition::setCoolingDehumidificationMeanCoincidentDryBulb2(double coolingDehumidificationMeanCoincidentDryBulb2) {
3644 57 m_coolingDehumidificationMeanCoincidentDryBulb2 = coolingDehumidificationMeanCoincidentDryBulb2;
3645 57 }
3646
3647 57 bool EpwDesignCondition::setCoolingEnthalpy0pt4(const std::string& coolingEnthalpy0pt4) {
3648 bool ok;
3649
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(coolingEnthalpy0pt4, &ok);
3650
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3651 1 m_coolingEnthalpy0pt4 = boost::none;
3652 } else {
3653
1/1
✓ Branch 1 taken 56 times.
56 setCoolingEnthalpy0pt4(value);
3654 }
3655 57 return ok;
3656 }
3657
3658 56 void EpwDesignCondition::setCoolingEnthalpy0pt4(double coolingEnthalpy0pt4) {
3659 56 m_coolingEnthalpy0pt4 = coolingEnthalpy0pt4;
3660 56 }
3661
3662 57 bool EpwDesignCondition::setCoolingEnthalpyMeanCoincidentDryBulb0pt4(const std::string& coolingEnthalpyMeanCoincidentDryBulb0pt4) {
3663 bool ok;
3664
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(coolingEnthalpyMeanCoincidentDryBulb0pt4, &ok);
3665
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3666 1 m_coolingEnthalpyMeanCoincidentDryBulb0pt4 = boost::none;
3667 } else {
3668
1/1
✓ Branch 1 taken 56 times.
56 setCoolingEnthalpyMeanCoincidentDryBulb0pt4(value);
3669 }
3670 57 return ok;
3671 }
3672
3673 56 void EpwDesignCondition::setCoolingEnthalpyMeanCoincidentDryBulb0pt4(double coolingEnthalpyMeanCoincidentDryBulb0pt4) {
3674 56 m_coolingEnthalpyMeanCoincidentDryBulb0pt4 = coolingEnthalpyMeanCoincidentDryBulb0pt4;
3675 56 }
3676
3677 57 bool EpwDesignCondition::setCoolingEnthalpy1(const std::string& coolingEnthalpy1) {
3678 bool ok;
3679
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(coolingEnthalpy1, &ok);
3680
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3681 1 m_coolingEnthalpy1 = boost::none;
3682 } else {
3683
1/1
✓ Branch 1 taken 56 times.
56 setCoolingEnthalpy1(value);
3684 }
3685 57 return ok;
3686 }
3687
3688 56 void EpwDesignCondition::setCoolingEnthalpy1(double coolingEnthalpy1) {
3689 56 m_coolingEnthalpy1 = coolingEnthalpy1;
3690 56 }
3691
3692 57 bool EpwDesignCondition::setCoolingEnthalpyMeanCoincidentDryBulb1(const std::string& coolingEnthalpyMeanCoincidentDryBulb1) {
3693 bool ok;
3694
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(coolingEnthalpyMeanCoincidentDryBulb1, &ok);
3695
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3696 1 m_coolingEnthalpyMeanCoincidentDryBulb1 = boost::none;
3697 } else {
3698
1/1
✓ Branch 1 taken 56 times.
56 setCoolingEnthalpyMeanCoincidentDryBulb1(value);
3699 }
3700 57 return ok;
3701 }
3702
3703 56 void EpwDesignCondition::setCoolingEnthalpyMeanCoincidentDryBulb1(double coolingEnthalpyMeanCoincidentDryBulb1) {
3704 56 m_coolingEnthalpyMeanCoincidentDryBulb1 = coolingEnthalpyMeanCoincidentDryBulb1;
3705 56 }
3706
3707 57 bool EpwDesignCondition::setCoolingEnthalpy2(const std::string& coolingEnthalpy2) {
3708 bool ok;
3709
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(coolingEnthalpy2, &ok);
3710
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3711 1 m_coolingEnthalpy2 = boost::none;
3712 } else {
3713
1/1
✓ Branch 1 taken 56 times.
56 setCoolingEnthalpy2(value);
3714 }
3715 57 return ok;
3716 }
3717
3718 56 void EpwDesignCondition::setCoolingEnthalpy2(double coolingEnthalpy2) {
3719 56 m_coolingEnthalpy2 = coolingEnthalpy2;
3720 56 }
3721
3722 57 bool EpwDesignCondition::setCoolingEnthalpyMeanCoincidentDryBulb2(const std::string& coolingEnthalpyMeanCoincidentDryBulb2) {
3723 bool ok;
3724
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(coolingEnthalpyMeanCoincidentDryBulb2, &ok);
3725
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3726 1 m_coolingEnthalpyMeanCoincidentDryBulb2 = boost::none;
3727 } else {
3728
1/1
✓ Branch 1 taken 56 times.
56 setCoolingEnthalpyMeanCoincidentDryBulb2(value);
3729 }
3730 57 return ok;
3731 }
3732
3733 56 void EpwDesignCondition::setCoolingEnthalpyMeanCoincidentDryBulb2(double coolingEnthalpyMeanCoincidentDryBulb2) {
3734 56 m_coolingEnthalpyMeanCoincidentDryBulb2 = coolingEnthalpyMeanCoincidentDryBulb2;
3735 56 }
3736
3737 52 bool EpwDesignCondition::setCoolingHours8To4AndDryBulb12pt8To20pt6(const std::string& coolingHours8To4AndDryBulb12pt8To20pt6) {
3738 bool ok;
3739
1/1
✓ Branch 1 taken 52 times.
52 int value = stringToInteger(coolingHours8To4AndDryBulb12pt8To20pt6, &ok);
3740
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 51 times.
52 if (!ok) {
3741 1 m_coolingHours8To4AndDryBulb12pt8To20pt6 = boost::none;
3742 } else {
3743
1/1
✓ Branch 1 taken 51 times.
51 setCoolingHours8To4AndDryBulb12pt8To20pt6(value);
3744 }
3745 52 return ok;
3746 }
3747
3748 51 void EpwDesignCondition::setCoolingHours8To4AndDryBulb12pt8To20pt6(int coolingHours8To4AndDryBulb12pt8To20pt6) {
3749 51 m_coolingHours8To4AndDryBulb12pt8To20pt6 = coolingHours8To4AndDryBulb12pt8To20pt6;
3750 51 }
3751
3752 57 bool EpwDesignCondition::setExtremeWindSpeed1(const std::string& extremeWindSpeed1) {
3753 bool ok;
3754
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(extremeWindSpeed1, &ok);
3755
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3756 1 m_extremeWindSpeed1 = boost::none;
3757 } else {
3758
1/1
✓ Branch 1 taken 56 times.
56 setExtremeWindSpeed1(value);
3759 }
3760 57 return ok;
3761 }
3762
3763 56 void EpwDesignCondition::setExtremeWindSpeed1(double extremeWindSpeed1) {
3764 56 m_extremeWindSpeed1 = extremeWindSpeed1;
3765 56 }
3766
3767 57 bool EpwDesignCondition::setExtremeWindSpeed2pt5(const std::string& extremeWindSpeed2pt5) {
3768 bool ok;
3769
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(extremeWindSpeed2pt5, &ok);
3770
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3771 1 m_extremeWindSpeed2pt5 = boost::none;
3772 } else {
3773
1/1
✓ Branch 1 taken 56 times.
56 setExtremeWindSpeed2pt5(value);
3774 }
3775 57 return ok;
3776 }
3777
3778 56 void EpwDesignCondition::setExtremeWindSpeed2pt5(double extremeWindSpeed2pt5) {
3779 56 m_extremeWindSpeed2pt5 = extremeWindSpeed2pt5;
3780 56 }
3781
3782 57 bool EpwDesignCondition::setExtremeWindSpeed5(const std::string& extremeWindSpeed5) {
3783 bool ok;
3784
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(extremeWindSpeed5, &ok);
3785
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3786 1 m_extremeWindSpeed5 = boost::none;
3787 } else {
3788
1/1
✓ Branch 1 taken 56 times.
56 setExtremeWindSpeed5(value);
3789 }
3790 57 return ok;
3791 }
3792
3793 56 void EpwDesignCondition::setExtremeWindSpeed5(double extremeWindSpeed5) {
3794 56 m_extremeWindSpeed5 = extremeWindSpeed5;
3795 56 }
3796
3797 57 bool EpwDesignCondition::setExtremeMaxWetBulb(const std::string& extremeMaxWetBulb) {
3798 bool ok;
3799
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(extremeMaxWetBulb, &ok);
3800
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3801 1 m_extremeMaxWetBulb = boost::none;
3802 } else {
3803
1/1
✓ Branch 1 taken 56 times.
56 setExtremeMaxWetBulb(value);
3804 }
3805 57 return ok;
3806 }
3807
3808 56 void EpwDesignCondition::setExtremeMaxWetBulb(double extremeMaxWetBulb) {
3809 56 m_extremeMaxWetBulb = extremeMaxWetBulb;
3810 56 }
3811
3812 57 bool EpwDesignCondition::setExtremeMeanMinDryBulb(const std::string& extremeMeanMinDryBulb) {
3813 bool ok;
3814
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(extremeMeanMinDryBulb, &ok);
3815
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3816 1 m_extremeMeanMinDryBulb = boost::none;
3817 } else {
3818
1/1
✓ Branch 1 taken 56 times.
56 setExtremeMeanMinDryBulb(value);
3819 }
3820 57 return ok;
3821 }
3822
3823 56 void EpwDesignCondition::setExtremeMeanMinDryBulb(double extremeMeanMinDryBulb) {
3824 56 m_extremeMeanMinDryBulb = extremeMeanMinDryBulb;
3825 56 }
3826
3827 57 bool EpwDesignCondition::setExtremeMeanMaxDryBulb(const std::string& extremeMeanMaxDryBulb) {
3828 bool ok;
3829
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(extremeMeanMaxDryBulb, &ok);
3830
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3831 1 m_extremeMeanMaxDryBulb = boost::none;
3832 } else {
3833
1/1
✓ Branch 1 taken 56 times.
56 setExtremeMeanMaxDryBulb(value);
3834 }
3835 57 return ok;
3836 }
3837
3838 56 void EpwDesignCondition::setExtremeMeanMaxDryBulb(double extremeMeanMaxDryBulb) {
3839 56 m_extremeMeanMaxDryBulb = extremeMeanMaxDryBulb;
3840 56 }
3841
3842 57 bool EpwDesignCondition::setExtremeStdDevMinDryBulb(const std::string& extremeStdDevMinDryBulb) {
3843 bool ok;
3844
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(extremeStdDevMinDryBulb, &ok);
3845
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3846 1 m_extremeStdDevMinDryBulb = boost::none;
3847 } else {
3848
1/1
✓ Branch 1 taken 56 times.
56 setExtremeStdDevMinDryBulb(value);
3849 }
3850 57 return ok;
3851 }
3852
3853 56 void EpwDesignCondition::setExtremeStdDevMinDryBulb(double extremeStdDevMinDryBulb) {
3854 56 m_extremeStdDevMinDryBulb = extremeStdDevMinDryBulb;
3855 56 }
3856
3857 57 bool EpwDesignCondition::setExtremeStdDevMaxDryBulb(const std::string& extremeStdDevMaxDryBulb) {
3858 bool ok;
3859
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(extremeStdDevMaxDryBulb, &ok);
3860
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3861 1 m_extremeStdDevMaxDryBulb = boost::none;
3862 } else {
3863
1/1
✓ Branch 1 taken 56 times.
56 setExtremeStdDevMaxDryBulb(value);
3864 }
3865 57 return ok;
3866 }
3867
3868 56 void EpwDesignCondition::setExtremeStdDevMaxDryBulb(double extremeStdDevMaxDryBulb) {
3869 56 m_extremeStdDevMaxDryBulb = extremeStdDevMaxDryBulb;
3870 56 }
3871
3872 57 bool EpwDesignCondition::setExtremeN5YearsMinDryBulb(const std::string& extremeN5YearsMinDryBulb) {
3873 bool ok;
3874
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(extremeN5YearsMinDryBulb, &ok);
3875
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3876 1 m_extremeN5YearsMinDryBulb = boost::none;
3877 } else {
3878
1/1
✓ Branch 1 taken 56 times.
56 setExtremeN5YearsMinDryBulb(value);
3879 }
3880 57 return ok;
3881 }
3882
3883 56 void EpwDesignCondition::setExtremeN5YearsMinDryBulb(double extremeN5YearsMinDryBulb) {
3884 56 m_extremeN5YearsMinDryBulb = extremeN5YearsMinDryBulb;
3885 56 }
3886
3887 57 bool EpwDesignCondition::setExtremeN5YearsMaxDryBulb(const std::string& extremeN5YearsMaxDryBulb) {
3888 bool ok;
3889
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(extremeN5YearsMaxDryBulb, &ok);
3890
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3891 1 m_extremeN5YearsMaxDryBulb = boost::none;
3892 } else {
3893
1/1
✓ Branch 1 taken 56 times.
56 setExtremeN5YearsMaxDryBulb(value);
3894 }
3895 57 return ok;
3896 }
3897
3898 56 void EpwDesignCondition::setExtremeN5YearsMaxDryBulb(double extremeN5YearsMaxDryBulb) {
3899 56 m_extremeN5YearsMaxDryBulb = extremeN5YearsMaxDryBulb;
3900 56 }
3901
3902 57 bool EpwDesignCondition::setExtremeN10YearsMinDryBulb(const std::string& extremeN10YearsMinDryBulb) {
3903 bool ok;
3904
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(extremeN10YearsMinDryBulb, &ok);
3905
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3906 1 m_extremeN10YearsMinDryBulb = boost::none;
3907 } else {
3908
1/1
✓ Branch 1 taken 56 times.
56 setExtremeN10YearsMinDryBulb(value);
3909 }
3910 57 return ok;
3911 }
3912
3913 56 void EpwDesignCondition::setExtremeN10YearsMinDryBulb(double extremeN10YearsMinDryBulb) {
3914 56 m_extremeN10YearsMinDryBulb = extremeN10YearsMinDryBulb;
3915 56 }
3916
3917 57 bool EpwDesignCondition::setExtremeN10YearsMaxDryBulb(const std::string& extremeN10YearsMaxDryBulb) {
3918 bool ok;
3919
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(extremeN10YearsMaxDryBulb, &ok);
3920
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3921 1 m_extremeN10YearsMaxDryBulb = boost::none;
3922 } else {
3923
1/1
✓ Branch 1 taken 56 times.
56 setExtremeN10YearsMaxDryBulb(value);
3924 }
3925 57 return ok;
3926 }
3927 56 void EpwDesignCondition::setExtremeN10YearsMaxDryBulb(double extremeN10YearsMaxDryBulb) {
3928 56 m_extremeN10YearsMaxDryBulb = extremeN10YearsMaxDryBulb;
3929 56 }
3930
3931 57 bool EpwDesignCondition::setExtremeN20YearsMinDryBulb(const std::string& extremeN20YearsMinDryBulb) {
3932 bool ok;
3933
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(extremeN20YearsMinDryBulb, &ok);
3934
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3935 1 m_extremeN20YearsMinDryBulb = boost::none;
3936 } else {
3937
1/1
✓ Branch 1 taken 56 times.
56 setExtremeN20YearsMinDryBulb(value);
3938 }
3939 57 return ok;
3940 }
3941
3942 56 void EpwDesignCondition::setExtremeN20YearsMinDryBulb(double extremeN20YearsMinDryBulb) {
3943 56 m_extremeN20YearsMinDryBulb = extremeN20YearsMinDryBulb;
3944 56 }
3945
3946 57 bool EpwDesignCondition::setExtremeN20YearsMaxDryBulb(const std::string& extremeN20YearsMaxDryBulb) {
3947 bool ok;
3948
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(extremeN20YearsMaxDryBulb, &ok);
3949
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3950 1 m_extremeN20YearsMaxDryBulb = boost::none;
3951 } else {
3952
1/1
✓ Branch 1 taken 56 times.
56 setExtremeN20YearsMaxDryBulb(value);
3953 }
3954 57 return ok;
3955 }
3956
3957 56 void EpwDesignCondition::setExtremeN20YearsMaxDryBulb(double extremeN20YearsMaxDryBulb) {
3958 56 m_extremeN20YearsMaxDryBulb = extremeN20YearsMaxDryBulb;
3959 56 }
3960
3961 57 bool EpwDesignCondition::setExtremeN50YearsMinDryBulb(const std::string& extremeN50YearsMinDryBulb) {
3962 bool ok;
3963
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(extremeN50YearsMinDryBulb, &ok);
3964
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3965 1 m_extremeN50YearsMinDryBulb = boost::none;
3966 } else {
3967
1/1
✓ Branch 1 taken 56 times.
56 setExtremeN50YearsMinDryBulb(value);
3968 }
3969 57 return ok;
3970 }
3971
3972 56 void EpwDesignCondition::setExtremeN50YearsMinDryBulb(double extremeN50YearsMinDryBulb) {
3973 56 m_extremeN50YearsMinDryBulb = extremeN50YearsMinDryBulb;
3974 56 }
3975
3976 57 bool EpwDesignCondition::setExtremeN50YearsMaxDryBulb(const std::string& extremeN50YearsMaxDryBulb) {
3977 bool ok;
3978
1/1
✓ Branch 1 taken 57 times.
57 double value = stringToDouble(extremeN50YearsMaxDryBulb, &ok);
3979
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 56 times.
57 if (!ok) {
3980 1 m_extremeN50YearsMaxDryBulb = boost::none;
3981 } else {
3982
1/1
✓ Branch 1 taken 56 times.
56 setExtremeN50YearsMaxDryBulb(value);
3983 }
3984 57 return ok;
3985 }
3986
3987 56 void EpwDesignCondition::setExtremeN50YearsMaxDryBulb(double extremeN50YearsMaxDryBulb) {
3988 56 m_extremeN50YearsMaxDryBulb = extremeN50YearsMaxDryBulb;
3989 56 }
3990
3991 9 std::vector<EpwDesignCondition> EpwFile::designConditions() {
3992
2/2
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 7 times.
9 if (m_designs.empty()) {
3993
5/8
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
2 if (!openstudio::filesystem::exists(m_path) || !openstudio::filesystem::is_regular_file(m_path)) {
3994 ✗ LOG_AND_THROW("Path '" << m_path << "' is not an EPW file");
3995 }
3996
3997 // set checksum
3998
1/1
✓ Branch 1 taken 2 times.
2 m_checksum = openstudio::checksum(m_path);
3999
4000 // open file
4001
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 std::ifstream ifs(openstudio::toSystemFilename(m_path));
4002
4003
2/3
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
2 if (!parse(ifs)) {
4004 ✗ ifs.close();
4005 ✗ LOG(Error, "EpwFile '" << toString(m_path) << "' cannot be processed");
4006 } else {
4007
1/1
✓ Branch 1 taken 2 times.
2 ifs.close();
4008 }
4009 2 }
4010 9 return m_designs;
4011 }
4012
4013 /*****************************************************************************************************************************************************
4014 * E P W G R O U N D T E M P E R A T U R E D E P T H *
4015 *****************************************************************************************************************************************************/
4016 static constexpr size_t NUMBER_GROUND_TEMP_STRINGS = 16;
4017
4018 ✗ EpwGroundTemperatureDepth::EpwGroundTemperatureDepth(double groundTemperatureDepth, double janGroundTemperature, double febGroundTemperature,
4019 double marGroundTemperature, double aprGroundTemperature, double mayGroundTemperature,
4020 double junGroundTemperature, double julGroundTemperature, double augGroundTemperature,
4021 double sepGroundTemperature, double octGroundTemperature, double novGroundTemperature,
4022 double decGroundTemperature, boost::optional<double> soilConductivity_,
4023 ✗ boost::optional<double> soilDensity_, boost::optional<double> soilSpecificHeat_) {
4024 ✗ setGroundTemperatureDepth(groundTemperatureDepth);
4025
4026 ✗ setJanGroundTemperature(janGroundTemperature);
4027 ✗ setFebGroundTemperature(febGroundTemperature);
4028 ✗ setMarGroundTemperature(marGroundTemperature);
4029 ✗ setAprGroundTemperature(aprGroundTemperature);
4030 ✗ setMayGroundTemperature(mayGroundTemperature);
4031 ✗ setJunGroundTemperature(junGroundTemperature);
4032 ✗ setJulGroundTemperature(julGroundTemperature);
4033 ✗ setAugGroundTemperature(augGroundTemperature);
4034 ✗ setSepGroundTemperature(sepGroundTemperature);
4035 ✗ setOctGroundTemperature(octGroundTemperature);
4036 ✗ setNovGroundTemperature(novGroundTemperature);
4037 ✗ setDecGroundTemperature(decGroundTemperature);
4038
4039 ✗ if (soilConductivity_) {
4040 ✗ setSoilConductivity(*soilConductivity_);
4041 }
4042 ✗ if (soilDensity_) {
4043 ✗ setSoilDensity(*soilDensity_);
4044 }
4045 ✗ if (soilSpecificHeat_) {
4046 ✗ setSoilSpecificHeat(*soilSpecificHeat_);
4047 }
4048 ✗ }
4049
4050 ✗ boost::optional<EpwGroundTemperatureDepth> EpwGroundTemperatureDepth::fromGroundTemperatureDepthsString(const std::string& line) {
4051 ✗ std::vector<std::string> strings = splitString(line, ',');
4052 ✗ return fromGroundTemperatureDepthsStrings(strings);
4053 ✗ }
4054
4055 159 boost::optional<EpwGroundTemperatureDepth> EpwGroundTemperatureDepth::fromGroundTemperatureDepthsStrings(const std::vector<std::string>& strings) {
4056 159 EpwGroundTemperatureDepth gtd;
4057
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 159 times.
159 if (strings.size() != NUMBER_GROUND_TEMP_STRINGS) {
4058 ✗ LOG_FREE(Error, "openstudio.EpwFile",
4059 "Expected " << NUMBER_GROUND_TEMP_STRINGS << " fields in EPW ground temperature depth instead of the " << strings.size() << " received");
4060 ✗ return boost::none;
4061 }
4062 // Use the appropriate setter on each field
4063
1/1
✓ Branch 2 taken 159 times.
159 gtd.setGroundTemperatureDepth(strings[EpwDepthField::GroundTemperatureDepth]);
4064
1/1
✓ Branch 2 taken 159 times.
159 gtd.setSoilConductivity(strings[EpwDepthField::SoilConductivity]);
4065
1/1
✓ Branch 2 taken 159 times.
159 gtd.setSoilDensity(strings[EpwDepthField::SoilDensity]);
4066
1/1
✓ Branch 2 taken 159 times.
159 gtd.setSoilSpecificHeat(strings[EpwDepthField::SoilSpecificHeat]);
4067
1/1
✓ Branch 2 taken 159 times.
159 gtd.setJanGroundTemperature(strings[EpwDepthField::JanGroundTemperature]);
4068
1/1
✓ Branch 2 taken 159 times.
159 gtd.setFebGroundTemperature(strings[EpwDepthField::FebGroundTemperature]);
4069
1/1
✓ Branch 2 taken 159 times.
159 gtd.setMarGroundTemperature(strings[EpwDepthField::MarGroundTemperature]);
4070
1/1
✓ Branch 2 taken 159 times.
159 gtd.setAprGroundTemperature(strings[EpwDepthField::AprGroundTemperature]);
4071
1/1
✓ Branch 2 taken 159 times.
159 gtd.setMayGroundTemperature(strings[EpwDepthField::MayGroundTemperature]);
4072
1/1
✓ Branch 2 taken 159 times.
159 gtd.setJunGroundTemperature(strings[EpwDepthField::JunGroundTemperature]);
4073
1/1
✓ Branch 2 taken 159 times.
159 gtd.setJulGroundTemperature(strings[EpwDepthField::JulGroundTemperature]);
4074
1/1
✓ Branch 2 taken 159 times.
159 gtd.setAugGroundTemperature(strings[EpwDepthField::AugGroundTemperature]);
4075
1/1
✓ Branch 2 taken 159 times.
159 gtd.setSepGroundTemperature(strings[EpwDepthField::SepGroundTemperature]);
4076
1/1
✓ Branch 2 taken 159 times.
159 gtd.setOctGroundTemperature(strings[EpwDepthField::OctGroundTemperature]);
4077
1/1
✓ Branch 2 taken 159 times.
159 gtd.setNovGroundTemperature(strings[EpwDepthField::NovGroundTemperature]);
4078
1/1
✓ Branch 2 taken 159 times.
159 gtd.setDecGroundTemperature(strings[EpwDepthField::DecGroundTemperature]);
4079
1/1
✓ Branch 2 taken 159 times.
159 return std::move(gtd);
4080 }
4081
4082 ✗ boost::optional<std::string> EpwGroundTemperatureDepth::getUnitsByName(const std::string& name) {
4083 ✗ EpwDepthField id;
4084 try {
4085 ✗ id = EpwDepthField(name);
4086 ✗ } catch (...) {
4087 // Could do a warning message here
4088 ✗ return boost::none;
4089 ✗ }
4090 ✗ return getUnits(id);
4091 }
4092
4093 ✗ std::string EpwGroundTemperatureDepth::getUnits(EpwDepthField field) {
4094 ✗ switch (field.value()) {
4095 ✗ case EpwDepthField::GroundTemperatureDepth:
4096 ✗ return "m";
4097 break;
4098 ✗ case EpwDepthField::SoilConductivity:
4099 ✗ return "W/m-K";
4100 break;
4101 ✗ case EpwDepthField::SoilDensity:
4102 ✗ return "kg/m3";
4103 break;
4104 ✗ case EpwDepthField::SoilSpecificHeat:
4105 ✗ return "J/kg-K";
4106 break;
4107 ✗ case EpwDepthField::JanGroundTemperature:
4108 ✗ return "C";
4109 break;
4110 ✗ case EpwDepthField::FebGroundTemperature:
4111 ✗ return "C";
4112 break;
4113 ✗ case EpwDepthField::MarGroundTemperature:
4114 ✗ return "C";
4115 break;
4116 ✗ case EpwDepthField::AprGroundTemperature:
4117 ✗ return "C";
4118 break;
4119 ✗ case EpwDepthField::MayGroundTemperature:
4120 ✗ return "C";
4121 break;
4122 ✗ case EpwDepthField::JunGroundTemperature:
4123 ✗ return "C";
4124 break;
4125 ✗ case EpwDepthField::JulGroundTemperature:
4126 ✗ return "C";
4127 break;
4128 ✗ case EpwDepthField::AugGroundTemperature:
4129 ✗ return "C";
4130 break;
4131 ✗ case EpwDepthField::SepGroundTemperature:
4132 ✗ return "C";
4133 break;
4134 ✗ case EpwDepthField::OctGroundTemperature:
4135 ✗ return "C";
4136 break;
4137 ✗ case EpwDepthField::NovGroundTemperature:
4138 ✗ return "C";
4139 break;
4140 ✗ case EpwDepthField::DecGroundTemperature:
4141 ✗ return "C";
4142 break;
4143 ✗ default:
4144 //return "None";
4145 ✗ break;
4146 }
4147 ✗ return "";
4148 }
4149
4150 ✗ boost::optional<double> EpwGroundTemperatureDepth::getFieldByName(const std::string& name) const {
4151 ✗ EpwDepthField id;
4152 try {
4153 ✗ id = EpwDepthField(name);
4154 ✗ } catch (...) {
4155 // Could do a warning message here
4156 ✗ return boost::none;
4157 ✗ }
4158 ✗ return getField(id);
4159 }
4160
4161 ✗ boost::optional<double> EpwGroundTemperatureDepth::getField(EpwDepthField id) const {
4162 ✗ switch (id.value()) {
4163 ✗ case EpwDepthField::GroundTemperatureDepth:
4164 ✗ return groundTemperatureDepth();
4165 break;
4166 ✗ case EpwDepthField::SoilConductivity:
4167 ✗ return soilConductivity();
4168 break;
4169 ✗ case EpwDepthField::SoilDensity:
4170 ✗ return soilDensity();
4171 break;
4172 ✗ case EpwDepthField::SoilSpecificHeat:
4173 ✗ return soilSpecificHeat();
4174 break;
4175 ✗ case EpwDepthField::JanGroundTemperature:
4176 ✗ return janGroundTemperature();
4177 break;
4178 ✗ case EpwDepthField::FebGroundTemperature:
4179 ✗ return febGroundTemperature();
4180 break;
4181 ✗ case EpwDepthField::MarGroundTemperature:
4182 ✗ return marGroundTemperature();
4183 break;
4184 ✗ case EpwDepthField::AprGroundTemperature:
4185 ✗ return aprGroundTemperature();
4186 break;
4187 ✗ case EpwDepthField::MayGroundTemperature:
4188 ✗ return mayGroundTemperature();
4189 break;
4190 ✗ case EpwDepthField::JunGroundTemperature:
4191 ✗ return junGroundTemperature();
4192 break;
4193 ✗ case EpwDepthField::JulGroundTemperature:
4194 ✗ return julGroundTemperature();
4195 break;
4196 ✗ case EpwDepthField::AugGroundTemperature:
4197 ✗ return augGroundTemperature();
4198 break;
4199 ✗ case EpwDepthField::SepGroundTemperature:
4200 ✗ return sepGroundTemperature();
4201 break;
4202 ✗ case EpwDepthField::OctGroundTemperature:
4203 ✗ return octGroundTemperature();
4204 break;
4205 ✗ case EpwDepthField::NovGroundTemperature:
4206 ✗ return novGroundTemperature();
4207 break;
4208 ✗ case EpwDepthField::DecGroundTemperature:
4209 ✗ return decGroundTemperature();
4210 break;
4211 ✗ default:
4212 // Could do a warning message here
4213 ✗ return boost::none;
4214 break;
4215 }
4216 return boost::none;
4217 }
4218
4219 427 double EpwGroundTemperatureDepth::groundTemperatureDepth() const {
4220 427 return m_groundTemperatureDepth;
4221 }
4222
4223 3 boost::optional<double> EpwGroundTemperatureDepth::soilConductivity() const {
4224 3 return m_soilConductivity_;
4225 }
4226
4227 3 boost::optional<double> EpwGroundTemperatureDepth::soilDensity() const {
4228 3 return m_soilDensity_;
4229 }
4230
4231 3 boost::optional<double> EpwGroundTemperatureDepth::soilSpecificHeat() const {
4232 3 return m_soilSpecificHeat_;
4233 }
4234
4235 3 double EpwGroundTemperatureDepth::janGroundTemperature() const {
4236 3 return m_janGroundTemperature;
4237 }
4238
4239 3 double EpwGroundTemperatureDepth::febGroundTemperature() const {
4240 3 return m_febGroundTemperature;
4241 }
4242
4243 3 double EpwGroundTemperatureDepth::marGroundTemperature() const {
4244 3 return m_marGroundTemperature;
4245 }
4246
4247 3 double EpwGroundTemperatureDepth::aprGroundTemperature() const {
4248 3 return m_aprGroundTemperature;
4249 }
4250
4251 3 double EpwGroundTemperatureDepth::mayGroundTemperature() const {
4252 3 return m_mayGroundTemperature;
4253 }
4254
4255 3 double EpwGroundTemperatureDepth::junGroundTemperature() const {
4256 3 return m_junGroundTemperature;
4257 }
4258
4259 3 double EpwGroundTemperatureDepth::julGroundTemperature() const {
4260 3 return m_julGroundTemperature;
4261 }
4262
4263 3 double EpwGroundTemperatureDepth::augGroundTemperature() const {
4264 3 return m_augGroundTemperature;
4265 }
4266
4267 3 double EpwGroundTemperatureDepth::sepGroundTemperature() const {
4268 3 return m_sepGroundTemperature;
4269 }
4270
4271 3 double EpwGroundTemperatureDepth::octGroundTemperature() const {
4272 3 return m_octGroundTemperature;
4273 }
4274
4275 3 double EpwGroundTemperatureDepth::novGroundTemperature() const {
4276 3 return m_novGroundTemperature;
4277 }
4278
4279 3 double EpwGroundTemperatureDepth::decGroundTemperature() const {
4280 3 return m_decGroundTemperature;
4281 }
4282
4283 159 bool EpwGroundTemperatureDepth::setGroundTemperatureDepth(const std::string& groundTemperatureDepth) {
4284 bool ok;
4285
1/1
✓ Branch 1 taken 159 times.
159 double value = stringToDouble(groundTemperatureDepth, &ok);
4286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 159 times.
159 if (!ok) {
4287 ✗ return false;
4288 }
4289
1/1
✓ Branch 1 taken 159 times.
159 setGroundTemperatureDepth(value);
4290 159 return ok;
4291 }
4292
4293 159 void EpwGroundTemperatureDepth::setGroundTemperatureDepth(double groundTemperatureDepth) {
4294 159 m_groundTemperatureDepth = groundTemperatureDepth;
4295 159 }
4296
4297 159 bool EpwGroundTemperatureDepth::setSoilConductivity(const std::string& soilConductivity) {
4298 bool ok;
4299
1/1
✓ Branch 1 taken 159 times.
159 double value = stringToDouble(soilConductivity, &ok);
4300
1/2
✓ Branch 0 taken 159 times.
✗ Branch 1 not taken.
159 if (!ok) {
4301 159 return false;
4302 }
4303 ✗ setSoilConductivity(value);
4304 ✗ return ok;
4305 }
4306
4307 ✗ void EpwGroundTemperatureDepth::setSoilConductivity(double soilConductivity) {
4308 ✗ m_soilConductivity_ = soilConductivity;
4309 ✗ }
4310
4311 159 bool EpwGroundTemperatureDepth::setSoilDensity(const std::string& soilDensity) {
4312 bool ok;
4313
1/1
✓ Branch 1 taken 159 times.
159 double value = stringToDouble(soilDensity, &ok);
4314
1/2
✓ Branch 0 taken 159 times.
✗ Branch 1 not taken.
159 if (!ok) {
4315 159 return false;
4316 }
4317 ✗ setSoilDensity(value);
4318 ✗ return ok;
4319 }
4320
4321 ✗ void EpwGroundTemperatureDepth::setSoilDensity(double soilDensity) {
4322 ✗ m_soilDensity_ = soilDensity;
4323 ✗ }
4324
4325 159 bool EpwGroundTemperatureDepth::setSoilSpecificHeat(const std::string& soilSpecificHeat) {
4326 bool ok;
4327
1/1
✓ Branch 1 taken 159 times.
159 double value = stringToDouble(soilSpecificHeat, &ok);
4328
1/2
✓ Branch 0 taken 159 times.
✗ Branch 1 not taken.
159 if (!ok) {
4329 159 return false;
4330 }
4331 ✗ setSoilSpecificHeat(value);
4332 ✗ return ok;
4333 }
4334
4335 ✗ void EpwGroundTemperatureDepth::setSoilSpecificHeat(double soilSpecificHeat) {
4336 ✗ m_soilSpecificHeat_ = soilSpecificHeat;
4337 ✗ }
4338
4339 159 bool EpwGroundTemperatureDepth::setJanGroundTemperature(const std::string& janGroundTemperature) {
4340 bool ok;
4341
1/1
✓ Branch 1 taken 159 times.
159 double value = stringToDouble(janGroundTemperature, &ok);
4342
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 159 times.
159 if (!ok) {
4343 ✗ return false;
4344 }
4345
1/1
✓ Branch 1 taken 159 times.
159 setJanGroundTemperature(value);
4346 159 return ok;
4347 }
4348
4349 159 void EpwGroundTemperatureDepth::setJanGroundTemperature(double janGroundTemperature) {
4350 159 m_janGroundTemperature = janGroundTemperature;
4351 159 }
4352
4353 159 bool EpwGroundTemperatureDepth::setFebGroundTemperature(const std::string& febGroundTemperature) {
4354 bool ok;
4355
1/1
✓ Branch 1 taken 159 times.
159 double value = stringToDouble(febGroundTemperature, &ok);
4356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 159 times.
159 if (!ok) {
4357 ✗ return false;
4358 }
4359
1/1
✓ Branch 1 taken 159 times.
159 setFebGroundTemperature(value);
4360 159 return ok;
4361 }
4362
4363 159 void EpwGroundTemperatureDepth::setFebGroundTemperature(double febGroundTemperature) {
4364 159 m_febGroundTemperature = febGroundTemperature;
4365 159 }
4366
4367 159 bool EpwGroundTemperatureDepth::setMarGroundTemperature(const std::string& marGroundTemperature) {
4368 bool ok;
4369
1/1
✓ Branch 1 taken 159 times.
159 double value = stringToDouble(marGroundTemperature, &ok);
4370
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 159 times.
159 if (!ok) {
4371 ✗ return false;
4372 }
4373
1/1
✓ Branch 1 taken 159 times.
159 setMarGroundTemperature(value);
4374 159 return ok;
4375 }
4376
4377 159 void EpwGroundTemperatureDepth::setMarGroundTemperature(double marGroundTemperature) {
4378 159 m_marGroundTemperature = marGroundTemperature;
4379 159 }
4380
4381 159 bool EpwGroundTemperatureDepth::setAprGroundTemperature(const std::string& aprGroundTemperature) {
4382 bool ok;
4383
1/1
✓ Branch 1 taken 159 times.
159 double value = stringToDouble(aprGroundTemperature, &ok);
4384
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 159 times.
159 if (!ok) {
4385 ✗ return false;
4386 }
4387
1/1
✓ Branch 1 taken 159 times.
159 setAprGroundTemperature(value);
4388 159 return ok;
4389 }
4390
4391 159 void EpwGroundTemperatureDepth::setAprGroundTemperature(double aprGroundTemperature) {
4392 159 m_aprGroundTemperature = aprGroundTemperature;
4393 159 }
4394
4395 159 bool EpwGroundTemperatureDepth::setMayGroundTemperature(const std::string& mayGroundTemperature) {
4396 bool ok;
4397
1/1
✓ Branch 1 taken 159 times.
159 double value = stringToDouble(mayGroundTemperature, &ok);
4398
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 159 times.
159 if (!ok) {
4399 ✗ return false;
4400 }
4401
1/1
✓ Branch 1 taken 159 times.
159 setMayGroundTemperature(value);
4402 159 return ok;
4403 }
4404
4405 159 void EpwGroundTemperatureDepth::setMayGroundTemperature(double mayGroundTemperature) {
4406 159 m_mayGroundTemperature = mayGroundTemperature;
4407 159 }
4408
4409 159 bool EpwGroundTemperatureDepth::setJunGroundTemperature(const std::string& junGroundTemperature) {
4410 bool ok;
4411
1/1
✓ Branch 1 taken 159 times.
159 double value = stringToDouble(junGroundTemperature, &ok);
4412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 159 times.
159 if (!ok) {
4413 ✗ return false;
4414 }
4415
1/1
✓ Branch 1 taken 159 times.
159 setJunGroundTemperature(value);
4416 159 return ok;
4417 }
4418
4419 159 void EpwGroundTemperatureDepth::setJunGroundTemperature(double junGroundTemperature) {
4420 159 m_junGroundTemperature = junGroundTemperature;
4421 159 }
4422
4423 159 bool EpwGroundTemperatureDepth::setJulGroundTemperature(const std::string& julGroundTemperature) {
4424 bool ok;
4425
1/1
✓ Branch 1 taken 159 times.
159 double value = stringToDouble(julGroundTemperature, &ok);
4426
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 159 times.
159 if (!ok) {
4427 ✗ return false;
4428 }
4429
1/1
✓ Branch 1 taken 159 times.
159 setJulGroundTemperature(value);
4430 159 return ok;
4431 }
4432
4433 159 void EpwGroundTemperatureDepth::setJulGroundTemperature(double julGroundTemperature) {
4434 159 m_julGroundTemperature = julGroundTemperature;
4435 159 }
4436
4437 159 bool EpwGroundTemperatureDepth::setAugGroundTemperature(const std::string& augGroundTemperature) {
4438 bool ok;
4439
1/1
✓ Branch 1 taken 159 times.
159 double value = stringToDouble(augGroundTemperature, &ok);
4440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 159 times.
159 if (!ok) {
4441 ✗ return false;
4442 }
4443
1/1
✓ Branch 1 taken 159 times.
159 setAugGroundTemperature(value);
4444 159 return ok;
4445 }
4446
4447 159 void EpwGroundTemperatureDepth::setAugGroundTemperature(double augGroundTemperature) {
4448 159 m_augGroundTemperature = augGroundTemperature;
4449 159 }
4450
4451 159 bool EpwGroundTemperatureDepth::setSepGroundTemperature(const std::string& sepGroundTemperature) {
4452 bool ok;
4453
1/1
✓ Branch 1 taken 159 times.
159 double value = stringToDouble(sepGroundTemperature, &ok);
4454
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 159 times.
159 if (!ok) {
4455 ✗ return false;
4456 }
4457
1/1
✓ Branch 1 taken 159 times.
159 setSepGroundTemperature(value);
4458 159 return ok;
4459 }
4460
4461 159 void EpwGroundTemperatureDepth::setSepGroundTemperature(double sepGroundTemperature) {
4462 159 m_sepGroundTemperature = sepGroundTemperature;
4463 159 }
4464
4465 159 bool EpwGroundTemperatureDepth::setOctGroundTemperature(const std::string& octGroundTemperature) {
4466 bool ok;
4467
1/1
✓ Branch 1 taken 159 times.
159 double value = stringToDouble(octGroundTemperature, &ok);
4468
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 159 times.
159 if (!ok) {
4469 ✗ return false;
4470 }
4471
1/1
✓ Branch 1 taken 159 times.
159 setOctGroundTemperature(value);
4472 159 return ok;
4473 }
4474
4475 159 void EpwGroundTemperatureDepth::setOctGroundTemperature(double octGroundTemperature) {
4476 159 m_octGroundTemperature = octGroundTemperature;
4477 159 }
4478
4479 159 bool EpwGroundTemperatureDepth::setNovGroundTemperature(const std::string& novGroundTemperature) {
4480 bool ok;
4481
1/1
✓ Branch 1 taken 159 times.
159 double value = stringToDouble(novGroundTemperature, &ok);
4482
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 159 times.
159 if (!ok) {
4483 ✗ return false;
4484 }
4485
1/1
✓ Branch 1 taken 159 times.
159 setNovGroundTemperature(value);
4486 159 return ok;
4487 }
4488
4489 159 void EpwGroundTemperatureDepth::setNovGroundTemperature(double novGroundTemperature) {
4490 159 m_novGroundTemperature = novGroundTemperature;
4491 159 }
4492
4493 159 bool EpwGroundTemperatureDepth::setDecGroundTemperature(const std::string& decGroundTemperature) {
4494 bool ok;
4495
1/1
✓ Branch 1 taken 159 times.
159 double value = stringToDouble(decGroundTemperature, &ok);
4496
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 159 times.
159 if (!ok) {
4497 ✗ return false;
4498 }
4499
1/1
✓ Branch 1 taken 159 times.
159 setDecGroundTemperature(value);
4500 159 return ok;
4501 }
4502
4503 159 void EpwGroundTemperatureDepth::setDecGroundTemperature(double decGroundTemperature) {
4504 159 m_decGroundTemperature = decGroundTemperature;
4505 159 }
4506
4507 1 std::vector<EpwGroundTemperatureDepth> EpwFile::groundTemperatureDepths() {
4508
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
1 if (m_depths.empty()) {
4509 ✗ if (!openstudio::filesystem::exists(m_path) || !openstudio::filesystem::is_regular_file(m_path)) {
4510 ✗ LOG_AND_THROW("Path '" << m_path << "' is not an EPW file");
4511 }
4512
4513 // set checksum
4514 ✗ m_checksum = openstudio::checksum(m_path);
4515
4516 // open file
4517 ✗ std::ifstream ifs(openstudio::toSystemFilename(m_path));
4518
4519 ✗ if (!parse(ifs)) {
4520 ✗ ifs.close();
4521 ✗ LOG(Error, "EpwFile '" << toString(m_path) << "' cannot be processed");
4522 } else {
4523 ✗ ifs.close();
4524 }
4525 ✗ }
4526 1 return m_depths;
4527 }
4528
4529 10 boost::optional<TimeSeries> EpwFile::getTimeSeries(const std::string& name) {
4530
2/2
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 5 times.
10 if (m_data.empty()) {
4531
5/8
✓ Branch 1 taken 5 times.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 5 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 5 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 5 times.
5 if (!openstudio::filesystem::exists(m_path) || !openstudio::filesystem::is_regular_file(m_path)) {
4532 ✗ LOG_AND_THROW("Path '" << m_path << "' is not an EPW file");
4533 }
4534
4535 // set checksum
4536
1/1
✓ Branch 1 taken 5 times.
5 m_checksum = openstudio::checksum(m_path);
4537
4538 // open file
4539
2/2
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
5 std::ifstream ifs(openstudio::toSystemFilename(m_path));
4540
4541
2/3
✓ Branch 1 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
5 if (!parse(ifs, true)) {
4542 ✗ ifs.close();
4543 ✗ LOG(Error, "EpwFile '" << toString(m_path) << "' cannot be processed");
4544 ✗ return boost::none;
4545 }
4546
1/1
✓ Branch 1 taken 5 times.
5 ifs.close();
4547 5 }
4548
1/1
✓ Branch 1 taken 10 times.
10 EpwDataField id;
4549 try {
4550
1/1
✓ Branch 1 taken 10 times.
10 id = EpwDataField(name);
4551 ✗ } catch (...) {
4552 ✗ LOG(Warn, "Unrecognized EPW data field '" << name << "'");
4553 ✗ return boost::none;
4554 ✗ }
4555
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 if (!m_data.empty()) {
4556
1/1
✓ Branch 1 taken 10 times.
10 std::string units = EpwDataPoint::getUnits(id);
4557 10 DateTimeVector dates;
4558
2/2
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
10 dates.push_back(DateTime()); // Use a placeholder to avoid an insert
4559 10 std::vector<double> values;
4560
2/2
✓ Branch 1 taken 80281 times.
✓ Branch 2 taken 9 times.
80290 for (unsigned int i = 0; i < m_data.size(); i++) {
4561
1/1
✓ Branch 2 taken 80281 times.
80281 DateTime dateTime = m_data[i].dateTime();
4562 // Time time=m_data[i].time();
4563
1/1
✓ Branch 2 taken 80281 times.
80281 boost::optional<double> value = m_data[i].getField(id);
4564
1/2
✓ Branch 0 taken 80281 times.
✗ Branch 1 not taken.
80281 if (value) {
4565
3/3
✓ Branch 1 taken 80281 times.
✓ Branch 3 taken 8784 times.
✓ Branch 4 taken 71497 times.
80281 if (isActual()) {
4566
2/2
✓ Branch 1 taken 8784 times.
✓ Branch 4 taken 8784 times.
8784 dates.push_back(DateTime(dateTime));
4567 } else {
4568 // Strip year
4569
8/8
✓ Branch 1 taken 71497 times.
✓ Branch 4 taken 71497 times.
✓ Branch 7 taken 71497 times.
✓ Branch 10 taken 71497 times.
✓ Branch 13 taken 71497 times.
✓ Branch 16 taken 71496 times.
✓ Branch 19 taken 71496 times.
✓ Branch 22 taken 71496 times.
71497 dates.push_back(DateTime(Date(dateTime.date().monthOfYear(), dateTime.date().dayOfMonth()), dateTime.time()));
4570 }
4571
2/2
✓ Branch 1 taken 80280 times.
✓ Branch 4 taken 80280 times.
80280 values.push_back(value.get());
4572 }
4573 }
4574
1/2
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
9 if (!values.empty()) {
4575
2/2
✓ Branch 1 taken 9 times.
✓ Branch 5 taken 9 times.
9 DateTime start = dates[1] - Time(0, 0, 0, 3600 / m_recordsPerHour);
4576
1/1
✓ Branch 2 taken 9 times.
9 dates[0] = start; // Overwrite the placeholder
4577
3/3
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 7 taken 9 times.
9 return boost::optional<TimeSeries>(TimeSeries(dates, openstudio::createVector(values), units));
4578 }
4579 30 }
4580 ✗ return boost::none;
4581 }
4582
4583 ✗ boost::optional<TimeSeries> EpwFile::getComputedTimeSeries(const std::string& name) {
4584 ✗ if (m_data.empty()) {
4585 ✗ if (!openstudio::filesystem::exists(m_path) || !openstudio::filesystem::is_regular_file(m_path)) {
4586 ✗ LOG_AND_THROW("Path '" << m_path << "' is not an EPW file");
4587 }
4588
4589 // set checksum
4590 ✗ m_checksum = openstudio::checksum(m_path);
4591
4592 // open file
4593 ✗ std::ifstream ifs(openstudio::toSystemFilename(m_path));
4594
4595 ✗ if (!parse(ifs, true)) {
4596 ✗ ifs.close();
4597 ✗ LOG(Error, "EpwFile '" << toString(m_path) << "' cannot be processed");
4598 ✗ return boost::none;
4599 }
4600 ✗ ifs.close();
4601 ✗ }
4602 ✗ EpwComputedField id;
4603 try {
4604 ✗ id = EpwComputedField(name);
4605 ✗ } catch (...) {
4606 ✗ LOG(Warn, "Unrecognized computed data field '" << name << "'");
4607 ✗ return boost::none;
4608 ✗ }
4609
4610 ✗ std::string units = EpwDataPoint::getUnits(id);
4611 boost::optional<double> (EpwDataPoint::*compute)() const;
4612 ✗ switch (id.value()) {
4613 ✗ case EpwComputedField::SaturationPressure:
4614 ✗ compute = &EpwDataPoint::saturationPressure;
4615 ✗ break;
4616 ✗ case EpwComputedField::Enthalpy:
4617 ✗ compute = &EpwDataPoint::enthalpy;
4618 ✗ break;
4619 ✗ case EpwComputedField::HumidityRatio:
4620 ✗ compute = &EpwDataPoint::humidityRatio;
4621 ✗ break;
4622 ✗ case EpwComputedField::WetBulbTemperature:
4623 ✗ compute = &EpwDataPoint::wetbulb;
4624 ✗ break;
4625 ✗ case EpwComputedField::Density:
4626 ✗ compute = &EpwDataPoint::density;
4627 ✗ break;
4628 ✗ case EpwComputedField::SpecificVolume:
4629 ✗ compute = &EpwDataPoint::specificVolume;
4630 ✗ break;
4631 ✗ default:
4632 ✗ return boost::none;
4633 }
4634 ✗ DateTimeVector dates;
4635 ✗ dates.push_back(DateTime()); // Use a placeholder to avoid an insert
4636 ✗ std::vector<double> values;
4637 ✗ for (unsigned int i = 0; i < m_data.size(); i++) {
4638 ✗ Date date = m_data[i].date();
4639 ✗ Time time = m_data[i].time();
4640 ✗ boost::optional<double> value = (m_data[i].*compute)();
4641 ✗ if (value) {
4642 ✗ dates.push_back(DateTime(date, time));
4643 ✗ values.push_back(value.get());
4644 }
4645 }
4646 ✗ if (!values.empty()) {
4647 ✗ DateTime start = dates[1] - Time(0, 0, 0, 3600 / m_recordsPerHour);
4648 ✗ dates[0] = start; // Overwrite the placeholder
4649 ✗ return boost::optional<TimeSeries>(TimeSeries(dates, openstudio::createVector(values), units));
4650 }
4651 ✗ return boost::none;
4652 ✗ }
4653
4654 ✗ bool EpwFile::translateToWth(openstudio::path path, std::string description) {
4655 ✗ if (m_data.empty()) {
4656 ✗ if (!openstudio::filesystem::exists(m_path) || !openstudio::filesystem::is_regular_file(m_path)) {
4657 ✗ LOG_AND_THROW("Path '" << m_path << "' is not an EPW file");
4658 }
4659
4660 // set checksum
4661 ✗ m_checksum = openstudio::checksum(m_path);
4662
4663 // open file
4664 ✗ std::ifstream ifs(openstudio::toSystemFilename(m_path));
4665
4666 ✗ if (!parse(ifs, true)) {
4667 ✗ ifs.close();
4668 ✗ LOG(Error, "EpwFile '" << toString(m_path) << "' cannot be processed");
4669 ✗ return false;
4670 }
4671 ✗ ifs.close();
4672 ✗ }
4673
4674 ✗ if (description.empty()) {
4675 ✗ description = "Translated from " + openstudio::toString(this->path());
4676 }
4677
4678 ✗ if (data().empty()) {
4679 ✗ LOG(Error, "EPW file contains no data to translate");
4680 ✗ return false;
4681 }
4682
4683 ✗ openstudio::filesystem::ofstream fp(path, std::ios_base::binary);
4684 ✗ if (!fp.is_open()) {
4685 ✗ LOG(Error, "Failed to open file '" + openstudio::toString(path) + "'");
4686 ✗ return false;
4687 }
4688
4689 ✗ fp << "WeatherFile ContamW 2.0\n";
4690 ✗ fp << description << "\n";
4691 ✗ fp << fmt::format("{}/{}\t!start date\n", openstudio::month(startDate().monthOfYear()), startDate().dayOfMonth());
4692 ✗ fp << fmt::format("%1/%2\t!end date\n", openstudio::month(endDate().monthOfYear()), endDate().dayOfMonth());
4693 ✗ fp << "!Date\tDofW\tDtype\tDST\tTgrnd [K]\n";
4694 ✗ openstudio::Time delta(1, 0);
4695 ✗ int dayofweek = startDayOfWeek().value() + 1;
4696 ✗ for (openstudio::Date current = startDate(); current <= endDate(); current += delta) {
4697 ✗ fp << fmt::format("%1/%2\t%3\t%3\t0\t283.15\n", openstudio::month(current.monthOfYear()), current.dayOfMonth(), dayofweek);
4698 ✗ dayofweek++;
4699 ✗ if (dayofweek > 7) {
4700 ✗ dayofweek = 1;
4701 }
4702 }
4703
4704 // Cheat to get data at the start time - this will need to change
4705 ✗ openstudio::EpwDataPoint lastPt = data()[data().size() - 1];
4706 ✗ std::vector<std::string> epwstrings = lastPt.toEpwStrings();
4707 ✗ openstudio::DateTime dateTime = data()[0].dateTime();
4708 ✗ openstudio::Time dt = timeStep();
4709 ✗ dateTime -= dt;
4710 ✗ epwstrings[0] = std::to_string(dateTime.date().year());
4711 ✗ epwstrings[1] = std::to_string(month(dateTime.date().monthOfYear()));
4712 ✗ epwstrings[2] = std::to_string(dateTime.date().dayOfMonth());
4713 ✗ epwstrings[3] = std::to_string(dateTime.time().hours());
4714 ✗ epwstrings[4] = std::to_string(dateTime.time().minutes());
4715 ✗ boost::optional<openstudio::EpwDataPoint> firstPtOpt = EpwDataPoint::fromEpwStrings(epwstrings);
4716 ✗ if (!firstPtOpt) {
4717 ✗ LOG(Error, "Failed to create starting data point for WTH file");
4718 ✗ return false;
4719 }
4720
4721 ✗ fp << "!Date\tTime\tTa [K]\tPb [Pa]\tWs [m/s]\tWd [deg]\tHr [g/kg]\tIth [kJ/m^2]\tIdn [kJ/m^2]\tTs [K]\tRn [-]\tSn [-]\n";
4722 ✗ boost::optional<std::string> output = firstPtOpt.get().toWthString();
4723 ✗ if (!output) {
4724 ✗ LOG(Error, "Translation to WTH has failed on starting data point");
4725 ✗ fp.close();
4726 ✗ return false;
4727 }
4728 ✗ fp << output.get() << '\n';
4729 ✗ for (unsigned int i = 0; i < data().size(); i++) {
4730 ✗ output = data()[i].toWthString();
4731 ✗ if (!output) {
4732 ✗ LOG(Error, "Translation to WTH has failed on data point " << i);
4733 ✗ fp.close();
4734 ✗ return false;
4735 }
4736 ✗ fp << output.get() << '\n';
4737 }
4738 ✗ fp.close();
4739 ✗ return true;
4740 ✗ }
4741
4742 ✗ bool EpwFile::translateToMos(const openstudio::path& path) {
4743 ✗ if (m_data.empty()) {
4744 ✗ if (!openstudio::filesystem::exists(m_path) || !openstudio::filesystem::is_regular_file(m_path)) {
4745 ✗ LOG_AND_THROW("Path '" << m_path << "' is not an EPW file");
4746 }
4747
4748 ✗ m_checksum = openstudio::checksum(m_path);
4749
4750 ✗ std::ifstream ifs(openstudio::toSystemFilename(m_path));
4751
4752 ✗ if (!parse(ifs, true)) {
4753 ✗ ifs.close();
4754 ✗ LOG(Error, "EpwFile '" << toString(m_path) << "' cannot be processed");
4755 ✗ return false;
4756 }
4757 ✗ ifs.close();
4758 ✗ }
4759
4760 ✗ if (data().empty()) {
4761 ✗ LOG(Error, "EPW file contains no data to translate");
4762 ✗ return false;
4763 }
4764
4765 ✗ std::vector<std::string> epwHeaderLines;
4766 ✗ bool sawDataPeriods = false;
4767 ✗ if (!m_path.empty() && openstudio::filesystem::exists(m_path)) {
4768 ✗ std::ifstream headerStream(openstudio::toSystemFilename(m_path));
4769 ✗ std::string rawLine;
4770 ✗ while (std::getline(headerStream, rawLine)) {
4771 ✗ epwHeaderLines.push_back(rawLine);
4772 ✗ std::string trimmed = rawLine;
4773 ✗ boost::trim(trimmed);
4774 ✗ if (boost::istarts_with(trimmed, "DATA PERIODS")) {
4775 ✗ sawDataPeriods = true;
4776 ✗ break;
4777 }
4778 ✗ }
4779 ✗ }
4780
4781 ✗ if (!sawDataPeriods) {
4782 ✗ LOG(Error, "Failed to read EPW header information from '" << m_path << "' needed for MOS export");
4783 ✗ return false;
4784 }
4785
4786 ✗ openstudio::filesystem::ofstream fp(path);
4787 ✗ if (!fp.is_open()) {
4788 ✗ LOG(Error, "Failed to open file '" + openstudio::toString(path) + "'");
4789 ✗ return false;
4790 }
4791
4792 ✗ fp << "#1\n";
4793 ✗ fp << fmt::format("double tab1({},{})\n", data().size(), 30);
4794 ✗ for (const auto& headerLine : epwHeaderLines) {
4795 ✗ fp << '#' << headerLine << '\n';
4796 }
4797
4798 static const std::array<const char*, 30> kColumnDescriptions = {
4799 "#C1 Time in seconds. Beginning of a year is 0s.",
4800 "#C2 Dry bulb temperature in Celsius at indicated time",
4801 "#C3 Dew point temperature in Celsius at indicated time",
4802 "#C4 Relative humidity in percent at indicated time",
4803 "#C5 Atmospheric station pressure in Pa at indicated time",
4804 "#C6 Extraterrestrial horizontal radiation in Wh/m2",
4805 "#C7 Extraterrestrial direct normal radiation in Wh/m2",
4806 "#C8 Horizontal infrared radiation intensity in Wh/m2",
4807 "#C9 Global horizontal radiation in Wh/m2",
4808 "#C10 Direct normal radiation in Wh/m2",
4809 "#C11 Diffuse horizontal radiation in Wh/m2",
4810 "#C12 Averaged global horizontal illuminance in lux during minutes preceding the indicated time",
4811 "#C13 Direct normal illuminance in lux during minutes preceding the indicated time",
4812 "#C14 Diffuse horizontal illuminance in lux during minutes preceding the indicated time",
4813 "#C15 Zenith luminance in Cd/m2 during minutes preceding the indicated time",
4814 "#C16 Wind direction at indicated time. N=0, E=90, S=180, W=270",
4815 "#C17 Wind speed in m/s at indicated time",
4816 "#C18 Total sky cover at indicated time",
4817 "#C19 Opaque sky cover at indicated time",
4818 "#C20 Visibility in km at indicated time",
4819 "#C21 Ceiling height in m",
4820 "#C22 Present weather observation",
4821 "#C23 Present weather codes",
4822 "#C24 Precipitable water in mm",
4823 "#C25 Aerosol optical depth",
4824 "#C26 Snow depth in cm",
4825 "#C27 Days since last snowfall",
4826 "#C28 Albedo",
4827 "#C29 Liquid precipitation depth in mm at indicated time",
4828 "#C30 Liquid precipitation quantity"};
4829
4830 ✗ for (const auto* description : kColumnDescriptions) {
4831 ✗ fp << description << '\n';
4832 }
4833
4834 static const std::array<EpwDataField, 29> kMosFields = {EpwDataField::DryBulbTemperature,
4835 EpwDataField::DewPointTemperature,
4836 EpwDataField::RelativeHumidity,
4837 EpwDataField::AtmosphericStationPressure,
4838 EpwDataField::ExtraterrestrialHorizontalRadiation,
4839 EpwDataField::ExtraterrestrialDirectNormalRadiation,
4840 EpwDataField::HorizontalInfraredRadiationIntensity,
4841 EpwDataField::GlobalHorizontalRadiation,
4842 EpwDataField::DirectNormalRadiation,
4843 EpwDataField::DiffuseHorizontalRadiation,
4844 EpwDataField::GlobalHorizontalIlluminance,
4845 EpwDataField::DirectNormalIlluminance,
4846 EpwDataField::DiffuseHorizontalIlluminance,
4847 EpwDataField::ZenithLuminance,
4848 EpwDataField::WindDirection,
4849 EpwDataField::WindSpeed,
4850 EpwDataField::TotalSkyCover,
4851 EpwDataField::OpaqueSkyCover,
4852 EpwDataField::Visibility,
4853 EpwDataField::CeilingHeight,
4854 EpwDataField::PresentWeatherObservation,
4855 EpwDataField::PresentWeatherCodes,
4856 EpwDataField::PrecipitableWater,
4857 EpwDataField::AerosolOpticalDepth,
4858 EpwDataField::SnowDepth,
4859 EpwDataField::DaysSinceLastSnowfall,
4860 EpwDataField::Albedo,
4861 EpwDataField::LiquidPrecipitationDepth,
4862 ✗ EpwDataField::LiquidPrecipitationQuantity};
4863
4864 ✗ const int baseYear = data().front().year();
4865 ✗ const DateTime baseDateTime(Date(MonthOfYear::Jan, 1, baseYear), Time(0, 0, 0));
4866
4867 ✗ for (const auto& point : data()) {
4868 ✗ const Time offset = point.dateTime() - baseDateTime;
4869 ✗ fp << fmt::format(fmt::runtime("{:.1f}"), static_cast<double>(offset.totalSeconds()));
4870 ✗ const auto epwStrings = point.toEpwStrings();
4871 ✗ for (const auto field : kMosFields) {
4872 ✗ const size_t index = static_cast<size_t>(field.value());
4873 ✗ if (index < epwStrings.size()) {
4874 ✗ fp << '\t' << epwStrings[index];
4875 } else {
4876 ✗ fp << '\t' << 0;
4877 }
4878 }
4879 ✗ fp << '\n';
4880 ✗ }
4881
4882 ✗ fp.close();
4883 ✗ return true;
4884 ✗ }
4885
4886 72 bool EpwFile::parse(std::istream& ifs, bool storeData) {
4887 // read line by line
4888 72 std::string line;
4889
4890 72 bool result = true;
4891
4892 // read first 8 lines
4893
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 72 times.
648 for (unsigned i = 0; i < 8; ++i) {
4894
4895
3/4
✓ Branch 1 taken 576 times.
✓ Branch 4 taken 576 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 576 times.
576 if (!std::getline(ifs, line)) {
4896 ✗ LOG(Error, "Could not read line " << i + 1 << " of EPW file '" << m_path << "'");
4897 ✗ return false;
4898 }
4899
4900
6/6
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 504 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 71 times.
✓ Branch 5 taken 1 time.
✓ Branch 6 taken 575 times.
576 if ((i == 0) && line.starts_with(UTF8_BOM)) {
4901
1/1
✓ Branch 2 taken 1 time.
1 line.erase(0, UTF8_BOM.size());
4902 }
4903
4904
8/9
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 72 times.
✓ Branch 3 taken 72 times.
✓ Branch 4 taken 72 times.
✓ Branch 5 taken 72 times.
✓ Branch 6 taken 72 times.
✓ Branch 7 taken 72 times.
✗ Branch 8 not taken.
576 switch (i) {
4905 72 case 0: // LOCATION,
4906
3/5
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 72 times.
✓ Branch 5 taken 72 times.
✗ Branch 6 not taken.
72 result = result && parseLocation(line);
4907 72 break;
4908 72 case 1: // DESIGN CONDITIONS
4909
3/5
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 72 times.
✓ Branch 5 taken 72 times.
✗ Branch 6 not taken.
72 result = result && parseDesignConditions(line);
4910 72 break;
4911 72 case 2: // TYPICAL/EXTREME PERIODS
4912 72 break;
4913 72 case 3: // GROUND TEMPERATURES
4914
3/5
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 72 times.
✓ Branch 5 taken 72 times.
✗ Branch 6 not taken.
72 result = result && parseGroundTemperatures(line);
4915 72 break;
4916 72 case 4: // HOLIDAYS/DAYLIGHT SAVINGS
4917
3/5
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 72 times.
✓ Branch 5 taken 72 times.
✗ Branch 6 not taken.
72 result = result && parseHolidaysDaylightSavings(line);
4918 72 break;
4919 72 case 5: // COMMENTS 1
4920 72 break;
4921 72 case 6: // COMMENTS 2
4922 72 break;
4923 72 case 7: // DATA PERIODS
4924
3/5
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 72 times.
✓ Branch 5 taken 72 times.
✗ Branch 6 not taken.
72 result = result && parseDataPeriod(line);
4925 72 break;
4926 576 default:;
4927 }
4928 }
4929
4930
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if (!result) {
4931 ✗ LOG(Error, "Failed to parse EPW file header '" << m_path << "'");
4932 ✗ return false;
4933 }
4934
4935 struct EPWString
4936 {
4937 const int lineNumber;
4938 const int year;
4939 const int month;
4940 const int day;
4941 const int hour;
4942 const int currentMinute;
4943 std::vector<std::string> strings;
4944 };
4945
4946 // read rest of file
4947 72 int lineNumber = 8;
4948 144 boost::optional<Date> startDate;
4949 144 boost::optional<Date> lastDate;
4950 144 boost::optional<Date> endDate;
4951 72 bool realYear = true;
4952 72 bool wrapAround = false;
4953
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
✗ Branch 3 not taken.
72 OS_ASSERT((60 % m_recordsPerHour) == 0);
4954 72 int minutesPerRecord = 60 / m_recordsPerHour;
4955 72 int currentMinute = 0;
4956 72 std::vector<EPWString> epw_strings;
4957
4/4
✓ Branch 1 taken 569832 times.
✓ Branch 4 taken 569832 times.
✓ Branch 6 taken 569760 times.
✓ Branch 7 taken 72 times.
569832 while (std::getline(ifs, line)) {
4958 569760 lineNumber++;
4959
1/1
✓ Branch 1 taken 569760 times.
569760 std::vector<std::string> strings = splitString(line, ',');
4960
1/2
✓ Branch 1 taken 569760 times.
✗ Branch 2 not taken.
569760 if (strings.size() >= 5) {
4961 try {
4962
1/1
✓ Branch 2 taken 569760 times.
569760 int year = std::stoi(strings[0]);
4963
1/1
✓ Branch 2 taken 569760 times.
569760 int month = std::stoi(strings[1]);
4964
1/1
✓ Branch 2 taken 569760 times.
569760 int day = std::stoi(strings[2]);
4965
4966
2/2
✓ Branch 1 taken 569760 times.
✓ Branch 4 taken 569760 times.
569760 Date date(month, day, year);
4967
2/2
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 569688 times.
569760 if (!startDate) {
4968
1/1
✓ Branch 1 taken 72 times.
72 startDate = date;
4969 }
4970
1/1
✓ Branch 1 taken 569760 times.
569760 endDate = date;
4971
4972
5/6
✓ Branch 0 taken 569760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 569688 times.
✓ Branch 3 taken 72 times.
✓ Branch 4 taken 569688 times.
✓ Branch 5 taken 72 times.
1139520 if (endDate && lastDate) {
4973
3/3
✓ Branch 1 taken 569688 times.
✓ Branch 4 taken 569688 times.
✓ Branch 7 taken 569688 times.
569688 Time delta = endDate.get() - lastDate.get();
4974
3/3
✓ Branch 1 taken 569688 times.
✓ Branch 4 taken 404 times.
✓ Branch 5 taken 569284 times.
569688 if (std::abs(delta.totalDays()) > 1) {
4975
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 361 times.
404 if (realYear) { // Warn once
4976
15/15
✓ Branch 1 taken 43 times.
✓ Branch 4 taken 43 times.
✓ Branch 7 taken 43 times.
✓ Branch 10 taken 43 times.
✓ Branch 13 taken 43 times.
✓ Branch 16 taken 43 times.
✓ Branch 19 taken 43 times.
✓ Branch 22 taken 43 times.
✓ Branch 25 taken 43 times.
✓ Branch 28 taken 43 times.
✓ Branch 31 taken 43 times.
✓ Branch 34 taken 43 times.
✓ Branch 37 taken 43 times.
✓ Branch 40 taken 43 times.
✓ Branch 43 taken 43 times.
43 LOG(Info, "Successive data points (" << lastDate.get() << " to " << endDate.get() << ", ending on line " << lineNumber
4977 << ") are greater than 1 day apart in EPW file '" << m_path
4978 << "'. Data will be treated as typical (TMY)");
4979 }
4980 404 realYear = false;
4981 }
4982
4983
8/8
✓ Branch 1 taken 569688 times.
✓ Branch 4 taken 569688 times.
✓ Branch 7 taken 569688 times.
✓ Branch 10 taken 569688 times.
✓ Branch 13 taken 569688 times.
✓ Branch 16 taken 569688 times.
✓ Branch 18 taken 2 times.
✓ Branch 19 taken 569686 times.
569688 if (endDate->monthOfYear().value() < lastDate->monthOfYear().value()) {
4984 2 wrapAround = true;
4985 }
4986 }
4987
1/1
✓ Branch 1 taken 569760 times.
569760 lastDate = date;
4988
4989 // Store the data if requested
4990
2/2
✓ Branch 0 taken 140232 times.
✓ Branch 1 taken 429528 times.
569760 if (storeData) {
4991
1/1
✓ Branch 2 taken 140232 times.
140232 int hour = std::stoi(strings[3]);
4992
1/1
✓ Branch 2 taken 140232 times.
140232 int minutesInFile = std::stoi(strings[4]);
4993 // Due to issues with some EPW files, we need to check stuff here
4994
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140232 times.
140232 if (m_recordsPerHour != 1) {
4995 ✗ currentMinute += minutesPerRecord;
4996 ✗ if (currentMinute >= 60) { // This could really be ==, but >= is used for safety
4997 ✗ currentMinute = 0;
4998 }
4999 }
5000 // Check for agreement between the file value and the computed value
5001
2/2
✓ Branch 0 taken 8760 times.
✓ Branch 1 taken 131472 times.
140232 if (currentMinute != minutesInFile) {
5002
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 8759 times.
8760 if (m_minutesMatch) { // Warn only once
5003
13/13
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
✓ Branch 16 taken 1 time.
✓ Branch 19 taken 1 time.
✓ Branch 22 taken 1 time.
✓ Branch 25 taken 1 time.
✓ Branch 28 taken 1 time.
✓ Branch 31 taken 1 time.
✓ Branch 34 taken 1 time.
✓ Branch 37 taken 1 time.
1 LOG(Error, "Minutes field (" << minutesInFile << ") on line " << lineNumber << " of EPW file '" << m_path
5004 << "' does not agree with computed value (" << currentMinute << "). Using computed value");
5005 1 m_minutesMatch = false;
5006 }
5007 }
5008
1/1
✓ Branch 1 taken 140232 times.
140232 epw_strings.push_back({lineNumber, year, month, day, hour, currentMinute, strings});
5009 }
5010
5011 ✗ } catch (...) {
5012 ✗ LOG(Error, "Could not read line " << lineNumber << " of EPW file '" << m_path << "'");
5013 ✗ return false;
5014 ✗ }
5015 } else {
5016 ✗ LOG(Error, "Insufficient weather data on line " << lineNumber << " of EPW file '" << m_path << "'");
5017 ✗ return false;
5018 }
5019 569760 }
5020
5021
2/2
✓ Branch 5 taken 140232 times.
✓ Branch 6 taken 72 times.
140304 for (const auto& epw_string : epw_strings) {
5022 140232 int day = epw_string.day;
5023
5024 // Fix for #5214: for TMY files where 28-day Feb is from a leap year, we need xxxx-Mar-01 00:00:00 and not xxxx-Feb-29 00:00:00
5025 // If the TMY file actually contained Feb 29, we still change xxxx-Feb-29 00:00:00 to xxxx-Mar-01 00:00:00, but it doesn't matter since you'd still get Bad Date on xxxx-Feb-29 01:00:00, etc.
5026
9/10
✓ Branch 0 taken 113904 times.
✓ Branch 1 taken 26328 times.
✓ Branch 2 taken 8760 times.
✓ Branch 3 taken 105144 times.
✓ Branch 4 taken 312 times.
✓ Branch 5 taken 8448 times.
✓ Branch 6 taken 13 times.
✓ Branch 7 taken 299 times.
✓ Branch 8 taken 13 times.
✗ Branch 9 not taken.
140232 if ((!realYear) && (epw_string.month == 2) && (day == 28) && (epw_string.hour == 24) && (epw_string.currentMinute == 0)) {
5027
2/2
✓ Branch 1 taken 13 times.
✓ Branch 4 taken 13 times.
13 Date date(epw_string.month, day, epw_string.year);
5028
3/3
✓ Branch 1 taken 13 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 10 times.
13 if (date.isLeapYear()) {
5029 3 day = 29;
5030 }
5031 }
5032
5033 boost::optional<EpwDataPoint> pt =
5034
1/1
✓ Branch 1 taken 140232 times.
140232 EpwDataPoint::fromEpwStrings(epw_string.year, epw_string.month, day, epw_string.hour, epw_string.currentMinute, epw_string.strings);
5035
1/2
✓ Branch 0 taken 140232 times.
✗ Branch 1 not taken.
140232 if (pt) {
5036
2/2
✓ Branch 1 taken 140232 times.
✓ Branch 4 taken 140232 times.
140232 m_data.push_back(pt.get());
5037 } else {
5038 ✗ LOG(Error, "Failed to parse line " << epw_string.lineNumber << " of EPW file '" << m_path << "'");
5039 ✗ return false;
5040 }
5041 140232 }
5042
5043
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 72 times.
72 if (!startDate) {
5044 ✗ LOG(Error, "Could not find start date in data section of EPW file '" << m_path << "'");
5045 ✗ return false;
5046 }
5047
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 72 times.
72 if (!endDate) {
5048 ✗ LOG(Error, "Could not find end date in data section of EPW file '" << m_path << "'");
5049 ✗ return false;
5050 }
5051
5052
9/12
✓ Branch 1 taken 72 times.
✓ Branch 4 taken 72 times.
✓ Branch 7 taken 72 times.
✓ Branch 10 taken 72 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 72 times.
✓ Branch 16 taken 72 times.
✓ Branch 19 taken 72 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 72 times.
✗ Branch 23 not taken.
✓ Branch 24 taken 72 times.
72 if ((m_startDate.monthOfYear() != startDate->monthOfYear()) || (m_startDate.dayOfMonth() != startDate->dayOfMonth())) {
5053 ✗ LOG(Error, "Header start date does not match data in EPW file '" << m_path << "'");
5054 ✗ return false;
5055 }
5056
5057
9/12
✓ Branch 1 taken 72 times.
✓ Branch 4 taken 72 times.
✓ Branch 7 taken 72 times.
✓ Branch 10 taken 72 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 72 times.
✓ Branch 16 taken 72 times.
✓ Branch 19 taken 72 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 72 times.
✗ Branch 23 not taken.
✓ Branch 24 taken 72 times.
72 if ((m_endDate.monthOfYear() != endDate->monthOfYear()) || (m_endDate.dayOfMonth() != endDate->dayOfMonth())) {
5058 ✗ LOG(Error, "Header end date does not match data in EPW file '" << m_path << "'");
5059 ✗ return false;
5060 }
5061
5062
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 43 times.
72 if (realYear) {
5063
4/4
✓ Branch 1 taken 29 times.
✓ Branch 4 taken 29 times.
✓ Branch 7 taken 20 times.
✓ Branch 8 taken 9 times.
29 if (m_startDayOfWeek != startDate->dayOfWeek()) {
5064
7/7
✓ Branch 1 taken 20 times.
✓ Branch 4 taken 20 times.
✓ Branch 7 taken 20 times.
✓ Branch 10 taken 20 times.
✓ Branch 13 taken 20 times.
✓ Branch 16 taken 20 times.
✓ Branch 19 taken 20 times.
20 LOG(Info, "Header start day of the week and actual start day of the week do not match in EPW file '"
5065 << m_path << "'. Data will be treated as typical (TMY)");
5066 // The flag needs to be changed so we can do the wrapAround check below
5067 20 realYear = false;
5068 } else {
5069 // set dates with years
5070
2/2
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
9 m_startDate = startDate.get();
5071
3/3
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 7 taken 9 times.
9 m_startDateActualYear = startDate->year();
5072
5073
2/2
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
9 m_endDate = endDate.get();
5074
3/3
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 7 taken 9 times.
9 m_endDateActualYear = endDate->year();
5075 }
5076 }
5077
5078
4/4
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 1 time.
✓ Branch 3 taken 62 times.
72 if (!realYear && wrapAround) {
5079
7/7
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
✓ Branch 16 taken 1 time.
✓ Branch 19 taken 1 time.
1 LOG(Error, "Wrap around years not supported for TMY data, EPW file '" << m_path << "'");
5080 1 return false;
5081 }
5082
5083
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 62 times.
71 if (realYear) {
5084 9 m_isActual = true;
5085 }
5086
5087 71 return result;
5088 140304 }
5089
5090 72 bool EpwFile::parseLocation(const std::string& line) {
5091 // LOCATION,Chicago Ohare Intl Ap,IL,USA,TMY3,725300,41.98,-87.92,-6.0,201.0
5092 // LOCATION, city, stateProvinceRegion, country, dataSource, wmoNumber, latitude, longitude, timeZone, elevation
5093
1/1
✓ Branch 1 taken 72 times.
72 std::vector<std::string> split = splitString(line, ',');
5094
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 72 times.
72 if (split.size() < 10) {
5095 ✗ LOG(Error, "Expected 10 location fields rather than the " << split.size() << " fields in EPW file '" << m_path << "'");
5096 ✗ return false;
5097
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 72 times.
72 } else if (split.size() > 10) {
5098 ✗ LOG(Warn, "Expected 10 location fields rather than the " << split.size() << " fields in EPW file '" << m_path
5099 << "', additional fields will be ignored");
5100 }
5101
5102
2/3
✓ Branch 2 taken 72 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 72 times.
72 if (split[0] != "LOCATION") {
5103 ✗ LOG(Error, "Missing LOCATION specifier in EPW file '" << m_path << "'");
5104 ✗ return false;
5105 }
5106
5107
1/1
✓ Branch 2 taken 72 times.
72 m_city = split[1];
5108
1/1
✓ Branch 2 taken 72 times.
72 boost::trim(m_city);
5109
1/1
✓ Branch 2 taken 72 times.
72 m_stateProvinceRegion = split[2];
5110
1/1
✓ Branch 2 taken 72 times.
72 boost::trim(m_stateProvinceRegion);
5111
1/1
✓ Branch 2 taken 72 times.
72 m_country = split[3];
5112
1/1
✓ Branch 2 taken 72 times.
72 boost::trim(m_country);
5113
1/1
✓ Branch 2 taken 72 times.
72 m_dataSource = split[4];
5114
1/1
✓ Branch 2 taken 72 times.
72 boost::trim(m_dataSource);
5115
1/1
✓ Branch 2 taken 72 times.
72 m_wmoNumber = split[5];
5116
1/1
✓ Branch 2 taken 72 times.
72 boost::trim(m_wmoNumber);
5117
5118
1/1
✓ Branch 2 taken 72 times.
72 std::string latitude = split[6];
5119
1/1
✓ Branch 2 taken 72 times.
72 boost::trim(latitude);
5120
1/1
✓ Branch 2 taken 72 times.
72 std::string longitude = split[7];
5121
1/1
✓ Branch 2 taken 72 times.
72 boost::trim(longitude);
5122
1/1
✓ Branch 2 taken 72 times.
72 std::string timeZone = split[8];
5123
1/1
✓ Branch 2 taken 72 times.
72 boost::trim(timeZone);
5124
1/1
✓ Branch 2 taken 72 times.
72 std::string elevation = split[9];
5125
1/1
✓ Branch 2 taken 72 times.
72 boost::trim(elevation);
5126
5127 try {
5128
1/1
✓ Branch 1 taken 72 times.
72 m_latitude = std::stod(latitude);
5129 ✗ } catch (...) {
5130 ✗ LOG(Error, "Non-numerical latitude in EPW file '" << m_path << "'");
5131 ✗ return false;
5132 ✗ }
5133 try {
5134
1/1
✓ Branch 1 taken 72 times.
72 m_longitude = std::stod(longitude);
5135 ✗ } catch (...) {
5136 ✗ LOG(Error, "Non-numerical longitude in EPW file '" << m_path << "'");
5137 ✗ return false;
5138 ✗ }
5139 try {
5140
1/1
✓ Branch 1 taken 72 times.
72 m_timeZone = std::stod(timeZone);
5141 ✗ } catch (...) {
5142 ✗ LOG(Error, "Non-numerical timezone in EPW file '" << m_path << "'");
5143 ✗ return false;
5144 ✗ }
5145 try {
5146
1/1
✓ Branch 1 taken 72 times.
72 m_elevation = std::stod(elevation);
5147 ✗ } catch (...) {
5148 ✗ LOG(Error, "Non-numerical elevation in EPW file '" << m_path << "'");
5149 ✗ return false;
5150 ✗ }
5151
5152 72 return true;
5153 72 }
5154
5155 72 bool EpwFile::parseDesignConditions(const std::string& line) {
5156 // DESIGN CONDITIONS,1,Climate Design Data 2009 ASHRAE Handbook,,Heating,12,-17.4,-14,-21.5,0.7,-11.7,-18.9,0.9,-6.9,14.1,1.8,12,2.4,3.3,160,Cooling,7,15.2,34.6,15.7,33.2,15.6,31.8,15.4,18.3,27.3,17.6,27,17,26.5,4.2,80,16,14,19.9,15.2,13.2,19.7,14.1,12.3,19.6,58.3,27,55.9,26.9,53.8,26.3,722,Extremes,11.9,10.4,8.8,20.7,-22.7,37.1,2.8,1.3,-24.7,38,-26.3,38.8,-27.9,39.5,-29.9,40.5
5157 // DESIGN CONDITIONS,Number of Design Conditions,Title of Design Condition,Design Stat,HDB 99.6%,HDB 99%,X WS 1%,X WS 2.5%,X WS 5%,CM WS .4%,CM MDB .4%,CM WS 1%,CM MDB 1%,MWS 99.6%,PWD 99.6%,MWS .4%,PWD .4%,X MnDB Max,X MnDB Min,X StdDB Max,X StdDB Min,Design Stat,CDB .4%,C MWB .4%,CDB 1%,C MWB 1%,CDB 2%,C MWB 2%,E WB .4%,E MDB .4%,E WB 1%,E MDB 1%,E WB 2%,E MDB 2%,DP .4%,HR .4%,MDB .4%,DP 1%,HR 1%,MDB 1%,DP 2%,HR 2%,MDB 2%,DB Range
5158 // Bail out if the design conditions array already has contents
5159
2/2
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 62 times.
72 if (!m_designs.empty()) {
5160 10 return true;
5161 }
5162
5163
1/1
✓ Branch 1 taken 62 times.
62 std::vector<std::string> split = splitString(line, ',');
5164
5165
2/3
✓ Branch 2 taken 62 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 62 times.
62 if (split[0] != "DESIGN CONDITIONS") {
5166 ✗ LOG(Error, "Missing DESIGN CONDITIONS specifier in EPW file '" << m_path << "'");
5167 ✗ return false;
5168
2/3
✓ Branch 2 taken 62 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 62 times.
62 } else if (split[1] == "0") {
5169 ✗ LOG(Warn, "Appears there are no design condition fields in the EPW file '" << m_path << "'");
5170 ✗ return true;
5171 }
5172
5173
1/1
✓ Branch 2 taken 62 times.
62 int nDesignConditions = std::stoi(split[1]);
5174
5175 62 size_t num_design_cond_fields = 68;
5176 62 size_t expected_split_size = 2 + nDesignConditions * num_design_cond_fields;
5177
2/2
✓ Branch 1 taken 1 time.
✓ Branch 2 taken 61 times.
62 if (split.size() != expected_split_size) {
5178 // Could technically happen if EPW was prepared with HoF 2017, but never seen a file like that
5179 1 num_design_cond_fields = 67;
5180 1 expected_split_size = 2 + nDesignConditions * num_design_cond_fields;
5181
5182
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
1 if (split.size() != expected_split_size) {
5183 ✗ LOG(Warn, "Expected " << expected_split_size << " design condition fields rather than the " << split.size() << " fields in the EPW file '"
5184 << m_path << "'. Design conditions will not be parsed.");
5185 ✗ nDesignConditions = 0;
5186 }
5187 }
5188
5189
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if (nDesignConditions > 1) {
5190 ✗ LOG(Warn, "Found " << nDesignConditions << " in the EPW file '" << m_path << "'");
5191 }
5192
5193
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 62 times.
114 for (int j = 0; j < nDesignConditions; j++) {
5194
1/1
✓ Branch 1 taken 52 times.
52 std::vector<std::string> design_condition(num_design_cond_fields);
5195
2/2
✓ Branch 0 taken 3535 times.
✓ Branch 1 taken 52 times.
3587 for (size_t k = 0; k < num_design_cond_fields; k++) {
5196
1/1
✓ Branch 3 taken 3535 times.
3535 design_condition[k] = split[k + 2 + (num_design_cond_fields * j)];
5197 }
5198
1/1
✓ Branch 1 taken 52 times.
52 boost::optional<EpwDesignCondition> dc = EpwDesignCondition::fromDesignConditionsStrings(design_condition);
5199
1/2
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
52 if (dc) {
5200
2/2
✓ Branch 1 taken 52 times.
✓ Branch 4 taken 52 times.
52 m_designs.push_back(dc.get());
5201 } else {
5202 ✗ LOG(Error, "Failed to parse design condition " << j + 1 << " of EPW file '" << m_path << "'");
5203 ✗ return false;
5204 }
5205 52 }
5206 62 return true;
5207 62 }
5208
5209 72 bool EpwFile::parseGroundTemperatures(const std::string& line) {
5210 // GROUND TEMPERATURES,3,.5,,,,-0.60,1.34,5.12,8.69,15.46,19.02,20.00,18.20,14.02,8.83,3.71,0.32,2,,,,2.08,2.55,4.70,7.10,12.30,15.62,17.28,16.91,14.53,10.94,6.90,3.72,4,,,,4.84,4.51,5.45,6.81,10.25,12.82,14.49,14.90,13.86,11.74,9.00,6.53
5211 // Number of Ground Temperature Depths,Ground Temperature Depth {m},Soil Conductivity {W/m-K},Soil Density {kg/m3},Soil Specific Heat {J/kg-K},Jan {C},Feb{C},Mar {C},Apr {C},May {C},Jun {C},Jul {C},Aug {C},Sep {C},Oct {C},Nov {C},Dec {C},<repeat to Number of temperature depths>
5212 // Bail out if the ground temperature depths array already has contents
5213
2/2
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 61 times.
72 if (!m_depths.empty()) {
5214 11 return true;
5215 }
5216
5217
1/1
✓ Branch 1 taken 61 times.
61 std::vector<std::string> split = splitString(line, ',');
5218
5219
2/3
✓ Branch 2 taken 61 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 61 times.
61 if (split[0] != "GROUND TEMPERATURES") {
5220 ✗ LOG(Error, "Missing GROUND TEMPERATURES specifier in EPW file '" << m_path << "'");
5221 ✗ return false;
5222
2/3
✓ Branch 2 taken 61 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 61 times.
61 } else if (split[1] == "0") {
5223 ✗ LOG(Warn, "Appears there are no ground temperature depth fields in the EPW file '" << m_path << "'");
5224 ✗ return true;
5225 }
5226
5227
1/1
✓ Branch 2 taken 61 times.
61 size_t nGroundTemperatureDepths = std::stoi(split[1]);
5228 61 size_t expected_split_size = 2 + (nGroundTemperatureDepths * NUMBER_GROUND_TEMP_STRINGS);
5229
5230
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 61 times.
61 if (split.size() != expected_split_size) {
5231 ✗ LOG(Error, "Expected " << expected_split_size << " ground temperature depth fields rather than the " << split.size()
5232 << " fields in the EPW file '" << m_path << "'. Ground temperature depths will not be parsed.");
5233 ✗ return false;
5234 }
5235
9/9
✓ Branch 1 taken 61 times.
✓ Branch 4 taken 61 times.
✓ Branch 7 taken 61 times.
✓ Branch 10 taken 61 times.
✓ Branch 13 taken 61 times.
✓ Branch 16 taken 61 times.
✓ Branch 19 taken 61 times.
✓ Branch 22 taken 61 times.
✓ Branch 25 taken 61 times.
61 LOG(Info, "Found " << nGroundTemperatureDepths << " ground temperature depths in the EPW file '" << m_path << "'");
5236
5237
2/2
✓ Branch 0 taken 159 times.
✓ Branch 1 taken 61 times.
220 for (size_t i = 0; i < nGroundTemperatureDepths; ++i) {
5238 159 std::vector<std::string> ground_temperature_depth(std::next(split.begin(), 2 + NUMBER_GROUND_TEMP_STRINGS * i),
5239
1/1
✓ Branch 3 taken 159 times.
477 std::next(split.begin(), 2 + NUMBER_GROUND_TEMP_STRINGS * (i + 1)));
5240
1/1
✓ Branch 1 taken 159 times.
159 boost::optional<EpwGroundTemperatureDepth> gtd = EpwGroundTemperatureDepth::fromGroundTemperatureDepthsStrings(ground_temperature_depth);
5241
1/2
✓ Branch 0 taken 159 times.
✗ Branch 1 not taken.
159 if (gtd) {
5242
2/2
✓ Branch 1 taken 159 times.
✓ Branch 5 taken 159 times.
159 m_depths.push_back(std::move(*gtd));
5243 } else {
5244 ✗ LOG(Error, "Failed to parse ground temperature depth group " << i + 1 << " of EPW file '" << m_path << "'");
5245 ✗ return false;
5246 }
5247 159 }
5248 // Ensure sorted by lower to higher depths
5249
1/1
✓ Branch 3 taken 61 times.
61 std::sort(m_depths.begin(), m_depths.end(),
5250 212 [](const auto& lhs, const auto& rhs) { return lhs.groundTemperatureDepth() < rhs.groundTemperatureDepth(); });
5251 61 return true;
5252 61 }
5253
5254 72 bool EpwFile::parseHolidaysDaylightSavings(const std::string& line) {
5255
5256 // HOLIDAYS/DAYLIGHT SAVINGS,No, 4/29,10/28,9,Hol:001, 1/ 1,Hol:002, 2/19,Hol:003, 5/28,Hol:004, 7/ 4,Hol:005, 9/ 3,Hol:006,10/ 8,Hol:007,11/12,Hol:008,11/22,Hol:009,12/25
5257 // specified, leapYearObserved, daylightSavingStartDay, daylightSavingEndDay, numberOfHolidays, FieldSet:<holidayName , holidayDay>
5258
5259
1/1
✓ Branch 1 taken 72 times.
72 std::vector<std::string> split = splitString(line, ',');
5260
1/1
✓ Branch 2 taken 72 times.
72 std::string specifier = split[0];
5261
1/1
✓ Branch 2 taken 72 times.
72 boost::trim(specifier);
5262
3/4
✓ Branch 1 taken 72 times.
✓ Branch 4 taken 72 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 72 times.
144 if (!istringEqual(specifier, "HOLIDAYS/DAYLIGHT SAVINGS")) {
5263 ✗ LOG(Error, "Missing 'HOLIDAYS/DAYLIGHT SAVINGS' specifier in EPW file '" << m_path << "'");
5264 ✗ return false;
5265 }
5266
5267
1/1
✓ Branch 2 taken 72 times.
72 std::string leapYearObserved = split[1];
5268
1/1
✓ Branch 2 taken 72 times.
72 boost::trim(leapYearObserved);
5269
2/2
✓ Branch 1 taken 72 times.
✓ Branch 4 taken 72 times.
72 m_leapYearObserved = istringEqual("Yes", leapYearObserved);
5270
5271
1/1
✓ Branch 2 taken 72 times.
72 std::string daylightSavingStartDay = split[2];
5272
1/1
✓ Branch 2 taken 72 times.
72 boost::trim(daylightSavingStartDay);
5273
1/1
✓ Branch 2 taken 72 times.
72 std::string daylightSavingEndDay = split[3];
5274
1/1
✓ Branch 2 taken 72 times.
72 boost::trim(daylightSavingEndDay);
5275
5276 72 bool processDaylightDates = true;
5277
3/3
✓ Branch 1 taken 72 times.
✓ Branch 3 taken 71 times.
✓ Branch 4 taken 1 time.
72 if (daylightSavingStartDay == "0") {
5278
5/5
✓ Branch 1 taken 71 times.
✓ Branch 4 taken 71 times.
✓ Branch 7 taken 71 times.
✓ Branch 10 taken 71 times.
✓ Branch 13 taken 71 times.
71 LOG(Debug, "No Daylightings Saving start Date");
5279 71 processDaylightDates = false;
5280 } else {
5281
2/3
✓ Branch 1 taken 1 time.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 time.
1 if (daylightSavingEndDay == "0") {
5282 ✗ LOG(Error, "No Daylightings Saving End Date, skipping.");
5283 ✗ processDaylightDates = false;
5284 } else {
5285
5286 try {
5287 // Parse start month and day, optional year
5288
1/1
✓ Branch 1 taken 1 time.
1 std::vector<std::string> dateSplit = splitString(daylightSavingStartDay, '/');
5289
2/6
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 time.
1 if (dateSplit.size() != 2 && dateSplit.size() != 3) {
5290 ✗ LOG(Error, "Bad data Daylight Savings Start Day format '" << daylightSavingStartDay << "' in EPW file '" << m_path << "'");
5291 ✗ return false;
5292 }
5293
1/1
✓ Branch 2 taken 1 time.
1 int month = std::stoi(dateSplit[0]);
5294
1/1
✓ Branch 2 taken 1 time.
1 int day = std::stoi(dateSplit[1]);
5295
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
1 if (dateSplit.size() == 3) {
5296 ✗ int year = std::stoi(dateSplit[1]);
5297 ✗ m_daylightSavingStartDate = Date(monthOfYear(month), day, year);
5298 } else {
5299
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
1 m_daylightSavingStartDate = Date(monthOfYear(month), day);
5300 }
5301
1/2
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
1 } catch (...) {
5302 ✗ LOG(Error, "Failed to parse Daylight Savings Start Day '" << daylightSavingStartDay << "' in EPW file '" << m_path << "'");
5303 ✗ return false;
5304 ✗ }
5305 }
5306 }
5307
5308
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 71 times.
72 if (processDaylightDates) {
5309
5310 try {
5311 // Parse end month and day, optional year
5312
1/1
✓ Branch 1 taken 1 time.
1 std::vector<std::string> dateSplit = splitString(daylightSavingEndDay, '/');
5313
2/6
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 time.
1 if (dateSplit.size() != 2 && dateSplit.size() != 3) {
5314 ✗ LOG(Error, "Bad data Daylight Savings End Day format '" << daylightSavingEndDay << "' in EPW file '" << m_path << "'");
5315 ✗ return false;
5316 }
5317
1/1
✓ Branch 2 taken 1 time.
1 int month = std::stoi(dateSplit[0]);
5318
1/1
✓ Branch 2 taken 1 time.
1 int day = std::stoi(dateSplit[1]);
5319
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
1 if (dateSplit.size() == 3) {
5320 ✗ int year = std::stoi(dateSplit[1]);
5321 ✗ m_daylightSavingEndDate = Date(monthOfYear(month), day, year);
5322 } else {
5323
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
1 m_daylightSavingEndDate = Date(monthOfYear(month), day);
5324 }
5325
1/2
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
1 } catch (...) {
5326 ✗ LOG(Error, "Failed to parse Daylight Savings End Day '" << daylightSavingEndDay << "' in EPW file '" << m_path << "'");
5327 ✗ return false;
5328 ✗ }
5329 }
5330
5331
1/1
✓ Branch 2 taken 72 times.
72 std::string numberOfHolidays = split[4];
5332
1/1
✓ Branch 2 taken 72 times.
72 boost::trim(numberOfHolidays);
5333 72 int nHolidays = 0;
5334 try {
5335
1/1
✓ Branch 1 taken 72 times.
72 nHolidays = std::stoi(numberOfHolidays);
5336 ✗ } catch (...) {
5337 ✗ LOG(Error, "Non-integral number of holidays in EPW file '" << m_path << "'");
5338 ✗ return false;
5339 ✗ }
5340
5341
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 72 times.
81 for (int i = 5; i < 5 + (2 * nHolidays); i += 2) {
5342
1/1
✓ Branch 2 taken 9 times.
9 std::string holidayName = split[i];
5343
1/1
✓ Branch 2 taken 9 times.
9 boost::trim(holidayName);
5344
1/1
✓ Branch 2 taken 9 times.
9 std::string holidayDay = split[i + 1];
5345
1/1
✓ Branch 2 taken 9 times.
9 boost::trim(holidayDay);
5346 // Need to parse the dates?
5347
5348
3/6
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 9 times.
9 if (holidayName.empty() || holidayDay.empty()) {
5349 ✗ LOG(Error,
5350 "Empty Holiday Day or Day for entry " << i << ": (holidayName, holidayDay) = (" << holidayName << ", " << holidayDay << "). Skipping.");
5351 ✗ continue;
5352 ✗ }
5353
2/2
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
9 m_holidays.push_back(EpwHoliday(holidayName, holidayDay));
5354 9 }
5355
5356 72 return true;
5357 72 }
5358
5359 3 boost::optional<Date> EpwFile::daylightSavingStartDate() const {
5360 3 return m_daylightSavingStartDate;
5361 }
5362
5363 3 boost::optional<Date> EpwFile::daylightSavingEndDate() const {
5364 3 return m_daylightSavingEndDate;
5365 }
5366
5367 2 std::vector<EpwHoliday> EpwFile::holidays() const {
5368 2 return m_holidays;
5369 }
5370
5371 72 bool EpwFile::parseDataPeriod(const std::string& line) {
5372 // DATA PERIODS,1,1,Data,Sunday, 1/ 1,12/31
5373 // DATA PERIODS, nDataPeriods, timeStep, startDayOfWeek, startDate, endDate
5374 // NOTE THAT ONLY ONE DATA PERIOD IS SUPPORTED
5375
1/1
✓ Branch 1 taken 72 times.
72 std::vector<std::string> split = splitString(line, ',');
5376
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 72 times.
72 if (split.size() < 7) {
5377 ✗ LOG(Error, "Expected 7 data period fields rather than the " << split.size() << " fields in EPW file '" << m_path << "'");
5378 ✗ return false;
5379
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 72 times.
72 } else if (split.size() > 7) {
5380 ✗ LOG(Warn, "Expected 7 data period fields rather than the " << split.size() << " fields in EPW file '" << m_path
5381 << "', additional fields will be ignored");
5382 }
5383
5384
2/3
✓ Branch 2 taken 72 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 72 times.
72 if (split[0] != "DATA PERIODS") {
5385 ✗ LOG(Error, "Missing DATA PERIODS specifier in EPW file '" << m_path << "'");
5386 ✗ return false;
5387 }
5388
5389
1/1
✓ Branch 2 taken 72 times.
72 std::string nDataPeriods = split[1];
5390
1/1
✓ Branch 2 taken 72 times.
72 boost::trim(nDataPeriods);
5391
1/1
✓ Branch 2 taken 72 times.
72 std::string timeStep = split[2];
5392
1/1
✓ Branch 2 taken 72 times.
72 boost::trim(timeStep);
5393
1/1
✓ Branch 2 taken 72 times.
72 std::string startDayOfWeek = split[4];
5394
1/1
✓ Branch 2 taken 72 times.
72 boost::trim(startDayOfWeek);
5395
1/1
✓ Branch 2 taken 72 times.
72 std::string startDate = split[5];
5396
1/1
✓ Branch 2 taken 72 times.
72 boost::trim(startDate);
5397
1/1
✓ Branch 2 taken 72 times.
72 std::string endDate = split[6];
5398
1/1
✓ Branch 2 taken 72 times.
72 boost::trim(endDate);
5399
5400 try {
5401
1/1
✓ Branch 1 taken 72 times.
72 int N = std::stoi(nDataPeriods);
5402
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if (N > 1) {
5403 ✗ LOG(Error, "More than one data period in EPW file '" << m_path << "', which is not supported");
5404 ✗ return false;
5405 }
5406 ✗ } catch (...) {
5407 ✗ LOG(Error, "Non-integral number of data periods in EPW file '" << m_path << "'");
5408 ✗ return false;
5409 ✗ }
5410
5411 try {
5412
1/1
✓ Branch 1 taken 72 times.
72 m_recordsPerHour = std::stoi(timeStep);
5413
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if ((60 % m_recordsPerHour) != 0) {
5414 ✗ LOG(Error, "Number of records per hour of " << m_recordsPerHour
5415 << " does not result in integral number of minutes between records in EPW file '" << m_path << "'");
5416 ✗ return false;
5417 }
5418 ✗ } catch (...) {
5419 ✗ LOG(Error, "Non-integral timestep in EPW file '" << m_path << "'");
5420 ✗ return false;
5421 ✗ }
5422
5423 try {
5424
1/1
✓ Branch 1 taken 72 times.
72 m_startDayOfWeek = DayOfWeek(startDayOfWeek);
5425 ✗ } catch (...) {
5426 ✗ LOG(Error, "Bad start day of week in EPW file '" << m_path << "'");
5427 ✗ return false;
5428 ✗ }
5429
5430 try {
5431 // Parse start month and day, optional year
5432
1/1
✓ Branch 1 taken 72 times.
72 split = splitString(startDate, '/');
5433
4/6
✓ Branch 1 taken 1 time.
✓ Branch 2 taken 71 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 time.
✗ Branch 6 not taken.
✓ Branch 7 taken 72 times.
72 if (split.size() != 2 && split.size() != 3) {
5434 ✗ LOG(Error, "Bad data period start date format '" << startDate << "' in EPW file '" << m_path << "'");
5435 ✗ return false;
5436 }
5437
1/1
✓ Branch 2 taken 72 times.
72 int month = std::stoi(split[0]);
5438
1/1
✓ Branch 2 taken 72 times.
72 int day = std::stoi(split[1]);
5439
2/2
✓ Branch 1 taken 1 time.
✓ Branch 2 taken 71 times.
72 if (split.size() == 3) {
5440
1/1
✓ Branch 2 taken 1 time.
1 int year = std::stoi(split[2]);
5441
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
1 m_startDate = Date(monthOfYear(month), day, year);
5442
1/1
✓ Branch 1 taken 1 time.
1 m_startDateActualYear = year;
5443 } else {
5444
3/3
✓ Branch 1 taken 71 times.
✓ Branch 4 taken 71 times.
✓ Branch 7 taken 71 times.
71 m_startDate = Date(monthOfYear(month), day);
5445 }
5446 ✗ } catch (...) {
5447 ✗ LOG(Error, "Failed to parse data period start date from '" << startDate << "' in EPW file '" << m_path << "'");
5448 ✗ return false;
5449 ✗ }
5450
5451 try {
5452 // Parse end month and day, optional year
5453
1/1
✓ Branch 1 taken 72 times.
72 split = splitString(endDate, '/');
5454
4/6
✓ Branch 1 taken 1 time.
✓ Branch 2 taken 71 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 time.
✗ Branch 6 not taken.
✓ Branch 7 taken 72 times.
72 if (split.size() != 2 && split.size() != 3) {
5455 ✗ LOG(Error, "Bad data period end date format '" << startDate << "' in EPW file '" << m_path << "'");
5456 ✗ return false;
5457 }
5458
1/1
✓ Branch 2 taken 72 times.
72 int month = std::stoi(split[0]);
5459
1/1
✓ Branch 2 taken 72 times.
72 int day = std::stoi(split[1]);
5460
2/2
✓ Branch 1 taken 1 time.
✓ Branch 2 taken 71 times.
72 if (split.size() == 3) {
5461
1/1
✓ Branch 2 taken 1 time.
1 int year = std::stoi(split[2]);
5462
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
1 m_endDate = Date(monthOfYear(month), day, year);
5463
1/1
✓ Branch 1 taken 1 time.
1 m_endDateActualYear = year;
5464 } else {
5465
3/3
✓ Branch 1 taken 71 times.
✓ Branch 4 taken 71 times.
✓ Branch 7 taken 71 times.
71 m_endDate = Date(monthOfYear(month), day);
5466 }
5467 ✗ } catch (...) {
5468 ✗ LOG(Error, "Failed to parse data period end date from '" << startDate << "' in EPW file '" << m_path << "'");
5469 ✗ return false;
5470 ✗ }
5471
5472 72 return true;
5473 72 }
5474
5475 80291 bool EpwFile::isActual() const {
5476 80291 return m_isActual;
5477 }
5478
5479 ✗ bool EpwFile::minutesMatch() const {
5480 ✗ return m_minutesMatch;
5481 }
5482
5483 ✗ IdfObject toIdfObject(const EpwFile& epwFile) {
5484 ✗ IdfObject result(IddObjectType::OS_WeatherFile);
5485
5486 ✗ bool success = true;
5487
5488 ✗ success = success && result.setString(0, epwFile.city());
5489 ✗ success = success && result.setString(1, epwFile.stateProvinceRegion());
5490 ✗ success = success && result.setString(2, epwFile.country());
5491 ✗ success = success && result.setString(3, epwFile.dataSource());
5492 ✗ success = success && result.setString(4, epwFile.wmoNumber());
5493 ✗ success = success && result.setDouble(5, epwFile.latitude());
5494 ✗ success = success && result.setDouble(6, epwFile.longitude());
5495 ✗ success = success && result.setDouble(7, epwFile.timeZone());
5496 ✗ success = success && result.setDouble(8, epwFile.elevation());
5497 ✗ success = success && result.setString(9, toString(epwFile.path()));
5498 ✗ success = success && result.setString(10, epwFile.checksum());
5499
5500 ✗ if (!success) {
5501 ✗ LOG_FREE(Error, "openstudio.EpwFile", "Unable to construct WeatherFile IdfObject from epwFile at path " << epwFile.path() << ".");
5502 }
5503
5504 ✗ return result;
5505 ✗ }
5506
5507 } // namespace openstudio
5508