1 |
/* RCSid $Id: loadEPW.h,v 2.1 2025/02/26 20:39:28 greg Exp $ */ |
2 |
/* |
3 |
* Header for EPW (or WEA) file loader |
4 |
* |
5 |
* G. Ward, Feb 2025 |
6 |
*/ |
7 |
|
8 |
#ifndef _RAD_LOADEPW_H_ |
9 |
#define _RAD_LOADEPW_H_ |
10 |
|
11 |
#ifdef __cplusplus |
12 |
extern "C" { |
13 |
#endif |
14 |
|
15 |
enum {Sunday, Monday, Tuesday, Wednesday, |
16 |
Thursday, Friday, Saturday}; |
17 |
|
18 |
extern const char WDname[7][10]; |
19 |
|
20 |
enum {January, February, March, April, May, June, July, |
21 |
August, September, October, November, December}; |
22 |
|
23 |
extern const char MOname[12][10]; |
24 |
|
25 |
enum {WEAnot=0, WEAradnorm=1, WEAradhoriz=2, WEAphotnorm=3}; |
26 |
|
27 |
/* EPW date and time */ |
28 |
typedef struct { |
29 |
float hour; /* decimal hour (0-24) */ |
30 |
short day; /* day of the month (1-31) */ |
31 |
short month; /* month of the year (0-11) */ |
32 |
short year; /* year (or 0) */ |
33 |
} EPWdate; |
34 |
|
35 |
/* EPW file header info. */ |
36 |
typedef struct { |
37 |
FILE *fp; /* open file pointer */ |
38 |
int lino; /* current line in file */ |
39 |
int dstart; /* starting data position in file */ |
40 |
short lin0; /* # lines in header */ |
41 |
short isWEA; /* input is WEA data type? */ |
42 |
EPWdate dtpos; /* date and time of current record */ |
43 |
struct Location { |
44 |
char city[64]; /* location city */ |
45 |
char state[64]; /* location state/province */ |
46 |
char country[64]; /* country */ |
47 |
char source[64]; /* data source */ |
48 |
char wmo[16]; /* WMO (EnergyPlus alpha?) */ |
49 |
double latitude; /* site latitude (deg north) */ |
50 |
double longitude; /* site longitude (deg east) */ |
51 |
float timezone; /* time zone (hours from GMT) */ |
52 |
float elevation; /* site altitude in meters */ |
53 |
} loc; /* location data */ |
54 |
/* struct DesConditions XXX unsupported */ |
55 |
/* struct VarPeriods XXX unsupported */ |
56 |
/* struct GroundTemps XXX unsupported */ |
57 |
/* struct SpecialDays XXX unsupported */ |
58 |
char *comments1; /* first set of additional comments */ |
59 |
char *comments2; /* second set of comments */ |
60 |
int nperiods; /* # of data periods */ |
61 |
struct DataPeriod { |
62 |
char name[64]; /* data period name */ |
63 |
short nperhour; /* # records/hour */ |
64 |
short startday; /* starting day of the week */ |
65 |
EPWdate firstdate; /* starting date */ |
66 |
EPWdate lastdate; /* ending date */ |
67 |
} period[1]; /* periods covered in EPW file */ |
68 |
} EPWheader; |
69 |
|
70 |
/* EPW record holder (NOTE: all lengths in meters, contrary to spec!) */ |
71 |
typedef struct { |
72 |
EPWdate date; /* measurement date and time */ |
73 |
char uncert[64]; /* uncertainty flags */ |
74 |
float dbtemp; /* dry bulb temperature (deg-C) */ |
75 |
float dptemp; /* dew point temperature (deg-C) */ |
76 |
float humidity; /* relative humidity (0-110 %) */ |
77 |
float atmospressure; /* atmospheric pressure (31000 - 120000) */ |
78 |
float exthorizirrad; /* extraterrestrial horizontal irradiance */ |
79 |
float extdirirrad; /* extraterrestrial direct normal irradiance */ |
80 |
float horizirrad_ir; /* infrared horizontal normal irradiance */ |
81 |
float globhorizirrad; /* global horizontal irradiance */ |
82 |
float dirirrad; /* direct normal irradiance */ |
83 |
float horizdiffirrad; /* horizontal diffuse irradiance */ |
84 |
float globhorizillum; /* global horizontal illuminance (lux) */ |
85 |
float diffillum; /* diffuse horizontal illuminance (lux) */ |
86 |
float dirillum; /* direct normal illuminance (lux) */ |
87 |
float zenlum; /* zenith luminance (cd/m2) */ |
88 |
float windirection; /* wind direction (deg E of N) */ |
89 |
float windspeed; /* wind speed in m/s */ |
90 |
float skycover; /* total sky coverage (fraction) */ |
91 |
float opskycover; /* opaque sky coverage (fraction) */ |
92 |
float visibility; /* visibility (meters!) */ |
93 |
float ceilheight; /* cloud ceiling height (meters) */ |
94 |
/* char weather[32]; XXX unsupported */ |
95 |
float precip; /* precipital water in meters(!) */ |
96 |
float optdepth; /* aerosol optical depth (fraction!) */ |
97 |
float snowdepth; /* snow depth (meters!) */ |
98 |
int nosnowdays; /* # days since last snow */ |
99 |
float albedo; /* ratio of reflected to global horiz. irrad */ |
100 |
float liqpdepth; /* liquid precipitation depth (meters!) */ |
101 |
float liqhours; /* liquid precipitation quantity (hours) */ |
102 |
} EPWrecord; |
103 |
|
104 |
extern const EPWrecord EPWrecInit; |
105 |
|
106 |
#define EPWisset(rp,field) ((rp)->field != EPWrecInit.field) |
107 |
|
108 |
/* specify NULL for stdin */ |
109 |
extern EPWheader * EPWopen(const char *fname); |
110 |
|
111 |
extern int EPWseek(EPWheader *epw, const EPWdate *dt); |
112 |
|
113 |
extern int EPWread(EPWheader *epw, EPWrecord *rp); |
114 |
|
115 |
extern void EPWclose(EPWheader *epw); |
116 |
|
117 |
#ifdef __cplusplus |
118 |
} |
119 |
#endif |
120 |
#endif /* ! _RAD_LOADEPW_H_ */ |