Functions

Structured data regridding

GRIDSPEC

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.

Detailed Description

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.


Function Documentation

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.

Parameters:
regrid_idobject id
loinclusive lower set of indices delimiting the box
hiinclusive upper set of indices delimiting the box
Returns:
NC_NOERR on success
Note:
The order of indices in lo and hi follows C convention.
Author:
Alexander Pletzer, Tech-X Corp.
Id:
nccf_add_regrid_forbidden.c 513 2011-02-14 22:48:17Z dkindig

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.

Parameters:
regrid_idobject Id
ori_data_iddata object on original grid
tgt_data_iddata object on target grid
Returns:
NC_NOERR on success
See also:
nccf_compute_regrid_weights
Author:
Alexander Pletzer, Tech-X Corp.
Id:
nccf_apply_regrid.c 513 2011-02-14 22:48:17Z dkindig

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.

Parameters:
regrid_idregridding object id
nitermaxmaximum number of passes before failing to locate a position
tolpostolerance in coordinate space
is_periodiclist of 1s and 0s, 0 if not periodic along a dimension, 1 if periodic.
Returns:
NC_NOERR on success
Note:
Grid coordinates are said to be periodic if and only if the coordinates on one edge match the coordinates on the opposite edge. A longitude-latitude grid is not periodic because the longitude values do not match on either side.
Returns:
NC_NOERR on success
Author:
Alexander Pletzer and David Kindig, Tech-X Corp.

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).

Parameters:
ori_grid_idoriginal grid id.
tgt_grid_idtarget grid id.
regrid_id(output) grid ID
Returns:
NC_NOERR on success
Author:
Alexander Pletzer and David Kindig, Tech-X Corp.

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

Author:
Alexander Pletzer, Dave Kindig, Tech-X Corp.

Definition at line 24 of file nccf_def_regrid_from_file.c.

int nccf_free_regrid ( int  regrid_id)

Free regridding object (destructor).

Parameters:
regrid_idobject Id.
Returns:
NC_NOERR on success
Author:
Alexander Pletzer, Tech-X Corp.
Id:
nccf_free_regrid.c 513 2011-02-14 22:48:17Z dkindig

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.

Parameters:
regrid_idobject Id
nnodes(output) number of nodes (2^ndims)
Returns:
NC_NOERR on success
Author:
Alexander Pletzer, Tech-X Corp.
Id:
nccf_inq_regrid_nnodes.c 513 2011-02-14 22:48:17Z dkindig

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.

Parameters:
regrid_idobject Id
ntargets(output) number of target values
Returns:
NC_NOERR on success
Author:
Alexander Pletzer, Tech-X Corp.
Id:
nccf_inq_regrid_ntargets.c 513 2011-02-14 22:48:17Z dkindig

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.

Parameters:
regrid_idobject Id
nvalid(output) number of non-masked values
Returns:
NC_NOERR on success
Author:
Alexander Pletzer, Tech-X Corp.
Id:
nccf_inq_regrid_nvalid.c 513 2011-02-14 22:48:17Z dkindig

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.

Parameters:
ncidnetcdf file id
regrid_idregrid ID created by nccf_def_regrid
Returns:
NC_NOERR on success
Author:
Alexander Pletzer, Dave Kindig, Tech-X Corp.

Definition at line 18 of file nccf_put_regrid.c.

 All Classes Files Functions Defines

Generated on Tue Mar 1 2011 06:36:59 for libCF. LibCF is a Unidata library.