Excerpt |
---|
|
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.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
Since version 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 |
---|
|
# ----------------------------------------------------------------------
# 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) |
Related articles
Content by Label |
---|
showLabels | false |
---|
max | 5 |
---|
spaces | ~usa |
---|
showSpace | false |
---|
sort | modified |
---|
reverse | true |
---|
type | page |
---|
cql | label = "metview-faqs" and label in ("grid","computation") and type = "page" and space = "UDOC" |
---|
labels | kb-how-to-article |
---|
|
...