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, ...@@ -80,15 +80,25 @@ def obsoper(self, inputs, mode,
subdir = subsimu_dates[0].strftime("%Y%m") subdir = subsimu_dates[0].strftime("%Y%m")
fp_header_glob = model.utils.flexpart_header.Flexpartheader() fp_header_glob = model.utils.flexpart_header.Flexpartheader()
fp_header_glob.read_header( try:
os.path.join(model.run_dir_glob, obsvect.datastore.head(1)['station'][0].decode().upper(), fp_header_glob.read_header(
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: if model.plugin.nested:
fp_header_nest = model.utils.flexpart_header.Flexpartheader() try:
fp_header_nest.read_header( fp_header_nest = model.utils.flexpart_header.Flexpartheader()
os.path.join(model.run_dir_nest, obsvect.datastore.head(1)['station'][0].decode().upper(), fp_header_nest.read_header(
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 # Trajectory life time
trajdays = fp_header_glob.trajdays trajdays = fp_header_glob.trajdays
...@@ -148,11 +158,17 @@ def obsoper(self, inputs, mode, ...@@ -148,11 +158,17 @@ def obsoper(self, inputs, mode,
obs_check[obs_i] = obs_i obs_check[obs_i] = obs_i
station = row.station station = row.station
runsubdir_nest = os.path.join( try:
model.run_dir_nest, station.decode().upper(), subdir) runsubdir_nest = os.path.join(
runsubdir_glob = os.path.join( model.run_dir_nest, station.decode().upper(), subdir)
model.run_dir_glob, 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') file_date = row.Index.strftime('%Y%m%d%H%M%S')
......
...@@ -74,8 +74,10 @@ def init_background(obsvect, **kwargs): ...@@ -74,8 +74,10 @@ def init_background(obsvect, **kwargs):
# Subdirectory for FLEXPART grid_initial files # Subdirectory for FLEXPART grid_initial files
subdir = row.Index.strftime("%Y%m") subdir = row.Index.strftime("%Y%m")
# station = row.station station = row.station
station = row.station.decode() # Sometimes datastores read from netcdf convert type str to type bytes
if isinstance(station, bytes):
station = station.decode()
runsubdir_glob = os.path.join( runsubdir_glob = os.path.join(
model.run_dir_glob, station.upper(), subdir) model.run_dir_glob, station.upper(), subdir)
file_date = row.Index.strftime('%Y%m%d%H%M%S') 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