Skip to content

Commit 01aeee5

Browse files
committed
Fix unit for 'Atmospheric Station Pressure'
1 parent a304c7b commit 01aeee5

File tree

3 files changed

+36
-22
lines changed

3 files changed

+36
-22
lines changed

nrel_psm3_2_epw/assets.py

+18-20
Original file line numberDiff line numberDiff line change
@@ -249,38 +249,36 @@ def download_epw(lon, lat, year, location, attributes, interval, utc, your_name,
249249

250250
# Actual file starts here
251251

252-
missing_values = np.array(np.ones(hours_per_year) * 999999).astype(int)
253-
254252
# st.write(df.index)
255253
epw_df = pd.DataFrame()
256254
epw_df['Year'] = datetimes.year.astype(int)
257255
epw_df['Month'] = datetimes.month.astype(int)
258256
epw_df['Day'] = datetimes.day.astype(int)
259257
epw_df['Hour'] = datetimes.hour.astype(int) + 1
260258
epw_df['Minute'] = datetimes.minute.astype(int)
261-
epw_df['Data Source and Uncertainty Flags'] = missing_values
259+
epw_df['Data Source and Uncertainty Flags'] = "'Created with NREL PSM3 input data'"
262260

263261
epw_df['Dry Bulb Temperature'] = df['Temperature'].values.flatten()
264262

265263
epw_df['Dew Point Temperature'] = df['Dew Point'].values.flatten()
266264

267265
epw_df['Relative Humidity'] = df['Relative Humidity'].values.flatten()
268266

269-
epw_df['Atmospheric Station Pressure'] = df['Pressure'].values.flatten()
270-
epw_df['Extraterrestrial Horizontal Radiation'] = missing_values
267+
epw_df['Atmospheric Station Pressure'] = df['Pressure'].astype(int).multiply(100).values.flatten()
268+
epw_df['Extraterrestrial Horizontal Radiation'] = 9999
271269
#
272-
epw_df['Extraterrestrial Direct Normal Radiation'] = missing_values
270+
epw_df['Extraterrestrial Direct Normal Radiation'] = 9999
273271
#
274-
epw_df['Horizontal Infrared Radiation Intensity'] = missing_values
272+
epw_df['Horizontal Infrared Radiation Intensity'] = 9999
275273
#
276274
epw_df['Global Horizontal Radiation'] = df['GHI'].values.flatten()
277275
epw_df['Direct Normal Radiation'] = df['DNI'].values.flatten()
278276
epw_df['Diffuse Horizontal Radiation'] = df['DHI'].values.flatten()
279277

280-
epw_df['Global Horizontal Illuminance'] = missing_values
281-
epw_df['Direct Normal Illuminance'] = missing_values
282-
epw_df['Diffuse Horizontal Illuminance'] = missing_values
283-
epw_df['Zenith Luminance'] = missing_values
278+
epw_df['Global Horizontal Illuminance'] = 999999
279+
epw_df['Direct Normal Illuminance'] = 999999
280+
epw_df['Diffuse Horizontal Illuminance'] = 999999
281+
epw_df['Zenith Luminance'] = 9999
284282

285283
epw_df['Wind Direction'] = df['Wind Direction'].values.flatten()
286284
epw_df['Wind Speed'] = df['Wind Speed'].values.flatten()
@@ -290,21 +288,21 @@ def download_epw(lon, lat, year, location, attributes, interval, utc, your_name,
290288
epw_df['Opaque Sky Cover'] = df['Cloud Type'].values.flatten()
291289
#
292290

293-
epw_df['Visibility'] = missing_values
294-
epw_df['Ceiling Height'] = missing_values
295-
epw_df['Present Weather Observation'] = missing_values
291+
epw_df['Visibility'] = 9999
292+
epw_df['Ceiling Height'] = 99999
293+
epw_df['Present Weather Observation'] = ''
296294
#
297-
epw_df['Present Weather Codes'] = missing_values
295+
epw_df['Present Weather Codes'] = ''
298296
epw_df['Precipitable Water'] = df['Precipitable Water'].values.flatten()
299-
epw_df['Aerosol Optical Depth'] = missing_values
297+
epw_df['Aerosol Optical Depth'] = .999
300298
#
301-
epw_df['Snow Depth'] = missing_values
302-
epw_df['Days Since Last Snowfall'] = missing_values
299+
epw_df['Snow Depth'] = 999
300+
epw_df['Days Since Last Snowfall'] = 99
303301
epw_df['Albedo'] = df['Surface Albedo'].values.flatten()
304302
#
305303

306-
epw_df['Liquid Precipitation Depth'] = missing_values
307-
epw_df['Liquid Precipitation Quantity'] = missing_values
304+
epw_df['Liquid Precipitation Depth'] = 999
305+
epw_df['Liquid Precipitation Quantity'] = 99
308306

309307
out.dataframe = epw_df
310308

nrel_psm3_2_epw/epw.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def _read_data(self, fp):
8080
'Wind Direction',
8181
'Wind Speed',
8282
'Total Sky Cover',
83-
'Opaque Sky Cover (used if Horizontal IR Intensity missing)',
83+
'Opaque Sky Cover',
8484
'Visibility',
8585
'Ceiling Height',
8686
'Present Weather Observation',

tests/test_download.py

+17-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
from nrel_psm3_2_epw.assets import *
55

6+
import pandas as pd
7+
68

79
def test_download_epw():
810
lat, lon = 40.755840, -73.982684
@@ -41,4 +43,18 @@ def test_download_epw():
4143
data = epw.EPW()
4244
data.read("NYC_40.75584_-73.982684_2012.epw")
4345

44-
assert (data.dataframe['Year'][0] == 2012)
46+
#(data.dataframe)
47+
48+
assert(data.dataframe['Year'][0] == 2012)
49+
assert((data.dataframe['Atmospheric Station Pressure'] > 31000) & (data.dataframe['Atmospheric Station Pressure'] < 120000)).all()
50+
assert((data.dataframe['Dry Bulb Temperature'] > -70) & (data.dataframe['Dry Bulb Temperature'] < 70)).all()
51+
assert((data.dataframe['Dew Point Temperature'] > -70) & (data.dataframe['Dew Point Temperature'] < 70)).all()
52+
assert((data.dataframe['Relative Humidity'] >= 0) & (data.dataframe['Relative Humidity'] < 110)).all()
53+
assert(data.dataframe['Global Horizontal Radiation'] >= 0).all()
54+
assert(data.dataframe['Direct Normal Radiation'] >= 0).all()
55+
assert(data.dataframe['Diffuse Horizontal Radiation'] >= 0).all()
56+
assert((data.dataframe['Wind Direction'] >= 0) & (data.dataframe['Relative Humidity'] <= 360)).all()
57+
assert((data.dataframe['Wind Speed'] >= 0) & (data.dataframe['Wind Speed'] <= 40)).all()
58+
assert((data.dataframe['Opaque Sky Cover'] >= 0) & (data.dataframe['Opaque Sky Cover'] <= 10)).all()
59+
assert((data.dataframe['Total Sky Cover'] >= 0) & (data.dataframe['Total Sky Cover'] <= 10)).all()
60+

0 commit comments

Comments
 (0)