Skip to content

Commit

Permalink
add temp data casting workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
lbdreyer committed May 31, 2020
1 parent d97be3f commit 643487c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions iris_grib/_save_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -1489,6 +1489,13 @@ def data_section(cube, grib):
# Enable missing values in the grib message.
gribapi.grib_set(grib, "bitmapPresent", 1)
gribapi.grib_set_double(grib, "missingValue", fill_value)

# A segmentation fault is raised by `gribapi.grib_set_double_array` if it
# tries to cast large data to float64. As a temporary fix we cast the data
# upfront
# TODO: remove the `astype` command once eccodes (gribapi) has been fixed.
if data.dtype != np.float64:
data = data.astype(np.float64)
gribapi.grib_set_double_array(grib, "values", data.flatten())

# todo: check packing accuracy?
Expand Down

0 comments on commit 643487c

Please sign in to comment.