libsim  Versione 7.1.8

◆ 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 
)

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

Definizione alla linea 420 del file volgrid6d_class_compute.F90.

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

Generated with Doxygen.