libsim  Versione6.3.0

◆ 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,
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]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 693 del file vol7d_class_compute.F90.

693 ! mode only for angles at the moment, with predefined histogram
694  IF (vartype == var_dir360) THEN
695 ! reduce to interval [-22.5,337.5]
696  WHERE (tmpvold(1:ndtr) > 337.5)
697  tmpvold(1:ndtr) = tmpvold(1:ndtr) - 360.
698  END WHERE
699  that%voldatid(i1,i,i3,j,i5,i6) = &
700  stat_mode_histogram(tmpvold(1:ndtr), &
701  8, -22.5d0, 337.5d0)
702  ENDIF
703  END SELECT
704  ENDDO
705  ENDDO
706  ENDDO
707  ENDDO
708  ENDIF
709 
710  CALL delete(map_ttr(i,j))
711  ENDDO do_otime
712 ENDDO do_otimerange
713 
714 DEALLOCATE(map_ttr)
715 DEALLOCATE(tmpvolr, tmpvold, lin_mask, weights)
716 
717 IF (PRESENT(other)) THEN ! create volume with the remaining data for further processing
718  CALL vol7d_copy(this, other, miss=.false., sort=.false., unique=.false., &
719  ltimerange=(this%timerange(:)%timerange /= tri))
720 ENDIF
721 
722 END SUBROUTINE vol7d_compute_stat_proc_agg
723 
724 
740 SUBROUTINE vol7d_decompute_stat_proc(this, that, step, other, stat_proc_input)
741 TYPE(vol7d),INTENT(inout) :: this
742 TYPE(vol7d),INTENT(out) :: that
743 TYPE(timedelta),INTENT(in) :: step
744 TYPE(vol7d),INTENT(inout),OPTIONAL :: other
745 INTEGER,INTENT(in),OPTIONAL :: stat_proc_input
746 
747 INTEGER :: i, tri, steps
748 
749 
750 IF (PRESENT(stat_proc_input)) THEN
751  tri = stat_proc_input
752 ELSE
753  tri = 0
754 ENDIF
755 ! be safe
756 CALL vol7d_alloc_vol(this)
757 
758 ! compute length of cumulation step in seconds
759 CALL getval(step, asec=steps)
760 
761 ! filter requested data
762 CALL vol7d_copy(this, that, miss=.false., sort=.false., unique=.false., &
763  ltimerange=(this%timerange(:)%timerange == tri .AND. &
764  this%timerange(:)%p1 == 0 .AND. this%timerange(:)%p2 == steps))
765 
766 ! convert timerange to instantaneous and go back half step in time
767 that%timerange(:)%timerange = 254
768 that%timerange(:)%p2 = 0
769 DO i = 1, SIZE(that%time(:))
770  that%time(i) = that%time(i) - step/2
771 ENDDO
772 
773 IF (PRESENT(other)) THEN ! create volume with the remaining data for further processing
774  CALL vol7d_copy(this, other, miss=.false., sort=.false., unique=.false., &
775  ltimerange=(this%timerange(:)%timerange /= tri .OR. &
776  this%timerange(:)%p1 /= 0 .OR. this%timerange(:)%p2 /= steps))
777 ENDIF
778 
779 END SUBROUTINE vol7d_decompute_stat_proc
780 
781 
808 SUBROUTINE vol7d_recompute_stat_proc_diff(this, that, stat_proc, step, full_steps, other)
809 TYPE(vol7d),INTENT(inout) :: this
810 TYPE(vol7d),INTENT(out) :: that
811 INTEGER,INTENT(in) :: stat_proc
812 TYPE(timedelta),INTENT(in) :: step
813 LOGICAL,INTENT(in),OPTIONAL :: full_steps
814 TYPE(vol7d),INTENT(out),OPTIONAL :: other
815 
816 INTEGER :: i1, i3, i5, i6, i, j, k, l, nitr, steps
817 INTEGER,POINTER :: map_tr(:,:,:,:,:), f(:)
818 LOGICAL,POINTER :: mask_timerange(:)
819 LOGICAL,ALLOCATABLE :: mask_time(:)
820 TYPE(vol7d) :: v7dtmp
821 
822 
823 ! be safe
824 CALL vol7d_alloc_vol(this)
825 ! initialise the template of the output volume
826 CALL init(that, time_definition=this%time_definition)
827 
828 ! compute length of cumulation step in seconds
829 CALL getval(step, asec=steps)
830 
831 ! compute the statistical processing relations, output time and
832 ! timerange are defined here
833 CALL recompute_stat_proc_diff_common(this%time, this%timerange, stat_proc, step, &
834  nitr, that%time, that%timerange, map_tr, f, mask_timerange, &
835  this%time_definition, full_steps)
836 
837 ! complete the definition of the empty output template
838 CALL vol7d_alloc(that, nana=0, nlevel=0, nnetwork=0)
839 CALL vol7d_alloc_vol(that)
840 ! shouldn't we exit here with an empty volume if stat_proc/=0,1 ?
841 ALLOCATE(mask_time(SIZE(this%time)))
842 DO l = 1, SIZE(this%time)
843  mask_time(l) = any(this%time(l) == that%time(:))
844 ENDDO
845 ! create template for the output volume, keep all ana, level, network
846 ! and variables; copy only the timeranges already satisfying the
847 ! requested step, if any and only the times already existing in the
848 ! output
849 CALL vol7d_copy(this, v7dtmp, miss=.false., sort=.false., unique=.false., &
850  ltimerange=mask_timerange(:), ltime=mask_time(:))
851 ! merge output created so far with template
852 CALL vol7d_merge(that, v7dtmp, lanasimple=.true., llevelsimple=.true.)
853 DEALLOCATE(mask_time)
854 
855 ! compute statistical processing
856 IF (ASSOCIATED(this%voldatir)) THEN
857  DO l = 1, SIZE(this%time)
858  DO k = 1, nitr
859  DO j = 1, SIZE(this%time)
860  DO i = 1, nitr
861  IF (c_e(map_tr(i,j,k,l,1))) THEN
862  DO i6 = 1, SIZE(this%network)
863  DO i5 = 1, SIZE(this%dativar%r)
864  DO i3 = 1, SIZE(this%level)
865  DO i1 = 1, SIZE(this%ana)
866  IF (c_e(this%voldatir(i1,l,i3,f(k),i5,i6)) .AND. &
867  c_e(this%voldatir(i1,j,i3,f(i),i5,i6))) THEN
868 
869  IF (stat_proc == 0) THEN ! average
870  that%voldatir( &
871  i1,map_tr(i,j,k,l,1),i3,map_tr(i,j,k,l,2),i5,i6) = &
872  (this%voldatir(i1,l,i3,f(k),i5,i6)*this%timerange(f(k))%p2 - &
873  this%voldatir(i1,j,i3,f(i),i5,i6)*this%timerange(f(i))%p2)/ &
874  steps ! optimize avoiding conversions
875  ELSE IF (stat_proc == 1 .OR. stat_proc == 4) THEN ! acc, diff
876  that%voldatir( &
877  i1,map_tr(i,j,k,l,1),i3,map_tr(i,j,k,l,2),i5,i6) = &
878  this%voldatir(i1,l,i3,f(k),i5,i6) - &
879  this%voldatir(i1,j,i3,f(i),i5,i6)
880  ENDIF
881 
882  ENDIF
883  ENDDO
884  ENDDO
885  ENDDO
886  ENDDO
887  ENDIF
888  ENDDO
889  ENDDO
890  ENDDO
891  ENDDO
892 ENDIF
893 
894 IF (ASSOCIATED(this%voldatid)) THEN
895  DO l = 1, SIZE(this%time)
896  DO k = 1, nitr
897  DO j = 1, SIZE(this%time)
898  DO i = 1, nitr
899  IF (c_e(map_tr(i,j,k,l,1))) THEN
900  DO i6 = 1, SIZE(this%network)
901  DO i5 = 1, SIZE(this%dativar%d)
902  DO i3 = 1, SIZE(this%level)
903  DO i1 = 1, SIZE(this%ana)
904  IF (c_e(this%voldatid(i1,l,i3,f(k),i5,i6)) .AND. &
905  c_e(this%voldatid(i1,j,i3,f(i),i5,i6))) THEN
906 ! IF (.NOT.c_e(that%voldatid( &
907 ! i1,map_tr(i,j,k,l,1),i3,map_tr(i,j,k,l,2),i5,i6))) THEN
908 
909  IF (stat_proc == 0) THEN ! average
910  that%voldatid( &
911  i1,map_tr(i,j,k,l,1),i3,map_tr(i,j,k,l,2),i5,i6) = &
912  (this%voldatid(i1,l,i3,f(k),i5,i6)*this%timerange(f(k))%p2 - &
913  this%voldatid(i1,j,i3,f(i),i5,i6)*this%timerange(f(i))%p2)/ &
914  steps ! optimize avoiding conversions
915  ELSE IF (stat_proc == 1 .OR. stat_proc == 4) THEN ! acc, diff
916  that%voldatid( &
917  i1,map_tr(i,j,k,l,1),i3,map_tr(i,j,k,l,2),i5,i6) = &
918  this%voldatid(i1,l,i3,f(k),i5,i6) - &
919  this%voldatid(i1,j,i3,f(i),i5,i6)
920  ENDIF
921 
922 ! ENDIF
923  ENDIF
924  ENDDO
925  ENDDO
926  ENDDO
927  ENDDO
928  ENDIF
929  ENDDO
930  ENDDO
931  ENDDO
932  ENDDO
933 ENDIF
934 
Distruttori per le 2 classi.
Restituiscono il valore dell'oggetto nella forma desiderata.
Costruttori per le classi datetime e timedelta.

Generated with Doxygen.