libsim  Versione 7.2.6

◆ vol7d_compute_stat_proc_agg()

subroutine vol7d_class_compute::vol7d_compute_stat_proc_agg ( type(vol7d), intent(inout)  this,
type(vol7d), 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  weighted,
type(vol7d), intent(inout), optional  other 
)

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:

  • 0 average
  • 2 maximum
  • 3 minimum
  • 4 difference
  • 6 standard deviation
  • 201 mode (only for wind direction sectors)

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

Parametri
[in,out]thisvolume providing data to be computed, it is not modified by the method, apart from performing a vol7d_alloc_vol on it
[out]thatoutput volume which will contain the computed data
[in]stat_proctype of statistical processing to be computed (from grib2 table)
[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]weightedif provided and .TRUE., the statistical process is computed, if possible, by weighting every value with a weight proportional to its validity interval
[in,out]otheroptional volume that, on exit, is going to contain the data that did not contribute to the accumulation computation

Definizione alla linea 682 del file vol7d_class_compute.F90.

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
726 ENDDO do_otimerange
727 
728 DEALLOCATE(map_ttr)
729 DEALLOCATE(tmpvolr, tmpvold, lin_mask, weights)
730 
731 IF (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))
734 ENDIF
735 
736 END SUBROUTINE vol7d_compute_stat_proc_agg
737 
738 
754 SUBROUTINE vol7d_decompute_stat_proc(this, that, step, other, stat_proc_input)
755 TYPE(vol7d),INTENT(inout) :: this
756 TYPE(vol7d),INTENT(out) :: that
757 TYPE(timedelta),INTENT(in) :: step
758 TYPE(vol7d),INTENT(inout),OPTIONAL :: other
759 INTEGER,INTENT(in),OPTIONAL :: stat_proc_input
760 
761 INTEGER :: i, tri, steps
762 
763 
764 IF (PRESENT(stat_proc_input)) THEN
765  tri = stat_proc_input
766 ELSE
767  tri = 0
768 ENDIF
769 ! be safe
770 CALL vol7d_alloc_vol(this)
771 
772 ! compute length of cumulation step in seconds
773 CALL getval(step, asec=steps)
774 
775 ! filter requested data
776 CALL 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
781 that%timerange(:)%timerange = 254
782 that%timerange(:)%p2 = 0
783 DO i = 1, SIZE(that%time(:))
784  that%time(i) = that%time(i) - step/2
785 ENDDO
786 
787 IF (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))
791 ENDIF
792 
793 END SUBROUTINE vol7d_decompute_stat_proc
794 
795 
822 SUBROUTINE vol7d_recompute_stat_proc_diff(this, that, stat_proc, step, full_steps, start, other)
823 TYPE(vol7d),INTENT(inout) :: this
824 TYPE(vol7d),INTENT(out) :: that
825 INTEGER,INTENT(in) :: stat_proc
826 TYPE(timedelta),INTENT(in) :: step
827 LOGICAL,INTENT(in),OPTIONAL :: full_steps
828 TYPE(datetime),INTENT(in),OPTIONAL :: start
829 TYPE(vol7d),INTENT(out),OPTIONAL :: other
830 
831 INTEGER :: i1, i3, i5, i6, i, j, k, l, nitr, steps
832 INTEGER,ALLOCATABLE :: map_tr(:,:,:,:,:), f(:), keep_tr(:,:,:)
833 LOGICAL,ALLOCATABLE :: mask_timerange(:)
834 LOGICAL,ALLOCATABLE :: mask_time(:)
835 TYPE(vol7d) :: v7dtmp
836 
837 
838 ! be safe
839 CALL vol7d_alloc_vol(this)
840 ! initialise the template of the output volume
841 CALL init(that, time_definition=this%time_definition)
842 
843 ! compute length of cumulation step in seconds
844 CALL getval(step, asec=steps)
845 
846 ! compute the statistical processing relations, output time and
847 ! timerange are defined here
848 CALL 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)
851 nitr = SIZE(f)
852 
853 ! complete the definition of the empty output template
854 CALL vol7d_alloc(that, nana=0, nlevel=0, nnetwork=0)
855 CALL vol7d_alloc_vol(that)
856 ! shouldn't we exit here with an empty volume if stat_proc/=0,1 ?
857 ALLOCATE(mask_time(SIZE(this%time)), mask_timerange(SIZE(this%timerange)))
858 DO l = 1, SIZE(this%time)
859  mask_time(l) = any(this%time(l) == that%time(:))
860 ENDDO
861 DO l = 1, SIZE(this%timerange)
862  mask_timerange(l) = any(this%timerange(l) == that%timerange(:))
863 ENDDO
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
868 CALL 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
871 CALL vol7d_merge(that, v7dtmp, lanasimple=.TRUE., llevelsimple=.TRUE.)
872 
873 ! compute statistical processing
874 IF (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
910 ENDIF
911 
912 IF (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
924 ! IF (.NOT.c_e(that%voldatid( &
925 ! i1,map_tr(i,j,k,l,1),i3,map_tr(i,j,k,l,2),i5,i6))) THEN
926 
927  IF (stat_proc == 0) THEN ! average
928  that%voldatid( &
929  i1,map_tr(i,j,k,l,1),i3,map_tr(i,j,k,l,2),i5,i6) = &
930  (this%voldatid(i1,l,i3,f(k),i5,i6)*this%timerange(f(k))%p2 - &
931  this%voldatid(i1,j,i3,f(i),i5,i6)*this%timerange(f(i))%p2)/ &
932  steps ! optimize avoiding conversions
933  ELSE IF (stat_proc == 1 .OR. stat_proc == 4) THEN ! acc, diff

Generated with Doxygen.