Commit 16da8766 authored by Espen Sollum's avatar Espen Sollum
Browse files

Adding a quick fix for str accidentally converted to type byte, until I find out why this happens

parent f468bc79
......@@ -80,15 +80,25 @@ def obsoper(self, inputs, mode,
subdir = subsimu_dates[0].strftime("%Y%m")
fp_header_glob = model.utils.flexpart_header.Flexpartheader()
try:
fp_header_glob.read_header(
os.path.join(model.run_dir_glob, obsvect.datastore.head(1)['station'][0].decode().upper(),
subdir, 'header'))
os.path.join(model.run_dir_glob, obsvect.datastore.head(1)['station'][0].decode().
upper(),subdir, 'header'))
except AttributeError as e:
fp_header_glob.read_header(
os.path.join(model.run_dir_glob, obsvect.datastore.head(1)['station'][0].
upper(),subdir, 'header'))
if model.plugin.nested:
try:
fp_header_nest = model.utils.flexpart_header.Flexpartheader()
fp_header_nest.read_header(
os.path.join(model.run_dir_nest, obsvect.datastore.head(1)['station'][0].decode().upper(),
subdir, 'header_nest'))
os.path.join(model.run_dir_nest, obsvect.datastore.head(1)['station'][0].
decode().upper(), subdir, 'header_nest'))
except AttributeError as e:
fp_header_nest.read_header(
os.path.join(model.run_dir_nest, obsvect.datastore.head(1)['station'][0].
upper(), subdir, 'header_nest'))
# Trajectory life time
trajdays = fp_header_glob.trajdays
......@@ -149,10 +159,16 @@ def obsoper(self, inputs, mode,
station = row.station
try:
runsubdir_nest = os.path.join(
model.run_dir_nest, station.decode().upper(), subdir)
runsubdir_glob = os.path.join(
model.run_dir_glob, station.decode().upper(), subdir)
except AttributeError as e:
runsubdir_nest = os.path.join(
model.run_dir_nest, station.upper(), subdir)
runsubdir_glob = os.path.join(
model.run_dir_glob, station.upper(), subdir)
file_date = row.Index.strftime('%Y%m%d%H%M%S')
......
......@@ -74,8 +74,10 @@ def init_background(obsvect, **kwargs):
# Subdirectory for FLEXPART grid_initial files
subdir = row.Index.strftime("%Y%m")
# station = row.station
station = row.station.decode()
station = row.station
# Sometimes datastores read from netcdf convert type str to type bytes
if isinstance(station, bytes):
station = station.decode()
runsubdir_glob = os.path.join(
model.run_dir_glob, station.upper(), subdir)
file_date = row.Index.strftime('%Y%m%d%H%M%S')
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment