YetAnotherCoupler 3.0.3
Loading...
Searching...
No Matches
Interpolation stack

Introduction

Individual interpolation methods may have limitations that prevent them from interpolating all required target field values. A typical solution is the definition of a fallback solution that tries to handle these remaining points.

YAC introduced the concept of the interpolation stack. It is a more general approach to defining fallback soluions. A interpolation stack is comprised of a list of one or more interpolation methods. To compute an interpolation, all required target field points are passed to the first method in a stack. This will try to generate interpolations for all target field points. The ones for which the method failed are passed to the next method in the stack. This is done until the end of the stack is reached.

There are no limitations on which interpolation methods can occure at which position in the stack as long as the respective methods are compatible with available source and target field data. This allows for a very flexible definition of an interpolation.

The Fixed value interpolation will assign a fixed value to all remaining target points in a stack. It can be used for example to mark target points, which could not be interpolated by the other methods in the stack. Since Fixed value interpolation will always successfully process all remaining target point, it does not make sense the other interpolation methods afterwards in the stack.

Example interpolation stacks

Average + Fixed

Description

A simple stack consist of an Average interpolation combined with Fixed value interpolation . The Average interpolation will fail for target points that are located outside of the region covered by the source grid or due to masked source points. The Fixed value interpolation will assign a fixed value (0.0 in this case) to these target points. This may be a fill value to ensure that the target model is able to continue working or it may be used to identify the respective points, which may help to debug potential problems.
(Grey target points are not interpolated and YAC will not assign any data to these points.)

Source field
Target field after AVG
Target field after FIXED

YAML

interpolation:
- average:
weighted: barycentric_coordinate
partial_coverage: false
- fixed:
user_value: -1.0

HCSBB + N-Nearest-Neighbour

Description

A higher order stack consisting of an Hybrid cubic spherical Bernstein-B├ęzier patch interpolation with a N-Nearest-Neighbour interpolation fallback, which is used for the extrapolation of target points not covered by the source grid.
(Grey target points are not interpolated and YAC will not assign any data to these points.)

Source field
Target field after HCSBB
Target field after NNN

YAML

interpolation:
- bernstein_bezier
- nnn:
n: 1

Source-Point-Mapping + Fixed

Description

A typical river-runoff stack can consist of Source to Target mapping combined with Fixed value interpolation. The Fixed value interpolation ensures that all target ocean cells receive a valid value in the get operation.
(Red cell indicate masked source cells or target cells that do not receive any data in the get operation.)

Source field
Target field after SPMAP
Target field after FIXED

YAML

interpolation:
- source_to_target_map:
weighted: arithmetic_average
spread_distance: 0.5
- fixed:
user_value: 0.0

Conservative 2nd + 1st

Description

A interpolation stack for conservative interpolation. It first tries to interpolate using a second order conservative method. It uses a bigger stencil, which can fail at the edges of grids or masks. As a backup a first order conservative method is used. It is more robust than the 2nd order. It is followed by a n-nearest neighbor method for all remaining cells. The fixed method is not required as nnn will already fill all remaining data points. It is for safety in case the nnn fails for some reason.

YAML

interpolation:
- conservative:
enforced_conservation: true
normalisation: destarea
order: 2
partial_coverage: false
- conservative:
enforced_conservation: true
normalisation: fracarea
order: 1
partial_coverage: false
- nnn:
n: 4
weighted: distance_weighted
- fixed:
user_value: -999.0

Interpolation stack to file

YAC support the writing of the results of any interpolation stack to file. Such a file can contain the weights of multiple Interpolation methods and list of targets that receive a fixed value. The file is decomposition independent. It can be read in through the use of Interpolation from weight file.

You may want to write a file in order to inspect the results of the interpolation stack. YAC futher supports this by providing a tool that allows you to visualise a weight file (see Creating weight files and visualise them).

In case the weight generation for a specific interpolation stack is very costly, you can write out the results and reuse the precomputed weights in a later run. However, reading in and distributing the weights from file also takes some time. Therefore, it may often be quicker to recompute the weights for each run.

Via the weight files other software can also use weights computed by YAC. The other software would have to support the YAC weight file format or the weight file would have to be converted, if possible.

Writing is activated through the use of the ‹enforce_write_weight_file› tag.

YAML

Writing

weight_file_name: my_weight_file.nc
interpolation:
conservative:
order: 1
enforced_conservation: false
partial_coverage: false
normalisation: fracarea
fixed:
user_value: -9999.0

Reading

interpolation:
- user_file:
filename: my_weight_file.nc