libsim  Versione8.0.0

◆ volgrid6d_compute_stat_proc_agg()

subroutine volgrid6d_class_compute::volgrid6d_compute_stat_proc_agg ( type(volgrid6d), intent(inout)  this,
type(volgrid6d), intent(out)  that,
integer, intent(in)  stat_proc,
type(timedelta), intent(in)  step,
type(datetime), intent(in), optional  start,
logical, intent(in), optional  full_steps,
type(timedelta), intent(in), optional  max_step,
logical, intent(in), optional  clone 
)

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:

  • 0 average
  • 2 maximum
  • 3 minimum
  • 4 difference

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".

Parametri
[in,out]thisvolume providing data to be recomputed, it is not modified by the method, apart from performing a volgrid6d_alloc_vol on it
[out]thatoutput volume which will contain the recomputed data
[in]stat_proctype of statistical processing to be recomputed (from grib2 table), only data having timerange of this type will be recomputed and will appear in the output volume
[in]steplength of the step over which the statistical processing is performed
[in]startstart of statistical processing interval
[in]full_stepsif .TRUE. and start is not provided, apply processing only on intervals starting at a forecast time or a reference time modulo step
[in]max_stepmaximum allowed distance in time between two contiguougs valid data within an interval, for the interval to be eligible for statistical processing
[in]cloneif provided and .TRUE. , clone the gaid's from this to that

Definizione alla linea 604 del file volgrid6d_class_compute.F90.

604  nlevel=SIZE(this%level), nvar=SIZE(this%var), ini=.false.)
605 that%level = this%level
606 that%var = this%var
607 
608 ! compute length of cumulation step in seconds
609 CALL getval(step, asec=steps)
610 
611 ! compute the statistical processing relations, output time and
612 ! timerange are defined here
613 CALL 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)
616 nitr = SIZE(f)
617 
618 ! complete the definition of the output volume
619 CALL volgrid6d_alloc_vol(that, decode=ASSOCIATED(this%voldati))
620 ! allocate workspace once
621 IF (.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))
625 ENDIF
626 
627 ! copy the timeranges already satisfying the requested step, if any
628 DO 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
657 ENDDO
658 
659 ! varbufr required for setting posdef, optimize with an array
660 IF (stat_proc == 1) THEN
661  ALLOCATE(varbufr(SIZE(this%var)))
662  DO i6 = 1, SIZE(this%var)
663  varbufr(i6) = convert(this%var(i6))
664  CALL vol7d_var_features_set(varbufr(i6))
665  ENDDO
666 ENDIF
667 ! compute statistical processing
668 DO l = 1, SIZE(this%time)
669  DO k = 1, nitr
670  DO j = 1, SIZE(this%time)
671  DO i = 1, nitr
672  IF (c_e(map_tr(i,j,k,l,1))) THEN
673  DO i6 = 1, SIZE(this%var)
674  DO i3 = 1, SIZE(this%level)
675 
676  IF (c_e(this%gaid(i3,j,f(i),i6)) .AND. &
677  c_e(this%gaid(i3,l,f(k),i6))) THEN
678 ! take the gaid from the second time/timerange contributing to the
679 ! result (l,f(k))
680  IF (lclone) THEN
681  CALL copy(this%gaid(i3,l,f(k),i6), &
682  that%gaid(i3,map_tr(i,j,k,l,1),map_tr(i,j,k,l,2),i6))
683  ELSE
684  that%gaid(i3,map_tr(i,j,k,l,1),map_tr(i,j,k,l,2),i6) = &
685  this%gaid(i3,l,f(k),i6)
686  ENDIF
687 
688 ! get/set 2d sections API is used
689  CALL volgrid_get_vol_2d(this, i3, l, f(k), i6, voldatiin1)
690  CALL volgrid_get_vol_2d(this, i3, j, f(i), i6, voldatiin2)
691  IF (ASSOCIATED(that%voldati)) &
692  CALL volgrid_get_vol_2d(that, i3, &
693  map_tr(i,j,k,l,1), map_tr(i,j,k,l,2), i6, voldatiout)
694 
695  IF (stat_proc == 0) THEN ! average
696  WHERE(c_e(voldatiin1(:,:)) .AND. c_e(voldatiin2(:,:)))
697  voldatiout(:,:) = &
698  (voldatiin1(:,:)*this%timerange(f(k))%p2 - &
699  voldatiin2(:,:)*this%timerange(f(i))%p2)/ &
700  steps
701  ELSEWHERE
702  voldatiout(:,:) = rmiss
703  END WHERE
704  ELSE IF (stat_proc == 1 .OR. stat_proc == 4) THEN ! acc, diff
705  WHERE(c_e(voldatiin1(:,:)) .AND. c_e(voldatiin2(:,:)))
706  voldatiout(:,:) = voldatiin1(:,:) - voldatiin2(:,:)
707  ELSEWHERE
708  voldatiout(:,:) = rmiss
709  END WHERE
710  IF (stat_proc == 1) THEN
711  CALL vol7d_var_features_posdef_apply(varbufr(i6), voldatiout)
712  ENDIF
713  ENDIF
714 
715  CALL volgrid_set_vol_2d(that, i3, &
716  map_tr(i,j,k,l,1), map_tr(i,j,k,l,2), i6, voldatiout)
717 
718  ENDIF
719  ENDDO
720  ENDDO
721  ENDIF
722  ENDDO
723  ENDDO
724  ENDDO
725 ENDDO
726 
727 IF (.NOT.ASSOCIATED(that%voldati)) THEN
728  DEALLOCATE(voldatiin1, voldatiin2, voldatiout)
729 ENDIF
730 
731 END SUBROUTINE volgrid6d_recompute_stat_proc_diff
732 
733 

Generated with Doxygen.