|
◆ vol7d_recompute_stat_proc_agg()
subroutine vol7d_class_compute::vol7d_recompute_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, |
|
|
real, intent(in), optional |
frac_valid, |
|
|
type(vol7d), intent(inout), optional |
other, |
|
|
integer, intent(in), optional |
stat_proc_input |
|
) |
| |
Specialized method for statistically processing a set of data already processed with the same statistical processing, on a different time interval.
This method performs statistical processing by aggregation of shorter intervals. 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
- real single or double precision variables
- timerange (vol7d_timerange_class::vol7d_timerange::timerange) of type stat_proc (or stat_proc_input if provided)
- any p1 (analysis/observation or forecast)
- p2 > 0 (processing interval non null, non instantaneous data) and equal to a multiplier of step
Output data will have timerange of type stat_proc and p2 = step. The supported statistical processing methods (parameter stat_proc) are:
- 0 average
- 1 accumulation
- 2 maximum
- 3 minimum
- 4 difference
- 6 standard deviation
- 200 vectorial mean
The start of processing period can be computed automatically from the input intervals as the first possible interval modulo step, or, for a better control, it can be specified explicitly by the optional argument start. Notice that start indicates the beginning of the processing interval, so in the final volume, the first datum may have time equal to start + step, e.g. in the case when time is the verification time, which is typical for observed datasets.
The purpose of the optional argument stat_proc_input is to allow processing with a certain statistical processing operator a dataset already processed with a different operator, by specifying the latter as stat_proc_input; this is useful, for example, if one wants to compute the monthly average of daily maximum temperatures; however this has to be used with care since the resulting data volume will not carry all the information about the processing which has been done, in the previous case, for example, the temperatures will simply look like monthly average temperatures. - Parametri
-
[in,out] | this | volume providing data to be recomputed, it is not modified by the method, apart from performing a vol7d_alloc_vol on it |
[out] | that | output volume which will contain the recomputed data |
[in] | stat_proc | type 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] | step | length of the step over which the statistical processing is performed |
[in] | start | start of statistical processing interval |
[in] | full_steps | if .TRUE. and start is not provided, apply processing only on intervals starting at a forecast time or a reference time modulo step |
[in] | frac_valid | minimum fraction of valid data required for considering acceptable a recomputed value, default=1. |
[in,out] | other | optional volume that, on exit, is going to contain the data that did not contribute to the statistical processing |
[in] | stat_proc_input | to be used with care, type of statistical processing of data that has to be processed (from grib2 table), only data having timerange of this type will be recomputed, the actual statistical processing performed and which will appear in the output volume, is however determined by stat_proc argument |
Definizione alla linea 439 del file vol7d_class_compute.F90.
441 SUBROUTINE makeother()
442 IF ( PRESENT(other)) THEN
443 CALL vol7d_copy(this, other, miss=.false., sort=.false., unique=.false., &
444 ltimerange=(this%timerange(:)%timerange /= tri .OR. this%timerange(:)%p2 == imiss &
445 .OR. this%timerange(:)%p2 == 0))
447 END SUBROUTINE makeother
449 END SUBROUTINE vol7d_recompute_stat_proc_agg
483 SUBROUTINE vol7d_compute_stat_proc_agg(this, that, stat_proc, &
484 step, start, full_steps, max_step, weighted, other)
485 TYPE(vol7d), INTENT(inout) :: this
486 TYPE(vol7d), INTENT(out) :: that
487 INTEGER, INTENT(in) :: stat_proc
488 TYPE(timedelta), INTENT(in) :: step
489 TYPE(datetime), INTENT(in), OPTIONAL :: start
490 LOGICAL, INTENT(in), OPTIONAL :: full_steps
491 TYPE(timedelta), INTENT(in), OPTIONAL :: max_step
492 LOGICAL, INTENT(in), OPTIONAL :: weighted
493 TYPE(vol7d), INTENT(inout), OPTIONAL :: other
496 TYPE(vol7d) :: v7dtmp
498 INTEGER :: i, j, n, ninp, ndtr, i1, i3, i5, i6, vartype, maxsize
499 TYPE(timedelta) :: lmax_step, act_max_step
500 TYPE(datetime) :: pstart, pend, reftime
501 TYPE(arrayof_ttr_mapper), POINTER :: map_ttr(:,:)
502 REAL, ALLOCATABLE :: tmpvolr(:)
503 DOUBLE PRECISION, ALLOCATABLE :: tmpvold(:), weights(:)
504 LOGICAL, ALLOCATABLE :: lin_mask(:)
506 CHARACTER(len=8) :: env_var
508 IF ( PRESENT(max_step)) THEN
511 lmax_step = timedelta_max
513 lweighted = optio_log(weighted)
517 CALL getenv( 'LIBSIM_CLIMAT_BEHAVIOR', env_var)
518 lweighted = lweighted .AND. len_trim(env_var) == 0
520 lweighted = lweighted .AND. stat_proc == 0
523 CALL vol7d_alloc_vol(this)
527 CALL vol7d_smart_sort(this, lsort_time=.true.)
528 CALL vol7d_reform(this, miss=.false., sort=.false., unique=.true.)
530 CALL vol7d_copy(this, v7dtmp, ltime=(/.false./), ltimerange=(/.false./))
533 CALL init(that, time_definition=this%time_definition)
535 CALL recompute_stat_proc_agg_common(this%time, this%timerange, stat_proc, tri, &
536 step, this%time_definition, that%time, that%timerange, map_ttr, start=start, &
537 full_steps=full_steps)
539 CALL vol7d_merge(that, v7dtmp)
541 maxsize = maxval(map_ttr(:,:)%arraysize)
542 ALLOCATE(tmpvolr(maxsize), tmpvold(maxsize), lin_mask(maxsize), weights(maxsize))
543 do_otimerange: DO j = 1, SIZE(that%timerange)
544 do_otime: DO i = 1, SIZE(that%time)
545 ninp = map_ttr(i,j)%arraysize
546 IF (ninp <= 0) cycle do_otime
548 CALL time_timerange_get_period(that%time(i), that%timerange(j), &
549 that%time_definition, pstart, pend, reftime)
551 IF ( ASSOCIATED(this%voldatir)) THEN
552 DO i1 = 1, SIZE(this%ana)
553 DO i3 = 1, SIZE(this%level)
554 DO i6 = 1, SIZE(this%network)
555 DO i5 = 1, SIZE(this%dativar%r)
557 IF (stat_proc == 4) THEN
559 IF (map_ttr(i,j)%array(1)%extra_info == 1 .AND. &
560 map_ttr(i,j)%array(ninp)%extra_info == 2) THEN
561 IF (c_e(this%voldatir(i1,map_ttr(i,j)%array(1)%it,i3, &
562 map_ttr(i,j)%array(1)%itr,i5,i6)) .AND. &
563 c_e(this%voldatir(i1,map_ttr(i,j)%array(ninp)%it,i3, &
564 map_ttr(i,j)%array(ninp)%itr,i5,i6))) THEN
565 that%voldatir(i1,i,i3,j,i5,i6) = &
566 this%voldatir(i1,map_ttr(i,j)%array(ninp)%it,i3, &
567 map_ttr(i,j)%array(ninp)%itr,i5,i6) - &
568 this%voldatir(i1,map_ttr(i,j)%array(1)%it,i3, &
569 map_ttr(i,j)%array(1)%itr,i5,i6)
576 vartype = vol7d_vartype(this%dativar%r(i5))
580 IF (c_e(this%voldatir(i1,map_ttr(i,j)%array(n)%it,i3, &
581 map_ttr(i,j)%array(n)%itr,i5,i6))) THEN
583 tmpvolr(ndtr) = this%voldatir(i1,map_ttr(i,j)%array(n)%it,i3, &
584 map_ttr(i,j)%array(n)%itr,i5,i6)
590 CALL compute_stat_proc_agg_sw(map_ttr(i,j)%array(1:ninp)%time, &
591 pstart, pend, lin_mask(1:ninp), act_max_step, weights)
593 CALL compute_stat_proc_agg_sw(map_ttr(i,j)%array(1:ninp)%time, &
594 pstart, pend, lin_mask(1:ninp), act_max_step)
596 IF (act_max_step > lmax_step) cycle
598 SELECT CASE(stat_proc)
601 that%voldatir(i1,i,i3,j,i5,i6) = &
602 sum(real(weights(1:ndtr))*tmpvolr(1:ndtr))
604 that%voldatir(i1,i,i3,j,i5,i6) = &
605 sum(tmpvolr(1:ndtr))/ndtr
608 that%voldatir(i1,i,i3,j,i5,i6) = &
609 maxval(tmpvolr(1:ndtr))
611 that%voldatir(i1,i,i3,j,i5,i6) = &
612 minval(tmpvolr(1:ndtr))
614 that%voldatir(i1,i,i3,j,i5,i6) = &
615 stat_stddev(tmpvolr(1:ndtr))
618 IF (vartype == var_dir360) THEN
621 WHERE (tmpvolr(1:ndtr) == 0.0)
622 tmpvolr(1:ndtr) = rmiss
623 ELSE WHERE (tmpvolr(1:ndtr) < 22.5 .AND. tmpvolr(1:ndtr) > 0.0)
624 tmpvolr(1:ndtr) = tmpvolr(1:ndtr) + 360.
626 that%voldatir(i1,i,i3,j,i5,i6) = &
627 stat_mode_histogram(tmpvolr(1:ndtr), &
637 IF ( ASSOCIATED(this%voldatid)) THEN
638 DO i1 = 1, SIZE(this%ana)
639 DO i3 = 1, SIZE(this%level)
640 DO i6 = 1, SIZE(this%network)
641 DO i5 = 1, SIZE(this%dativar%d)
|