libsim Versione 7.2.1
|
◆ volgrid6d_compute_stat_proc_agg()
Method for statistically processing a set of instantaneous data. This method performs statistical processing by aggregation of instantaneous data. The output that volgrid6d 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:
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 592 del file volgrid6d_class_compute.F90. 594
595
596! be safe
597CALL volgrid6d_alloc_vol(this)
598! when volume is not decoded it is better to clone anyway to avoid
599! overwriting fields
600lclone = optio_log(clone) .OR. .NOT.ASSOCIATED(this%voldati)
601! initialise the output volume
602CALL init(that, griddim=this%griddim, time_definition=this%time_definition)
603CALL volgrid6d_alloc(that, dim=this%griddim%dim, &
604 nlevel=SIZE(this%level), nvar=SIZE(this%var), ini=.false.)
605that%level = this%level
606that%var = this%var
607
608! compute length of cumulation step in seconds
609CALL getval(step, asec=steps)
610
611! compute the statistical processing relations, output time and
612! timerange are defined here
613CALL recompute_stat_proc_diff_common(this%time, this%timerange, stat_proc, step, &
614 that%time, that%timerange, map_tr, f, keep_tr, &
615 this%time_definition, full_steps, start)
616nitr = SIZE(f)
617
618! complete the definition of the output volume
619CALL volgrid6d_alloc_vol(that, decode=ASSOCIATED(this%voldati))
620! allocate workspace once
621IF (.NOT.ASSOCIATED(that%voldati)) THEN
622 ALLOCATE(voldatiin1(this%griddim%dim%nx, this%griddim%dim%ny), &
623 voldatiin2(this%griddim%dim%nx, this%griddim%dim%ny), &
624 voldatiout(this%griddim%dim%nx, this%griddim%dim%ny))
625ENDIF
626
627! copy the timeranges already satisfying the requested step, if any
628DO i4 = 1, SIZE(this%time)
629 DO i = 1, nitr
630 IF (c_e(keep_tr(i, i4, 2))) THEN
631 l = keep_tr(i, i4, 1)
632 k = keep_tr(i, i4, 2)
633#ifdef DEBUG
634 CALL l4f_category_log(this%category, l4f_debug, &
635 'volgrid6d_recompute_stat_proc_diff, good timerange: '//t2c(f(i))// &
636 '->'//t2c(k))
637#endif
638 DO i6 = 1, SIZE(this%var)
639 DO i3 = 1, SIZE(this%level)
640 IF (c_e(this%gaid(i3,i4,f(i),i6))) THEN
641 IF (lclone) THEN
642 CALL copy(this%gaid(i3,i4,f(i),i6), that%gaid(i3,l,k,i6))
643 ELSE
644 that%gaid(i3,l,k,i6) = this%gaid(i3,i4,f(i),i6)
645 ENDIF
646 IF (ASSOCIATED(that%voldati)) THEN
647 that%voldati(:,:,i3,l,k,i6) = this%voldati(:,:,i3,i4,f(i),i6)
648 ELSE
649 CALL volgrid_get_vol_2d(this, i3, i4, f(i), i6, voldatiout)
650 CALL volgrid_set_vol_2d(that, i3, l, k, i6, voldatiout)
651 ENDIF
652 ENDIF
653 ENDDO
654 ENDDO
655 ENDIF
656 ENDDO
657ENDDO
658
659! varbufr required for setting posdef, optimize with an array
660ALLOCATE(varbufr(SIZE(this%var)))
661DO i6 = 1, SIZE(this%var)
662 varbufr(i6) = convert(this%var(i6))
663ENDDO
664! compute statistical processing
665DO l = 1, SIZE(this%time)
666 DO k = 1, nitr
667 DO j = 1, SIZE(this%time)
668 DO i = 1, nitr
669 IF (c_e(map_tr(i,j,k,l,1))) THEN
670 DO i6 = 1, SIZE(this%var)
671 DO i3 = 1, SIZE(this%level)
672
673 IF (c_e(this%gaid(i3,j,f(i),i6)) .AND. &
674 c_e(this%gaid(i3,l,f(k),i6))) THEN
675! take the gaid from the second time/timerange contributing to the
676! result (l,f(k))
677 IF (lclone) THEN
678 CALL copy(this%gaid(i3,l,f(k),i6), &
679 that%gaid(i3,map_tr(i,j,k,l,1),map_tr(i,j,k,l,2),i6))
680 ELSE
681 that%gaid(i3,map_tr(i,j,k,l,1),map_tr(i,j,k,l,2),i6) = &
682 this%gaid(i3,l,f(k),i6)
683 ENDIF
684
685! get/set 2d sections API is used
686 CALL volgrid_get_vol_2d(this, i3, l, f(k), i6, voldatiin1)
687 CALL volgrid_get_vol_2d(this, i3, j, f(i), i6, voldatiin2)
688 IF (ASSOCIATED(that%voldati)) &
689 CALL volgrid_get_vol_2d(that, i3, &
690 map_tr(i,j,k,l,1), map_tr(i,j,k,l,2), i6, voldatiout)
691
692 IF (stat_proc == 0) THEN ! average
693 WHERE(c_e(voldatiin1(:,:)) .AND. c_e(voldatiin2(:,:)))
694 voldatiout(:,:) = &
695 (voldatiin1(:,:)*this%timerange(f(k))%p2 - &
696 voldatiin2(:,:)*this%timerange(f(i))%p2)/ &
697 steps
698 ELSEWHERE
699 voldatiout(:,:) = rmiss
700 END WHERE
701 ELSE IF (stat_proc == 1 .OR. stat_proc == 4) THEN ! acc, diff
702 WHERE(c_e(voldatiin1(:,:)) .AND. c_e(voldatiin2(:,:)))
703 voldatiout(:,:) = voldatiin1(:,:) - voldatiin2(:,:)
704 ELSEWHERE
705 voldatiout(:,:) = rmiss
706 END WHERE
707 IF (stat_proc == 1) THEN
708 CALL vol7d_var_features_posdef_apply(varbufr(i6), voldatiout)
709 ENDIF
710 ENDIF
711
712 CALL volgrid_set_vol_2d(that, i3, &
713 map_tr(i,j,k,l,1), map_tr(i,j,k,l,2), i6, voldatiout)
714
715 ENDIF
716 ENDDO
717 ENDDO
718 ENDIF
719 ENDDO
720 ENDDO
721 ENDDO
722ENDDO
723
724IF (.NOT.ASSOCIATED(that%voldati)) THEN
725 DEALLOCATE(voldatiin1, voldatiin2, voldatiout)
726ENDIF
727
728END SUBROUTINE volgrid6d_recompute_stat_proc_diff
729
730
|