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 ...@@ -47,6 +47,7 @@ doc/Doxyfile -text
doc/cdo-poster.pdf -text doc/cdo-poster.pdf -text
doc/cdo.pdf -text doc/cdo.pdf -text
doc/cdoBrochureWeb.pdf -text svneol=unset#unset doc/cdoBrochureWeb.pdf -text svneol=unset#unset
doc/cdo_limits -text
doc/cdo_refcard.pdf -text doc/cdo_refcard.pdf -text
doc/cdo_spectralnudgingdata.pdf -text doc/cdo_spectralnudgingdata.pdf -text
doc/eca_operator.pdf -text doc/eca_operator.pdf -text
......
...@@ -3,6 +3,10 @@ ...@@ -3,6 +3,10 @@
* using CDI library version 1.6.4 * using CDI library version 1.6.4
* Version 1.6.4 released * Version 1.6.4 released
2014-03-14 Uwe Schulzweida
* remapcon: check for missing values in normalisation
2014-03-10 Uwe Schulzweida 2014-03-10 Uwe Schulzweida
* added Option -H to do not append to netCDF "history" global attribute * 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,7 +989,7 @@ void *Remap(void *argument) ...@@ -989,7 +989,7 @@ void *Remap(void *argument)
gridsize2 = gridInqSize(gridID2); gridsize2 = gridInqSize(gridID2);
/* used only to check the result of remapcon */ /* 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; double grid2_err;
...@@ -997,21 +997,27 @@ void *Remap(void *argument) ...@@ -997,21 +997,27 @@ void *Remap(void *argument)
{ {
for ( i = 0; i < gridsize2; i++ ) for ( i = 0; i < gridsize2; i++ )
{ {
grid2_err = remaps[r].tgt_grid.cell_frac[i]*remaps[r].tgt_grid.cell_area[i]; if ( !DBL_IS_EQUAL(array2[i], missval) )
if ( fabs(grid2_err) > 0 ) {
array2[i] = array2[i]/grid2_err; grid2_err = remaps[r].tgt_grid.cell_frac[i]*remaps[r].tgt_grid.cell_area[i];
else if ( fabs(grid2_err) > 0 )
array2[i] = missval; array2[i] = array2[i]/grid2_err;
else
array2[i] = missval;
}
} }
} }
else if ( remaps[r].vars.norm_opt == NORM_OPT_DESTAREA ) else if ( remaps[r].vars.norm_opt == NORM_OPT_DESTAREA )
{ {
for ( i = 0; i < gridsize2; i++ ) for ( i = 0; i < gridsize2; i++ )
{ {
if ( fabs(remaps[r].tgt_grid.cell_frac[i]) > 0 ) if ( !DBL_IS_EQUAL(array2[i], missval) )
array2[i] = array2[i]/remaps[r].tgt_grid.cell_frac[i]; {
else if ( fabs(remaps[r].tgt_grid.cell_frac[i]) > 0 )
array2[i] = missval; array2[i] = array2[i]/remaps[r].tgt_grid.cell_frac[i];
else
array2[i] = missval;
}
} }
} }
......
...@@ -51,6 +51,8 @@ char *strdup(const char *s); ...@@ -51,6 +51,8 @@ char *strdup(const char *s);
*/ */
#endif #endif
#define strcompare(s1, s2) (strncmp(s1, s2, strlen(s2)))
/* sxxxYYYYMMDDhhmm0 */ /* sxxxYYYYMMDDhhmm0 */
#define DATE_LEN 31 /* YYYYMMDDhhmmss allocate DTLEN+1 !!!! */ #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 ...@@ -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)); nce(nc_inq_attlen(nc_file_id, NC_GLOBAL, "normalization", &attlen));
normalize_opt[attlen] = 0; normalize_opt[attlen] = 0;
rv->sort_add = FALSE;
if ( strcmp(normalize_opt, "none") == 0 ) if ( strcmp(normalize_opt, "none") == 0 )
rv->norm_opt = NORM_OPT_NONE; rv->norm_opt = NORM_OPT_NONE;
else if ( strcmp(normalize_opt, "fracarea") == 0 ) 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 ...@@ -498,10 +500,10 @@ void read_remap_scrip(const char *interp_file, int gridID1, int gridID2, int *ma
*submap_type = SUBMAP_TYPE_NONE; *submap_type = SUBMAP_TYPE_NONE;
*remap_order = 1; *remap_order = 1;
if ( memcmp(map_method, "Conservative", 12) == 0 ) if ( strcompare(map_method, "Conservative") == 0 )
{ {
int iatt; 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; rv->map_type = MAP_TYPE_CONSPHERE;
else else
rv->map_type = MAP_TYPE_CONSERV; rv->map_type = MAP_TYPE_CONSERV;
...@@ -509,19 +511,19 @@ void read_remap_scrip(const char *interp_file, int gridID1, int gridID2, int *ma ...@@ -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); status = nc_get_att_int(nc_file_id, NC_GLOBAL, "remap_order", &iatt);
if ( status == NC_NOERR ) *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 ( strcompare(map_method, "Bilinear") == 0 ) rv->map_type = MAP_TYPE_BILINEAR;
else if ( memcmp(map_method, "Bicubic", 7) == 0 ) rv->map_type = MAP_TYPE_BICUBIC; else if ( strcompare(map_method, "Bicubic") == 0 ) rv->map_type = MAP_TYPE_BICUBIC;
else if ( memcmp(map_method, "Distance", 8) == 0 ) else if ( strcompare(map_method, "Distance") == 0 )
{ {
rv->map_type = MAP_TYPE_DISTWGT; rv->map_type = MAP_TYPE_DISTWGT;
*num_neighbors = 4; *num_neighbors = 4;
} }
else if ( memcmp(map_method, "Nearest", 7) == 0 ) else if ( strcompare(map_method, "Nearest") == 0 )
{ {
rv->map_type = MAP_TYPE_DISTWGT; rv->map_type = MAP_TYPE_DISTWGT;
*num_neighbors = 1; *num_neighbors = 1;
} }
else if ( memcmp(map_method, "Largest", 7) == 0 ) else if ( strcompare(map_method, "Largest") == 0 )
{ {
rv->map_type = MAP_TYPE_CONSERV; rv->map_type = MAP_TYPE_CONSERV;
*submap_type = SUBMAP_TYPE_LAF; *submap_type = SUBMAP_TYPE_LAF;
......
...@@ -5813,11 +5813,19 @@ void remap_consphere(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapvars_t * ...@@ -5813,11 +5813,19 @@ void remap_consphere(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapvars_t *
//printf("target: %ld\n", tgt_grid_add); //printf("target: %ld\n", tgt_grid_add);
if ( lyac ) 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); for ( int n = 0; n < tgt_num_cell_corners; ++n )
printf(" TargetCell.coordinates_y[%d] = %g*rad;\n", n, tgt_grid_cell->coordinates_y[n]/DEG2RAD); {
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 */ /* Create search arrays */
...@@ -5913,15 +5921,21 @@ void remap_consphere(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapvars_t * ...@@ -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); 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 ( 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 ) 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_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(" SourceCell[ii].coordinates_y[%ld] = %g*rad;\n", k, src_grid_cells[n].coordinates_y[k]/DEG2RAD);
} }
printf(" ii++;\n"); 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