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

remapconclip update

parent d36b05a1
......@@ -44,7 +44,7 @@
enum {REMAPCON, REMAPCON2, REMAPBIL, REMAPBIC, REMAPDIS, REMAPNN, REMAPLAF, REMAPSUM,
GENCON, GENCON2, GENBIL, GENBIC, GENDIS, GENNN, GENLAF, REMAPXXX, REMAPCONTEST, GENCONTEST};
GENCON, GENCON2, GENBIL, GENBIC, GENDIS, GENNN, GENLAF, REMAPXXX, REMAPCONCLIP, GENCONCLIP};
enum {HEAP_SORT, MERGE_SORT};
......@@ -53,9 +53,9 @@ void get_map_type(int operfunc, int *map_type, int *submap_type, int *num_neighb
{
switch ( operfunc )
{
case REMAPCONTEST:
case GENCONTEST:
*map_type = MAP_TYPE_CONTEST;
case REMAPCONCLIP:
case GENCONCLIP:
*map_type = MAP_TYPE_CONCLIP;
*remap_order = 1;
break;
case REMAPCON:
......@@ -127,9 +127,9 @@ int maptype2operfunc(int map_type, int submap_type, int num_neighbors, int remap
}
}
}
else if ( map_type == MAP_TYPE_CONTEST )
else if ( map_type == MAP_TYPE_CONCLIP )
{
operfunc = REMAPCONTEST;
operfunc = REMAPCONCLIP;
cdoPrint("Using remaptest");
}
else if ( map_type == MAP_TYPE_BILINEAR )
......@@ -450,8 +450,8 @@ void *Remap(void *argument)
cdoOperatorAdd("gennn", GENNN, 1, NULL);
cdoOperatorAdd("genlaf", GENLAF, 1, NULL);
cdoOperatorAdd("remap", REMAPXXX, 0, NULL);
cdoOperatorAdd("remapcontest", REMAPCONTEST, 0, NULL);
cdoOperatorAdd("gencontest", GENCONTEST, 1, NULL);
cdoOperatorAdd("remapconclip", REMAPCONCLIP, 0, NULL);
cdoOperatorAdd("genconclip", GENCONCLIP, 1, NULL);
operatorID = cdoOperatorID();
operfunc = cdoOperatorF1(operatorID);
......@@ -626,7 +626,7 @@ void *Remap(void *argument)
get_map_type(operfunc, &map_type, &submap_type, &num_neighbors, &remap_order);
if ( map_type == MAP_TYPE_CONSERV ||map_type == MAP_TYPE_CONTEST )
if ( map_type == MAP_TYPE_CONSERV ||map_type == MAP_TYPE_CONCLIP )
{
norm_opt = NORM_OPT_FRACAREA;
......@@ -712,7 +712,7 @@ void *Remap(void *argument)
}
}
if ( map_type != MAP_TYPE_CONSERV && map_type != MAP_TYPE_CONTEST &&
if ( map_type != MAP_TYPE_CONSERV && map_type != MAP_TYPE_CONCLIP &&
gridInqType(gridID1) == GRID_GME && gridInqType(gridID2) == GRID_GME )
cdoAbort("Only conservative remapping is available to remap between GME grids!");
/*
......@@ -863,7 +863,7 @@ void *Remap(void *argument)
memcpy(remaps[r].src_grid.mask, imask, remaps[r].src_grid.size*sizeof(int));
if ( map_type == MAP_TYPE_CONSERV || map_type == MAP_TYPE_CONTEST )
if ( map_type == MAP_TYPE_CONSERV || map_type == MAP_TYPE_CONCLIP )
{
memset(remaps[r].src_grid.cell_area, 0, remaps[r].src_grid.size*sizeof(double));
memset(remaps[r].src_grid.cell_frac, 0, remaps[r].src_grid.size*sizeof(double));
......@@ -880,7 +880,7 @@ void *Remap(void *argument)
else if ( map_type == MAP_TYPE_BILINEAR ) remap_bilin(&remaps[r].src_grid, &remaps[r].tgt_grid, &remaps[r].vars);
else if ( map_type == MAP_TYPE_BICUBIC ) remap_bicub(&remaps[r].src_grid, &remaps[r].tgt_grid, &remaps[r].vars);
else if ( map_type == MAP_TYPE_DISTWGT ) remap_distwgt(num_neighbors, &remaps[r].src_grid, &remaps[r].tgt_grid, &remaps[r].vars);
else if ( map_type == MAP_TYPE_CONTEST ) remap_contest(&remaps[r].src_grid, &remaps[r].tgt_grid, &remaps[r].vars);
else if ( map_type == MAP_TYPE_CONCLIP ) remap_conclip(&remaps[r].src_grid, &remaps[r].tgt_grid, &remaps[r].vars);
if ( remaps[r].vars.num_links != remaps[r].vars.max_links )
resize_remap_vars(&remaps[r].vars, remaps[r].vars.num_links-remaps[r].vars.max_links);
......@@ -941,7 +941,7 @@ void *Remap(void *argument)
gridsize2 = gridInqSize(gridID2);
/* used only to check the result of remapcon */
if ( operfunc == REMAPCON || operfunc == REMAPCON2|| operfunc == REMAPCONTEST )
if ( operfunc == REMAPCON || operfunc == REMAPCON2|| operfunc == REMAPCONCLIP )
{
double grid2_err;
......@@ -996,7 +996,7 @@ void *Remap(void *argument)
}
vlistInqVarName(vlistID1, varID, varname);
if ( operfunc == REMAPCON || operfunc == REMAPCON2 || operfunc == REMAPCONTEST )
if ( operfunc == REMAPCON || operfunc == REMAPCON2 || operfunc == REMAPCONCLIP )
if ( strcmp(varname, "gridbox_area") == 0 )
{
scale_gridbox_area(gridsize, array1, gridsize2, array2, remaps[r].tgt_grid.cell_area);
......
......@@ -369,8 +369,8 @@ void *Maggraph(void *argument);
#define PressureOperators {"pressure_fl", "pressure_hl", "deltap"}
#define RegresOperators {"regres"}
#define RemapOperators {"remap"}
#define RemapgridOperators {"remapcontest", "remapcon", "remapbil", "remapbic", "remapdis", "remapnn", "remaplaf", "remapcon2", "remapsum"}
#define GenweightsOperators {"gencontest", "gencon", "genbil", "genbic", "gendis", "gennn", "genlaf", "gencon2"}
#define RemapgridOperators {"remapconclip", "remapcon", "remapbil", "remapbic", "remapdis", "remapnn", "remaplaf", "remapcon2", "remapsum"}
#define GenweightsOperators {"genconclip", "gencon", "genbil", "genbic", "gendis", "gennn", "genlaf", "gencon2"}
#define RemapetaOperators {"remapeta", "remapeta_s", "remapeta_z"}
#define ReplaceOperators {"replace"}
#define ReplacevaluesOperators {"setvals", "setrtoc", "setrtoc2"}
......
......@@ -37,7 +37,7 @@ typedef RESTR_TYPE restr_t;
#define MAP_TYPE_BILINEAR 2
#define MAP_TYPE_BICUBIC 3
#define MAP_TYPE_DISTWGT 4
#define MAP_TYPE_CONTEST 5
#define MAP_TYPE_CONCLIP 5
#define SUBMAP_TYPE_NONE 0
#define SUBMAP_TYPE_LAF 1
......@@ -154,7 +154,7 @@ void remap_sum(double *restrict dst_array, double missval, long dst_size, long n
void remap_bilin(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapvars_t *rv);
void remap_bicub(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapvars_t *rv);
void remap_conserv(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapvars_t *rv);
void remap_contest(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapvars_t *rv);
void remap_conclip(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapvars_t *rv);
void remap_distwgt(int num_neighbors, remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapvars_t *rv);
void resize_remap_vars(remapvars_t *rv, int increment);
......
......@@ -363,7 +363,7 @@ void remapGridRealloc(int map_type, remapgrid_t *grid, int remap_grid_basis)
grid->cell_center_lon = (double *) realloc(grid->cell_center_lon, grid->size*sizeof(double));
grid->cell_center_lat = (double *) realloc(grid->cell_center_lat, grid->size*sizeof(double));
if ( map_type == MAP_TYPE_CONSERV || map_type == MAP_TYPE_CONTEST )
if ( map_type == MAP_TYPE_CONSERV || map_type == MAP_TYPE_CONCLIP )
{
grid->cell_area = (double *) realloc(grid->cell_area, grid->size*sizeof(double));
memset(grid->cell_area, 0, grid->size*sizeof(double));
......@@ -773,7 +773,7 @@ void calc_lat_bins(remapgrid_t *src_grid, remapgrid_t *tgt_grid, int map_type)
calc_bin_addr(src_grid->size, nbins, bin_lats, src_grid->cell_bound_box, src_grid->bin_addr);
if ( map_type == MAP_TYPE_CONSERV || map_type == MAP_TYPE_CONTEST )
if ( map_type == MAP_TYPE_CONSERV || map_type == MAP_TYPE_CONCLIP )
{
tgt_grid->bin_addr = (int *) realloc(tgt_grid->bin_addr, 2*nbins*sizeof(int));
......@@ -830,8 +830,8 @@ void remap_reg2d_init(int gridID, remapgrid_t *grid)
gridGenBounds1(nx, grid->reg2d_center_lon, grid->reg2d_corner_lon);
gridGenBounds1(ny, grid->reg2d_center_lat, grid->reg2d_corner_lat);
for ( long i = 0; i < nxp1; ++i ) printf("lon %ld %g\n", i, grid->reg2d_corner_lon[i]);
for ( long i = 0; i < nyp1; ++i ) printf("lat %ld %g\n", i, grid->reg2d_corner_lat[i]);
//for ( long i = 0; i < nxp1; ++i ) printf("lon %ld %g\n", i, grid->reg2d_corner_lon[i]);
//for ( long i = 0; i < nyp1; ++i ) printf("lat %ld %g\n", i, grid->reg2d_corner_lat[i]);
}
......@@ -1009,7 +1009,7 @@ void remap_grids_init(int map_type, int lextrapolate, int gridID1, remapgrid_t *
src_grid->remap_grid_type = -1;
tgt_grid->remap_grid_type = -1;
if ( (map_type == MAP_TYPE_BILINEAR || map_type == MAP_TYPE_BICUBIC || map_type == MAP_TYPE_DISTWGT || map_type == MAP_TYPE_CONTEST ) &&
if ( (map_type == MAP_TYPE_BILINEAR || map_type == MAP_TYPE_BICUBIC || map_type == MAP_TYPE_DISTWGT || map_type == MAP_TYPE_CONCLIP ) &&
!gridIsRotated(gridID1) &&
(gridInqType(gridID1) == GRID_LONLAT || gridInqType(gridID1) == GRID_GAUSSIAN) )
src_grid->remap_grid_type = REMAP_GRID_TYPE_REG2D;
......@@ -1023,7 +1023,7 @@ void remap_grids_init(int map_type, int lextrapolate, int gridID1, remapgrid_t *
else
src_grid->lextrapolate = FALSE;
if ( map_type == MAP_TYPE_CONSERV || map_type == MAP_TYPE_CONTEST )
if ( map_type == MAP_TYPE_CONSERV || map_type == MAP_TYPE_CONCLIP )
{
src_grid->luse_cell_corners = TRUE;
src_grid->lneed_cell_corners = TRUE;
......@@ -1151,7 +1151,7 @@ void remap_vars_init(int map_type, long src_grid_size, long tgt_grid_size, remap
if ( ompNumThreads > 1 )
{
if ( map_type == MAP_TYPE_CONSERV ) rv->sort_add = TRUE;
else if ( map_type == MAP_TYPE_CONTEST ) rv->sort_add = TRUE;
else if ( map_type == MAP_TYPE_CONCLIP ) rv->sort_add = TRUE;
else if ( map_type == MAP_TYPE_BILINEAR ) rv->sort_add = TRUE;
else if ( map_type == MAP_TYPE_BICUBIC ) rv->sort_add = TRUE;
else if ( map_type == MAP_TYPE_DISTWGT ) rv->sort_add = TRUE;
......@@ -1161,7 +1161,7 @@ void remap_vars_init(int map_type, long src_grid_size, long tgt_grid_size, remap
#endif
{
if ( map_type == MAP_TYPE_CONSERV ) rv->sort_add = TRUE;
else if ( map_type == MAP_TYPE_CONTEST ) rv->sort_add = TRUE;
else if ( map_type == MAP_TYPE_CONCLIP ) rv->sort_add = TRUE;
else if ( map_type == MAP_TYPE_BILINEAR ) rv->sort_add = FALSE;
else if ( map_type == MAP_TYPE_BICUBIC ) rv->sort_add = FALSE;
else if ( map_type == MAP_TYPE_DISTWGT ) rv->sort_add = TRUE;
......@@ -1169,7 +1169,7 @@ void remap_vars_init(int map_type, long src_grid_size, long tgt_grid_size, remap
}
if ( map_type == MAP_TYPE_CONSERV ) rv->num_wts = 3;
else if ( map_type == MAP_TYPE_CONTEST ) rv->num_wts = 3;
else if ( map_type == MAP_TYPE_CONCLIP ) rv->num_wts = 3;
else if ( map_type == MAP_TYPE_BILINEAR ) rv->num_wts = 1;
else if ( map_type == MAP_TYPE_BICUBIC ) rv->num_wts = 4;
else if ( map_type == MAP_TYPE_DISTWGT ) rv->num_wts = 1;
......@@ -4333,7 +4333,7 @@ long get_srch_cells_reg2d(const int *restrict src_grid_dims,
bound_lon1 = tgt_cell_bound_box[2];
bound_lon2 = tgt_cell_bound_box[3];
if ( bound_lon1 <= src_lon_min && bound_lon2 > src_lon_min )
if ( bound_lon1 <= src_lon_min && bound_lon2 >= src_lon_min )
{
bound_lon1 += 2*M_PI;
bound_lon2 += 2*M_PI;
......@@ -4349,7 +4349,7 @@ long get_srch_cells_reg2d(const int *restrict src_grid_dims,
bound_lon1 = tgt_cell_bound_box[2];
bound_lon2 = tgt_cell_bound_box[3];
if ( bound_lon1 < src_lon_max && bound_lon2 >= src_lon_max )
if ( bound_lon1 <= src_lon_max && bound_lon2 >= src_lon_max )
{
bound_lon1 -= 2*M_PI;
bound_lon2 -= 2*M_PI;
......@@ -5388,8 +5388,8 @@ void restrict_boundbox(const double *restrict grid_bound_box, double *restrict b
if ( bound_box[0] < grid_bound_box[0] && bound_box[1] > grid_bound_box[0] ) bound_box[0] = grid_bound_box[0];
if ( bound_box[1] > grid_bound_box[1] && bound_box[0] < grid_bound_box[1] ) bound_box[1] = grid_bound_box[1];
if ( bound_box[2] >= grid_bound_box[3] ) { bound_box[2] -= 2*M_PI; bound_box[3] -= 2*M_PI; }
if ( bound_box[3] <= grid_bound_box[2] ) { bound_box[2] += 2*M_PI; bound_box[3] += 2*M_PI; }
if ( bound_box[2] > grid_bound_box[3] ) { bound_box[2] -= 2*M_PI; bound_box[3] -= 2*M_PI; }
if ( bound_box[3] < grid_bound_box[2] ) { bound_box[2] += 2*M_PI; bound_box[3] += 2*M_PI; }
// if ( bound_box[2] < grid_bound_box[2] && bound_box[3] > grid_bound_box[2] ) bound_box[2] = grid_bound_box[2];
// if ( bound_box[3] > grid_bound_box[3] && bound_box[2] < grid_bound_box[3] ) bound_box[3] = grid_bound_box[3];
}
......@@ -5426,7 +5426,7 @@ void boundbox_from_corners1(long ic, long nc, const double *restrict corner_lon,
#include "area.h"
#endif
void remap_contest(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapvars_t *rv)
void remap_conclip(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapvars_t *rv)
{
/* local variables */
......@@ -5614,7 +5614,7 @@ void remap_contest(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapvars_t *rv
#endif
*/
findex++;
if ( lprogress ) progressStatus(0.5, 0.5, findex/grid2_size);
if ( lprogress ) progressStatus(0, 1, findex/grid2_size);
/* Get search cells */
......@@ -5622,7 +5622,8 @@ void remap_contest(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapvars_t *rv
{
boundbox_from_corners1(tgt_grid_add, grid2_corners, tgt_grid->cell_corner_lon, tgt_grid->cell_corner_lat, tgt_cell_bound_box);
restrict_boundbox(src_grid_bound_box, tgt_cell_bound_box);
printf("bound_box %ld lon: %g %g lat: %g %g\n", tgt_grid_add, RAD2DEG*tgt_cell_bound_box[2],RAD2DEG*tgt_cell_bound_box[3],RAD2DEG*tgt_cell_bound_box[0],RAD2DEG*tgt_cell_bound_box[1] );
if ( cdoVerbose )
printf("bound_box %ld lon: %g %g lat: %g %g\n", tgt_grid_add, RAD2DEG*tgt_cell_bound_box[2],RAD2DEG*tgt_cell_bound_box[3],RAD2DEG*tgt_cell_bound_box[0],RAD2DEG*tgt_cell_bound_box[1] );
}
if ( remap_grid_type == REMAP_GRID_TYPE_REG2D )
......@@ -5632,7 +5633,8 @@ void remap_contest(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapvars_t *rv
num_srch_cells = get_srch_cells(tgt_grid_add, nbins, tgt_grid->bin_addr, src_grid->bin_addr,
tgt_grid->cell_bound_box, src_grid->cell_bound_box, grid1_size, srch_add);
printf("tgt_grid_add %ld num_srch_cells %ld\n", tgt_grid_add, num_srch_cells);
if ( cdoVerbose )
printf("tgt_grid_add %ld num_srch_cells %ld\n", tgt_grid_add, num_srch_cells);
if ( num_srch_cells == 0 ) continue;
......@@ -5767,7 +5769,7 @@ void remap_contest(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapvars_t *rv
tgt_grid->cell_frac[tgt_grid_add] += weights[3];
}
tgt_grid->cell_area[tgt_grid_add] += weights[3];
tgt_grid->cell_area[tgt_grid_add] += weights[3];
}
/*
#if defined(_OPENMP)
......@@ -5948,7 +5950,7 @@ void remap_contest(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapvars_t *rv
if ( cdoTimer ) timer_stop(timer_remap_con);
} /* remap_contest */
} /* remap_conclip */
/*****************************************************************************/
......
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