I have two GRIB fields on different grids - how can I get them onto the same grid so that I can perform computations on them?
Step-by-step guide
The first, and fastest, way to do this is through the GRIB Filter icon. This allows you to change the resolution and area of a GRIB field - see this tutorial for an example.
However, some regriddings are not possible using this icon, for example converting a regular lat/lon grid into a reduced Gaussian grid. If the transformation you want does not work using this icon, you can use the following Macro function instead. It can be slower, but allows conversion between any grid types that Metview understands.
# ---------------------------------------------------------------------- # grid_to_grid # converts the data_source fieldset onto the same grid as in data_target # NOTE: all the GRIB meta-data is taken from data_target # ---------------------------------------------------------------------- function grid_to_grid(data_source:fieldset, data_target:fieldset) result = nil data_target_gpt = grib_to_geo(data : data_target[1]) # convert the target grid to geopoints for i = 1 to count(data_source) do data_target_gpt_interpolated = interpolate(data_source[i], data_target_gpt) # interpolate to these grid points new_values = values(data_target_gpt_interpolated) # extract the interpolated values new_data_target = set_values(data_target[i], new_values) # put the interpolated values into the target grid result = result & new_data_target end for return result end grid_to_grid # usage a = read('mygrib_grid1.grib') b = read('mygrib_grid2.grib') b = grid_to_grid(b, a) # regrid b to be the same as a diff = a - b
Related articles
Content by label
There is no content with the specified labels