libsim Versione 7.2.6
|
◆ 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 2601 del file grid_transform_class.F90. 2602 point = georef_coord_new(x=lon1, y=lat1)
2603
2604 DO n = 1, this%trans%poly%arraysize
2605 IF (inside(point, this%trans%poly%array(n))) THEN ! stop at the first matching polygon
2606 this%inter_index_x(i,1) = n
2607 EXIT
2608 ENDIF
2609 ENDDO
2610 ENDDO
2611
2612 this%outnx=this%trans%poly%arraysize
2613 this%outny=1
2614 CALL vol7d_alloc(v7d_out, nana=this%outnx)
2615
2616! setup output point list, equal to average of polygon points
2617! warning, in case of concave areas points may coincide!
2618 CALL poly_to_coordinates(this%trans%poly, v7d_out)
2619
2620 this%valid = .true. ! warning, no check of subtype
2621
2622ELSE IF (this%trans%trans_type == 'metamorphosis') THEN
2623
2624! common to all metamorphosis subtypes
2625 this%innx = SIZE(v7d_in%ana)
2626 this%inny = 1
2627! allocate index array
2628 ALLOCATE(this%point_index(this%innx,this%inny))
2629 this%point_index(:,:) = imiss
2630
2631 IF (this%trans%sub_type == 'all' ) THEN
2632
2633 CALL metamorphosis_all_setup()
2634
2635 ELSE IF (this%trans%sub_type == 'coordbb' ) THEN
2636
2637 ALLOCATE(lon(this%innx),lat(this%innx))
2638
2639! count and mark points falling into requested bounding-box
2640 this%outnx = 0
2641 this%outny = 1
2642 CALL getval(v7d_in%ana(:)%coord,lon=lon,lat=lat)
2643 DO i = 1, this%innx
2644! IF (geo_coord_inside_rectang()
2645 IF (lon(i) > this%trans%rect_coo%ilon .AND. &
2646 lon(i) < this%trans%rect_coo%flon .AND. &
2647 lat(i) > this%trans%rect_coo%ilat .AND. &
2648 lat(i) < this%trans%rect_coo%flat) THEN ! improve!
2649 this%outnx = this%outnx + 1
2650 this%point_index(i,1) = this%outnx
2651 ENDIF
2652 ENDDO
2653
2654 IF (this%outnx <= 0) THEN
2655 CALL l4f_category_log(this%category,l4f_warn, &
2656 "metamorphosis:coordbb: no points inside bounding box "//&
2657 trim(to_char(this%trans%rect_coo%ilon))//","// &
2658 trim(to_char(this%trans%rect_coo%flon))//","// &
2659 trim(to_char(this%trans%rect_coo%ilat))//","// &
2660 trim(to_char(this%trans%rect_coo%flat)))
2661 ENDIF
2662
2663 CALL vol7d_alloc(v7d_out, nana=this%outnx)
2664
2665! collect coordinates of points falling into requested bounding-box
2666 n = 0
2667 DO i = 1, this%innx
2668 IF (c_e(this%point_index(i,1))) THEN
2669 n = n + 1
2670 CALL init(v7d_out%ana(n),lon=lon(i),lat=lat(i))
2671 ENDIF
2672 ENDDO
2673 DEALLOCATE(lon, lat)
2674
2675 this%valid = .true.
2676
2677 ELSE IF (this%trans%sub_type == 'poly' ) THEN
2678
2679! count and mark points falling into requested polygon
2680 this%outnx = 0
2681 this%outny = 1
2682 DO i = 1, this%innx
2683! temporary, improve!!!!
2684 CALL getval(v7d_in%ana(i)%coord,lon=lon1,lat=lat1)
2685 point = georef_coord_new(x=lon1, y=lat1)
2686 DO n = 1, this%trans%poly%arraysize
2687 IF (inside(point, this%trans%poly%array(n))) THEN ! stop at the first matching polygon
2688 this%outnx = this%outnx + 1
2689 this%point_index(i,1) = n
2690 EXIT
|