libsim Versione 7.2.4
|
◆ vol7d_compute_stat_proc_agg()
Method for statistically processing a set of instantaneous data. This method performs statistical processing by aggregation of instantaneous data. Only floating point single or double precision data are processed. The output that vol7d object contains elements from the original volume this satisfying the conditions
Output data will have timerange of type stat_proc, and p2 = step. The supported statistical processing methods (parameter stat_proc) are:
In the case of average, it is possible to weigh the data proportionally to the length of the time interval for which every single value is valid, i.e. halfway between the time level of the value itself and the time of its nearest valid neighbours (argument weighted). A maximum distance in time for input valid data can be assigned with the optional argument max_step, in order to filter datasets with too long "holes".
Definizione alla linea 672 del file vol7d_class_compute.F90. 674 ENDDO
675 IF (ndtr == 0) cycle
676 IF (lweighted) THEN
677 CALL compute_stat_proc_agg_sw(map_ttr(i,j)%array(1:ninp)%time, &
678 pstart, pend, lin_mask(1:ninp), act_max_step, weights)
679 ELSE
680 CALL compute_stat_proc_agg_sw(map_ttr(i,j)%array(1:ninp)%time, &
681 pstart, pend, lin_mask(1:ninp), act_max_step)
682 ENDIF
683 IF (act_max_step > lmax_step) cycle
684
685 SELECT CASE(stat_proc)
686 CASE (0) ! average
687 IF (lweighted) THEN
688 that%voldatid(i1,i,i3,j,i5,i6) = &
689 sum(real(weights(1:ndtr))*tmpvold(1:ndtr))
690 ELSE
691 that%voldatid(i1,i,i3,j,i5,i6) = &
692 sum(tmpvold(1:ndtr))/ndtr
693 ENDIF
694 CASE (2) ! maximum
695 that%voldatid(i1,i,i3,j,i5,i6) = &
696 maxval(tmpvold(1:ndtr))
697 CASE (3) ! minimum
698 that%voldatid(i1,i,i3,j,i5,i6) = &
699 minval(tmpvold(1:ndtr))
700 CASE (6) ! stddev
701 that%voldatid(i1,i,i3,j,i5,i6) = &
702 stat_stddev(tmpvold(1:ndtr))
703 CASE (201) ! mode
704! mode only for angles at the moment, with predefined histogram
705 IF (vartype == var_dir360) THEN
706! remove undefined wind direction (=0), improve check?
707! and reduce to interval [22.5,382.5[
708 WHERE (tmpvold(1:ndtr) == 0.0d0)
709 tmpvold(1:ndtr) = dmiss
710 ELSE WHERE (tmpvold(1:ndtr) < 22.5d0 .AND. tmpvold(1:ndtr) > 0.0d0)
711 tmpvold(1:ndtr) = tmpvold(1:ndtr) + 360.0d0
712 END WHERE
713 that%voldatid(i1,i,i3,j,i5,i6) = &
714 stat_mode_histogram(tmpvold(1:ndtr), &
715 8, 22.5d0, 382.5d0)
716 ENDIF
717 END SELECT
718 ENDDO
719 ENDDO
720 ENDDO
721 ENDDO
722 ENDIF
723
724 CALL delete(map_ttr(i,j))
725 ENDDO do_otime
726ENDDO do_otimerange
727
728DEALLOCATE(map_ttr)
729DEALLOCATE(tmpvolr, tmpvold, lin_mask, weights)
730
731IF (PRESENT(other)) THEN ! create volume with the remaining data for further processing
732 CALL vol7d_copy(this, other, miss=.false., sort=.false., unique=.false., &
733 ltimerange=(this%timerange(:)%timerange /= tri))
734ENDIF
735
736END SUBROUTINE vol7d_compute_stat_proc_agg
737
738
754SUBROUTINE vol7d_decompute_stat_proc(this, that, step, other, stat_proc_input)
755TYPE(vol7d),INTENT(inout) :: this
756TYPE(vol7d),INTENT(out) :: that
757TYPE(timedelta),INTENT(in) :: step
758TYPE(vol7d),INTENT(inout),OPTIONAL :: other
759INTEGER,INTENT(in),OPTIONAL :: stat_proc_input
760
761INTEGER :: i, tri, steps
762
763
764IF (PRESENT(stat_proc_input)) THEN
765 tri = stat_proc_input
766ELSE
767 tri = 0
768ENDIF
769! be safe
770CALL vol7d_alloc_vol(this)
771
772! compute length of cumulation step in seconds
773CALL getval(step, asec=steps)
774
775! filter requested data
776CALL vol7d_copy(this, that, miss=.FALSE., sort=.FALSE., unique=.FALSE., &
777 ltimerange=(this%timerange(:)%timerange == tri .AND. &
778 this%timerange(:)%p1 == 0 .AND. this%timerange(:)%p2 == steps))
779
780! convert timerange to instantaneous and go back half step in time
781that%timerange(:)%timerange = 254
782that%timerange(:)%p2 = 0
783DO i = 1, SIZE(that%time(:))
784 that%time(i) = that%time(i) - step/2
785ENDDO
786
787IF (PRESENT(other)) THEN ! create volume with the remaining data for further processing
788 CALL vol7d_copy(this, other, miss=.false., sort=.false., unique=.false., &
789 ltimerange=(this%timerange(:)%timerange /= tri .OR. &
790 this%timerange(:)%p1 /= 0 .OR. this%timerange(:)%p2 /= steps))
791ENDIF
792
793END SUBROUTINE vol7d_decompute_stat_proc
794
795
822SUBROUTINE vol7d_recompute_stat_proc_diff(this, that, stat_proc, step, full_steps, start, other)
823TYPE(vol7d),INTENT(inout) :: this
824TYPE(vol7d),INTENT(out) :: that
825INTEGER,INTENT(in) :: stat_proc
826TYPE(timedelta),INTENT(in) :: step
827LOGICAL,INTENT(in),OPTIONAL :: full_steps
828TYPE(datetime),INTENT(in),OPTIONAL :: start
829TYPE(vol7d),INTENT(out),OPTIONAL :: other
830
831INTEGER :: i1, i3, i5, i6, i, j, k, l, nitr, steps
832INTEGER,ALLOCATABLE :: map_tr(:,:,:,:,:), f(:), keep_tr(:,:,:)
833LOGICAL,ALLOCATABLE :: mask_timerange(:)
834LOGICAL,ALLOCATABLE :: mask_time(:)
835TYPE(vol7d) :: v7dtmp
836
837
838! be safe
839CALL vol7d_alloc_vol(this)
840! initialise the template of the output volume
841CALL init(that, time_definition=this%time_definition)
842
843! compute length of cumulation step in seconds
844CALL getval(step, asec=steps)
845
846! compute the statistical processing relations, output time and
847! timerange are defined here
848CALL recompute_stat_proc_diff_common(this%time, this%timerange, stat_proc, step, &
849 that%time, that%timerange, map_tr, f, keep_tr, &
850 this%time_definition, full_steps, start)
851nitr = SIZE(f)
852
853! complete the definition of the empty output template
854CALL vol7d_alloc(that, nana=0, nlevel=0, nnetwork=0)
855CALL vol7d_alloc_vol(that)
856! shouldn't we exit here with an empty volume if stat_proc/=0,1 ?
857ALLOCATE(mask_time(SIZE(this%time)), mask_timerange(SIZE(this%timerange)))
858DO l = 1, SIZE(this%time)
859 mask_time(l) = any(this%time(l) == that%time(:))
860ENDDO
861DO l = 1, SIZE(this%timerange)
862 mask_timerange(l) = any(this%timerange(l) == that%timerange(:))
863ENDDO
864! create template for the output volume, keep all ana, level, network
865! and variables; copy only the timeranges already satisfying the
866! requested step, if any and only the times already existing in the
867! output
868CALL vol7d_copy(this, v7dtmp, miss=.FALSE., sort=.FALSE., unique=.FALSE., &
869 ltimerange=mask_timerange(:), ltime=mask_time(:))
870! merge output created so far with template
871CALL vol7d_merge(that, v7dtmp, lanasimple=.TRUE., llevelsimple=.TRUE.)
872
873! compute statistical processing
874IF (ASSOCIATED(this%voldatir)) THEN
875 DO l = 1, SIZE(this%time)
876 DO k = 1, nitr
877 DO j = 1, SIZE(this%time)
878 DO i = 1, nitr
879 IF (c_e(map_tr(i,j,k,l,1))) THEN
880 DO i6 = 1, SIZE(this%network)
881 DO i5 = 1, SIZE(this%dativar%r)
882 DO i3 = 1, SIZE(this%level)
883 DO i1 = 1, SIZE(this%ana)
884 IF (c_e(this%voldatir(i1,l,i3,f(k),i5,i6)) .AND. &
885 c_e(this%voldatir(i1,j,i3,f(i),i5,i6))) THEN
886
887 IF (stat_proc == 0) THEN ! average
888 that%voldatir( &
889 i1,map_tr(i,j,k,l,1),i3,map_tr(i,j,k,l,2),i5,i6) = &
890 (this%voldatir(i1,l,i3,f(k),i5,i6)*this%timerange(f(k))%p2 - &
891 this%voldatir(i1,j,i3,f(i),i5,i6)*this%timerange(f(i))%p2)/ &
892 steps ! optimize avoiding conversions
893 ELSE IF (stat_proc == 1 .OR. stat_proc == 4) THEN ! acc, diff
894 that%voldatir( &
895 i1,map_tr(i,j,k,l,1),i3,map_tr(i,j,k,l,2),i5,i6) = &
896 this%voldatir(i1,l,i3,f(k),i5,i6) - &
897 this%voldatir(i1,j,i3,f(i),i5,i6)
898 ENDIF
899
900 ENDIF
901 ENDDO
902 ENDDO
903 ENDDO
904 ENDDO
905 ENDIF
906 ENDDO
907 ENDDO
908 ENDDO
909 ENDDO
910ENDIF
911
912IF (ASSOCIATED(this%voldatid)) THEN
913 DO l = 1, SIZE(this%time)
914 DO k = 1, nitr
915 DO j = 1, SIZE(this%time)
916 DO i = 1, nitr
917 IF (c_e(map_tr(i,j,k,l,1))) THEN
918 DO i6 = 1, SIZE(this%network)
919 DO i5 = 1, SIZE(this%dativar%d)
920 DO i3 = 1, SIZE(this%level)
921 DO i1 = 1, SIZE(this%ana)
922 IF (c_e(this%voldatid(i1,l,i3,f(k),i5,i6)) .AND. &
923 c_e(this%voldatid(i1,j,i3,f(i),i5,i6))) THEN
|