You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

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.

Since Metview started using mir as its interpolation library (Metview 5.5 shipped externally with this), many more regriddings are possible than was the case before, in particular, we can now extract a sub-area from 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




  • No labels