202 FUNCTION flowdurationcurve(data, quantiles, mask, concavity_index, mid_segment_slope, mhigh_segment_volume, &
203 high_segment_volume, low_segment_volume)
205 use mo_percentile,
only : percentile
206 use mo_utils,
only : ge, le
211 real(dp),
dimension(:),
intent(in) :: data
214 real(dp),
dimension(:),
intent(in) :: quantiles
217 logical,
dimension(:),
optional,
intent(in) :: mask
220 real(dp),
optional,
intent(out) :: concavity_index
223 real(dp),
optional,
intent(out) :: mid_segment_slope
226 real(dp),
optional,
intent(out) :: mhigh_segment_volume
229 real(dp),
optional,
intent(out) :: high_segment_volume
232 real(dp),
optional,
intent(out) :: low_segment_volume
239 logical,
dimension(size(data, 1)) :: maske
242 real(dp) :: min_flow_value
245 real(dp) :: flow_value_thres
249 if (
present(mask))
then
255 flowdurationcurve = percentile(
data, (1._dp - quantiles) * 100._dp, mask = maske, mode_in = 5)
257 if (
present(concavity_index))
then
259 (percentile(
data, (1._dp - 0.10_dp) * 100._dp, mask = maske, mode_in = 5) - &
260 percentile(
data, (1._dp - 0.99_dp) * 100._dp, mask = maske, mode_in = 5)) / &
261 (percentile(
data, (1._dp - 0.01_dp) * 100._dp, mask = maske, mode_in = 5) - &
262 percentile(
data, (1._dp - 0.99_dp) * 100._dp, mask = maske, mode_in = 5))
265 if (
present(mid_segment_slope))
then
267 mid_segment_slope = &
268 log(percentile(
data, (1._dp - 0.2_dp) * 100._dp, mask = maske, mode_in = 5)) - &
269 log(percentile(
data, (1._dp - 0.7_dp) * 100._dp, mask = maske, mode_in = 5))
272 if (
present(mhigh_segment_volume))
then
275 flow_value_thres = percentile(
data, (1._dp - 0.2_dp) * 100._dp, mask = maske, mode_in = 5)
276 mhigh_segment_volume = sum(
data, mask = (maske .and. ge(
data, flow_value_thres)))
281 if (
present(high_segment_volume))
then
283 flow_value_thres = percentile(
data, (1._dp - 0.02_dp) * 100._dp, mask = maske, mode_in = 5)
284 high_segment_volume = sum(
data, mask = (maske .and. ge(
data, flow_value_thres)))
287 if (
present(low_segment_volume))
then
289 min_flow_value = minval(
data, mask = maske)
290 flow_value_thres = percentile(
data, (1._dp - 0.7) * 100._dp, mask = maske, mode_in = 5)
291 low_segment_volume = -1.0_dp * &
292 sum(log(data) - log(min_flow_value), mask = (maske .and. le(
data, flow_value_thres)))
347 real(dp),
dimension(:),
intent(in) :: data
350 logical,
dimension(size(data, 1)),
optional,
intent(in) :: mask
353 real(dp),
optional,
intent(out) :: rld
356 real(dp),
optional,
intent(out) :: dld
359 logical,
dimension(size(data, 1)) :: maske
365 integer(i4) :: n_peak
368 integer(i4) :: n_decline
371 integer(i4) :: n_rise
374 logical,
dimension(size(data, 1)) :: goes_up
377 real(dp) :: thres_rise
381 if (
present(mask))
then
387 if ((.not.
present(rld)) .and. (.not.
present(dld)))
then
388 call error_message(
'mo_signatures: limb_densities: Neither RLD or DLD is specified in calling sequence.')
398 do jj = 1,
size(
data, 1) - 1
399 if (maske(jj) .and. maske(jj + 1))
then
400 if (
data(jj) <
data(jj + 1) - thres_rise)
then
406 n_rise = count(goes_up)
407 n_decline = count(maske) - count(goes_up)
413 do jj = 1,
size(
data, 1) - 1
414 if (maske(jj) .and. maske(jj + 1))
then
415 if (goes_up(jj) .and. .not.(goes_up(jj + 1)))
then
416 n_peak = n_peak + 1_i4
452 if (
present(rld))
then
453 if (n_peak>0_i4)
then
454 rld = real(n_rise, dp) / real(n_peak, dp)
460 if (
present(dld))
then
461 if (n_peak>0_i4)
then
462 dld = real(n_decline, dp) / real(n_peak, dp)
513 use mo_julian,
only : date2dec, dec2date
518 real(dp),
dimension(:),
intent(in) :: data
521 logical,
dimension(size(data, 1)),
optional,
intent(in) :: mask
524 integer(i4),
optional,
intent(in) :: yr_start
527 integer(i4),
optional,
intent(in) :: mo_start
530 integer(i4),
optional,
intent(in) :: dy_start
535 logical,
dimension(size(data, 1)) :: maske
541 integer(i4) :: yr, mo, dy, imo
544 integer(i4),
dimension(12) :: counter
547 real(dp),
dimension(12) :: flow_month
550 real(dp) :: ref_jul_day
553 if (
present(mask))
then
559 if (.not.
present(yr_start))
then
560 call error_message(
'mo_signatures: MaximumMonthlyFlow: Year of of data point has to be given!')
565 if (
present(mo_start))
then
571 if (
present(dy_start))
then
579 ref_jul_day = date2dec(yy = yr, mm = mo, dd = dy) - 1.0_dp
581 do ii = 1,
size(
data, 1)
584 call dec2date(ref_jul_day + real(ii, dp), mm = imo)
586 counter(imo) = counter(imo) + 1
587 flow_month(imo) = flow_month(imo) +
data(ii)
591 if (any(counter == 0_i4))
then
592 call error_message(
'mo_signatures: MaximumMonthlyFlow: There are months with no data points!')
654 SUBROUTINE moments(data, mask, mean_data, stddev_data, median_data, max_data, mean_log, stddev_log, median_log, &
657 use mo_moment,
only : mean, stddev
658 use mo_percentile,
only : median
663 real(dp),
dimension(:),
intent(in) :: data
666 logical,
dimension(size(data, 1)),
optional,
intent(in) :: mask
669 real(dp),
optional,
intent(out) :: mean_data
672 real(dp),
optional,
intent(out) :: stddev_data
675 real(dp),
optional,
intent(out) :: median_data
678 real(dp),
optional,
intent(out) :: max_data
681 real(dp),
optional,
intent(out) :: mean_log
684 real(dp),
optional,
intent(out) :: stddev_log
687 real(dp),
optional,
intent(out) :: median_log
690 real(dp),
optional,
intent(out) :: max_log
692 logical,
dimension(size(data, 1)) :: maske
694 real(dp),
dimension(size(data, 1)) :: logdata
697 if (
present(mask))
then
703 if (.not.(
present(mean_data)) .and. .not.(
present(stddev_data)) .and. &
704 .not.(
present(median_data)) .and. .not.(
present(max_data)) .and. &
705 .not.(
present(mean_log)) .and. .not.(
present(stddev_log)) .and. &
706 .not.(
present(median_log)) .and. .not.(
present(max_log)))
then
707 call error_message(
'mo_signatures: Moments: None of the optional output arguments is specified')
710 if (
present(mean_data)) mean_data = mean(
data, mask = maske)
711 if (
present(stddev_data)) stddev_data = stddev(
data, mask = maske)
712 if (
present(median_data)) median_data = median(
data, mask = maske)
713 if (
present(max_data)) max_data = maxval(
data, mask = maske)
715 if (
present(mean_log) .or.
present(stddev_log))
then
716 where (
data > 0.0_dp)
723 if (
present(mean_log)) mean_log = mean(logdata, mask = maske)
724 if (
present(stddev_log)) stddev_log = stddev(logdata, mask = maske)
725 if (
present(median_log)) median_log = median(logdata, mask = maske)
726 if (
present(max_log)) max_log = maxval(logdata, mask = maske)
782 use mo_percentile,
only : percentile
787 real(dp),
dimension(:),
intent(in) :: data
790 real(dp),
dimension(:),
intent(in) :: quantiles
793 logical,
dimension(size(data, 1)),
optional,
intent(in) :: mask
796 real(dp),
optional,
intent(out) :: slope_peak_distribution
804 integer(i4) :: ii, jj
807 logical,
dimension(size(data, 1)) :: maske
810 integer(i4) :: n_peak
813 real(dp),
dimension(2) :: pp
816 real(dp),
dimension(2) :: data_pp
819 real(dp),
allocatable,
dimension(:) :: data_peak
823 if (
present(mask))
then
831 do jj = 2,
size(
data, 1) - 1
832 if (maske(jj - 1) .and. maske(jj) .and. maske(jj + 1))
then
833 if ((
data(jj - 1) .le.
data(jj)) .and. (
data(jj + 1) .le.
data(jj)))
then
834 n_peak = n_peak + 1_i4
839 allocate(data_peak(n_peak))
843 do ii = 2,
size(
data, 1) - 1
844 if (maske(ii - 1) .and. maske(ii) .and. maske(ii + 1))
then
845 if((
data(ii - 1) .le.
data(ii)) .and. (
data(ii + 1) .le.
data(ii)))
then
847 data_peak(jj) =
data(ii)
852 if (
present(slope_peak_distribution))
then
854 pp = (/ 0.1_dp, 0.5_dp /)
855 data_pp = percentile(data_peak, (1.0_dp - pp) * 100._dp, mode_in = 5)
856 slope_peak_distribution = (data_pp(1) - data_pp(2)) / (0.9_dp - 0.5_dp)
859 peakdistribution = percentile(data_peak, (1.0_dp - quantiles) * 100._dp, mode_in = 5)
860 deallocate(data_peak)
917 FUNCTION runoffratio(data, domain_area, mask, precip_series, precip_sum, log_data)
922 real(dp),
dimension(:),
intent(in) :: data
925 real(dp),
intent(in) :: domain_area
928 logical,
dimension(size(data, 1)),
optional,
intent(in) :: mask
931 real(dp),
dimension(size(data, 1)),
optional,
intent(in) :: precip_series
934 real(dp),
optional,
intent(in) :: precip_sum
937 logical,
optional,
intent(in) :: log_data
943 logical,
dimension(size(data, 1)) :: maske
948 real(dp) :: sum_discharge
950 real(dp) :: sum_precip
954 if (
present(mask))
then
960 if (
present(log_data))
then
966 if ((
present(precip_series) .and.
present(precip_sum)) .or. &
967 (.not.
present(precip_series) .and. .not.
present(precip_sum)))
then
968 call error_message(
'mo_signatures: RunoffRatio: Exactly one precipitation information', raise=.false.)
969 call error_message(
' (precipitation series or sum of precipitation) ', raise=.false.)
970 call error_message(
' has to be specified!')
973 if (
present(mask) .and.
present(precip_sum))
then
974 call error_message(
'mo_signatures: RunoffRatio: Already aggregated precipitation (precip_sum) and', raise=.false.)
975 call error_message(
' mask can not be used together.', raise=.false.)
976 call error_message(
' Precip_series should be used instead!')
986 sum_discharge = sum(log(data) * 86.4_dp / domain_area, mask = maske)
988 sum_discharge = sum(
data * 86.4_dp / domain_area, mask = maske)
991 if (
present(precip_sum))
then
992 sum_precip = precip_sum
994 sum_precip = sum(precip_series, mask = maske)
real(dp) function, public runoffratio(data, domain_area, mask, precip_series, precip_sum, log_data)
Runoff ratio (accumulated daily discharge [mm/d] / accumulated daily precipitation [mm/d]).
real(dp) function, dimension(size(quantiles, 1)), public peakdistribution(data, quantiles, mask, slope_peak_distribution)
Calculates the peak distribution.
subroutine, public moments(data, mask, mean_data, stddev_data, median_data, max_data, mean_log, stddev_log, median_log, max_log)
Moments of data and log-transformed data, e.g.
real(dp) function, dimension(size(lags, 1)), public autocorrelation(data, lags, mask)
Autocorrelation of a given data series.
real(dp) function, dimension(size(quantiles, 1)), public flowdurationcurve(data, quantiles, mask, concavity_index, mid_segment_slope, mhigh_segment_volume, high_segment_volume, low_segment_volume)
Flow duration curves.