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

remapcon: check for missing values in normalisation

parent 664fb2ce
......@@ -47,6 +47,7 @@ doc/Doxyfile -text
doc/cdo-poster.pdf -text
doc/cdo.pdf -text
doc/cdoBrochureWeb.pdf -text svneol=unset#unset
doc/cdo_limits -text
doc/cdo_refcard.pdf -text
doc/cdo_spectralnudgingdata.pdf -text
doc/eca_operator.pdf -text
......
......@@ -3,6 +3,10 @@
* using CDI library version 1.6.4
* Version 1.6.4 released
2014-03-14 Uwe Schulzweida
* remapcon: check for missing values in normalisation
2014-03-10 Uwe Schulzweida
* added Option -H to do not append to netCDF "history" global attribute
......
32-bit integer:
date YYYYMMDD -> -214748 < year < 214748
gridsize -> max: 2147483647, 65455x32727
......@@ -989,13 +989,15 @@ void *Remap(void *argument)
gridsize2 = gridInqSize(gridID2);
/* used only to check the result of remapcon */
if ( operfunc == REMAPCON || operfunc == REMAPCON2|| operfunc == REMAPCONS )
if ( operfunc == REMAPCON || operfunc == REMAPCON2 || operfunc == REMAPCONS )
{
double grid2_err;
if ( remaps[r].vars.norm_opt == NORM_OPT_NONE )
{
for ( i = 0; i < gridsize2; i++ )
{
if ( !DBL_IS_EQUAL(array2[i], missval) )
{
grid2_err = remaps[r].tgt_grid.cell_frac[i]*remaps[r].tgt_grid.cell_area[i];
if ( fabs(grid2_err) > 0 )
......@@ -1004,9 +1006,12 @@ void *Remap(void *argument)
array2[i] = missval;
}
}
}
else if ( remaps[r].vars.norm_opt == NORM_OPT_DESTAREA )
{
for ( i = 0; i < gridsize2; i++ )
{
if ( !DBL_IS_EQUAL(array2[i], missval) )
{
if ( fabs(remaps[r].tgt_grid.cell_frac[i]) > 0 )
array2[i] = array2[i]/remaps[r].tgt_grid.cell_frac[i];
......@@ -1014,6 +1019,7 @@ void *Remap(void *argument)
array2[i] = missval;
}
}
}
if ( remap_area_min > 0 )
{
......
......@@ -51,6 +51,8 @@ char *strdup(const char *s);
*/
#endif
#define strcompare(s1, s2) (strncmp(s1, s2, strlen(s2)))
/* sxxxYYYYMMDDhhmm0 */
#define DATE_LEN 31 /* YYYYMMDDhhmmss allocate DTLEN+1 !!!! */
......
......@@ -474,6 +474,8 @@ void read_remap_scrip(const char *interp_file, int gridID1, int gridID2, int *ma
nce(nc_inq_attlen(nc_file_id, NC_GLOBAL, "normalization", &attlen));
normalize_opt[attlen] = 0;
rv->sort_add = FALSE;
if ( strcmp(normalize_opt, "none") == 0 )
rv->norm_opt = NORM_OPT_NONE;
else if ( strcmp(normalize_opt, "fracarea") == 0 )
......@@ -498,10 +500,10 @@ void read_remap_scrip(const char *interp_file, int gridID1, int gridID2, int *ma
*submap_type = SUBMAP_TYPE_NONE;
*remap_order = 1;
if ( memcmp(map_method, "Conservative", 12) == 0 )
if ( strcompare(map_method, "Conservative") == 0 )
{
int iatt;
if ( memcmp(map_method, "Conservative remapping using clipping on sphere", 47) == 0 )
if ( strcompare(map_method, "Conservative remapping using clipping on sphere") == 0 )
rv->map_type = MAP_TYPE_CONSPHERE;
else
rv->map_type = MAP_TYPE_CONSERV;
......@@ -509,19 +511,19 @@ void read_remap_scrip(const char *interp_file, int gridID1, int gridID2, int *ma
status = nc_get_att_int(nc_file_id, NC_GLOBAL, "remap_order", &iatt);
if ( status == NC_NOERR ) *remap_order = iatt;
}
else if ( memcmp(map_method, "Bilinear", 8) == 0 ) rv->map_type = MAP_TYPE_BILINEAR;
else if ( memcmp(map_method, "Bicubic", 7) == 0 ) rv->map_type = MAP_TYPE_BICUBIC;
else if ( memcmp(map_method, "Distance", 8) == 0 )
else if ( strcompare(map_method, "Bilinear") == 0 ) rv->map_type = MAP_TYPE_BILINEAR;
else if ( strcompare(map_method, "Bicubic") == 0 ) rv->map_type = MAP_TYPE_BICUBIC;
else if ( strcompare(map_method, "Distance") == 0 )
{
rv->map_type = MAP_TYPE_DISTWGT;
*num_neighbors = 4;
}
else if ( memcmp(map_method, "Nearest", 7) == 0 )
else if ( strcompare(map_method, "Nearest") == 0 )
{
rv->map_type = MAP_TYPE_DISTWGT;
*num_neighbors = 1;
}
else if ( memcmp(map_method, "Largest", 7) == 0 )
else if ( strcompare(map_method, "Largest") == 0 )
{
rv->map_type = MAP_TYPE_CONSERV;
*submap_type = SUBMAP_TYPE_LAF;
......
......@@ -5813,12 +5813,20 @@ void remap_consphere(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapvars_t *
//printf("target: %ld\n", tgt_grid_add);
if ( lyac )
// if ( tgt_grid_add == 682 )
if ( tgt_grid_add == 174752 )
{
for ( int n = 0; n < tgt_num_cell_corners; ++n )
{
printf(" TargetCell.coordinates_x[%d] = %g*rad;\n", n, tgt_grid_cell->coordinates_x[n]/DEG2RAD);
printf(" TargetCell.coordinates_y[%d] = %g*rad;\n", n, tgt_grid_cell->coordinates_y[n]/DEG2RAD);
}
/*
printf("> -Z1\n");
for ( int n = 0; n < tgt_num_cell_corners; ++n )
printf(" %g %g\n", tgt_grid_cell->coordinates_x[n]/DEG2RAD, tgt_grid_cell->coordinates_y[n]/DEG2RAD);
printf(" %g %g\n", tgt_grid_cell->coordinates_x[0]/DEG2RAD, tgt_grid_cell->coordinates_y[0]/DEG2RAD);
*/
}
/* Create search arrays */
......@@ -5913,15 +5921,21 @@ void remap_consphere(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapvars_t *
LLtoXYZ(src_grid_cells[n].coordinates_x[ic], src_grid_cells[n].coordinates_y[ic], src_grid_cells[n].coordinates_xyz+ic*3);
if ( lyac )
// if ( tgt_grid_add == 682 )
if ( tgt_grid_add == 174752 )
{
printf("n %d\n", (int)n);
// printf("n %d\n", (int)n);
for ( k = 0; k < srch_corners; ++k )
{
printf(" SourceCell[ii].coordinates_x[%ld] = %g*rad;\n", k, src_grid_cells[n].coordinates_x[k]/DEG2RAD);
printf(" SourceCell[ii].coordinates_y[%ld] = %g*rad;\n", k, src_grid_cells[n].coordinates_y[k]/DEG2RAD);
}
printf(" ii++;\n");
/*
printf("> -Z1\n");
for ( k = 0; k < srch_corners; ++k )
printf(" %g %g\n", src_grid_cells[n].coordinates_x[k]/DEG2RAD, src_grid_cells[n].coordinates_y[k]/DEG2RAD);
printf(" %g %g\n", src_grid_cells[n].coordinates_x[0]/DEG2RAD, src_grid_cells[n].coordinates_y[0]/DEG2RAD);
*/
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment