libsim  Versione7.2.1

◆ volgrid6d_recompute_stat_proc_agg()

subroutine volgrid6d_class_compute::volgrid6d_recompute_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,
real, intent(in), optional  frac_valid,
logical, intent(in), optional  clone,
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.

The output that volgrid6d object contains elements from the original volume this satisfying the conditions

  • 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
  • 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 explicitely by the optional argument start. Be warned that, in the final volume, the first reference time will actually be start + step, since start indicates the beginning of first processing interval, while reference time (for analysis/oservation) is the end of the interval.

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]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]frac_validminimum fraction of valid data required for considering acceptable a recomputed value, default=1.
[in]cloneif provided and .TRUE. , clone the gaid's from this to that
[in]stat_proc_inputto 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 431 del file volgrid6d_class_compute.F90.

431 CALL init(that)
432 ! be safe
433 CALL volgrid6d_alloc_vol(this)
434 
435 ! when volume is not decoded it is better to clone anyway to avoid
436 ! overwriting fields
437 lclone = optio_log(clone) .OR. .NOT.ASSOCIATED(this%voldati)
438 ! initialise the output volume
439 CALL init(that, griddim=this%griddim, time_definition=this%time_definition)
440 CALL volgrid6d_alloc(that, dim=this%griddim%dim, ntimerange=1, &
441  nlevel=SIZE(this%level), nvar=SIZE(this%var), ini=.false.)
442 that%level = this%level
443 that%var = this%var
444 
445 CALL recompute_stat_proc_agg_common(this%time, this%timerange, stat_proc, tri, &
446  step, this%time_definition, that%time, that%timerange, map_ttr, &
447  start=start, full_steps=full_steps)
448 
449 CALL volgrid6d_alloc_vol(that, decode=ASSOCIATED(this%voldati))
450 
451 do_otimerange: DO j = 1, SIZE(that%timerange)
452  do_otime: DO i = 1, SIZE(that%time)
453  ninp = map_ttr(i,j)%arraysize
454  IF (ninp <= 0) cycle do_otime
455 
456  IF (stat_proc == 4) THEN ! check validity for difference
457  IF (map_ttr(i,j)%array(1)%extra_info /= 1 .OR. &
458  map_ttr(i,j)%array(ninp)%extra_info /= 2) THEN
459  CALL delete(map_ttr(i,j))
460  cycle do_otime
461  ENDIF
462  ELSE
463 ! check validity condition (missing values in volume are not accounted for)
464  DO n = 2, ninp
465  IF (map_ttr(i,j)%array(n)%time - map_ttr(i,j)%array(n-1)%time > &
466  lmax_step) THEN
467  CALL delete(map_ttr(i,j))
468  cycle do_otime
469  ENDIF
470  ENDDO
471  ENDIF
472 
473  DO i6 = 1, SIZE(this%var)
474  DO i3 = 1, SIZE(this%level)
475  CALL volgrid_get_vol_2d(that, i3, i, j, i6, voldatiout)
476 
477  IF (stat_proc == 4) THEN ! special treatment for difference
478  IF (lclone) THEN
479  CALL copy(this%gaid(i3, map_ttr(i,j)%array(1)%it,&
480  map_ttr(i,j)%array(1)%itr,i6), that%gaid(i3,i,j,i6))
481  ELSE
482  that%gaid(i3,i,j,i6) = this%gaid(i3, map_ttr(i,j)%array(1)%it, &
483  map_ttr(i,j)%array(1)%itr,i6)
484  ENDIF
485 ! improve the next workflow?
486  CALL volgrid_get_vol_2d(this, i3, map_ttr(i,j)%array(ninp)%it, &
487  map_ttr(i,j)%array(ninp)%itr, i6, voldatiin)
488  voldatiout = voldatiin
489  CALL volgrid_get_vol_2d(this, i3, map_ttr(i,j)%array(1)%it, &
490  map_ttr(i,j)%array(1)%itr, i6, voldatiin)
491 
492  WHERE(c_e(voldatiin(:,:)) .AND. c_e(voldatiout(:,:)))
493  voldatiout(:,:) = voldatiout(:,:) - voldatiin(:,:)
494  ELSEWHERE
495  voldatiout(:,:) = rmiss
496  END WHERE
497 
498  ELSE ! other stat_proc
499  DO n = 1, ninp
500  CALL volgrid_get_vol_2d(this, i3, map_ttr(i,j)%array(n)%it, &
501  map_ttr(i,j)%array(n)%itr, i6, voldatiin)
502 
503  IF (n == 1) THEN
504  voldatiout = voldatiin
505  IF (lclone) THEN
506  CALL copy(this%gaid(i3, map_ttr(i,j)%array(n)%it,&
507  map_ttr(i,j)%array(n)%itr,i6), that%gaid(i3,i,j,i6))
508  ELSE
509  that%gaid(i3,i,j,i6) = this%gaid(i3, map_ttr(i,j)%array(n)%it, &
510  map_ttr(i,j)%array(n)%itr,i6)
511  ENDIF
512 
513  ELSE ! second or more time
514  SELECT CASE(stat_proc)
515  CASE (0, 1) ! average, accumulation
516  WHERE(c_e(voldatiin(:,:)) .AND. c_e(voldatiout(:,:)))
517  voldatiout(:,:) = voldatiout(:,:) + voldatiin(:,:)
518  ELSEWHERE
519  voldatiout(:,:) = rmiss
520  END WHERE
521  CASE(2) ! maximum
522  WHERE(c_e(voldatiin(:,:)) .AND. c_e(voldatiout(:,:)))
523  voldatiout(:,:) = max(voldatiout(:,:), voldatiin(:,:))
524  ELSEWHERE
525  voldatiout(:,:) = rmiss
526  END WHERE
527  CASE(3) ! minimum
528  WHERE(c_e(voldatiin(:,:)) .AND. c_e(voldatiout(:,:)))
529  voldatiout(:,:) = min(voldatiout(:,:), voldatiin(:,:))
530  ELSEWHERE
531  voldatiout(:,:) = rmiss
532  END WHERE
533  END SELECT
534 
535  ENDIF ! first time
536  ENDDO
537  IF (stat_proc == 0) THEN ! average
538  WHERE(c_e(voldatiout(:,:)))
539  voldatiout(:,:) = voldatiout(:,:)/ninp
540  END WHERE
541  ENDIF
542  ENDIF
543  CALL volgrid_set_vol_2d(that, i3, i, j, i6, voldatiout)
544  ENDDO ! level
545  ENDDO ! var
546  CALL delete(map_ttr(i,j))
547  ENDDO do_otime
548 ENDDO do_otimerange
549 
550 DEALLOCATE(map_ttr)
551 
552 
553 END SUBROUTINE volgrid6d_compute_stat_proc_agg
554 
555 

Generated with Doxygen.