52 #define size_block 30000
69 #ifndef GEO_TRANSFORMATIONS_OFF
77 model->setNormalization( env );
88 int pixelcount = hdr.
ydim * hdr.
xdim;
89 int pixelstep = pixelcount/20;
99 if ( callbackWrapper && pixels%pixelstep == 0 ) {
120 pair<Coord,Coord> lonlat = *it;
128 Sample const &amb = env->get( lg, lt );
131 if ( amb.
size() == 0 ) {
140 val = model->getValue( amb );
142 if ( val < 0.0 || val > 1.0 ) {
144 std::string msg =
Log::format(
"Suitability for point (%f, %f) is outside the range: %f", lg, lt, val );
154 map->
put( lg, lt, val );
158 if ( callbackWrapper && pixels%pixelstep == 0 ) {
160 float progress = pixels/(float)pixelcount;
162 if ( progress > 1.0 ) {
176 if ( callbackWrapper ) {
210 buff X[N_X][size_block];
212 MPI_Request req_dado[N_X];
213 MPI_Request inf_N[N_X];
216 int env_dado[N_X],total_pixels;
217 int pixel_next,interval_pixels[3];
218 int count_tag,max_count_tag;
224 MPI_Comm_rank(MPI_COMM_WORLD,&myrank);
228 #ifndef GEO_TRANSFORMATIONS_OFF
236 model->setNormalization( env );
247 MPI_Comm_rank(MPI_COMM_WORLD,&myrank);
248 MPI_Comm_size(MPI_COMM_WORLD,&mysize);
250 int pixels, init_pixel, lim_pixel;
254 MPI_Barrier(MPI_COMM_WORLD);
258 max_count_tag=10+total_pixels/size_block;
259 if ((total_pixels%size_block)!=0)
262 while (count_tag<max_count_tag) {
263 MPI_Recv(&N,1,MPI_INT,MPI_ANY_SOURCE,count_tag,MPI_COMM_WORLD,&status);
264 MPI_Recv(X[0],N*
sizeof(buff),MPI_UNSIGNED_CHAR,status.MPI_SOURCE,count_tag,MPI_COMM_WORLD,&status);
266 for (j=0; j< N; j++) {
267 if (X[0][j].val==100000)
268 map->
put( X[0][j].lg, X[0][j].lt);
270 map->
put(X[0][j].lg,X[0][j].lt,X[0][j].val );
277 if (myrank==mysize-1) {
280 interval_pixels[2]=10;
282 while (pixel_next<(total_pixels)) {
283 lim_pixel=pixel_next+size_block;
285 if (lim_pixel>total_pixels)
286 lim_pixel=total_pixels;
288 interval_pixels[0]=pixel_next;
289 interval_pixels[1]=lim_pixel;
290 pixel_next=lim_pixel;
291 MPI_Recv(&req_pixels,1,MPI_INT,MPI_ANY_SOURCE,1,MPI_COMM_WORLD,&status);
292 MPI_Send(interval_pixels,3,MPI_INT,status.MPI_SOURCE,2,MPI_COMM_WORLD);
293 interval_pixels[2]++;
296 for (k=1;k<(mysize-1);k++) {
297 interval_pixels[0]=total_pixels;
298 MPI_Recv(&req_pixels,1,MPI_INT,MPI_ANY_SOURCE,1,MPI_COMM_WORLD,&status);
299 MPI_Send(interval_pixels,2,MPI_INT,status.MPI_SOURCE,2,MPI_COMM_WORLD);
304 for (
int k=0;k<N_X;k++)
306 MPI_Send(&ix,1,MPI_INT,(mysize-1),1,MPI_COMM_WORLD);
307 MPI_Recv(interval_pixels,3,MPI_INT,(mysize-1),2,MPI_COMM_WORLD,&status);;
308 init_pixel=interval_pixels[0];
309 lim_pixel=interval_pixels[1];
311 while (init_pixel<(total_pixels)) {
312 my_it.nextblock(init_pixel);
316 for (pixels=init_pixel; pixels<lim_pixel; pixels++) {
318 pair<Coord,Coord> lonlat = *my_it;
320 Coord lg = lonlat.first;
321 Coord lt = lonlat.second;
324 Sample const &amb = env->get( lg, lt );
327 if ( amb.
size() == 0 ) {
340 Scalar val = model->getValue( amb );
363 MPI_Isend(&n_elem[ix],1,MPI_INT,0,interval_pixels[2],MPI_COMM_WORLD,&inf_N[ix]);
365 MPI_Isend(X[ix],j*
sizeof(buff),MPI_UNSIGNED_CHAR,0,interval_pixels[2],MPI_COMM_WORLD,&req_dado[ix]);
369 if (env_dado[ix]==1) {
370 MPI_Wait(&inf_N[ix],&status);
371 MPI_Wait(&req_dado[ix],&status);
375 MPI_Send(&ix,1,MPI_INT,(mysize-1),1,MPI_COMM_WORLD);
376 MPI_Recv(interval_pixels,3,MPI_INT,(mysize-1),2,MPI_COMM_WORLD,&status);;
377 init_pixel=interval_pixels[0];
378 lim_pixel=interval_pixels[1];
382 MPI_Barrier(MPI_COMM_WORLD);
386 if ( callbackWrapper ) {
MapIterator begin() const
void warn(const char *format,...)
'Warn' level.
void addPrediction(Scalar predictionValue)
double Scalar
Type of map values.
static std::string format(const char *fmt,...)
static Log * instance()
Returns the instance pointer, creating the object on the first call.
Scalar getPredictionThreshold() const
void reset(Scalar predictionThreshold=0.5)
int put(Coord x, Coord y, Scalar val)
static bool createMap(const Model &model, const EnvironmentPtr &env, Map *map, AreaStats *areaStats=0, CallbackWrapper *callbackWrapper=0)
const Header & getHeader() const
void info(const char *format,...)
'Info' level.
double Coord
Type of map coordinates.
void debug(const char *format,...)
'Debug' level.
void notifyModelProjectionProgress(float progress)