Skip to content

Commit 235087f

Browse files
committed
Cleanup
Update requirements.txt Fixes
1 parent 364499d commit 235087f

File tree

6 files changed

+98
-209
lines changed

6 files changed

+98
-209
lines changed

.github/workflows/codeql-analysis.yml

-70
This file was deleted.

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,5 @@ __pycache__/
132132
*.bak
133133
.vscode/settings.json
134134
run_act_test.bat
135+
.DS_Store
136+
*.py~

nrel_psm3_2_epw/assets.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
import json
1+
import calendar
22
import sys
3+
from datetime import datetime
34

45
import numpy as np
56
import pandas as pd
67
import requests
8+
79
from . import epw
8-
from datetime import datetime
9-
import calendar
1010

1111

1212
def download_epw(lon, lat, year, location, attributes, interval, utc, your_name, api_key, reason_for_use,
1313
your_affiliation, your_email, mailing_list, leap_year):
1414
currentYear = datetime.now().year
15-
if int(year) == currentYear or int(year) == currentYear-1:
15+
if int(year) == currentYear or int(year) == currentYear - 1:
1616
raise Exception("NREL does not provide data for the current year " + str(
1717
year) + ". It is also unlikely that there is data availability for " + str(int(year) - 1) + ".")
1818

@@ -42,8 +42,8 @@ def download_epw(lon, lat, year, location, attributes, interval, utc, your_name,
4242

4343
try:
4444
r = requests.request("GET", url, params=
45-
payload, headers=headers, timeout=20)
46-
45+
payload, headers=headers, timeout=20)
46+
4747
print(r.text)
4848
r.raise_for_status()
4949

