libsim  Versione 7.2.6

◆ 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 602 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 ALLOCATE(varbufr(SIZE(this%var)))
661 DO i6 = 1, SIZE(this%var)
662  varbufr(i6) = convert(this%var(i6))
663 ENDDO
664 ! compute statistical processing
665 DO 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
722 ENDDO
723 
724 IF (.NOT.ASSOCIATED(that%voldati)) THEN
725  DEALLOCATE(voldatiin1, voldatiin2, voldatiout)
726 ENDIF
727 
728 END SUBROUTINE volgrid6d_recompute_stat_proc_diff
729 
730 

Generated with Doxygen.