Skip to content

Commit bd2e503

Browse files
committed
fix(wea): Add country to header
1 parent 5965698 commit bd2e503

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

ladybug/epw.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1698,7 +1698,7 @@ def to_mos(self, file_path):
16981698
return file_path
16991699

17001700
def _get_wea_header(self):
1701-
return "place %s\n" % self.location.city + \
1701+
return "place %s_%s\n" % (self.location.city, self.location.country) + \
17021702
"latitude %.2f\n" % self.location.latitude + \
17031703
"longitude %.2f\n" % -self.location.longitude + \
17041704
"time_zone %d\n" % (-self.location.time_zone * 15) + \

ladybug/wea.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ def is_annual(self):
607607
@property
608608
def header(self):
609609
"""Get the Wea header as a string."""
610-
return "place %s\n" % self.location.city + \
610+
return "place %s_%s\n" % (self.location.city, self.location.country) + \
611611
"latitude %.2f\n" % self.location.latitude + \
612612
"longitude %.2f\n" % -self.location.longitude + \
613613
"time_zone %d\n" % (-self.location.time_zone * 15) + \
@@ -1125,7 +1125,14 @@ def _parse_wea_header(weaf, wea_file_name):
11251125
assert first_line.startswith('place'), 'Failed to find place in .wea header.\n' \
11261126
'{} is not a valid wea file.'.format(wea_file_name)
11271127
location = Location()
1128-
location.city = ' '.join(first_line.split()[1:])
1128+
place_info = ' '.join(first_line.split()[1:])
1129+
if '_' in place_info:
1130+
city, country = place_info.rsplit('_', 1)
1131+
else:
1132+
city = place_info
1133+
country = '-'
1134+
location.city = city
1135+
location.country = country
11291136
location.latitude = float(weaf.readline().split()[-1])
11301137
location.longitude = -float(weaf.readline().split()[-1])
11311138
location.time_zone = -int(weaf.readline().split()[-1]) / 15

0 commit comments

Comments
 (0)