Skip to content
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

grib save : minor update #229

Merged
merged 2 commits into from
Nov 30, 2012
Merged
Changes from 1 commit
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
Next Next commit
first results
  • Loading branch information
bblay committed Nov 27, 2012
commit ae1214e59a75b33bea10aba741cb0dec7cd09182
22 changes: 14 additions & 8 deletions lib/iris/fileformats/grib_save_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,17 +264,23 @@ def hybrid_surfaces(cube, grib):

def non_hybrid_surfaces(cube, grib):

# pressure?
# pressure
if cube.coords("air_pressure") or cube.coords("pressure"):
grib_v_code = 100
output_unit = iris.unit.Unit("Pa")
v_coord = (cube.coords("air_pressure") or cube.coords("pressure"))[0]

# altitude
elif cube.coords("altitude"):
grib_v_code = 102
output_unit = iris.unit.Unit("m")
v_coord = cube.coord("altitude")

# # height?
# elif cube.coords("height"):
# grib_v_code = 102 # XXX is this correct?
# output_unit = iris.unti.Unit("m")
# v_coord = cube.coord("height")
# height
elif cube.coords("height"):
grib_v_code = 103
output_unit = iris.unit.Unit("m")
v_coord = cube.coord("height")

else:
raise iris.exceptions.TranslationError("Vertical coordinate not found / handled")
Expand Down Expand Up @@ -440,10 +446,10 @@ def data(cube, grib):

# mdi
if isinstance(cube.data, numpy.ma.core.MaskedArray):
gribapi.grib_set_long(grib, "missingValue", cube.data.fill_value)
gribapi.grib_set_double(grib, "missingValue", float(cube.data.fill_value))
data = cube.data.filled()
else:
gribapi.grib_set_long(grib, "missingValue", -1e9)
gribapi.grib_set_double(grib, "missingValue", float(-1e9))
data = cube.data

# values
Expand Down