Skip to content

Updates to enable writing of string variables #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified bin/cis
100755 → 100644
Empty file.
Empty file modified bin/cis.lsf
100755 → 100644
Empty file.
Empty file modified cis/cis_main.py
100755 → 100644
Empty file.
Empty file modified cis/data_io/hdf_sd.py
100755 → 100644
Empty file.
2 changes: 1 addition & 1 deletion cis/data_io/ungridded_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ def update_range(self, range=None):
cis_standard_time_unit.num2date(self.data.max()))
else:
range = (self.data.min(), self.data.max())
except ValueError as e:
except Exception as e: #MRR: ValueError fails with string variables, need Exception
# If we can't set a range for some reason then just leave it blank
range = ()

Expand Down
11 changes: 9 additions & 2 deletions cis/data_io/write_netcdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
'uint32': "u4",
'uint64': "u8",
'float32': "f4",
'float64': "f8"}
'float64': "f8", #MRR
'object': "S2"} #MRR

index_name = 'obs'

Expand Down Expand Up @@ -102,7 +103,13 @@ def __create_variable(nc_file, data, prefer_standard_name=False):
if (name is None) or prefer_standard_name:
if (data.metadata.standard_name is not None) and (len(data.metadata.standard_name) > 0):
name = data.metadata.standard_name
out_type = types[str(data.data.dtype)]
#MRR added 4 lines below to deal with string type variables
if str(data.data.dtype)[0:2] == "<U":
out_type = 'S'+str(data.data.dtype)[2]
else:
out_type = types[str(data.data.dtype)]
#MRR commented 1 line below
# out_type = types[str(data.data.dtype)]
logging.info("Creating variable: {name}({index}) {type}".format(name=name, index=index_name, type=out_type))
if name not in nc_file.variables:
# Generate a warning if we have insufficient disk space
Expand Down
4 changes: 2 additions & 2 deletions cis/plotting/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ def drawcoastlines(ax, coastlinescolour):
ext = _get_extent(ax)

if _test_natural_earth_available():
coastline_res = coastline_scales[0][1]
for scale, res in coastline_scales[1:]:
coastline_res = coastline_scales[2][1] #MRR: change default to highest res
for scale, res in coastline_scales[0:]:
if scale > ext:
coastline_res = res

Expand Down