libsim Versione 7.2.4
|
◆ volgrid6d_recompute_stat_proc_agg()
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
Output data will have timerange of type stat_proc and p2 = step. The supported statistical processing methods (parameter stat_proc) are:
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.
Definizione alla linea 419 del file volgrid6d_class_compute.F90. 421
422
423NULLIFY(voldatiin, voldatiout)
424tri = 254
425IF (PRESENT(max_step)) THEN
426 lmax_step = max_step
427ELSE
428 lmax_step = timedelta_max
429ENDIF
430
431CALL init(that)
432! be safe
433CALL volgrid6d_alloc_vol(this)
434
435! when volume is not decoded it is better to clone anyway to avoid
436! overwriting fields
437lclone = optio_log(clone) .OR. .NOT.ASSOCIATED(this%voldati)
438! initialise the output volume
439CALL init(that, griddim=this%griddim, time_definition=this%time_definition)
440CALL volgrid6d_alloc(that, dim=this%griddim%dim, ntimerange=1, &
441 nlevel=SIZE(this%level), nvar=SIZE(this%var), ini=.false.)
442that%level = this%level
443that%var = this%var
444
445CALL 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
449CALL volgrid6d_alloc_vol(that, decode=ASSOCIATED(this%voldati))
450
451do_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
548ENDDO do_otimerange
549
550DEALLOCATE(map_ttr)
551
552
553END SUBROUTINE volgrid6d_compute_stat_proc_agg
554
555
|