libsim Versione 7.2.1
|
◆ grid_transform_vol7d_grid_init()
Constructor for a grid_transform object, defining a particular sparse points-to-grid transformation. It defines an object describing a transformation from a set of sparse points to a rectangular grid; the abstract type of transformation is described in the transformation object trans (type transform_def) which must have been properly initialised. The additional information required here is the list of the input sparse points in the form of a vol7d object (parameter v7d_in), which can be the same volume that will be successively used for interpolation, or a volume with just the same coordinate data, and the description of the output grid griddim (a griddim_def object). The generated grid_transform object is specific to the sparse point list and grid provided. The function c_e can be used in order to check whether the object has been successfully initialised, if the result is .FALSE., it should not be used further on.
Definizione alla linea 2576 del file grid_transform_class.F90. 2577 point = georef_coord_new(x=lon1, y=lat1)
2578
2579 DO n = 1, this%trans%poly%arraysize
2580 IF (inside(point, this%trans%poly%array(n))) THEN ! stop at the first matching polygon
2581 this%inter_index_x(i,1) = n
2582 EXIT
2583 ENDIF
2584 ENDDO
2585 ENDDO
2586
2587 this%outnx=this%trans%poly%arraysize
2588 this%outny=1
2589 CALL vol7d_alloc(v7d_out, nana=this%outnx)
2590
2591! setup output point list, equal to average of polygon points
2592! warning, in case of concave areas points may coincide!
2593 CALL poly_to_coordinates(this%trans%poly, v7d_out)
2594
2595 this%valid = .true. ! warning, no check of subtype
2596
2597ELSE IF (this%trans%trans_type == 'metamorphosis') THEN
2598
2599! common to all metamorphosis subtypes
2600 this%innx = SIZE(v7d_in%ana)
2601 this%inny = 1
2602! allocate index array
2603 ALLOCATE(this%point_index(this%innx,this%inny))
2604 this%point_index(:,:) = imiss
2605
2606 IF (this%trans%sub_type == 'all' ) THEN
2607
2608 CALL metamorphosis_all_setup()
2609
2610 ELSE IF (this%trans%sub_type == 'coordbb' ) THEN
2611
2612 ALLOCATE(lon(this%innx),lat(this%innx))
2613
2614! count and mark points falling into requested bounding-box
2615 this%outnx = 0
2616 this%outny = 1
2617 CALL getval(v7d_in%ana(:)%coord,lon=lon,lat=lat)
2618 DO i = 1, this%innx
2619! IF (geo_coord_inside_rectang()
2620 IF (lon(i) > this%trans%rect_coo%ilon .AND. &
2621 lon(i) < this%trans%rect_coo%flon .AND. &
2622 lat(i) > this%trans%rect_coo%ilat .AND. &
2623 lat(i) < this%trans%rect_coo%flat) THEN ! improve!
2624 this%outnx = this%outnx + 1
2625 this%point_index(i,1) = this%outnx
2626 ENDIF
2627 ENDDO
2628
2629 IF (this%outnx <= 0) THEN
2630 CALL l4f_category_log(this%category,l4f_warn, &
2631 "metamorphosis:coordbb: no points inside bounding box "//&
2632 trim(to_char(this%trans%rect_coo%ilon))//","// &
2633 trim(to_char(this%trans%rect_coo%flon))//","// &
2634 trim(to_char(this%trans%rect_coo%ilat))//","// &
2635 trim(to_char(this%trans%rect_coo%flat)))
2636 ENDIF
2637
2638 CALL vol7d_alloc(v7d_out, nana=this%outnx)
2639
2640! collect coordinates of points falling into requested bounding-box
2641 n = 0
2642 DO i = 1, this%innx
2643 IF (c_e(this%point_index(i,1))) THEN
2644 n = n + 1
2645 CALL init(v7d_out%ana(n),lon=lon(i),lat=lat(i))
2646 ENDIF
2647 ENDDO
2648 DEALLOCATE(lon, lat)
2649
2650 this%valid = .true.
2651
2652 ELSE IF (this%trans%sub_type == 'poly' ) THEN
2653
2654! count and mark points falling into requested polygon
2655 this%outnx = 0
2656 this%outny = 1
2657 DO i = 1, this%innx
2658! temporary, improve!!!!
2659 CALL getval(v7d_in%ana(i)%coord,lon=lon1,lat=lat1)
2660 point = georef_coord_new(x=lon1, y=lat1)
2661 DO n = 1, this%trans%poly%arraysize
2662 IF (inside(point, this%trans%poly%array(n))) THEN ! stop at the first matching polygon
2663 this%outnx = this%outnx + 1
2664 this%point_index(i,1) = n
2665 EXIT
|