@@ -66,7 +66,7 @@ def download_epw(lon, lat, year, location, attributes, interval, utc, your_name,
6666

6767
hours_per_year = 8760
6868

69-
if calendar.isleap(int(year)) and bool(leap_year) is True and all_data.shape[0] == 8784+2:
69+
if calendar.isleap(int(year)) and bool(leap_year) is True and all_data.shape[0] == 8784 + 2:
7070
hours_per_year = 8784
7171

7272
datetimes = pd.date_range('01/01/' + str(year),
@@ -310,7 +310,7 @@ def download_epw(lon, lat, year, location, attributes, interval, utc, your_name,
310310

311311
d = "_"
312312
file_name = str(location) + d + str(lat) + d + \
313-
str(lon) + d + str(year) + '.epw'
313+
str(lon) + d + str(year) + '.epw'
314314

315315
out.write(file_name)
316316
print("Success: File", file_name, "written")

nrel_psm3_2_epw/epw.py

+72-75
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
# -*- coding: utf-8 -*-
2-
import pandas as pd
32
import csv
43

4+
import pandas as pd
5+
6+
57
class EPW():
68
"""A class which represents an EnergyPlus weather (epw) file
79
"""
8-
10+
911
def __init__(self):
1012
"""
1113
"""
12-
self.headers={}
13-
self.dataframe=pd.DataFrame()
14-
15-
16-
def read(self,fp):
14+
self.headers = {}
15+
self.dataframe = pd.DataFrame()
16+
17+
def read(self, fp):
1718
"""Reads an epw file
1819
1920
Arguments:
2021
- fp (str): the file path of the epw file
2122
2223
"""
23-
24-
self.headers=self._read_headers(fp)
25-
self.dataframe=self._read_data(fp)
26-
27-
28-
def _read_headers(self,fp):
24+
25+
self.headers = self._read_headers(fp)
26+
self.dataframe = self._read_data(fp)
27+
28+
def _read_headers(self, fp):
2929
"""Reads the headers of an epw file
3030
3131
Arguments:
@@ -35,19 +35,18 @@ def _read_headers(self,fp):
3535
- d (dict): a dictionary containing the header rows
3636
3737
"""
38-
39-
d={}
38+
39+
d = {}
4040
with open(fp, newline='') as csvfile:
4141
csvreader = csv.reader(csvfile, delimiter=',', quotechar='"')
4242
for row in csvreader:
4343
if row[0].isdigit():
4444
break
4545
else:
46-
d[row[0]]=row[1:]
46+
d[row[0]] = row[1:]
4747
return d
48-
49-
50-
def _read_data(self,fp):
48+
49+
def _read_data(self, fp):
5150
"""Reads the climate data of an epw file
5251
5352
Arguments:
@@ -57,52 +56,51 @@ def _read_data(self,fp):
5756
- df (pd.DataFrame): a DataFrame comtaining the climate data
5857
5958
"""
60-
61-
names=['Year',
62-
'Month',
63-
'Day',
64-
'Hour',
65-
'Minute',
66-
'Data Source and Uncertainty Flags',
67-
'Dry Bulb Temperature',
68-
'Dew Point Temperature',
69-
'Relative Humidity',
70-
'Atmospheric Station Pressure',
71-
'Extraterrestrial Horizontal Radiation',
72-
'Extraterrestrial Direct Normal Radiation',
73-
'Horizontal Infrared Radiation Intensity',
74-
'Global Horizontal Radiation',
75-
'Direct Normal Radiation',
76-
'Diffuse Horizontal Radiation',
77-
'Global Horizontal Illuminance',
78-
'Direct Normal Illuminance',
79-
'Diffuse Horizontal Illuminance',
80-
'Zenith Luminance',
81-
'Wind Direction',
82-
'Wind Speed',
83-
'Total Sky Cover',
84-
'Opaque Sky Cover (used if Horizontal IR Intensity missing)',
85-
'Visibility',
86-
'Ceiling Height',
87-
'Present Weather Observation',
88-
'Present Weather Codes',
89-
'Precipitable Water',
90-
'Aerosol Optical Depth',
91-
'Snow Depth',
92-
'Days Since Last Snowfall',
93-
'Albedo',
94-
'Liquid Precipitation Depth',
95-
'Liquid Precipitation Quantity']
96-
97-
first_row=self._first_row_with_climate_data(fp)
98-
df=pd.read_csv(fp,
99-
skiprows=first_row,
100-
header=None,
101-
names=names)
59+
60+
names = ['Year',
61+
'Month',
62+
'Day',
63+
'Hour',
64+
'Minute',
65+
'Data Source and Uncertainty Flags',
66+
'Dry Bulb Temperature',
67+
'Dew Point Temperature',
68+
'Relative Humidity',
69+
'Atmospheric Station Pressure',
70+
'Extraterrestrial Horizontal Radiation',
71+
'Extraterrestrial Direct Normal Radiation',
72+
'Horizontal Infrared Radiation Intensity',
73+
'Global Horizontal Radiation',
74+
'Direct Normal Radiation',
75+
'Diffuse Horizontal Radiation',
76+
'Global Horizontal Illuminance',
77+
'Direct Normal Illuminance',
78+
'Diffuse Horizontal Illuminance',
79+
'Zenith Luminance',
80+
'Wind Direction',
81+
'Wind Speed',
82+
'Total Sky Cover',
83+
'Opaque Sky Cover (used if Horizontal IR Intensity missing)',
84+
'Visibility',
85+
'Ceiling Height',
86+
'Present Weather Observation',
87+
'Present Weather Codes',
88+
'Precipitable Water',
89+
'Aerosol Optical Depth',
90+
'Snow Depth',
91+
'Days Since Last Snowfall',
92+
'Albedo',
93+
'Liquid Precipitation Depth',
94+
'Liquid Precipitation Quantity']
95+
96+
first_row = self._first_row_with_climate_data(fp)
97+
df = pd.read_csv(fp,
98+
skiprows=first_row,
99+
header=None,
100+
names=names)
102101
return df
103-
104-
105-
def _first_row_with_climate_data(self,fp):
102+
103+
def _first_row_with_climate_data(self, fp):
106104
"""Finds the first row with the climate data of an epw file
107105
108106
Arguments:
@@ -112,27 +110,26 @@ def _first_row_with_climate_data(self,fp):
112110
- i (int): the row number
113111
114112
"""
115-
113+
116114
with open(fp, newline='') as csvfile:
117115
csvreader = csv.reader(csvfile, delimiter=',', quotechar='"')
118-
for i,row in enumerate(csvreader):
116+
for i, row in enumerate(csvreader):
119117
if row[0].isdigit():
120118
break
121119
return i
122-
123-
124-
def write(self,fp):
120+
121+
def write(self, fp):
125122
"""Writes an epw file
126123
127124
Arguments:
128125
- fp (str): the file path of the new epw file
129126
130127
"""
131-
128+
132129
with open(fp, 'w', newline='') as csvfile:
133130
csvwriter = csv.writer(csvfile, delimiter=',',
134-
quotechar='"', quoting=csv.QUOTE_MINIMAL)
135-
for k,v in self.headers.items():
136-
csvwriter.writerow([k]+v)
137-
for row in self.dataframe.itertuples(index= False):
138-
csvwriter.writerow(i for i in row)
131+
quotechar='"', quoting=csv.QUOTE_MINIMAL)
132+
for k, v in self.headers.items():
133+
csvwriter.writerow([k] + v)
134+
for row in self.dataframe.itertuples(index=False):
135+
csvwriter.writerow(i for i in row)

requirements.txt

+4-48
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,4 @@
1-
altair==5.2.0
2-
attrs==23.2.0
3-
blinker==1.7.0
4-
cachetools==5.3.2
5-
certifi==2024.2.2
6-
charset-normalizer==3.3.2
7-
click==8.0.0
8-
colorama==0.4.6
9-
DateTime==5.4
10-
gitdb==4.0.11
11-
GitPython==3.1.42
12-
idna==3.6
13-
importlib-metadata==7.0.1
14-
Jinja2==3.1.3
15-
jsonschema==4.21.1
16-
jsonschema-specifications==2023.12.1
17-
markdown-it-py==3.0.0
18-
MarkupSafe==2.1.5
19-
mdurl==0.1.2
20-
numpy==1.26.4
21-
packaging==23.2
22-
pandas==2.2.0
23-
pillow==10.2.0
24-
protobuf==4.25.3
25-
pyarrow==15.0.0
26-
pydeck==0.8.1b0
27-
Pygments==2.17.2
28-
python-dateutil==2.8.2
29-
pytz==2024.1
30-
referencing==0.33.0
31-
requests==2.31.0
32-
rich==13.7.0
33-
rpds-py==0.18.0
34-
six==1.16.0
35-
smmap==5.0.1
36-
streamlit==1.31.1
37-
tenacity==8.2.3
38-
toml==0.10.2
39-
toolz==0.12.1
40-
tornado==6.4
41-
typing_extensions==4.9.0
42-
tzdata==2024.1
43-
tzlocal==5.2
44-
urllib3==2.2.0
45-
validators==0.22.0
46-
watchdog==4.0.0
47-
zipp==3.17.0
48-
zope.interface==6.2
1+
click==8
2+
numpy
3+
pandas
4+
requests

0 commit comments

Comments
 (0)