Skip to content

Commit

Permalink
Per #1753, wrap the call to get_fill_value() in a try block in case t…
Browse files Browse the repository at this point in the history
…he input in a regular numpy array instead of a masked array.
  • Loading branch information
John Halley Gotway committed Apr 16, 2021
1 parent 68e96be commit 7b0a8d0
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions met/data/wrappers/write_tmp_dataplane.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,20 @@
attrs = met_in.attrs
met_info['attrs'] = attrs

# determine fill value
try:
fill = met_data.get_fill_value()
except:
fill = -9999.

# write NetCDF file
ds = nc.Dataset(netcdf_filename, 'w')

# create dimensions and variable
nx, ny = met_in.met_data.shape
ds.createDimension('x', nx)
ds.createDimension('y', ny)
dp = ds.createVariable('met_data', met_in.met_data.dtype, ('x', 'y'),
fill_value=met_in.met_data.get_fill_value())
dp = ds.createVariable('met_data', met_in.met_data.dtype, ('x', 'y'), fill_value=fill)
dp[:] = met_in.met_data

# append attributes
Expand Down

0 comments on commit 7b0a8d0

Please sign in to comment.