Commit ddf694f7 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Docu update

parent 043bbd05
2009-01-?? Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* using CDI library version 1.3.0
* New operator: remapcon2 - Second order conservative remapping
* New operator: remaplaf - Largest area fraction remapping
* New operator: remapnn - Nearest neighbor remapping
* add support for GRID type Sinusoidal
* add support for GRID type Lambert Azimuthal Equal Area
* import_cmsaf: add support for monthly mean diurnal cycle
* remapcon: add support for second order remapping (use env REMAP_ORDER=2)
* remap: check grid and weights
* remap: set num_srch_bins to nlat/2 (speed up)
* sinfo: extent grid description
......
......@@ -343,15 +343,20 @@ Operator catalog:
-------------------------------------------------------------
Remapgrid remapbil Bilinear interpolation
Remapgrid remapbic Bicubic interpolation
Remapgrid remapcon Conservative remapping
Remapgrid remapdis Distance-weighted average remapping
Remapgrid remapnn Nearest neighbor remapping
Remapgrid remapcon First order conservative remapping
Remapgrid remapcon2 Second order conservative remapping
Remapgrid remaplaf Largest area fraction remapping
Genweights genbil Generate bilinear interpolation weights
Genweights genbic Generate bicubic interpolation weights
Genweights gencon Generate conservative interpolation weights
Genweights gendis Generate distance-weighted average remap weights
Genweights gennn Generate nearest neighbor remap weights
Genweights gencon Generate 1st order conservative remap weights
Genweights gencon2 Generate 2nd order conservative remap weights
Genweights genlaf Generate largest area fraction remap weights
Remap remap SCRIP grid remapping
Intgrid interpolate PINGO grid interpolation
Intgrid intgridbil Bilinear grid interpolation
Remapeta remapeta Remap vertical hybrid level
Vertint ml2pl Model to pressure level interpolation
Vertint ml2hl Model to height level interpolation
......
No preview for this file type
......@@ -5,15 +5,16 @@
@Section = Interpolation
@Class = Interpolation
@Arguments = ifile ofile
@Operators = genbil genbic gencon gendis
@Operators = genbil genbic gendis gennn gencon gencon2 genlaf
@BeginDescription
Grid interpolation can be a very time-consuming process. Especially if the
data are on an unstructured or a large grid. In this case the \htmlref{SCRIP}{SCRIP}
interpolation process can be split into two parts. Firstly the generation of the
interpolation weights, which is the most time-consuming part. These interpolation
weights can be reused for every remapping process with the operator @mod{remap}.
This method should be used only if all input fields are on the same grid and a possibly
Interpolation between different horizontal grids can be a very time-consuming
process. Especially if the data are on an unstructured or a large grid.
In this case the \htmlref{SCRIP}{SCRIP} interpolation process can be split
into two parts. Firstly the generation of the interpolation weights, which is
the most time-consuming part. These interpolation weights can be reused for
every remapping process with the operator @mod{remap}. This method should be
used only if all input fields are on the same grid and a possibly
mask (missing values) does not change. This module contains operators to
generate SCRIP interpolation weights of the first input field.
Each operator is using a different interpolation method.
......@@ -45,25 +46,58 @@ This interpolation method only works on regular quadrilateral grids.
@EndOperator
@BeginOperator_gendis
@Name = gendis
@Title = Generate distance-weighted average remap weights
@Parameter = grid
@BeginDescription
Generates distance-weighted average remapping weights of the four
nearest neighbor values and writes the result to a file.
@EndDescription
@EndOperator
@BeginOperator_gennn
@Name = gennn
@Title = Generate nearest neighbor remap weights
@Parameter = grid
@BeginDescription
Generates nearest neighbor remapping weights and writes the result to a file.
@EndDescription
@EndOperator
@BeginOperator_gencon
@Title = Generate conservative interpolation weights
@Title = Generate 1st order conservative remap weights
@Parameter = grid
@BeginDescription
Generates first order conservative interpolation weights and
Generates first order conservative remapping weights and
writes the result to a file.
@EndDescription
@EndOperator
@BeginOperator_gendis
@Name = gendis
@Title = Generate distance-weighted average remap weights
@BeginOperator_gencon2
@Title = Generate 2nd order conservative remap weights
@Parameter = grid
@BeginDescription
Generates distance-weighted average remapping weights of the four
nearest neighbor values and writes the result to a file.
Generates second order conservative remapping weights and
writes the result to a file.
@EndDescription
@EndOperator
@BeginOperator_genlaf
@Title = Generate largest area fraction remap weights
@Parameter = grid
@BeginDescription
Generates largest area fraction remapping weights and
writes the result to a file.
@EndDescription
@EndOperator
......
......@@ -5,7 +5,7 @@
@Section = Interpolation
@Class = Interpolation
@Arguments = ifile ofile
@Operators = interpolate intgridbil
@Operators = interpolate
@BeginDescription
......
......@@ -13,8 +13,8 @@
@Parameter = grid weights
@BeginDescription
This operator remaps all input fields to a new grid. The remap type and the
interpolation weights of one input grid are read from a netCDF file. The netCDF
This operator remaps all input fields to a new horizontal grid. The remap type and
the interpolation weights of one input grid are read from a netCDF file. The netCDF
file with the weights should follow the \htmlref{SCRIP}{SCRIP} convention. Normally these weights
come from a previous call to module @mod{GENWEIGHTS} or were created by the original
SCRIP package.
......@@ -38,7 +38,7 @@ not to SCRIP!
@BeginExample
Say @file{ifile} contains fields on a regular grid.
Say @file{ifile} contains fields on a regular quadrilateral grid.
To remap all fields bilinear to a T42 Gaussian grid use:
@BeginVerbatim
cdo genbil,t42grid ifile remapweights.nc
......
......@@ -5,12 +5,12 @@
@Section = Interpolation
@Class = Interpolation
@Arguments = ifile ofile
@Operators = remapbil remapbic remapcon remapdis
@Operators = remapbil remapbic remapdis remapnn remapcon remapcon2 remaplaf
@BeginDescription
This module contains operators to interpolate all input fields to a new grid.
This module contains operators to remap all input fields to a new horizontal grid.
Each operator uses a different remapping method. The interpolation is based
on a special SCRIP library version. For a detailed description of the remapping
on an adapted SCRIP library version. For a detailed description of the remapping
methods see @cite{SCRIP}.
@EndDescription
@EndModule
......@@ -40,9 +40,32 @@ This interpolation method only works on regular quadrilateral grids.
@EndOperator
@BeginOperator_remapdis
@Name = remapdis
@Title = Distance-weighted average remapping
@Parameter = grid
@BeginDescription
Performs a distance-weighted average remapping of the four nearest neighbor
values on all input fields.
@EndDescription
@EndOperator
@BeginOperator_remapnn
@Name = remapnn
@Title = Nearest neighbor remapping
@Parameter = grid
@BeginDescription
Performs a nearest neighbor remapping on all input fields.
@EndDescription
@EndOperator
@BeginOperator_remapcon
@Name = remapcon
@Title = Conservative remapping
@Title = First order conservative remapping
@Parameter = grid
@BeginDescription
......@@ -51,14 +74,24 @@ Performs a first order conservative remapping on all input fields.
@EndOperator
@BeginOperator_remapdis
@Name = remapdis
@Title = Distance-weighted average remapping
@BeginOperator_remapcon2
@Name = remapcon2
@Title = Second order conservative remapping
@Parameter = grid
@BeginDescription
Performs a distance-weighted average remapping of the four nearest neighbor
values on all input fields.
Performs a second order conservative remapping on all input fields.
@EndDescription
@EndOperator
@BeginOperator_remaplaf
@Name = remaplaf
@Title = Largest area fraction remapping
@Parameter = grid
@BeginDescription
Performs a largest area fraction remapping on all input fields.
@EndDescription
@EndOperator
......
......@@ -18,14 +18,22 @@
/*
This module contains the following operators:
Interpolate remapcon Conservative remapping
Interpolate remapcon First order conservative remapping
Interpolate remapcon2 Second order onservative remapping
Interpolate remaplaf Largest area fraction
Interpolate remapbil Bilinear interpolation
Interpolate remapbic Bicubic interpolation
Interpolate remapdis Distance-weighted averaging
Genweights gencon Generate conservative interpolation weights
Interpolate remapnn Nearest neighbor remapping
Interpolate remaplaf Largest area fraction remapping
Genweights gencon Generate first order conservative remap weights
Genweights gencon2 Generate second order conservative remap weights
Genweights genlaf Generate largest area fraction weights
Genweights genbil Generate bilinear interpolation weights
Genweights genbic Generate bicubic interpolation weights
Genweights gendis Generate distance-weighted averaging weights
Genweights gennn Generate nearest neighbor weights
Genweights genlaf Generate largest ares fraction weights
Remap remap SCRIP grid remapping
*/
......@@ -44,8 +52,8 @@
void *Remap(void *argument)
{
static char func[] = "Remap";
enum {REMAPCON, REMAPBIL, REMAPBIC, REMAPDIS, REMAPDIS1, REMAPCON1,
GENCON, GENBIL, GENBIC, GENDIS, REMAPXXX};
enum {REMAPCON, REMAPCON2, REMAPBIL, REMAPBIC, REMAPDIS, REMAPNN, REMAPLAF,
GENCON, GENCON2, GENBIL, GENBIC, GENDIS, GENNN, GENLAF, REMAPXXX};
int operatorID;
int operfunc;
int streamID1, streamID2 = -1;
......@@ -63,6 +71,7 @@ void *Remap(void *argument)
int nremaps = 0;
int norm_opt = NORM_OPT_NONE;
int map_type = -1;
int submap_type = SUBMAP_TYPE_NONE;
int max_remaps = 0;
int remap_test = 0;
int remap_order = 1;
......@@ -87,15 +96,19 @@ void *Remap(void *argument)
cdoInitialize(argument);
cdoOperatorAdd("remapcon", REMAPCON, 0, NULL);
cdoOperatorAdd("remapcon2", REMAPCON2, 0, NULL);
cdoOperatorAdd("remapbil", REMAPBIL, 0, NULL);
cdoOperatorAdd("remapbic", REMAPBIC, 0, NULL);
cdoOperatorAdd("remapdis", REMAPDIS, 0, NULL);
cdoOperatorAdd("remapdis1", REMAPDIS1, 0, NULL);
cdoOperatorAdd("remapcon1", REMAPCON1, 0, NULL);
cdoOperatorAdd("remapnn", REMAPNN, 0, NULL);
cdoOperatorAdd("remaplaf", REMAPLAF, 0, NULL);
cdoOperatorAdd("gencon", GENCON, 1, NULL);
cdoOperatorAdd("gencon2", GENCON2, 1, NULL);
cdoOperatorAdd("genbil", GENBIL, 1, NULL);
cdoOperatorAdd("genbic", GENBIC, 1, NULL);
cdoOperatorAdd("gendis", GENDIS, 1, NULL);
cdoOperatorAdd("gennn", GENNN, 1, NULL);
cdoOperatorAdd("genlaf", GENLAF, 1, NULL);
cdoOperatorAdd("remap", REMAPXXX, 0, NULL);
operatorID = cdoOperatorID();
......@@ -128,7 +141,7 @@ void *Remap(void *argument)
cdoPrint("Set REMAP_MAX_ITER to %d", remap_max_iter);
}
}
/*
envstr = getenv("REMAP_ORDER");
if ( envstr )
{
......@@ -144,7 +157,7 @@ void *Remap(void *argument)
cdoPrint("Set REMAP_ORDER to %d", remap_order);
}
}
*/
envstr = getenv("REMAP_TEST");
if ( envstr )
{
......@@ -281,7 +294,8 @@ void *Remap(void *argument)
{
int gridsize2;
read_remap_scrip(remap_file, gridID1, gridID2, &map_type, &remaps[0].grid, &remaps[0].vars);
read_remap_scrip(remap_file, gridID1, gridID2, &map_type, &submap_type,
&remap_order, &remaps[0].grid, &remaps[0].vars);
nremaps = 1;
gridsize = remaps[0].grid.grid1_size;
remaps[0].gridID = gridID1;
......@@ -334,8 +348,24 @@ void *Remap(void *argument)
if ( map_type == MAP_TYPE_CONSERV )
{
operfunc = REMAPCON;
cdoPrint("Using remapcon");
if ( submap_type == SUBMAP_TYPE_LAF )
{
operfunc = REMAPLAF;
cdoPrint("Using remaplaf");
}
else
{
if ( remap_order == 2 )
{
operfunc = REMAPCON2;
cdoPrint("Using remapcon2");
}
else
{
operfunc = REMAPCON;
cdoPrint("Using remapcon");
}
}
}
else if ( map_type == MAP_TYPE_BILINEAR )
{
......@@ -352,13 +382,55 @@ void *Remap(void *argument)
operfunc = REMAPDIS;
cdoPrint("Using remapdis");
}
else if ( map_type == MAP_TYPE_DISTWGT1 )
{
operfunc = REMAPNN;
cdoPrint("Using remapnn");
}
else
cdoAbort("unsupported mapping method (map_type = %d)", map_type);
cdoAbort("Unsupported mapping method (map_type = %d)", map_type);
if ( remap_test ) reorder_links(&remaps[0].vars);
}
if ( operfunc == REMAPCON || operfunc == REMAPCON1 || operfunc == GENCON )
switch ( operfunc )
{
case REMAPCON:
case GENCON:
map_type = MAP_TYPE_CONSERV;
remap_order = 1;
break;
case REMAPCON2:
case GENCON2:
map_type = MAP_TYPE_CONSERV;
remap_order = 2;
break;
case REMAPLAF:
case GENLAF:
map_type = MAP_TYPE_CONSERV;
submap_type = SUBMAP_TYPE_LAF;
break;
case REMAPBIL:
case GENBIL:
map_type = MAP_TYPE_BILINEAR;
break;
case REMAPBIC:
case GENBIC:
map_type = MAP_TYPE_BICUBIC;
break;
case REMAPDIS:
case GENDIS:
map_type = MAP_TYPE_DISTWGT;
break;
case REMAPNN:
case GENNN:
map_type = MAP_TYPE_DISTWGT1;
break;
default:
cdoAbort("Unknown mapping method");
}
if ( map_type == MAP_TYPE_CONSERV )
{
norm_opt = NORM_OPT_FRACAREA;
......@@ -387,38 +459,12 @@ void *Remap(void *argument)
}
}
switch ( operfunc )
{
case REMAPCON:
case REMAPCON1:
case GENCON:
map_type = MAP_TYPE_CONSERV;
break;
case REMAPBIL:
case GENBIL:
map_type = MAP_TYPE_BILINEAR;
break;
case REMAPBIC:
case GENBIC:
map_type = MAP_TYPE_BICUBIC;
break;
case REMAPDIS:
case GENDIS:
map_type = MAP_TYPE_DISTWGT;
break;
case REMAPDIS1:
map_type = MAP_TYPE_DISTWGT1;
break;
default:
cdoAbort("unknown mapping method");
}
grid1sizemax = vlistGridsizeMax(vlistID1);
if ( map_type == MAP_TYPE_BICUBIC ) need_gradiants = TRUE;
if ( map_type == MAP_TYPE_CONSERV && remap_order == 2 )
{
cdoPrint("Second order remapping");
if ( cdoVerbose ) cdoPrint("Second order remapping");
need_gradiants = TRUE;
}
else
......@@ -654,8 +700,8 @@ void *Remap(void *argument)
remap_gradients(remaps[r].grid, array1, grad1_lat, grad1_lon, grad1_latlon);
}
if ( operfunc == REMAPCON1 )
remap_con1(array2, missval, gridInqSize(gridID2), remaps[r].vars.num_links, remaps[r].vars.wts,
if ( operfunc == REMAPLAF )
remap_laf(array2, missval, gridInqSize(gridID2), remaps[r].vars.num_links, remaps[r].vars.wts,
remaps[r].vars.grid2_add, remaps[r].vars.grid1_add, array1);
else
remap(array2, missval, gridInqSize(gridID2), remaps[r].vars.num_links, remaps[r].vars.wts,
......@@ -664,7 +710,7 @@ void *Remap(void *argument)
gridsize2 = gridInqSize(gridID2);
if ( operfunc == REMAPCON )
if ( operfunc == REMAPCON || operfunc == REMAPCON2 )
{
double grid2_err;
......@@ -692,7 +738,7 @@ void *Remap(void *argument)
}
vlistInqVarName(vlistID1, varID, varname);
if ( operfunc == REMAPCON )
if ( operfunc == REMAPCON || operfunc == REMAPCON2 )
if ( strcmp(varname, "gridbox_area") == 0 )
{
double array1sum = 0;
......@@ -746,7 +792,7 @@ void *Remap(void *argument)
WRITE_REMAP:
if ( lwrite_remap )
write_remap_scrip(cdoStreamName(1), map_type, remaps[r].grid, remaps[r].vars);
write_remap_scrip(cdoStreamName(1), map_type, submap_type, remap_order, remaps[r].grid, remaps[r].vars);
streamClose(streamID1);
......
......@@ -137,6 +137,8 @@ void fill_gridvals(int xsize, int ysize, double *xvals, double *yvals)
break;
}
}
/* printf("xmin %g, xmax %g, ymin %g, ymax %g\n", xmin, xmax, ymin, ymax); */
for ( i = 0; i < xsize*ysize; ++i )
{
......@@ -282,6 +284,10 @@ int gridFromH5file(const char *gridfile)
if ( lon_id >= 0 && lat_id >= 0 )
{
hid_t type_id;
hid_t native_type;
int ftype = 0;
dataspace = H5Dget_space(lon_id); /* dataspace handle */
rank = H5Sget_simple_extent_ndims(dataspace);
status = H5Sget_simple_extent_dims(dataspace, dims_out, NULL);
......@@ -296,6 +302,24 @@ int gridFromH5file(const char *gridfile)
(unsigned long)(dims_out[1]), (unsigned long)(dims_out[0]));
*/
type_id = H5Dget_type(lon_id); /* get datatype*/
native_type = H5Tget_native_type(type_id, H5T_DIR_ASCEND);
if ( H5Tequal(native_type, H5T_NATIVE_SCHAR) > 0 ) {ftype=0;}
else if ( H5Tequal(native_type, H5T_NATIVE_UCHAR) > 0 ) {ftype=0;}
else if ( H5Tequal(native_type, H5T_NATIVE_SHORT) > 0 ) {ftype=0;}
else if ( H5Tequal(native_type, H5T_NATIVE_USHORT) > 0 ) {ftype=0;}
else if ( H5Tequal(native_type, H5T_NATIVE_INT) > 0 ) {ftype=0;}
else if ( H5Tequal(native_type, H5T_NATIVE_UINT) > 0 ) {ftype=0;}
else if ( H5Tequal(native_type, H5T_NATIVE_FLOAT) > 0 ) {ftype=1;}
else if ( H5Tequal(native_type, H5T_NATIVE_DOUBLE) > 0 ) {ftype=1;}
else
{
cdoWarning("Grid has unsupported native datatype!");
goto RETURN;
}
H5Tclose(native_type);
grid.xsize = (int)dims_out[1];
grid.ysize = (int)dims_out[0];
grid.size = grid.xsize*grid.ysize;
......@@ -303,8 +327,21 @@ int gridFromH5file(const char *gridfile)
grid.xvals = (double *) malloc(grid.size*sizeof(double));
grid.yvals = (double *) malloc(grid.size*sizeof(double));
status = H5Dread(lon_id, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, grid.xvals);
status = H5Dread(lat_id, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, grid.yvals);
if ( ftype )
{
status = H5Dread(lon_id, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, grid.xvals);
status = H5Dread(lat_id, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, grid.yvals);
}
else
{
int *iarray, i;
iarray = (int *) malloc(grid.size*sizeof(int));
status = H5Dread(lon_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, iarray);
for ( i = 0; i < grid.size; ++i ) grid.xvals[i] = iarray[i];
status = H5Dread(lat_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, iarray);
for ( i = 0; i < grid.size; ++i ) grid.yvals[i] = iarray[i];
free(iarray);
}
status = H5Sclose(dataspace);
......
......@@ -306,8 +306,8 @@ void *Wct(void *argument);
#define PinfoOperators {"pinfo", "pinfov"}
#define RegresOperators {"regres"}
#define RemapOperators {"remap"}
#define RemapgridOperators {"remapcon", "remapbil", "remapbic", "remapdis", "remapdis1", "remapcon1"}
#define GenweightsOperators {"gencon", "genbil", "genbic", "gendis"}
#define RemapgridOperators {"remapcon", "remapbil", "remapbic", "remapdis", "remapnn", "remaplaf", "remapcon2"}
#define GenweightsOperators {"gencon", "genbil", "genbic", "gendis", "gennn", "genlaf", "gencon2"}
#define RemapetaOperators {"remapeta"}
#define ReplaceOperators {"replace"}
#define RotuvOperators {"rotuvb"}
......@@ -707,6 +707,8 @@ static char *opalias[][2] =
{"delvar", "delname" },
{"vardup", "pardup" },
{"varmul", "parmul" },
{"remapcon1", "remaplaf" },
{"remapdis1", "remapnn" },
{"showvar", "showname" },
{"selvar", "selname" },
{"setvar", "setname" },
......
......@@ -2524,29 +2524,36 @@ static char *SubtrendHelp[] = {
static char *RemapgridHelp[] = {
"NAME",
" remapbil, remapbic, remapcon, remapdis - SCRIP grid interpolation",
" remapbil, remapbic, remapdis, remapnn, remapcon, remapcon2, remaplaf - ",
" SCRIP grid interpolation",
"",
"SYNOPSIS",
" <operator>,grid ifile ofile",
"",
"DESCRIPTION",
" This module contains operators to interpolate all input fields to a new grid.",
" This module contains operators to remap all input fields to a new horizontal grid.",
" Each operator uses a different remapping method. The interpolation is based",
" on a special SCRIP library version. For a detailed description of the remapping ",
" on an adapted SCRIP library version. For a detailed description of the remapping ",
" methods see SCRIP.",
"",
"OPERATORS",
" remapbil Bilinear interpolation",
" Performs a bilinear interpolation on all input fields.",
" This interpolation method only works on regular quadrilateral grids.",
" remapbic Bicubic interpolation",
" Performs a bicubic interpolation on all input fields.",
" This interpolation method only works on regular quadrilateral grids.",
" remapcon Conservative remapping",
" Performs a first order conservative remapping on all input fields.",
" remapdis Distance-weighted average remapping",
" Performs a distance-weighted average remapping of the four nearest neighbor ",
" values on all input fields.",
" remapbil Bilinear interpolation",
" Performs a bilinear interpolation on all input fields.",
" This interpolation method only works on regular quadrilateral grids.",
" remapbic Bicubic interpolation",
" Performs a bicubic interpolation on all input fields.",
" This interpolation method only works on regular quadrilateral grids.",
" remapdis Distance-weighted average remapping",
" Performs a distance-weighted average remapping of the four nearest neighbor ",
" values on all input fields.",
" remapnn Nearest neighbor remapping",
" Performs a nearest neighbor remapping on all input fields.",
" remapcon First order conservative remapping",
" Performs a first order conservative remapping on all input fields.",
" remapcon2 Second order conservative remapping",
" Performs a second order conservative remapping on all input fields.",
" remaplaf Largest area fraction remapping",
" Performs a largest area fraction remapping on all input fields.",
"",
"PARAMETER",
" grid STRING Target grid description file or name",
......@@ -2562,35 +2569,45 @@ static char *RemapgridHelp[] = {
static char *GenweightsHelp[] = {
"NAME",
" genbil, genbic, gencon, gendis - Generate SCRIP grid interpolation weights",
" genbil, genbic, gendis, gennn, gencon, gencon2, genlaf - ",
" Generate SCRIP grid interpolation weights",
"",
"SYNOPSIS",
" <operator>,grid ifile ofile",
"",
"DESCRIPTION",