Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Confirmed.


Excerpt
hiddentrue

The first, and fastest, way to do this is through the GRIB Filter icon. This allows GRIB Filter and Regrid icons allow you to change the resolution and area of a GRIB field - see this tutorial for an example.

Step-by-step guide

The first, and fastest, If you already know the desired resolution, one 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.As a last resort, 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, using Metview's own interpolate() function to derive each target pointversion 5.10, Metview has an advanced regridding module called Regrid. This has a mode that allows a template GRIB to be used to define the output grid. The following Python example shows the retrieval of a temperature field on one grid resolution and a subarea, and a land-sea mask on another grid; the land-sea mask is then put onto the same grid and subarea as the temperature field.

Code Block
languagepy
# ----------------------------------------------------------------------
# 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
import metview as mv

t = mv.retrieve(param='t', grid=[0.5, 0.5], area=[50, 10, 80, 40])
lsm = mv.retrieve(param='lsm', levtype='sfc', grid=[0.2, 0.2])

regridded_lsm = mv.regrid(data=lsm,
               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 gridgrid_definition_mode='template',
        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 - btemplate_data=t)

Content by Label
showLabelsfalse
max5
spaces~usa
showSpacefalse
sortmodified
reversetrue
typepage
cqllabel = "metview-faqs" and label in ("grid","computation") and type = "page" and space = "UDOC"
labelskb-how-to-article

...