Regridding is an interpolation operation, which takes the data attached to an original grid and computes corresponding values on a target grid. More...
Functions | |
| int | nccf_def_regrid (int ori_grid_id, int tgt_grid_id, int *regrid_id) |
| Define a regridding object (acts as a constructor). | |
| int | nccf_free_regrid (int regrid_id) |
| Free regridding object (destructor). | |
| int | nccf_compute_regrid_weights (int regrid_id, int nitermax, double tolpos, const int is_periodic[]) |
| Compute the weights of a regridding object. | |
| int | nccf_apply_regrid (int regrid_id, int ori_data_id, int tgt_data_id) |
| Regrid data, should be called after nccf_compute_regrid_weights. | |
| int | nccf_inq_regrid_ntargets (int regrid_id, int *ntargets) |
| Get the number of target points in the domain. | |
| int | nccf_inq_regrid_nvalid (int regrid_id, int *nvalid) |
| Get the number of non-masked values in the domain. | |
| int | nccf_inq_regrid_nnodes (int regrid_id, int *nnodes) |
| Get the number of nodes per cell. | |
| int | nccf_add_regrid_forbidden (int regrid_id, const int lo[], const int hi[]) |
| Add a forbidden box, any target point inside the box will not be interpolated. | |
| int | nccf_put_regrid (int ncid, int regrid_id) |
| Write regrid weights, indices and domain location to a file. | |
| int | nccf_def_regrid_from_file (const char *filename, int *regrid_id) |
| Create a regrid object from a file. | |
Regridding is an interpolation operation, which takes the data attached to an original grid and computes corresponding values on a target grid.
The regridding operation assumes that both grids are structured and involves linear interpolation, i.e. only the closest neighbor values are used to determine the interpolated values. The interpolated values are guaranteed to be within the range of neighboring values.
Interpolation requires the location of a target position in index space. A pseudo-Newton scheme is used to find the index position. A single iteration is sufficient in the case of a uniform grid, more iterations are required when the grid is locally refined and/or highly warped.
Regridding only applies to target positions that have been found to lie within the original grid. Regridding is a no-operation for those target positions that lie outside the original grid, or for target positions which could not be determined to lie within the original grid. It is not an error to have non-overlapping original and target grids.
When regridding it is possible to exclude some regions (e.g. land in an ocean model) and this is achieved by adding forbidden boxes to the regridding object. Care should also be taken when the original grid has a cut in coordinate space, that is a discontinuity in coordinates. This case arises when the longitudes jump by 360 degrees in particular. To remove the possibility for the interpolation algorithm to erroneously find the target position to lie within the cut (multi-valued coordinates are not allowed), it is advisable to add a forbidden box at the cut location.
| int nccf_add_regrid_forbidden | ( | int | regrid_id, |
| const int | lo[], | ||
| const int | hi[] | ||
| ) |
Add a forbidden box, any target point inside the box will not be interpolated.
| regrid_id | object id |
| lo | inclusive lower set of indices delimiting the box |
| hi | inclusive upper set of indices delimiting the box |
Definition at line 11 of file nccf_add_regrid_forbidden.c.
| int nccf_apply_regrid | ( | int | regrid_id, |
| int | ori_data_id, | ||
| int | tgt_data_id | ||
| ) |
Regrid data, should be called after nccf_compute_regrid_weights.
| regrid_id | object Id |
| ori_data_id | data object on original grid |
| tgt_data_id | data object on target grid |
Definition at line 13 of file nccf_apply_regrid.c.
| int nccf_compute_regrid_weights | ( | int | regrid_id, |
| int | nitermax, | ||
| double | tolpos, | ||
| const int | is_periodic[] | ||
| ) |
Compute the weights of a regridding object.
| regrid_id | regridding object id |
| nitermax | maximum number of passes before failing to locate a position |
| tolpos | tolerance in coordinate space |
| is_periodic | list of 1s and 0s, 0 if not periodic along a dimension, 1 if periodic. |
Definition at line 109 of file nccf_compute_regrid_weights.c.
| int nccf_def_regrid | ( | int | ori_grid_id, |
| int | tgt_grid_id, | ||
| int * | regrid_id | ||
| ) |
Define a regridding object (acts as a constructor).
| ori_grid_id | original grid id. |
| tgt_grid_id | target grid id. |
| regrid_id | (output) grid ID |
Definition at line 15 of file nccf_def_regrid.c.
| int nccf_def_regrid_from_file | ( | const char * | filename, |
| int * | regrid_id | ||
| ) |
Create a regrid object from a file.
/param filename File to read from /param ndims Dimensions of grid /param regrid_id regrid object to write /return NC_NOERR on success
Definition at line 24 of file nccf_def_regrid_from_file.c.
| int nccf_free_regrid | ( | int | regrid_id | ) |
Free regridding object (destructor).
| regrid_id | object Id. |
Definition at line 13 of file nccf_free_regrid.c.
| int nccf_inq_regrid_nnodes | ( | int | regrid_id, |
| int * | nnodes | ||
| ) |
Get the number of nodes per cell.
| regrid_id | object Id |
| nnodes | (output) number of nodes (2^ndims) |
Definition at line 12 of file nccf_inq_regrid_nnodes.c.
| int nccf_inq_regrid_ntargets | ( | int | regrid_id, |
| int * | ntargets | ||
| ) |
Get the number of target points in the domain.
| regrid_id | object Id |
| ntargets | (output) number of target values |
Definition at line 12 of file nccf_inq_regrid_ntargets.c.
| int nccf_inq_regrid_nvalid | ( | int | regrid_id, |
| int * | nvalid | ||
| ) |
Get the number of non-masked values in the domain.
| regrid_id | object Id |
| nvalid | (output) number of non-masked values |
Definition at line 12 of file nccf_inq_regrid_nvalid.c.
| int nccf_put_regrid | ( | int | ncid, |
| int | regrid_id | ||
| ) |
Write regrid weights, indices and domain location to a file.
| ncid | netcdf file id |
| regrid_id | regrid ID created by nccf_def_regrid |
Definition at line 18 of file nccf_put_regrid.c.