-
Notifications
You must be signed in to change notification settings - Fork 195
/
EpwFile.cpp
4414 lines (3935 loc) · 152 KB
/
EpwFile.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/***********************************************************************************************************************
* OpenStudio(R), Copyright (c) Alliance for Sustainable Energy, LLC.
* See also https://openstudio.net/license
***********************************************************************************************************************/
#include "EpwFile.hpp"
#include "../idf/IdfObject.hpp"
#include "../idd/IddEnums.hpp"
#include <utilities/idd/IddEnums.hxx>
#include "../core/Checksum.hpp"
#include "../core/StringHelpers.hpp"
#include "../core/Assert.hpp"
#include <fmt/format.h>
#include <cmath>
namespace openstudio {
static double psat(double T) {
// Compute water vapor saturation pressure, eqns 5 and 6 from ASHRAE Fundamentals 2009 Ch. 1
// This version takes T in C rather than Kelvin since most of the other eqns use C
T += 273.15;
double C1 = -5.6745359e+03;
double C2 = 6.3925247e+00;
double C3 = -9.6778430e-03;
double C4 = 6.2215701e-07;
double C5 = 2.0747825e-09;
double C6 = -9.4840240e-13;
double C7 = 4.1635019e+00;
double C8 = -5.8002206e+03;
double C9 = 1.3914993e+00;
double C10 = -4.8640239e-02;
double C11 = 4.1764768e-05;
double C12 = -1.4452093e-08;
double C13 = 6.5459673e+00;
double rhs;
if (T < 273.15) {
rhs = C1 / T + C2 + T * (C3 + T * (C4 + T * (C5 + T * C6))) + C7 * std::log(T);
} else {
rhs = C8 / T + C9 + T * (C10 + T * (C11 + T * C12)) + C13 * std::log(T);
}
return exp(rhs);
}
static double psatp(double T, double psat) {
// Compute the derivative of the water vapor saturation pressure function (eqns 5 and 6 from
// ASHRAE Fundamentals 2009 Ch. 1)
// This version takes T in C rather than Kelvin since most of the other eqns use C
T += 273.15;
double C1 = -5.6745359e+03;
double C3 = -9.6778430e-03;
double C4 = 6.2215701e-07;
double C5 = 2.0747825e-09;
double C6 = -9.4840240e-13;
double C7 = 4.1635019e+00;
double C8 = -5.8002206e+03;
double C10 = -4.8640239e-02;
double C11 = 4.1764768e-05;
double C12 = -1.4452093e-08;
double C13 = 6.5459673e+00;
double fp;
double T2 = T * T;
double T3 = T * T2;
if (T < 273.15) {
fp = -C1 / T2 + C3 + 2 * T * C4 + 3 * T2 * C5 + 4 * T3 * C6 + C7 / T;
} else {
fp = -C8 / T2 + C10 + 2 * T * C11 + 3 * T2 * C12 + C13 / T;
}
//std::cout << "psatp: " << T - 273.15 << " " << fp << " " << fp*psat << '\n';
return fp * psat;
}
// Note JM 2019-01-03: suppress -Wunused-function warning for this API function
[[maybe_unused]] static double enthalpy(double T, double p, double phi) {
// Compute moist air enthalpy, eqns 5, 6, 22, 24, and 32 from ASHRAE Fundamentals 2009 Ch. 1
double pw = phi * psat(T); // Partial pressure of water vapor, eqn 24 (uses eqns 5 and 6)
double W = 0.621945 * pw / (p - pw); // Humidity ratio, eqn 22
return 1.006 * T + W * (2501 + 1.86 * T); // Moist air specific enthalpy, eqn 32
}
[[maybe_unused]] static double enthalpyFromDewPoint(double T, double p, double Tdewpoint) {
// Compute moist air enthalpy, eqns 5, 6, 22, 32, and 38 from ASHRAE Fundamentals 2009 Ch. 1
double pw = openstudio::psat(Tdewpoint); // Partial pressure of water vapor, eqn 38 (uses eqns 5 and 6)
double W = 0.621945 * pw / (p - pw); // Humidity ratio, eqn 22
return 1.006 * T + W * (2501 + 1.86 * T); // Moist air specific enthalpy, eqn 32
}
// Using equation 35/37 in ASHRAE Fundamentals 2009 Ch. 1:
//
// W = (A W*_s - B)/C
//
// where A, B, C, and W*_s are all function of wet bulb t*
// Solve for the root of
//
// f = W C - A W*_s + B
//
// To make things even more opaque, lets use
//
// A = a0 + a1 t*
// B = b (t - t*)
// C = c0 + c1 t + c2 t*
//
static boost::optional<double> solveForWetBulb(double drybulb, double p, double W, double deltaLimit, int itermax) {
double tstar = drybulb;
double Ap;
double Bp;
double Cp;
double a0;
double a1;
double b;
double c0;
double c1t;
double c2;
int i = 0;
a0 = 2501;
a1 = -2.326;
b = 1.006;
c0 = 2501;
c1t = 1.86 * drybulb;
c2 = -4.186;
Ap = -2.326;
Bp = -1.006;
Cp = -4.186;
if (drybulb < 0) {
a0 = 2830;
a1 = -0.24;
c0 = 2830;
c2 = -2.1;
Ap = -0.24;
Cp = -2.1;
}
while (i < itermax) {
i++;
double A = a0 + a1 * tstar;
double B = b * (drybulb - tstar);
double C = c0 + c1t + c2 * tstar;
double pwsstar = psat(tstar);
double pwsstarp = psatp(tstar, pwsstar);
double deltap = p - pwsstar;
double Wsstar = 0.621945 * pwsstar / deltap;
double Wsstarp = (0.621945 * pwsstarp * deltap + 0.621945 * pwsstar * pwsstarp) / (deltap * deltap);
double f = W * C - A * Wsstar + B;
double fp = W * Cp - A * Wsstarp - Ap * Wsstar + Bp;
double delta = -f / fp;
tstar += delta;
// std::cout << i << " " << tstar << " " << delta / (273.15 + tstar) << '\n';
if (std::fabs(delta / (273.15 + tstar)) <= deltaLimit) {
return boost::optional<double>(tstar);
}
}
return boost::none;
}
// Using equation 38 in ASHRAE Fundamentals 2009 Ch. 1:
//
// psat(td) = pw
//
static boost::optional<double> solveForDewPoint(double drybulb, double pw, double deltaLimit, int itermax) {
//double deltaLimit = percentChange*0.01;
double tdew = drybulb;
int i = 0;
while (i < itermax) {
i++;
double pws = psat(tdew);
double f = pws - pw;
double fp = psatp(tdew, pws);
double delta = -f / fp;
tdew += delta;
// std::cout << i << " " << tdew << " " << delta / (273.15 + tdew) << '\n';
if (std::fabs(delta / (273.15 + tdew)) <= deltaLimit) {
return boost::optional<double>(tdew);
}
}
return boost::none;
}
AirState::AirState() {
// Set parameters
m_drybulb = 20.0;
m_pressure = 101325.0;
m_phi = 0.5;
// Compute moist air properties, eqns from ASHRAE Fundamentals 2009 Ch. 1, should probably just set all of these
m_psat = psat(m_drybulb); // Water vapor saturation pressure (uses eqns 5 and 6)
double pw = m_phi * m_psat; // Relative humidity, eqn 24
m_W = 0.621945 * pw / (m_pressure - pw); // Humidity ratio, eqn 22
// TODO: Use the function above
m_h = 1.006 * m_drybulb + m_W * (2501 + 1.86 * m_drybulb); // Moist air specific enthalpy, eqn 32
m_v = 0.287042 * (m_drybulb + 273.15) * (1 + 1.607858 * m_W) / m_pressure; // Specific volume, eqn 28
// Compute the dew point temperature here
boost::optional<double> dewpoint = solveForDewPoint(m_drybulb, pw, 1e-4, 100);
OS_ASSERT(dewpoint);
m_dewpoint = dewpoint.get();
// Compute the wet bulb temperature here
boost::optional<double> wetbulb = solveForWetBulb(m_drybulb, m_pressure, m_W, 1e-4, 100);
OS_ASSERT(wetbulb);
m_wetbulb = wetbulb.get();
}
boost::optional<AirState> AirState::fromDryBulbDewPointPressure(double drybulb, double dewpoint, double pressure) {
AirState state;
if (drybulb < -100.0 || drybulb > 200.0) {
// Out of the range of our current psat function
return boost::none;
}
if (dewpoint < -100.0 || dewpoint > 200.0) {
// Out of the range of our current psat function
return boost::none;
}
state.m_drybulb = drybulb;
state.m_dewpoint = dewpoint;
state.m_pressure = pressure;
// Compute moist air properties, eqns from ASHRAE Fundamentals 2009 Ch. 1
double pw = psat(dewpoint); // // Partial pressure of water vapor, eqn 38 (uses eqns 5 and 6)
state.m_W = 0.621945 * pw / (pressure - pw); // Humidity ratio, eqn 22
state.m_psat = psat(drybulb); // Water vapor saturation pressure (uses eqns 5 and 6)
//double Ws = 0.621945 * state.m_psat / (pressure - state.m_psat);
state.m_phi = pw / state.m_psat; // Relative humidity, eqn 24
state.m_h = 1.006 * drybulb + state.m_W * (2501 + 1.86 * drybulb); // Moist air specific enthalpy, eqn 32
state.m_v = 0.287042 * (drybulb + 273.15) * (1 + 1.607858 * state.m_W) / pressure; // Specific volume, eqn 28
// Compute the wet bulb temperature here
boost::optional<double> wetbulb = solveForWetBulb(drybulb, pressure, state.m_W, 1e-4, 100);
if (!wetbulb) {
return boost::none;
}
state.m_wetbulb = wetbulb.get();
return boost::optional<AirState>(state);
}
boost::optional<AirState> AirState::fromDryBulbRelativeHumidityPressure(double drybulb, double RH, double pressure) {
AirState state;
if (drybulb < -100.0 || drybulb > 200.0) {
// Out of the range of our current psat function
return boost::none;
}
if (RH > 100.0 || RH < 0.0) {
// Out of the range
return boost::none;
}
state.m_drybulb = drybulb;
state.m_phi = 0.01 * RH;
state.m_pressure = pressure;
// Compute moist air properties, eqns from ASHRAE Fundamentals 2009 Ch. 1
state.m_psat = psat(drybulb); // Water vapor saturation pressure (uses eqns 5 and 6)
double pw = state.m_phi * state.m_psat; // Relative humidity, eqn 24
state.m_W = 0.621945 * pw / (pressure - pw); // Humidity ratio, eqn 22
state.m_h = 1.006 * drybulb + state.m_W * (2501 + 1.86 * drybulb); // Moist air specific enthalpy, eqn 32
state.m_v = 0.287042 * (drybulb + 273.15) * (1 + 1.607858 * state.m_W) / pressure; // Specific volume, eqn 28
// Compute the dew point temperature here
boost::optional<double> dewpoint = solveForDewPoint(drybulb, pw, 1e-4, 100);
if (!dewpoint) {
return boost::none;
}
state.m_dewpoint = dewpoint.get();
// Compute the wet bulb temperature here
boost::optional<double> wetbulb = solveForWetBulb(drybulb, pressure, state.m_W, 1e-4, 100);
if (!wetbulb) {
return boost::none;
}
state.m_wetbulb = wetbulb.get();
return boost::optional<AirState>(state);
}
double AirState::drybulb() const {
return m_drybulb;
}
double AirState::dewpoint() const {
return m_dewpoint;
}
double AirState::wetbulb() const {
return m_wetbulb;
}
double AirState::relativeHumidity() const {
return 100.0 * m_phi;
}
double AirState::pressure() const {
return m_pressure;
}
double AirState::enthalpy() const {
return m_h;
}
double AirState::saturationPressure() const {
return m_psat;
}
double AirState::density() const {
return 1.0 / m_v;
}
double AirState::specificVolume() const {
return m_v;
}
double AirState::humidityRatio() const {
return m_W;
}
double AirState::R() {
return 8314.472 / 28.966; // eqn 1 from ASHRAE Fundamentals 2009 Ch. 1
}
EpwDataPoint::EpwDataPoint()
: m_year(1),
m_month(1),
m_day(1),
m_hour(1),
m_minute(0),
m_dataSourceandUncertaintyFlags(""),
m_dryBulbTemperature("99.9"),
m_dewPointTemperature("99.9"),
m_relativeHumidity("999"),
m_atmosphericStationPressure("999999"),
m_extraterrestrialHorizontalRadiation("9999"),
m_extraterrestrialDirectNormalRadiation("9999"),
m_horizontalInfraredRadiationIntensity("9999"),
m_globalHorizontalRadiation("9999"),
m_directNormalRadiation("9999"),
m_diffuseHorizontalRadiation("9999"),
m_globalHorizontalIlluminance("999999"),
m_directNormalIlluminance("999999"),
m_diffuseHorizontalIlluminance("999999"),
m_zenithLuminance("9999"),
m_windDirection("999"),
m_windSpeed("999"),
m_totalSkyCover(99),
m_opaqueSkyCover(99),
m_visibility("9999"),
m_ceilingHeight("99999"),
m_presentWeatherObservation(0),
m_presentWeatherCodes(0),
m_precipitableWater("999"),
m_aerosolOpticalDepth(".999"),
m_snowDepth("999"),
m_daysSinceLastSnowfall("99"),
m_albedo("999"),
m_liquidPrecipitationDepth("999"),
m_liquidPrecipitationQuantity("99") {}
EpwDataPoint::EpwDataPoint(int year, int month, int day, int hour, int minute, const std::string& dataSourceandUncertaintyFlags,
double dryBulbTemperature, double dewPointTemperature, double relativeHumidity, double atmosphericStationPressure,
double extraterrestrialHorizontalRadiation, double extraterrestrialDirectNormalRadiation,
double horizontalInfraredRadiationIntensity, double globalHorizontalRadiation, double directNormalRadiation,
double diffuseHorizontalRadiation, double globalHorizontalIlluminance, double directNormalIlluminance,
double diffuseHorizontalIlluminance, double zenithLuminance, double windDirection, double windSpeed, int totalSkyCover,
int opaqueSkyCover, double visibility, double ceilingHeight, int presentWeatherObservation, int presentWeatherCodes,
double precipitableWater, double aerosolOpticalDepth, double snowDepth, double daysSinceLastSnowfall, double albedo,
double liquidPrecipitationDepth, double liquidPrecipitationQuantity) {
setYear(year);
setMonth(month);
setDay(day);
setHour(hour);
setMinute(minute);
setDataSourceandUncertaintyFlags(dataSourceandUncertaintyFlags);
setDryBulbTemperature(dryBulbTemperature);
setDewPointTemperature(dewPointTemperature);
setRelativeHumidity(relativeHumidity);
setAtmosphericStationPressure(atmosphericStationPressure);
setExtraterrestrialHorizontalRadiation(extraterrestrialHorizontalRadiation);
setExtraterrestrialDirectNormalRadiation(extraterrestrialDirectNormalRadiation);
setHorizontalInfraredRadiationIntensity(horizontalInfraredRadiationIntensity);
setGlobalHorizontalRadiation(globalHorizontalRadiation);
setDirectNormalRadiation(directNormalRadiation);
setDiffuseHorizontalRadiation(diffuseHorizontalRadiation);
setGlobalHorizontalIlluminance(globalHorizontalIlluminance);
setDirectNormalIlluminance(directNormalIlluminance);
setDiffuseHorizontalIlluminance(diffuseHorizontalIlluminance);
setZenithLuminance(zenithLuminance);
setWindDirection(windDirection);
setWindSpeed(windSpeed);
setTotalSkyCover(totalSkyCover);
setOpaqueSkyCover(opaqueSkyCover);
setVisibility(visibility);
setCeilingHeight(ceilingHeight);
setPresentWeatherObservation(presentWeatherObservation);
setPresentWeatherCodes(presentWeatherCodes);
setPrecipitableWater(precipitableWater);
setAerosolOpticalDepth(aerosolOpticalDepth);
setSnowDepth(snowDepth);
setDaysSinceLastSnowfall(daysSinceLastSnowfall);
setAlbedo(albedo);
setLiquidPrecipitationDepth(liquidPrecipitationDepth);
setLiquidPrecipitationQuantity(liquidPrecipitationQuantity);
}
EpwDesignCondition::EpwDesignCondition()
: m_titleOfDesignCondition(),
m_heatingColdestMonth(),
m_heatingDryBulb99pt6(),
m_heatingDryBulb99(),
m_heatingHumidificationDewPoint99pt6(),
m_heatingHumidificationHumidityRatio99pt6(),
m_heatingHumidificationMeanCoincidentDryBulb99pt6(),
m_heatingHumidificationDewPoint99(),
m_heatingHumidificationHumidityRatio99(),
m_heatingHumidificationMeanCoincidentDryBulb99(),
m_heatingColdestMonthWindSpeed0pt4(),
m_heatingColdestMonthMeanCoincidentDryBulb0pt4(),
m_heatingColdestMonthWindSpeed1(),
m_heatingColdestMonthMeanCoincidentDryBulb1(),
m_heatingMeanCoincidentWindSpeed99pt6(),
m_heatingPrevailingCoincidentWindDirection99pt6(),
m_coolingHottestMonth(),
m_coolingDryBulbRange(),
m_coolingDryBulb0pt4(),
m_coolingMeanCoincidentWetBulb0pt4(),
m_coolingDryBulb1(),
m_coolingMeanCoincidentWetBulb1(),
m_coolingDryBulb2(),
m_coolingMeanCoincidentWetBulb2(),
m_coolingEvaporationWetBulb0pt4(),
m_coolingEvaporationMeanCoincidentDryBulb0pt4(),
m_coolingEvaporationWetBulb1(),
m_coolingEvaporationMeanCoincidentDryBulb1(),
m_coolingEvaporationWetBulb2(),
m_coolingEvaporationMeanCoincidentDryBulb2(),
m_coolingMeanCoincidentWindSpeed0pt4(),
m_coolingPrevailingCoincidentWindDirection0pt4(),
m_coolingDehumidificationDewPoint0pt4(),
m_coolingDehumidificationHumidityRatio0pt4(),
m_coolingDehumidificationMeanCoincidentDryBulb0pt4(),
m_coolingDehumidificationDewPoint1(),
m_coolingDehumidificationHumidityRatio1(),
m_coolingDehumidificationMeanCoincidentDryBulb1(),
m_coolingDehumidificationDewPoint2(),
m_coolingDehumidificationHumidityRatio2(),
m_coolingDehumidificationMeanCoincidentDryBulb2(),
m_coolingEnthalpy0pt4(),
m_coolingEnthalpyMeanCoincidentDryBulb0pt4(),
m_coolingEnthalpy1(),
m_coolingEnthalpyMeanCoincidentDryBulb1(),
m_coolingEnthalpy2(),
m_coolingEnthalpyMeanCoincidentDryBulb2(),
m_coolingHours8To4AndDryBulb12pt8To20pt6(),
m_extremeWindSpeed1(),
m_extremeWindSpeed2pt5(),
m_extremeWindSpeed5(),
m_extremeMaxWetBulb(),
m_extremeMeanMinDryBulb(),
m_extremeMeanMaxDryBulb(),
m_extremeStdDevMinDryBulb(),
m_extremeStdDevMaxDryBulb(),
m_extremeN5YearsMinDryBulb(),
m_extremeN5YearsMaxDryBulb(),
m_extremeN10YearsMinDryBulb(),
m_extremeN10YearsMaxDryBulb(),
m_extremeN20YearsMinDryBulb(),
m_extremeN20YearsMaxDryBulb(),
m_extremeN50YearsMinDryBulb(),
m_extremeN50YearsMaxDryBulb() {}
EpwDesignCondition::EpwDesignCondition(
const std::string& titleOfDesignCondition, int heatingColdestMonth, double heatingDryBulb99pt6, double heatingDryBulb99,
double heatingHumidificationDewPoint99pt6, double heatingHumidificationHumidityRatio99pt6, double heatingHumidificationMeanCoincidentDryBulb99pt6,
double heatingHumidificationDewPoint99, double heatingHumidificationHumidityRatio99, double heatingHumidificationMeanCoincidentDryBulb99,
double heatingColdestMonthWindSpeed0pt4, double heatingColdestMonthMeanCoincidentDryBulb0pt4, double heatingColdestMonthWindSpeed1,
double heatingColdestMonthMeanCoincidentDryBulb1, double heatingMeanCoincidentWindSpeed99pt6, int heatingPrevailingCoincidentWindDirection99pt6,
int coolingHottestMonth, double coolingDryBulbRange, double coolingDryBulb0pt4, double coolingMeanCoincidentWetBulb0pt4, double coolingDryBulb1,
double coolingMeanCoincidentWetBulb1, double coolingDryBulb2, double coolingMeanCoincidentWetBulb2, double coolingEvaporationWetBulb0pt4,
double coolingEvaporationMeanCoincidentDryBulb0pt4, double coolingEvaporationWetBulb1, double coolingEvaporationMeanCoincidentDryBulb1,
double coolingEvaporationWetBulb2, double coolingEvaporationMeanCoincidentDryBulb2, double coolingMeanCoincidentWindSpeed0pt4,
int coolingPrevailingCoincidentWindDirection0pt4, double coolingDehumidificationDewPoint0pt4, double coolingDehumidificationHumidityRatio0pt4,
double coolingDehumidificationMeanCoincidentDryBulb0pt4, double coolingDehumidificationDewPoint1, double coolingDehumidificationHumidityRatio1,
double coolingDehumidificationMeanCoincidentDryBulb1, double coolingDehumidificationDewPoint2, double coolingDehumidificationHumidityRatio2,
double coolingDehumidificationMeanCoincidentDryBulb2, double coolingEnthalpy0pt4, double coolingEnthalpyMeanCoincidentDryBulb0pt4,
double coolingEnthalpy1, double coolingEnthalpyMeanCoincidentDryBulb1, double coolingEnthalpy2, double coolingEnthalpyMeanCoincidentDryBulb2,
int coolingHours8To4AndDryBulb12pt8To20pt6, double extremeWindSpeed1, double extremeWindSpeed2pt5, double extremeWindSpeed5,
double extremeMaxWetBulb, double extremeMeanMinDryBulb, double extremeMeanMaxDryBulb, double extremeStdDevMinDryBulb,
double extremeStdDevMaxDryBulb, double extremeN5YearsMinDryBulb, double extremeN5YearsMaxDryBulb, double extremeN10YearsMinDryBulb,
double extremeN10YearsMaxDryBulb, double extremeN20YearsMinDryBulb, double extremeN20YearsMaxDryBulb, double extremeN50YearsMinDryBulb,
double extremeN50YearsMaxDryBulb) {
setTitleOfDesignCondition(titleOfDesignCondition);
setHeatingColdestMonth(heatingColdestMonth);
setHeatingDryBulb99pt6(heatingDryBulb99pt6);
setHeatingDryBulb99(heatingDryBulb99);
setHeatingHumidificationDewPoint99pt6(heatingHumidificationDewPoint99pt6);
setHeatingHumidificationHumidityRatio99pt6(heatingHumidificationHumidityRatio99pt6);
setHeatingHumidificationMeanCoincidentDryBulb99pt6(heatingHumidificationMeanCoincidentDryBulb99pt6);
setHeatingHumidificationDewPoint99(heatingHumidificationDewPoint99);
setHeatingHumidificationHumidityRatio99(heatingHumidificationHumidityRatio99);
setHeatingHumidificationMeanCoincidentDryBulb99(heatingHumidificationMeanCoincidentDryBulb99);
setHeatingColdestMonthWindSpeed0pt4(heatingColdestMonthWindSpeed0pt4);
setHeatingColdestMonthMeanCoincidentDryBulb0pt4(heatingColdestMonthMeanCoincidentDryBulb0pt4);
setHeatingColdestMonthWindSpeed1(heatingColdestMonthWindSpeed1);
setHeatingColdestMonthMeanCoincidentDryBulb1(heatingColdestMonthMeanCoincidentDryBulb1);
setHeatingMeanCoincidentWindSpeed99pt6(heatingMeanCoincidentWindSpeed99pt6);
setHeatingPrevailingCoincidentWindDirection99pt6(heatingPrevailingCoincidentWindDirection99pt6);
setCoolingHottestMonth(coolingHottestMonth);
setCoolingDryBulbRange(coolingDryBulbRange);
setCoolingDryBulb0pt4(coolingDryBulb0pt4);
setCoolingMeanCoincidentWetBulb0pt4(coolingMeanCoincidentWetBulb0pt4);
setCoolingDryBulb1(coolingDryBulb1);
setCoolingMeanCoincidentWetBulb1(coolingMeanCoincidentWetBulb1);
setCoolingDryBulb2(coolingDryBulb2);
setCoolingMeanCoincidentWetBulb2(coolingMeanCoincidentWetBulb2);
setCoolingEvaporationWetBulb0pt4(coolingEvaporationWetBulb0pt4);
setCoolingEvaporationMeanCoincidentDryBulb0pt4(coolingEvaporationMeanCoincidentDryBulb0pt4);
setCoolingEvaporationWetBulb1(coolingEvaporationWetBulb1);
setCoolingEvaporationMeanCoincidentDryBulb1(coolingEvaporationMeanCoincidentDryBulb1);
setCoolingEvaporationWetBulb2(coolingEvaporationWetBulb2);
setCoolingEvaporationMeanCoincidentDryBulb2(coolingEvaporationMeanCoincidentDryBulb2);
setCoolingMeanCoincidentWindSpeed0pt4(coolingMeanCoincidentWindSpeed0pt4);
setCoolingPrevailingCoincidentWindDirection0pt4(coolingPrevailingCoincidentWindDirection0pt4);
setCoolingDehumidificationDewPoint0pt4(coolingDehumidificationDewPoint0pt4);
setCoolingDehumidificationHumidityRatio0pt4(coolingDehumidificationHumidityRatio0pt4);
setCoolingDehumidificationMeanCoincidentDryBulb0pt4(coolingDehumidificationMeanCoincidentDryBulb0pt4);
setCoolingDehumidificationDewPoint1(coolingDehumidificationDewPoint1);
setCoolingDehumidificationHumidityRatio1(coolingDehumidificationHumidityRatio1);
setCoolingDehumidificationMeanCoincidentDryBulb1(coolingDehumidificationMeanCoincidentDryBulb1);
setCoolingDehumidificationDewPoint2(coolingDehumidificationDewPoint2);
setCoolingDehumidificationHumidityRatio2(coolingDehumidificationHumidityRatio2);
setCoolingDehumidificationMeanCoincidentDryBulb2(coolingDehumidificationMeanCoincidentDryBulb2);
setCoolingEnthalpy0pt4(coolingEnthalpy0pt4);
setCoolingEnthalpyMeanCoincidentDryBulb0pt4(coolingEnthalpyMeanCoincidentDryBulb0pt4);
setCoolingEnthalpy1(coolingEnthalpy1);
setCoolingEnthalpyMeanCoincidentDryBulb1(coolingEnthalpyMeanCoincidentDryBulb1);
setCoolingEnthalpy2(coolingEnthalpy2);
setCoolingEnthalpyMeanCoincidentDryBulb2(coolingEnthalpyMeanCoincidentDryBulb2);
setCoolingHours8To4AndDryBulb12pt8To20pt6(coolingHours8To4AndDryBulb12pt8To20pt6);
setExtremeWindSpeed1(extremeWindSpeed1);
setExtremeWindSpeed2pt5(extremeWindSpeed2pt5);
setExtremeWindSpeed5(extremeWindSpeed5);
setExtremeMaxWetBulb(extremeMaxWetBulb);
setExtremeMeanMinDryBulb(extremeMeanMinDryBulb);
setExtremeMeanMaxDryBulb(extremeMeanMaxDryBulb);
setExtremeStdDevMinDryBulb(extremeStdDevMinDryBulb);
setExtremeStdDevMaxDryBulb(extremeStdDevMaxDryBulb);
setExtremeN5YearsMinDryBulb(extremeN5YearsMinDryBulb);
setExtremeN5YearsMaxDryBulb(extremeN5YearsMaxDryBulb);
setExtremeN10YearsMinDryBulb(extremeN10YearsMinDryBulb);
setExtremeN10YearsMaxDryBulb(extremeN10YearsMaxDryBulb);
setExtremeN20YearsMinDryBulb(extremeN20YearsMinDryBulb);
setExtremeN20YearsMaxDryBulb(extremeN20YearsMaxDryBulb);
setExtremeN50YearsMinDryBulb(extremeN50YearsMinDryBulb);
setExtremeN50YearsMaxDryBulb(extremeN50YearsMaxDryBulb);
}
boost::optional<EpwDataPoint> EpwDataPoint::fromEpwString(const std::string& line) {
std::vector<std::string> list = splitString(line, ',');
return fromEpwStrings(list);
}
boost::optional<EpwDataPoint> EpwDataPoint::fromEpwStrings(const std::vector<std::string>& list, bool pedantic) {
EpwDataPoint pt;
// Expect 35 items in the list
if (list.size() < 35) {
if (pedantic) {
LOG_FREE(Error, "openstudio.EpwFile", "Expected 35 fields in EPW data instead of the " << list.size() << " received");
return boost::none;
} else {
LOG_FREE(Warn, "openstudio.EpwFile",
"Expected 35 fields in EPW data instead of the " << list.size() << " received. The remaining fields will not be available");
}
} else if (list.size() > 35) {
LOG_FREE(Warn, "openstudio.EpwFile",
"Expected 35 fields in EPW data instead of the " << list.size() << " received. The additional data will be ignored");
}
// Use the appropriate setter on each field
if (!pt.setYear(list[EpwDataField::Year])) {
return boost::none;
}
if (!pt.setMonth(list[EpwDataField::Month])) {
return boost::none;
}
if (!pt.setDay(list[EpwDataField::Day])) {
return boost::none;
}
if (!pt.setHour(list[EpwDataField::Hour])) {
return boost::none;
}
if (!pt.setMinute(list[EpwDataField::Minute])) {
return boost::none;
}
pt.setDataSourceandUncertaintyFlags(list[EpwDataField::DataSourceandUncertaintyFlags]);
pt.setDryBulbTemperature(list[EpwDataField::DryBulbTemperature]);
pt.setDewPointTemperature(list[EpwDataField::DewPointTemperature]);
pt.setRelativeHumidity(list[EpwDataField::RelativeHumidity]);
pt.setAtmosphericStationPressure(list[EpwDataField::AtmosphericStationPressure]);
pt.setExtraterrestrialHorizontalRadiation(list[EpwDataField::ExtraterrestrialHorizontalRadiation]);
pt.setExtraterrestrialDirectNormalRadiation(list[EpwDataField::ExtraterrestrialDirectNormalRadiation]);
pt.setHorizontalInfraredRadiationIntensity(list[EpwDataField::HorizontalInfraredRadiationIntensity]);
pt.setGlobalHorizontalRadiation(list[EpwDataField::GlobalHorizontalRadiation]);
pt.setDirectNormalRadiation(list[EpwDataField::DirectNormalRadiation]);
pt.setDiffuseHorizontalRadiation(list[EpwDataField::DiffuseHorizontalRadiation]);
pt.setGlobalHorizontalIlluminance(list[EpwDataField::GlobalHorizontalIlluminance]);
pt.setDirectNormalIlluminance(list[EpwDataField::DirectNormalIlluminance]);
pt.setDiffuseHorizontalIlluminance(list[EpwDataField::DiffuseHorizontalIlluminance]);
pt.setZenithLuminance(list[EpwDataField::ZenithLuminance]);
pt.setWindDirection(list[EpwDataField::WindDirection]);
pt.setWindSpeed(list[EpwDataField::WindSpeed]);
pt.setTotalSkyCover(list[EpwDataField::TotalSkyCover]);
pt.setOpaqueSkyCover(list[EpwDataField::OpaqueSkyCover]);
pt.setVisibility(list[EpwDataField::Visibility]);
pt.setCeilingHeight(list[EpwDataField::CeilingHeight]);
pt.setPresentWeatherObservation(list[EpwDataField::PresentWeatherObservation]);
pt.setPresentWeatherCodes(list[EpwDataField::PresentWeatherCodes]);
pt.setPrecipitableWater(list[EpwDataField::PrecipitableWater]);
pt.setAerosolOpticalDepth(list[EpwDataField::AerosolOpticalDepth]);
pt.setSnowDepth(list[EpwDataField::SnowDepth]);
pt.setDaysSinceLastSnowfall(list[EpwDataField::DaysSinceLastSnowfall]);
pt.setAlbedo(list[EpwDataField::Albedo]);
pt.setLiquidPrecipitationDepth(list[EpwDataField::LiquidPrecipitationDepth]);
pt.setLiquidPrecipitationQuantity(list[EpwDataField::LiquidPrecipitationQuantity]);
return boost::optional<EpwDataPoint>(pt);
}
boost::optional<EpwDataPoint> EpwDataPoint::fromEpwStrings(int year, int month, int day, int hour, int minute, const std::vector<std::string>& list,
bool pedantic) {
EpwDataPoint pt;
// Expect 30 items in the list
if (list.size() < 35) {
if (pedantic) {
LOG_FREE(Error, "openstudio.EpwFile", "Expected 35 fields in EPW data instead of the " << list.size() << " received");
return boost::none;
} else {
LOG_FREE(Warn, "openstudio.EpwFile",
"Expected 35 fields in EPW data instead of the " << list.size() << " received. The remaining fields will not be available");
}
} else if (list.size() > 35) {
LOG_FREE(Warn, "openstudio.EpwFile",
"Expected 35 fields in EPW data instead of the " << list.size() << " received. The additional data will be ignored");
}
// Use the appropriate setter on each field
pt.setYear(year);
if (!pt.setMonth(month)) {
return boost::none;
}
if (!pt.setDay(day)) {
return boost::none;
}
if (!pt.setHour(hour)) {
return boost::none;
}
if (!pt.setMinute(minute)) {
return boost::none;
}
pt.setDataSourceandUncertaintyFlags(list[EpwDataField::DataSourceandUncertaintyFlags]);
pt.setDryBulbTemperature(list[EpwDataField::DryBulbTemperature]);
pt.setDewPointTemperature(list[EpwDataField::DewPointTemperature]);
pt.setRelativeHumidity(list[EpwDataField::RelativeHumidity]);
pt.setAtmosphericStationPressure(list[EpwDataField::AtmosphericStationPressure]);
pt.setExtraterrestrialHorizontalRadiation(list[EpwDataField::ExtraterrestrialHorizontalRadiation]);
pt.setExtraterrestrialDirectNormalRadiation(list[EpwDataField::ExtraterrestrialDirectNormalRadiation]);
pt.setHorizontalInfraredRadiationIntensity(list[EpwDataField::HorizontalInfraredRadiationIntensity]);
pt.setGlobalHorizontalRadiation(list[EpwDataField::GlobalHorizontalRadiation]);
pt.setDirectNormalRadiation(list[EpwDataField::DirectNormalRadiation]);
pt.setDiffuseHorizontalRadiation(list[EpwDataField::DiffuseHorizontalRadiation]);
pt.setGlobalHorizontalIlluminance(list[EpwDataField::GlobalHorizontalIlluminance]);
pt.setDirectNormalIlluminance(list[EpwDataField::DirectNormalIlluminance]);
pt.setDiffuseHorizontalIlluminance(list[EpwDataField::DiffuseHorizontalIlluminance]);
pt.setZenithLuminance(list[EpwDataField::ZenithLuminance]);
pt.setWindDirection(list[EpwDataField::WindDirection]);
pt.setWindSpeed(list[EpwDataField::WindSpeed]);
pt.setTotalSkyCover(list[EpwDataField::TotalSkyCover]);
pt.setOpaqueSkyCover(list[EpwDataField::OpaqueSkyCover]);
pt.setVisibility(list[EpwDataField::Visibility]);
pt.setCeilingHeight(list[EpwDataField::CeilingHeight]);
pt.setPresentWeatherObservation(list[EpwDataField::PresentWeatherObservation]);
pt.setPresentWeatherCodes(list[EpwDataField::PresentWeatherCodes]);
pt.setPrecipitableWater(list[EpwDataField::PrecipitableWater]);
pt.setAerosolOpticalDepth(list[EpwDataField::AerosolOpticalDepth]);
pt.setSnowDepth(list[EpwDataField::SnowDepth]);
pt.setDaysSinceLastSnowfall(list[EpwDataField::DaysSinceLastSnowfall]);
pt.setAlbedo(list[EpwDataField::Albedo]);
pt.setLiquidPrecipitationDepth(list[EpwDataField::LiquidPrecipitationDepth]);
pt.setLiquidPrecipitationQuantity(list[EpwDataField::LiquidPrecipitationQuantity]);
return boost::optional<EpwDataPoint>(pt);
}
boost::optional<EpwDesignCondition> EpwDesignCondition::fromDesignConditionsString(const std::string& line) {
std::vector<std::string> list = splitString(line, ',');
return fromDesignConditionsStrings(list);
}
boost::optional<EpwDesignCondition> EpwDesignCondition::fromDesignConditionsStrings(const std::vector<std::string>& list) {
EpwDesignCondition dc;
// Expect 68 items in the list
if (list.size() < 68) {
LOG_FREE(Error, "openstudio.EpwFile", "Expected 68 fields in EPW design condition instead of the " << list.size() << " received");
return boost::none;
}
// Use the appropriate setter on each field
dc.setTitleOfDesignCondition(list[EpwDesignField::TitleOfDesignCondition]);
dc.setHeatingColdestMonth(list[EpwDesignField::HeatingColdestMonth]);
dc.setHeatingDryBulb99pt6(list[EpwDesignField::HeatingDryBulb99pt6]);
dc.setHeatingDryBulb99(list[EpwDesignField::HeatingDryBulb99]);
dc.setHeatingHumidificationDewPoint99pt6(list[EpwDesignField::HeatingHumidificationDewPoint99pt6]);
dc.setHeatingHumidificationHumidityRatio99pt6(list[EpwDesignField::HeatingHumidificationHumidityRatio99pt6]);
dc.setHeatingHumidificationMeanCoincidentDryBulb99pt6(list[EpwDesignField::HeatingHumidificationMeanCoincidentDryBulb99pt6]);
dc.setHeatingHumidificationDewPoint99(list[EpwDesignField::HeatingHumidificationDewPoint99]);
dc.setHeatingHumidificationHumidityRatio99(list[EpwDesignField::HeatingHumidificationHumidityRatio99]);
dc.setHeatingHumidificationMeanCoincidentDryBulb99(list[EpwDesignField::HeatingHumidificationMeanCoincidentDryBulb99]);
dc.setHeatingColdestMonthWindSpeed0pt4(list[EpwDesignField::HeatingColdestMonthWindSpeed0pt4]);
dc.setHeatingColdestMonthMeanCoincidentDryBulb0pt4(list[EpwDesignField::HeatingColdestMonthMeanCoincidentDryBulb0pt4]);
dc.setHeatingColdestMonthWindSpeed1(list[EpwDesignField::HeatingColdestMonthWindSpeed1]);
dc.setHeatingColdestMonthMeanCoincidentDryBulb1(list[EpwDesignField::HeatingColdestMonthMeanCoincidentDryBulb1]);
dc.setHeatingMeanCoincidentWindSpeed99pt6(list[EpwDesignField::HeatingMeanCoincidentWindSpeed99pt6]);
dc.setHeatingPrevailingCoincidentWindDirection99pt6(list[EpwDesignField::HeatingPrevailingCoincidentWindDirection99pt6]);
dc.setCoolingHottestMonth(list[EpwDesignField::CoolingHottestMonth]);
dc.setCoolingDryBulbRange(list[EpwDesignField::CoolingDryBulbRange]);
dc.setCoolingDryBulb0pt4(list[EpwDesignField::CoolingDryBulb0pt4]);
dc.setCoolingMeanCoincidentWetBulb0pt4(list[EpwDesignField::CoolingMeanCoincidentWetBulb0pt4]);
dc.setCoolingDryBulb1(list[EpwDesignField::CoolingDryBulb1]);
dc.setCoolingMeanCoincidentWetBulb1(list[EpwDesignField::CoolingMeanCoincidentWetBulb1]);
dc.setCoolingDryBulb2(list[EpwDesignField::CoolingDryBulb2]);
dc.setCoolingMeanCoincidentWetBulb2(list[EpwDesignField::CoolingMeanCoincidentWetBulb2]);
dc.setCoolingEvaporationWetBulb0pt4(list[EpwDesignField::CoolingEvaporationWetBulb0pt4]);
dc.setCoolingEvaporationMeanCoincidentDryBulb0pt4(list[EpwDesignField::CoolingEvaporationMeanCoincidentDryBulb0pt4]);
dc.setCoolingEvaporationWetBulb1(list[EpwDesignField::CoolingEvaporationWetBulb1]);
dc.setCoolingEvaporationMeanCoincidentDryBulb1(list[EpwDesignField::CoolingEvaporationMeanCoincidentDryBulb1]);
dc.setCoolingEvaporationWetBulb2(list[EpwDesignField::CoolingEvaporationWetBulb2]);
dc.setCoolingEvaporationMeanCoincidentDryBulb2(list[EpwDesignField::CoolingEvaporationMeanCoincidentDryBulb2]);
dc.setCoolingMeanCoincidentWindSpeed0pt4(list[EpwDesignField::CoolingMeanCoincidentWindSpeed0pt4]);
dc.setCoolingPrevailingCoincidentWindDirection0pt4(list[EpwDesignField::CoolingPrevailingCoincidentWindDirection0pt4]);
dc.setCoolingDehumidificationDewPoint0pt4(list[EpwDesignField::CoolingDehumidificationDewPoint0pt4]);
dc.setCoolingDehumidificationHumidityRatio0pt4(list[EpwDesignField::CoolingDehumidificationHumidityRatio0pt4]);
dc.setCoolingDehumidificationMeanCoincidentDryBulb0pt4(list[EpwDesignField::CoolingDehumidificationMeanCoincidentDryBulb0pt4]);
dc.setCoolingDehumidificationDewPoint1(list[EpwDesignField::CoolingDehumidificationDewPoint1]);
dc.setCoolingDehumidificationHumidityRatio1(list[EpwDesignField::CoolingDehumidificationHumidityRatio1]);
dc.setCoolingDehumidificationMeanCoincidentDryBulb1(list[EpwDesignField::CoolingDehumidificationMeanCoincidentDryBulb1]);
dc.setCoolingDehumidificationDewPoint2(list[EpwDesignField::CoolingDehumidificationDewPoint2]);
dc.setCoolingDehumidificationHumidityRatio2(list[EpwDesignField::CoolingDehumidificationHumidityRatio2]);
dc.setCoolingDehumidificationMeanCoincidentDryBulb2(list[EpwDesignField::CoolingDehumidificationMeanCoincidentDryBulb2]);
dc.setCoolingEnthalpy0pt4(list[EpwDesignField::CoolingEnthalpy0pt4]);
dc.setCoolingEnthalpyMeanCoincidentDryBulb0pt4(list[EpwDesignField::CoolingEnthalpyMeanCoincidentDryBulb0pt4]);
dc.setCoolingEnthalpy1(list[EpwDesignField::CoolingEnthalpy1]);
dc.setCoolingEnthalpyMeanCoincidentDryBulb1(list[EpwDesignField::CoolingEnthalpyMeanCoincidentDryBulb1]);
dc.setCoolingEnthalpy2(list[EpwDesignField::CoolingEnthalpy2]);
dc.setCoolingEnthalpyMeanCoincidentDryBulb2(list[EpwDesignField::CoolingEnthalpyMeanCoincidentDryBulb2]);
dc.setCoolingHours8To4AndDryBulb12pt8To20pt6(list[EpwDesignField::CoolingHours8To4AndDryBulb12pt8To20pt6]);
dc.setExtremeWindSpeed1(list[EpwDesignField::ExtremeWindSpeed1]);
dc.setExtremeWindSpeed2pt5(list[EpwDesignField::ExtremeWindSpeed2pt5]);
dc.setExtremeWindSpeed5(list[EpwDesignField::ExtremeWindSpeed5]);
dc.setExtremeMaxWetBulb(list[EpwDesignField::ExtremeMaxWetBulb]);
dc.setExtremeMeanMinDryBulb(list[EpwDesignField::ExtremeMeanMinDryBulb]);
dc.setExtremeMeanMaxDryBulb(list[EpwDesignField::ExtremeMeanMaxDryBulb]);
dc.setExtremeStdDevMinDryBulb(list[EpwDesignField::ExtremeStdDevMinDryBulb]);
dc.setExtremeStdDevMaxDryBulb(list[EpwDesignField::ExtremeStdDevMaxDryBulb]);
dc.setExtremeN5YearsMinDryBulb(list[EpwDesignField::ExtremeN5YearsMinDryBulb]);
dc.setExtremeN5YearsMaxDryBulb(list[EpwDesignField::ExtremeN5YearsMaxDryBulb]);
dc.setExtremeN10YearsMinDryBulb(list[EpwDesignField::ExtremeN10YearsMinDryBulb]);
dc.setExtremeN10YearsMaxDryBulb(list[EpwDesignField::ExtremeN10YearsMaxDryBulb]);
dc.setExtremeN20YearsMinDryBulb(list[EpwDesignField::ExtremeN20YearsMinDryBulb]);
dc.setExtremeN20YearsMaxDryBulb(list[EpwDesignField::ExtremeN20YearsMaxDryBulb]);
dc.setExtremeN50YearsMinDryBulb(list[EpwDesignField::ExtremeN50YearsMinDryBulb]);
dc.setExtremeN50YearsMaxDryBulb(list[EpwDesignField::ExtremeN50YearsMaxDryBulb]);
return boost::optional<EpwDesignCondition>(dc);
}
std::vector<std::string> EpwDataPoint::toEpwStrings() const {
std::vector<std::string> list;
list.reserve(35);
list.push_back(std::to_string(m_year));
list.push_back(std::to_string(m_month));
list.push_back(std::to_string(m_day));
list.push_back(std::to_string(m_hour));
list.push_back(std::to_string(m_minute));
list.push_back(m_dataSourceandUncertaintyFlags);
list.push_back(m_dryBulbTemperature);
list.push_back(m_dewPointTemperature);
list.push_back(m_relativeHumidity);
list.push_back(m_atmosphericStationPressure);
list.push_back(m_extraterrestrialHorizontalRadiation);
list.push_back(m_extraterrestrialDirectNormalRadiation);
list.push_back(m_horizontalInfraredRadiationIntensity);
list.push_back(m_globalHorizontalRadiation);
list.push_back(m_directNormalRadiation);
list.push_back(m_diffuseHorizontalRadiation);
list.push_back(m_globalHorizontalIlluminance);
list.push_back(m_directNormalIlluminance);
list.push_back(m_diffuseHorizontalIlluminance);
list.push_back(m_zenithLuminance);
list.push_back(m_windDirection);
list.push_back(m_windSpeed);
list.push_back(std::to_string(m_totalSkyCover));
list.push_back(std::to_string(m_opaqueSkyCover));
list.push_back(m_visibility);
list.push_back(m_ceilingHeight);
list.push_back(std::to_string(m_presentWeatherObservation));
list.push_back(std::to_string(m_presentWeatherCodes));
list.push_back(m_precipitableWater);
list.push_back(m_aerosolOpticalDepth);
list.push_back(m_snowDepth);
list.push_back(m_daysSinceLastSnowfall);
list.push_back(m_albedo);
list.push_back(m_liquidPrecipitationDepth);
list.push_back(m_liquidPrecipitationQuantity);
return list;
}
boost::optional<std::string> EpwDataPoint::getUnitsByName(const std::string& name) {
EpwDataField id;
try {
id = EpwDataField(name);
} catch (...) {
// Could do a warning message here
return boost::none;
}
return boost::optional<std::string>(getUnits(id));
}
std::string EpwDataPoint::getUnits(EpwDataField field) {
std::string string;
switch (field.value()) {
case EpwDataField::Year:
//string = "None";
break;
case EpwDataField::Month:
//string = "None";
break;
case EpwDataField::Day:
//string = "None";
break;
case EpwDataField::Hour:
//string = "None";
break;
case EpwDataField::Minute:
//string = "None";
break;
case EpwDataField::DataSourceandUncertaintyFlags:
//string = "None";
break;
case EpwDataField::DryBulbTemperature:
string = "C";
break;
case EpwDataField::DewPointTemperature:
string = "C";
break;
case EpwDataField::RelativeHumidity:
//string = "None";
break;
case EpwDataField::AtmosphericStationPressure:
string = "Pa";
break;
case EpwDataField::ExtraterrestrialHorizontalRadiation:
string = "Wh/m2";
break;
case EpwDataField::ExtraterrestrialDirectNormalRadiation:
string = "Wh/m2";
break;
case EpwDataField::HorizontalInfraredRadiationIntensity:
string = "Wh/m2";
break;
case EpwDataField::GlobalHorizontalRadiation:
string = "Wh/m2";
break;
case EpwDataField::DirectNormalRadiation:
string = "Wh/m2";
break;
case EpwDataField::DiffuseHorizontalRadiation:
string = "Wh/m2";
break;
case EpwDataField::GlobalHorizontalIlluminance:
string = "lux";
break;
case EpwDataField::DirectNormalIlluminance:
string = "lux";
break;
case EpwDataField::DiffuseHorizontalIlluminance:
string = "lux";
break;
case EpwDataField::ZenithLuminance:
string = "Cd/m2";
break;
case EpwDataField::WindDirection:
string = "degrees";
break;
case EpwDataField::WindSpeed:
string = "m/s";
break;
case EpwDataField::TotalSkyCover:
//string = "None";
break;
case EpwDataField::OpaqueSkyCover:
//string = "None";
break;
case EpwDataField::Visibility:
string = "km";
break;
case EpwDataField::CeilingHeight:
string = "m";
break;
case EpwDataField::PresentWeatherObservation:
//string = "None";
break;
case EpwDataField::PresentWeatherCodes:
//string = "None";
break;
case EpwDataField::PrecipitableWater:
string = "mm";
break;
case EpwDataField::AerosolOpticalDepth:
string = "thousandths";
break;
case EpwDataField::SnowDepth:
string = "cm";
break;
case EpwDataField::DaysSinceLastSnowfall:
//string = "None";
break;
case EpwDataField::Albedo:
//string = "None";
break;
case EpwDataField::LiquidPrecipitationDepth:
string = "mm";
break;
case EpwDataField::LiquidPrecipitationQuantity:
string = "hr";
break;
default:
//string = "None";
break;
}
return string;
}
boost::optional<std::string> EpwDesignCondition::getUnitsByName(const std::string& name) {
EpwDesignField id;
try {
id = EpwDesignField(name);
} catch (...) {
// Could do a warning message here
return boost::none;
}
return getUnits(id);
}
std::string EpwDesignCondition::getUnits(EpwDesignField field) {
std::string string;
switch (field.value()) {
case EpwDesignField::TitleOfDesignCondition:
//string = "None";
break;
case EpwDesignField::HeatingColdestMonth:
//string = "None";
break;
case EpwDesignField::HeatingDryBulb99pt6:
string = "C";
break;
case EpwDesignField::HeatingDryBulb99:
string = "C";
break;
case EpwDesignField::HeatingHumidificationDewPoint99pt6:
string = "C";
break;
case EpwDesignField::HeatingHumidificationHumidityRatio99pt6:
string = "g/kg";
break;
case EpwDesignField::HeatingHumidificationMeanCoincidentDryBulb99pt6:
string = "C";
break;
case EpwDesignField::HeatingHumidificationDewPoint99:
string = "C";
break;
case EpwDesignField::HeatingHumidificationHumidityRatio99:
string = "g/kg";
break;
case EpwDesignField::HeatingHumidificationMeanCoincidentDryBulb99:
string = "C";
break;
case EpwDesignField::HeatingColdestMonthWindSpeed0pt4:
string = "m/s";
break;
case EpwDesignField::HeatingColdestMonthMeanCoincidentDryBulb0pt4:
string = "C";
break;
case EpwDesignField::HeatingColdestMonthWindSpeed1:
string = "m/s";
break;
case EpwDesignField::HeatingColdestMonthMeanCoincidentDryBulb1:
string = "C";
break;
case EpwDesignField::HeatingMeanCoincidentWindSpeed99pt6:
string = "m/s";
break;
case EpwDesignField::HeatingPrevailingCoincidentWindDirection99pt6:
string = "degrees";
break;
case EpwDesignField::CoolingHottestMonth:
//string = "None";
break;
case EpwDesignField::CoolingDryBulbRange:
string = "C";
break;
case EpwDesignField::CoolingDryBulb0pt4:
string = "C";
break;
case EpwDesignField::CoolingMeanCoincidentWetBulb0pt4:
string = "C";
break;
case EpwDesignField::CoolingDryBulb1:
string = "C";
break;
case EpwDesignField::CoolingMeanCoincidentWetBulb1: