Class TimeSeriesFunctions

java.lang.Object
hec.hecmath.functions.TimeSeriesFunctions
All Implemented Interfaces:
Constants

public class TimeSeriesFunctions extends Object implements Constants
  • Field Details

    • validTimeSeriesTypes

      public static Set<String> validTimeSeriesTypes
    • instTimeSeriesTypes

      public static Set<String> instTimeSeriesTypes
    • periodTimeSeriesTypes

      public static Set<String> periodTimeSeriesTypes
    • totalTimeSeriesTypes

      public static Set<String> totalTimeSeriesTypes
    • averageTimeSeriesTypes

      public static Set<String> averageTimeSeriesTypes
    • dssTimeSeriesTypes

      public static Set<String> dssTimeSeriesTypes
    • cwmsTimeSeriesTypes

      public static Set<String> cwmsTimeSeriesTypes
  • Constructor Details

    • TimeSeriesFunctions

      public TimeSeriesFunctions()
  • Method Details

    • parseTimeIntervalString

      public static int parseTimeIntervalString(String timeIntervalStr) throws ComputationException
      Throws:
      ComputationException
    • setAlwaysAllowUnsafe

      public static boolean setAlwaysAllowUnsafe(boolean state)
    • setAlwaysWarnUnsafe

      public static boolean setAlwaysWarnUnsafe(boolean state)
    • setAlwaysCreateQuality

      public static boolean setAlwaysCreateQuality(boolean state)
    • validateTimeSeriesContainer

      public static void validateTimeSeriesContainer(TimeSeriesContainer tsc) throws ComputationException
      Throws:
      ComputationException
    • validateIndex

      public static void validateIndex(TimeSeriesContainer tsc, int index) throws ComputationException
      Throws:
      ComputationException
    • isRegular

      public static boolean isRegular(TimeSeriesContainer tsc)
    • isIregular

      public static boolean isIregular(TimeSeriesContainer tsc)
    • collectValidValues

      public static List<ValueContainer> collectValidValues(TimeSeriesContainer tsc)
    • isValid

      public static boolean isValid(TimeSeriesContainer tsc, int index)
      Determine if the data value in tsc is valid (not missing, rejected, or undefined) for the index location index.

      Parameters:
      tsc - a TimeSeriesContainer.
      index - the array index of the value of interest.
      Returns:
      true if the value is valid (not missing or undefined).
      Throws:
      ComputationException
    • isMissing

      protected static boolean isMissing(TimeSeriesContainer tsc, int index)
      Determine if the data value in tsc is missing (missing quality or undefined value) for the index location index.

      Parameters:
      tsc - a TimeSeriesContainer.
      index - the array index of the value of interest.
      Returns:
      true if the value is valid (not missing or undefined).
      Throws:
      ComputationException
    • bisearch

      public static int bisearch(int[] xarray, int x, int n)
      binary search with upper limit
      Parameters:
      xarray - the array to find the position in
      x - the item to find the position for
      n - the upper limit in the array
      Returns:
      the position
    • bisearch

      public static int bisearch(double[] xarray, double x, int n)
      binary search with upper limit
      Parameters:
      xarray - the array to find the position in
      x - the item to find the position for
      n - the upper limit in the array
      Returns:
      the position
    • findInterval

      public static int findInterval(int[] times, int time, int lastIndex)
      Find interval times array in which "time" lies in and return the index position of the first point. times[idx] <= time < times[idx+1]
    • findValidValue

      public static int findValidValue(TimeSeriesContainer tsc, int index, boolean lookAfter)
      find the first valid value index before or after a specified index
      Parameters:
      tsc - the TimeSeriesContainer to check
      index - the index to look before or after
      lookAfter - whether to look after
      Returns:
      the first valid value index
    • integrate

      public static double integrate(TimeSeriesContainer tsc, int time0, int time1, String dataType, int functionType, double missingAllowed, intContainer lastIndex, doubleContainer sumTime)
      integrate or accumulate tsc over the interval time0 to time1
    • intervalStats

      public static double intervalStats(int functionType, TimeSeriesContainer tsc, int time0, int time1, int interval, String dataType, double missingAllowed, intContainer lastIndex, intContainer timeOfOccurrence)
      Compute max, min and count between time0 and time1 for time series transform. Return value for the appropriate function specified by functionType.
    • add

      Throws:
      ComputationException
    • add

      public static TimeSeriesContainer add(List<ValueContainer> vcl, String c) throws ComputationException
      Throws:
      ComputationException
    • subtract

      public static TimeSeriesContainer subtract(List<ValueContainer> vcl, Condition c) throws ComputationException
      Throws:
      ComputationException
    • subtract

      public static TimeSeriesContainer subtract(List<ValueContainer> vcl, String c) throws ComputationException
      Throws:
      ComputationException
    • multiply

      public static TimeSeriesContainer multiply(List<ValueContainer> vcl, Condition c) throws ComputationException
      Throws:
      ComputationException
    • multiply

      public static TimeSeriesContainer multiply(List<ValueContainer> vcl, String c) throws ComputationException
      Throws:
      ComputationException
    • divide

      public static TimeSeriesContainer divide(List<ValueContainer> vcl, Condition c) throws ComputationException
      Throws:
      ComputationException
    • divide

      public static TimeSeriesContainer divide(List<ValueContainer> vcl, String c) throws ComputationException
      Throws:
      ComputationException
    • integer_divide

      public static TimeSeriesContainer integer_divide(List<ValueContainer> vcl, Condition c) throws ComputationException
      Throws:
      ComputationException
    • integer_divide

      public static TimeSeriesContainer integer_divide(List<ValueContainer> vcl, String c) throws ComputationException
      Throws:
      ComputationException
    • modulo

      public static TimeSeriesContainer modulo(List<ValueContainer> vcl, Condition c) throws ComputationException
      Throws:
      ComputationException
    • modulo

      public static TimeSeriesContainer modulo(List<ValueContainer> vcl, String c) throws ComputationException
      Throws:
      ComputationException
    • exponentiation

      public static TimeSeriesContainer exponentiation(List<ValueContainer> vcl, Condition c) throws ComputationException
      Throws:
      ComputationException
    • exponentiation

      public static TimeSeriesContainer exponentiation(List<ValueContainer> vcl, String c) throws ComputationException
      Throws:
      ComputationException
    • abs

      Throws:
      ComputationException
    • abs

      public static TimeSeriesContainer abs(List<ValueContainer> vcl, String c) throws ComputationException
      Throws:
      ComputationException
    • neg

      Throws:
      ComputationException
    • neg

      public static TimeSeriesContainer neg(List<ValueContainer> vcl, String c) throws ComputationException
      Throws:
      ComputationException
    • inverse

      public static TimeSeriesContainer inverse(List<ValueContainer> vcl, Condition c) throws ComputationException
      Throws:
      ComputationException
    • inverse

      public static TimeSeriesContainer inverse(List<ValueContainer> vcl, String c) throws ComputationException
      Throws:
      ComputationException
    • sign

      Throws:
      ComputationException
    • sign

      public static TimeSeriesContainer sign(List<ValueContainer> vcl, String c) throws ComputationException
      Throws:
      ComputationException
    • sqrt

      Throws:
      ComputationException
    • sqrt

      public static TimeSeriesContainer sqrt(List<ValueContainer> vcl, String c) throws ComputationException
      Throws:
      ComputationException
    • exp

      Throws:
      ComputationException
    • exp

      public static TimeSeriesContainer exp(List<ValueContainer> vcl, String c) throws ComputationException
      Throws:
      ComputationException
    • log

      Throws:
      ComputationException
    • log

      public static TimeSeriesContainer log(List<ValueContainer> vcl, String c) throws ComputationException
      Throws:
      ComputationException
    • log10

      public static TimeSeriesContainer log10(List<ValueContainer> vcl, Condition c) throws ComputationException
      Throws:
      ComputationException
    • log10

      public static TimeSeriesContainer log10(List<ValueContainer> vcl, String c) throws ComputationException
      Throws:
      ComputationException
    • sin

      Throws:
      ComputationException
    • sin

      public static TimeSeriesContainer sin(List<ValueContainer> vcl, String c) throws ComputationException
      Throws:
      ComputationException
    • cos

      Throws:
      ComputationException
    • cos

      public static TimeSeriesContainer cos(List<ValueContainer> vcl, String c) throws ComputationException
      Throws:
      ComputationException
    • tan

      Throws:
      ComputationException
    • tan

      public static TimeSeriesContainer tan(List<ValueContainer> vcl, String c) throws ComputationException
      Throws:
      ComputationException
    • asin

      Throws:
      ComputationException
    • asin

      public static TimeSeriesContainer asin(List<ValueContainer> vcl, String c) throws ComputationException
      Throws:
      ComputationException
    • acos

      Throws:
      ComputationException
    • acos

      public static TimeSeriesContainer acos(List<ValueContainer> vcl, String c) throws ComputationException
      Throws:
      ComputationException
    • atan

      Throws:
      ComputationException
    • atan

      public static TimeSeriesContainer atan(List<ValueContainer> vcl, String c) throws ComputationException
      Throws:
      ComputationException
    • floor

      public static TimeSeriesContainer floor(List<ValueContainer> vcl, Condition c) throws ComputationException
      Throws:
      ComputationException
    • floor

      public static TimeSeriesContainer floor(List<ValueContainer> vcl, String c) throws ComputationException
      Throws:
      ComputationException
    • ceil

      Throws:
      ComputationException
    • ceil

      public static TimeSeriesContainer ceil(List<ValueContainer> vcl, String c) throws ComputationException
      Throws:
      ComputationException
    • round

      public static TimeSeriesContainer round(List<ValueContainer> vcl, Condition c) throws ComputationException
      Throws:
      ComputationException
    • round

      public static TimeSeriesContainer round(List<ValueContainer> vcl, String c) throws ComputationException
      Throws:
      ComputationException
    • truncate

      public static TimeSeriesContainer truncate(List<ValueContainer> vcl, Condition c) throws ComputationException
      Throws:
      ComputationException
    • truncate

      public static TimeSeriesContainer truncate(List<ValueContainer> vcl, String c) throws ComputationException
      Throws:
      ComputationException
    • fmod

      Throws:
      ComputationException
    • fmod

      public static TimeSeriesContainer fmod(List<ValueContainer> vcl, String c) throws ComputationException
      Throws:
      ComputationException
    • sum

      Throws:
      ComputationException
    • sum

      public static TimeSeriesContainer sum(List<ValueContainer> vcl, String c) throws ComputationException
      Throws:
      ComputationException
    • product

      public static TimeSeriesContainer product(List<ValueContainer> vcl, Condition c) throws ComputationException
      Throws:
      ComputationException
    • product

      public static TimeSeriesContainer product(List<ValueContainer> vcl, String c) throws ComputationException
      Throws:
      ComputationException
    • max

      Throws:
      ComputationException
    • max

      public static TimeSeriesContainer max(List<ValueContainer> vcl, String c) throws ComputationException
      Throws:
      ComputationException
    • min

      Throws:
      ComputationException
    • min

      public static TimeSeriesContainer min(List<ValueContainer> vcl, String c) throws ComputationException
      Throws:
      ComputationException
    • mean

      Throws:
      ComputationException
    • mean

      public static TimeSeriesContainer mean(List<ValueContainer> vcl, String c) throws ComputationException
      Throws:
      ComputationException
    • gmean

      public static TimeSeriesContainer gmean(List<ValueContainer> vcl, Condition c) throws ComputationException
      Throws:
      ComputationException
    • gmean

      public static TimeSeriesContainer gmean(List<ValueContainer> vcl, String c) throws ComputationException
      Throws:
      ComputationException
    • hmean

      public static TimeSeriesContainer hmean(List<ValueContainer> vcl, Condition c) throws ComputationException
      Throws:
      ComputationException
    • hmean

      public static TimeSeriesContainer hmean(List<ValueContainer> vcl, String c) throws ComputationException
      Throws:
      ComputationException
    • rms

      Throws:
      ComputationException
    • rms

      public static TimeSeriesContainer rms(List<ValueContainer> vcl, String c) throws ComputationException
      Throws:
      ComputationException
    • stdev

      public static TimeSeriesContainer stdev(List<ValueContainer> vcl, Condition c) throws ComputationException
      Throws:
      ComputationException
    • stdev

      public static TimeSeriesContainer stdev(List<ValueContainer> vcl, String c) throws ComputationException
      Throws:
      ComputationException
    • var

      Throws:
      ComputationException
    • var

      public static TimeSeriesContainer var(List<ValueContainer> vcl, String c) throws ComputationException
      Throws:
      ComputationException
    • med

      Throws:
      ComputationException
    • med

      public static TimeSeriesContainer med(List<ValueContainer> vcl, String c) throws ComputationException
      Throws:
      ComputationException
    • p1

      Throws:
      ComputationException
    • p1

      Throws:
      ComputationException
    • p2

      Throws:
      ComputationException
    • p2

      Throws:
      ComputationException
    • p5

      Throws:
      ComputationException
    • p5

      Throws:
      ComputationException
    • p10

      Throws:
      ComputationException
    • p10

      public static TimeSeriesContainer p10(List<ValueContainer> vcl, String c) throws ComputationException
      Throws:
      ComputationException
    • p20

      Throws:
      ComputationException
    • p20

      public static TimeSeriesContainer p20(List<ValueContainer> vcl, String c) throws ComputationException
      Throws:
      ComputationException
    • p25

      Throws:
      ComputationException
    • p25

      public static TimeSeriesContainer p25(List<ValueContainer> vcl, String c) throws ComputationException
      Throws:
      ComputationException
    • p75

      Throws:
      ComputationException
    • p75

      public static TimeSeriesContainer p75(List<ValueContainer> vcl, String c) throws ComputationException
      Throws:
      ComputationException
    • p80

      Throws:
      ComputationException
    • p80

      public static TimeSeriesContainer p80(List<ValueContainer> vcl, String c) throws ComputationException
      Throws:
      ComputationException
    • p90

      Throws:
      ComputationException
    • p90

      public static TimeSeriesContainer p90(List<ValueContainer> vcl, String c) throws ComputationException
      Throws:
      ComputationException
    • p95

      Throws:
      ComputationException
    • p95

      public static TimeSeriesContainer p95(List<ValueContainer> vcl, String c) throws ComputationException
      Throws:
      ComputationException
    • p98

      Throws:
      ComputationException
    • p98

      public static TimeSeriesContainer p98(List<ValueContainer> vcl, String c) throws ComputationException
      Throws:
      ComputationException
    • p99

      Throws:
      ComputationException
    • p99

      public static TimeSeriesContainer p99(List<ValueContainer> vcl, String c) throws ComputationException
      Throws:
      ComputationException
    • roundOff

      public static TimeSeriesContainer roundOff(TimeSeriesContainer tsc, int digitsPrecision, int powerOfTensPlace) throws ComputationException
      Derive a new time series with values of the current time series rounded to the specified precision and/or power of tens place. digitsPrecision controls the number of significant digits displayed and can range from 1 to 8. powerOfTensPlace is the magnitude of 10 to which to round to. For example, -1 specifies rounding to one-tenth (0.1).

      Examples: 1234.123456 will round to:

            1230.0      for   digitsPrecision = 3,  powerOfTensPlace = -1
            1234.1      for   digitsPrecision = 6,  powerOfTensPlace = -1
            1230        for   digitsPrecision = 6,  powerOfTensPlace = 1
      Values which are missing in the original time series will be missing in the new time series.

      Parameters:
      digitsPrecision - Number of digits of precision, between 1 and 8.
      powerOfTensPlace - Magnitude of ten to round to.
      Returns:
      A new time series composed of values of the current time series rounded to the specified precision.
      Throws:
      ComputationException
    • accumulation

      public static TimeSeriesContainer accumulation(TimeSeriesContainer tsc) throws ComputationException
      Derive a new time series by computing a running accumulation of the parameter time series tsc.

      For time points in which the parameter time series tsc value is missing or rejected, the value in the accumulation time series remains constant (same as the accumulated value at the last valid point location).

      The new time series will have all quality values set to "no quality".

      Returns:
      A new time series representing the running accumulation of the current time series
      Throws:
      ComputationException
    • accumulation

      public static TimeSeriesContainer accumulation(TimeSeriesContainer tsc, boolean allowUnsafe, boolean warnUnsafe, boolean createQuality) throws ComputationException
      Derive a new time series by computing a running accumulation of the parameter time series tsc.

      For time points in which the parameter time series tsc value is missing or rejected, the value in the accumulation time series remains constant (same as the accumulated value at the last valid point location).

      The new time series will have all quality values set to "no quality".

      Parameters:
      tsc - the TimeSeriesContainer
      allowUnsafe - flag specifying whether to allow "unsafe" math operations.
      warnUnsafe - flag specifying whether to warn about "unsafe" math operations.
      Returns:
      A new time series representing the running accumulation of the current time series
      Throws:
      ComputationException
    • min

      public static double min(TimeSeriesContainer tsc) throws ComputationException
      Find the minimum value of the time series. Missing and rejected values are excluded.

      Parameters:
      tsc - the TimeSeriesContainer
      Returns:
      the minimum value of the time series.
      Throws:
      ComputationException
    • min

      public static double min(TimeSeriesContainer tsc, double floor) throws ComputationException
      Find the minimum value of the time series above a floor. Missing and rejected values are excluded.

      Parameters:
      tsc - the TimeSeriesContainer
      floor - the value to compute the minimum above
      Returns:
      the minimum value of the time series.
      Throws:
      ComputationException
    • minDate

      public static int minDate(TimeSeriesContainer tsc) throws ComputationException
      Find the date/time of the minimum value of the time series. Missing and rejected values are excluded.

      Parameters:
      tsc - the TimeSeriesContainer
      Returns:
      the date and time of the minimum value as an int value translatable by HecTime
      Throws:
      ComputationException
      See Also:
    • minDate

      public static int minDate(TimeSeriesContainer tsc, double floor) throws ComputationException
      Find the date/time of the minimum value of the time series above a floor. Missing and rejected values are excluded.

      Parameters:
      tsc - the TimeSeriesContainer
      floor - the value to compute the minimum above
      Returns:
      the date and time of the minimum value as an int value translatable by HecTime
      Throws:
      ComputationException
      See Also:
    • max

      public static double max(TimeSeriesContainer tsc) throws ComputationException
      Find the maximum value of the time series. Missing and rejected values are excluded.

      Parameters:
      tsc - the TimeSeriesContainer
      Returns:
      the maximum value of the time series.
      Throws:
      ComputationException
    • max

      public static double max(TimeSeriesContainer tsc, double ceiling) throws ComputationException
      Find the maximum value of the time series below a ceiling. Missing and rejected values are excluded.

      Parameters:
      tsc - the TimeSeriesContainer
      ceiling - the value under which to compute the maximum
      Returns:
      the maximum value of the time series.
      Throws:
      ComputationException
    • maxDate

      public static int maxDate(TimeSeriesContainer tsc) throws ComputationException
      Find the date/time of the maximum value of the time series under a ceiling. Missing and rejected values are excluded.

      Parameters:
      tsc - the TimeSeriesContainer
      Returns:
      the date and time of the maximum value as an int value translatable by HecTime
      Throws:
      ComputationException
      See Also:
    • maxDate

      public static int maxDate(TimeSeriesContainer tsc, double ceiling) throws ComputationException
      Find the date/time of the maximum value of the time series. Missing and rejected values are excluded.

      Parameters:
      tsc - the TimeSeriesContainer
      ceiling - the value under which to compute the maximum
      Returns:
      the date and time of the maximum value as an int value translatable by HecTime
      Throws:
      ComputationException
      See Also:
    • mean

      public static double mean(TimeSeriesContainer tsc) throws ComputationException
      Compute the mean value of the time series. Missing and rejected values are excluded.

      Parameters:
      tsc - the TimeSeriesContainer
      Returns:
      the mean value of the time series.
      Throws:
      ComputationException
    • gmean

      public static double gmean(TimeSeriesContainer tsc) throws ComputationException
      Compute the geometric mean value of the time series. Missing and rejected values are excluded.

      Parameters:
      tsc - the TimeSeriesContainer
      Returns:
      the geometric mean value of the time series.
      Throws:
      ComputationException
    • hmean

      public static double hmean(TimeSeriesContainer tsc) throws ComputationException
      Compute the harmonic mean value of the time series. Missing and rejected values are excluded.

      Parameters:
      tsc - the TimeSeriesContainer
      Returns:
      the harmonic mean value of the time series.
      Throws:
      ComputationException
    • rms

      public static double rms(TimeSeriesContainer tsc) throws ComputationException
      Compute the root mean square (quadratic mean) value of the time series. Missing and rejected values are excluded.

      Parameters:
      tsc - the TimeSeriesContainer
      Returns:
      the root mean square (quadratic mean) mean value of the time series.
      Throws:
      ComputationException
    • var

      public static double var(TimeSeriesContainer tsc) throws ComputationException
      Compute the variance value of the time series. Missing and rejected values are excluded.

      Parameters:
      tsc - the TimeSeriesContainer
      Returns:
      the variance mean value of the time series.
      Throws:
      ComputationException
    • sum

      public static double sum(TimeSeriesContainer tsc) throws ComputationException
      Compute the total accumulated amount for time series. Missing and rejected values are excluded.

      Parameters:
      tsc - the TimeSeriesContainer
      Returns:
      the total accumulated value of the time series.
      Throws:
      ComputationException
    • standardDeviation

      public static double standardDeviation(TimeSeriesContainer tsc) throws ComputationException
      Compute the standard deviation of the time series values. Missing and rejected values are excluded. A minimum of three valid values are required for the computation.

      Parameters:
      tsc - the TimeSeriesContainer
      Returns:
      the standard deviation value of the time series.
      Throws:
      ComputationException
    • skewCoefficient

      public static double skewCoefficient(TimeSeriesContainer tsc) throws ComputationException
      Compute the skew coefficient of the time series values. Missing values and rejected are excluded. A minimum of three valid values are required for the computation.

      Parameters:
      tsc - the TimeSeriesContainer
      Returns:
      the skew coefficient value of the time series.
      Throws:
      ComputationException
    • kurtosisCoefficient

      public static double kurtosisCoefficient(TimeSeriesContainer tsc) throws ComputationException
      Compute the kurtosis coefficient of the time series values. Missing values and rejected are excluded. A minimum of four valid values are required for the computation.

      Parameters:
      tsc - the TimeSeriesContainer
      Returns:
      the kurtosis coefficient value of the time series.
      Throws:
      ComputationException
    • mode

      public static double mode(TimeSeriesContainer tsc) throws ComputationException
      Compute the mode of the time series values. Missing values and rejected are excluded. A minimum of one valid value is required for the computation.

      Parameters:
      tsc - the TimeSeriesContainer
      Returns:
      the mode coefficient value of the time series.
      Throws:
      ComputationException
    • med

      public static double med(TimeSeriesContainer tsc) throws ComputationException
      Compute the median of the time series values. Missing values and rejected are excluded. A minimum of one valid value is required for the computation.

      Parameters:
      tsc - the TimeSeriesContainer
      Returns:
      the median coefficient value of the time series.
      Throws:
      ComputationException
    • p1

      public static double p1(TimeSeriesContainer tsc) throws ComputationException
      Compute the p1 of the time series values. Missing values and rejected are excluded. A minimum of one valid value is required for the computation.

      Parameters:
      tsc - the TimeSeriesContainer
      Returns:
      the p1 coefficient value of the time series.
      Throws:
      ComputationException
    • p2

      public static double p2(TimeSeriesContainer tsc) throws ComputationException
      Compute the p2 of the time series values. Missing values and rejected are excluded. A minimum of one valid value is required for the computation.

      Parameters:
      tsc - the TimeSeriesContainer
      Returns:
      the p2 coefficient value of the time series.
      Throws:
      ComputationException
    • p5

      public static double p5(TimeSeriesContainer tsc) throws ComputationException
      Compute the p5 of the time series values. Missing values and rejected are excluded. A minimum of one valid value is required for the computation.

      Parameters:
      tsc - the TimeSeriesContainer
      Returns:
      the p5 coefficient value of the time series.
      Throws:
      ComputationException
    • p10

      public static double p10(TimeSeriesContainer tsc) throws ComputationException
      Compute the p10 of the time series values. Missing values and rejected are excluded. A minimum of one valid value is required for the computation.

      Parameters:
      tsc - the TimeSeriesContainer
      Returns:
      the p10 coefficient value of the time series.
      Throws:
      ComputationException
    • p20

      public static double p20(TimeSeriesContainer tsc) throws ComputationException
      Compute the p20 of the time series values. Missing values and rejected are excluded. A minimum of one valid value is required for the computation.

      Parameters:
      tsc - the TimeSeriesContainer
      Returns:
      the p20 coefficient value of the time series.
      Throws:
      ComputationException
    • p25

      public static double p25(TimeSeriesContainer tsc) throws ComputationException
      Compute the p25 of the time series values. Missing values and rejected are excluded. A minimum of one valid value is required for the computation.

      Parameters:
      tsc - the TimeSeriesContainer
      Returns:
      the p25 coefficient value of the time series.
      Throws:
      ComputationException
    • p75

      public static double p75(TimeSeriesContainer tsc) throws ComputationException
      Compute the p75 of the time series values. Missing values and rejected are excluded. A minimum of one valid value is required for the computation.

      Parameters:
      tsc - the TimeSeriesContainer
      Returns:
      the p75 coefficient value of the time series.
      Throws:
      ComputationException
    • p80

      public static double p80(TimeSeriesContainer tsc) throws ComputationException
      Compute the p80 of the time series values. Missing values and rejected are excluded. A minimum of one valid value is required for the computation.

      Parameters:
      tsc - the TimeSeriesContainer
      Returns:
      the p80 coefficient value of the time series.
      Throws:
      ComputationException
    • p90

      public static double p90(TimeSeriesContainer tsc) throws ComputationException
      Compute the p90 of the time series values. Missing values and rejected are excluded. A minimum of one valid value is required for the computation.

      Parameters:
      tsc - the TimeSeriesContainer
      Returns:
      the p90 coefficient value of the time series.
      Throws:
      ComputationException
    • p95

      public static double p95(TimeSeriesContainer tsc) throws ComputationException
      Compute the p95 of the time series values. Missing values and rejected are excluded. A minimum of one valid value is required for the computation.

      Parameters:
      tsc - the TimeSeriesContainer
      Returns:
      the p95 coefficient value of the time series.
      Throws:
      ComputationException
    • p98

      public static double p98(TimeSeriesContainer tsc) throws ComputationException
      Compute the p98 of the time series values. Missing values and rejected are excluded. A minimum of one valid value is required for the computation.

      Parameters:
      tsc - the TimeSeriesContainer
      Returns:
      the p98 coefficient value of the time series.
      Throws:
      ComputationException
    • p99

      public static double p99(TimeSeriesContainer tsc) throws ComputationException
      Compute the p99 of the time series values. Missing values and rejected are excluded. A minimum of one valid value is required for the computation.

      Parameters:
      tsc - the TimeSeriesContainer
      Returns:
      the p99 coefficient value of the time series.
      Throws:
      ComputationException
    • numberValidValues

      public static int numberValidValues(TimeSeriesContainer tsc) throws ComputationException
      Count the number of valid (non-missing and non-rejected) values in the time series values.
      Parameters:
      tsc - the TimeSeriesContainer
      Returns:
      the number of valid (non-missing and non-rejected) values in the time series.
      Throws:
      ComputationException
    • numberInvalidValues

      public static int numberInvalidValues(TimeSeriesContainer tsc) throws ComputationException
      Count the number of invalid (missing or rejected) values in the time series values.

      Parameters:
      tsc - the TimeSeriesContainer
      Returns:
      the number of invalid (missing or rejected) values in the time series.
      Throws:
      ComputationException
    • numberMissingValues

      public static int numberMissingValues(TimeSeriesContainer tsc) throws ComputationException
      Count the number of missing (but not rejected) values in the time series values.

      Parameters:
      tsc - the TimeSeriesContainer
      Returns:
      the number of missing (but not rejected) values in the time series.
      Throws:
      ComputationException
    • numberRejectedValues

      public static int numberRejectedValues(TimeSeriesContainer tsc) throws ComputationException
      Count the number of rejected (but not missing) values in the time series values.

      Parameters:
      tsc - the TimeSeriesContainer
      Returns:
      the number of rejected (but not missing) values in the time series.
      Throws:
      ComputationException
    • numberQuestionedValues

      public static int numberQuestionedValues(TimeSeriesContainer tsc) throws ComputationException
      Count the number of questioned values in the time series values.

      Parameters:
      tsc - the TimeSeriesContainer
      Returns:
      the number of questioned values in the time series.
      Throws:
      ComputationException
    • firstValidDate

      public static int firstValidDate(TimeSeriesContainer tsc) throws ComputationException
      Find the date and time of the first valid time series value.

      Parameters:
      tsc - the TimeSeriesContainer
      Returns:
      the date and time of the first valid value as an int value translatable by HecTime
      Throws:
      ComputationException
      See Also:
    • firstValidValue

      public static double firstValidValue(TimeSeriesContainer tsc) throws ComputationException
      Find the first valid value in the time series.

      Returns:
      the value of the first valid time series value.
      Throws:
      HecMathException
      ComputationException
    • lastValidDate

      public static int lastValidDate(TimeSeriesContainer tsc) throws ComputationException
      Find the date and time of the last valid time series value.

      Parameters:
      tsc - the TimeSeriesContainer
      Returns:
      the date and time of the last valid value as an int value translatable by HecTime
      Throws:
      ComputationException
      See Also:
    • lastValidValue

      public static double lastValidValue(TimeSeriesContainer tsc) throws ComputationException
      Find the last valid value in the time series.

      Parameters:
      tsc - the TimeSeriesContainer
      Returns:
      the value of the last valid time series value.
      Throws:
      HecMathException
      ComputationException
    • differences

      public static TimeSeriesContainer differences(TimeSeriesContainer tsc, boolean time_based, boolean allowUnsafe, boolean warnUnsafe, boolean createQuality) throws ComputationException
      Derive a new time series from the differences (time-based or otherwise) of the current time series. The time series must be of type "INST-CUM". The value in the new time is set to missing if either the current or previous point in the current time series is set to missing (need to have two consecutive valid values).

      By default, if the data type of the current time series is "INST-CUM", the data type of the new time series is set to "PER-CUM".

      Parameters:
      tsc - the TimeSeriesContainer
      time_based - flag specifying whether compute successive difference (false) or time derivatives (true)
      allowUnsafe - flag specifying whether to allow "unsafe" math operations.
      warnUnsafe - flag specifying whether to warn about "unsafe" math operations.
      Returns:
      A new time series of successive differences.
      Throws:
      ComputationException
      ComputationException
    • successiveDifferences

      public static TimeSeriesContainer successiveDifferences(TimeSeriesContainer tsc) throws ComputationException
      Derive a new time series from the successive differences of the current time series. The time series must be of type "INST-CUM". The value in the new time is set to missing if either the current or previous point in the current time series is set to missing (need to have two consecutive valid values).

      By default, if the data type of the current time series is "INST-CUM", the data type of the new time series is set to "PER-CUM".

      Parameters:
      tsc - the TimeSeriesContainer
      Returns:
      A new time series of successive differences.
      Throws:
      ComputationException
    • successiveDifferences

      public static TimeSeriesContainer successiveDifferences(TimeSeriesContainer tsc, boolean allowUnsafe, boolean warnUnsafe, boolean createQuality) throws ComputationException
      Derive a new time series from the successive differences of the current time series. The time series must be of type "INST-CUM". The value in the new time is set to missing if either the current or previous point in the current time series is set to missing (need to have two consecutive valid values).

      By default, if the data type of the current time series is "INST-CUM", the data type of the new time series is set to "PER-CUM".

      Parameters:
      tsc - the TimeSeriesContainer
      allowUnsafe - flag specifying whether to allow "unsafe" math operations.
      warnUnsafe - flag specifying whether to warn about "unsafe" math operations.
      Returns:
      A new time series of successive differences.
      Throws:
      ComputationException
    • timeDerivative

      public static TimeSeriesContainer timeDerivative(TimeSeriesContainer tsc) throws ComputationException
      Derive a new time series from the successive difference rates of the current time series. The time series must be of type "INST-CUM". The value in the new time is set to missing if either the current or previous point in the current time series is set to missing (need to have two consecutive valid values).

      By default, if the data type of the current time series is "INST-CUM", the data type of the new time series is set to "PER-CUM".

      Parameters:
      tsc - the TimeSeriesContainer
      Returns:
      A new time series of successive differences.
      Throws:
      ComputationException
    • timeDerivative

      public static TimeSeriesContainer timeDerivative(TimeSeriesContainer tsc, boolean allowUnsafe, boolean warnUnsafe, boolean createQuality) throws ComputationException
      Derive a new time series from the successive difference rates of the current time series. The time series must be of type "INST-CUM". The value in the new time is set to missing if either the current or previous point in the current time series is set to missing (need to have two consecutive valid values).

      By default, if the data type of the current time series is "INST-CUM", the data type of the new time series is set to "PER-CUM".

      Parameters:
      tsc - the TimeSeriesContainer
      allowUnsafe - flag specifying whether to allow "unsafe" math operations.
      warnUnsafe - flag specifying whether to warn about "unsafe" math operations.
      Returns:
      A new time series of successive differences.
      Throws:
      ComputationException
    • movingAverage

      public static TimeSeriesContainer movingAverage(TimeSeriesContainer tsc, TimeSeriesFunctions.MovingAverageMethod method, int numberToAverageOver, boolean onlyValidValues, boolean useReduced) throws ComputationException
      Derive a new time series by performing a moving average of with the specified method. Only valid (non missing, non-rejected) values are used to average, although invalid values may exist within the range of values to average, depending on the setting of the onlyValidValues argument. Average values near the beginning or end of the time series may or may not be computed based on the setting of the useReduced argument.
      Parameters:
      tsc - The time series to derive from.
      method - The moving average method to use. Currently-supported methods are FORWARD, CENTERED, and OLYMPIC.
      numberToAverageOver - The number of values to average for each element. Must be 2 or greater, and must be odd for CENTERED or OLYMPIC methods.
      onlyValidValues - Specifies whether to require a complete set of valid values in order to compute an average for a given element. If true, then any elements that would use an invalid element in its average will be set to missing. If false, then the average for a given element will be computed with fewer values than specified in the numberToAverageOver argument if an invalid element in the tsc argument is encounterd.
      useReduced - Specifies whether to compute averages for elements near enough to the beginning or end of the time series that the numberToAverageOver argument cannot be satisfied. If true, then the number of elements required for the average will be reduced accordingly. If false, elements near the beginning and/or end of the time series will be set to missing.
      Returns:
      The derived time series.
      Throws:
      ComputationException
    • centeredMovingAverage

      public static TimeSeriesContainer centeredMovingAverage(TimeSeriesContainer tsc, int numberToAverageOver, boolean onlyValidValues, boolean useReduced) throws ComputationException
      Perform a centered moving average smoothing of the time series.

      Derive a new time series from the centered moving average of numberToAverageOver values in the current time series.

      If onlyValidValues is set to true, then if points in the averaging interval are missing values, the point in the new time series is set to missing. If onlyValidValues is set to false and missing values are contained in the averaging interval, a smoothed point is still computed using the valid values in the interval. If there are no valid values in the averaging interval, the point in the new time series is set to missing.

      If useReduced is set to true, then centered moving average points can be still be computed at the beginning and end of the time series even if there are less than numberToAverageOver values in the interval. If useReduced is set to false, then the first and last numberToAverageOver/2 points of the new time series are set to missing.

      Parameters:
      tsc - The time series to derive from.
      numberToAverageOver - the number of values to average over for computing the centered moving average. Must be greater than 2 and odd.
      onlyValidValues - all values in the averaging interval must be valid for the computed point in the new time series to be valid.
      useReduced - allow points at the beginning and end of the centered moving average time series to be computed from a reduced ( less than numberToAverageOver ) number of points. Otherwise, set the first and last numberToAverageOver/2 points of the new time series to missing.
      Returns:
      A new time series computed from the olypic smoothing average of current time series.
      Throws:
      ComputationException - if the numberToAverageOver is less than 3 or not odd.
    • olympicSmoothing

      public static TimeSeriesContainer olympicSmoothing(TimeSeriesContainer tsc, int numberToAverageOver, boolean onlyValidValues, boolean useReduced) throws ComputationException
      Perform an Olympic smoothing average of the time series.

      Derive a new time series from the Olympic smoothing average of numberToAverageOver values in the current time series. Olympic smoothing is the same as centered moving average except that the minimum and maximum values in the averaging interval are ignored.

      If onlyValidValues is set to true, then if points in the averaging interval are missing values, the point in the new time series is set to missing. If onlyValidValues is set to false and missing values are contained in the averaging interval, a smoothed point is still computed using the valid values in the interval. If there are no valid values in the averaging interval, the point in the new time series is set to missing.

      If useReduced is set to true, then centered moving average points can be still be computed at the beginning and end of the time series even if there are less than numberToAverageOver values in the interval. If useReduced is set to false, then the first and last numberToAverageOver/2 points of the new time series are set to missing.

      Parameters:
      tsc - The time series to derive from.
      numberToAverageOver - the number of values to average over for computing the centered moving average. Must be greater than 2 and odd.
      onlyValidValues - all values in the averaging interval must be valid for the computed point in the new time series to be valid.
      useReduced - allow points at the beginning and end of the centered moving average time series to be computed from a reduced ( less than numberToAverageOver ) number of points. Otherwise, set the first and last numberToAverageOver/2 points of the new time series to missing.
      Returns:
      a new time series computed from the olypic smoothing average of current time series.
      Throws:
      ComputationException - if the numberToAverageOver is less than 3 or not odd.
    • forwardMovingAverage

      public static TimeSeriesContainer forwardMovingAverage(TimeSeriesContainer tsc, int numberToAverageOver, boolean onlyValidValues, boolean useReduced) throws ComputationException
      Compute a forward moving average of the time series.

      Derive a new time series from the forward moving average of the last numberToAverageOver values of the current time series.

      If onlyValidValues is set to true, then if points in the averaging interval are missing values, the point in the new time series is set to missing. If onlyValidValues is set to false and missing values are contained in the averaging interval, a smoothed point is still computed using the valid values in the interval. If there are no valid values in the averaging interval, the point in the new time series is set to missing.

      If useReduced is set to true, then forward moving average points can be still be computed at the beginning of the time series even if there are less than numberToAverageOver values in the interval. If useReduced is set to false, then the first numberToAverageOver points of the new time series are set to missing.

      Parameters:
      tsc - The time series to derive from.
      numberToAverageOver - the number of values to average over for computing the forward moving average. Must be greater than or equal to 2.
      onlyValidValues - all values in the averaging interval must be valid for the computed point in the new time series to be valid.
      useReduced - allow points at the beginning and end of the centered moving average time series to be computed from a reduced ( less than numberToAverageOver ) number of points. Otherwise, set the first and last numberToAverageOver/2 points of the new time series to missing.
      Returns:
      a new time series computed from the forward moving average of current time series.
      Throws:
      ComputationException
    • forwardMovingAverage

      public static TimeSeriesContainer forwardMovingAverage(TimeSeriesContainer tsc, int numberToAverageOver) throws ComputationException
      Compute a forward moving average of the time series.

      Derive a new time series from the forward moving average of the last numberToAverageOver values of the current time series. If a missing value is occurs over the numberToAverageOver points, the value is excluded from the computation and the average is over one less value. At least to valid values must be defined over the averaging interval or else the point in the new time series is set to missing.

      Parameters:
      tsc - The time series to derive from.
      numberToAverageOver - the number of values to average over for computing the forward moving average. Must be greater than or equal to 2.
      Returns:
      a new time series computed from the forward moving average of current time series.
      Throws:
      ComputationException
    • screenWithMaxMin

      public static TimeSeriesContainer screenWithMaxMin(TimeSeriesContainer tsc, double minValueLimit, double maxValueLimit, double changeLimit, boolean setInvalidValueToSpecified, double invalidValueReplacement, String qualityFlagForInvalidValue) throws ComputationException
      Flag values in time series exceeding minimum and maximum limit values or maximum change limit.

      Values in the time series are screened for quality. Values below minValueLimit or above maxValueLimit or with a change from the previous time series value greater than changeLimit fail the quality test. The maximum change comparison is done only when consecutive values are not flagged.

      If setInvalidToSpecifiedValue is set to "true", values failing the screening test are set to the specified value.

      If qualityFlagForInvalidValue is set to a character or string recognized as a valid quality flag, the quality flag will be set for tested values. If there is no previously existing quality available for the time series, the quality flag array will be created for the time series. Values failing the quality test are set to the user specified quality flag for invalid values. If there is existing quality data and the time series value passes the quality test, the existing quality flag for the points is unchanged. If there was no previously existing quality and the time series value passes the quality test, the quality flag for the point is set to "Okay".

      Parameters:
      tsc - The time series to derive from.
      minValueLimit - minimum valid value limit.
      maxValueLimit - maximum valid value limit.
      changeLimit - maximum change allowed in the tested value from the previous time series value.
      setInvalidValueToSpecified - if true, time series values failing the quality test are set to the specified value.
      invalidValueReplacement - The value to use for replacing invalid values is setInvalidToSpecifiedValue is set to "true".
      qualityFlagForInvalidValue - character string representing the quality flag setting for values failing the quality test. The accepted character strings are: "M" or "Missing", "R" or "Rejected", "Q" or "Questionable".
      Returns:
      A copy of the time series with values failing the quality test set to missing and/or with the quality flag set to the user specified quality for invalid values.
      Throws:
      ComputationException
      See Also:
    • screenWithMaxMin

      public static TimeSeriesContainer screenWithMaxMin(TimeSeriesContainer tsc, double minValueLimit, double maxValueLimit, double changeLimit, boolean setInvalidValueToUndefined, String qualityFlagForInvalidValue) throws ComputationException
      Flag values in time series exceeding minimum and maximum limit values or maximum change limit.

      Values in the time series are screened for quality. Values below minValueLimit or above maxValueLimit or with a change from the previous time series value greater than changeLimit fail the quality test. The maximum change comparison is done only when consecutive values are not flagged.

      If setInvalidToMissingValue is set to "true", values failing the screening test are set to the "Missing" value.

      If qualityFlagForInvalidValue is set to a character or string recognized as a valid quality flag, the quality flag will be set for tested values. If there is no previously existing quality available for the time series, the quality flag array will be created for the time series. Values failing the quality test are set to the user specified quality flag for invalid values. If there is existing quality data and the time series value passes the quality test, the existing quality flag for the points is unchanged. If there was no previously existing quality and the time series value passes the quality test, the quality flag for the point is set to "Okay".

      Parameters:
      tsc - The time series to derive from.
      minValueLimit - minimum valid value limit.
      maxValueLimit - maximum valid value limit.
      changeLimit - maximum change allowed in the tested value from the previous time series value.
      setInvalidValueToUndefined - if true, time series values failing the quality test are set to the "Undefined" value.
      qualityFlagForInvalidValue - character string representing the quality flag setting for values failing the quality test. The accepted character strings are: "M" or "Missing", "R" or "Rejected", "Q" or "Questionable".
      Returns:
      A copy of the time series with values failing the quality test set to missing and/or with the quality flag set to the user specified quality for invalid values.
      Throws:
      ComputationException
      See Also:
    • screenWithMaxMin

      public static TimeSeriesContainer screenWithMaxMin(TimeSeriesContainer tsc, double minRejectLimit, double minQuestionLimit, double maxQuestionLimit, double maxRejectLimit) throws ComputationException
      Flag values in time series exceeding minimum and maximum limit values as questionable or rejected.

      Values in the time series are screened for quality. Values below minRejectLimit or above maxRejectLimit are marked with a rejected quality flag. Other values below minQuestionLimit or above maxQuestionLimit are marked with a questioned quality flag. Other values are marked with an okay quality flag unless they are already marked as rejected or questioned.

      Parameters:
      tsc - The time series to derive from.
      minRejectLimit - Values below this will be marked as rejected.
      minQuestionLimit - Values below this, but not below minRejectLimit will be marked as questioned.
      maxQuestionLimit - Values above this, but not above maxRejectLimit will be marked as questioned.
      maxRejectLimit - Values above this will be marked as rejected.
      Returns:
      A copy of the time series with values with the quality set as described.
      Throws:
      ComputationException
      See Also:
    • screenWithRateOfChange

      public static TimeSeriesContainer screenWithRateOfChange(TimeSeriesContainer tsc, double minRejectLimit, double minQuestionLimit, double maxQuestionLimit, double maxRejectLimit) throws ComputationException
      Flag values in time series whose rate of change from the last valid value exceed minimum/maximum limits values as questionable or rejected.

      Values in the time series are screened for quality. Values whose rate of change from the last valid value are below minRejectLimit or above maxRejectLimit are marked with a rejected quality flag. Other whose rate of change from the last valid value are values below minQuestionLimit or above maxQuestionLimit are marked with a questioned quality flag. Other values are marked with an okay quality flag unless they are already marked as rejected or questioned.

      Parameters:
      tsc - The time series to derive from.
      minRejectLimit - Values whose rate of change from the last valid value are below this will be marked as rejected.
      minQuestionLimit - Values whose rate of change from the last valid value are below this, but not below minRejectLimit will be marked as questioned.
      maxQuestionLimit - Values whose rate of change from the last valid value are above this, but not above maxRejectLimit will be marked as questioned.
      maxRejectLimit - Values whose rate of change from the last valid value are above this will be marked as rejected.
      Returns:
      A copy of the time series with values with the quality set as described.
      Throws:
      ComputationException
    • screenWithDurationMagnitude

      public static TimeSeriesContainer screenWithDurationMagnitude(TimeSeriesContainer tsc, String durationStr, double minRejectLimit, double minQuestionLimit, double maxQuestionLimit, double maxRejectLimit) throws ComputationException
      Flag values in time series whose accumulation over a specified period lies minimum/maximum limits values as questionable or rejected.

      Values in the time series are screened for quality. All (non-missing) values whose accumulated value for the specified duration is below minRejectLimit or above maxRejectLimit are marked with a rejected quality flag. Other whose whose accumulated value for the specified duration is below minQuestionLimit or above maxQuestionLimit are marked with a questioned quality flag. Other values are marked with an okay quality flag unless they are already marked as rejected or questioned.

      Parameters:
      tsc - The time series to derive from.
      durationStr - The time period over which to perform the test, of the form nX, where in is an integer and X is one of Minutes, Hours, or Days, which can be abbreviated to one or more characters.
      minRejectLimit - Values whose accumulated value for the specified duration is below this will be marked as rejected.
      minQuestionLimit - Values whose accumulated value for the specified duration is below this, but not below minRejectLimit will be marked as questioned.
      maxQuestionLimit - Values whose accumulated value for the specified duration is above this, but not above maxRejectLimit will be marked as questioned.
      maxRejectLimit - Values whose accumulated value for the specified duration is above this will be marked as rejected.
      Returns:
      A copy of the time series with values with the quality set as described.
      Throws:
      ComputationException
    • durationMinutes

      public static int durationMinutes(String durationStr) throws ComputationException
      Throws:
      ComputationException
    • screenWithDurationMagnitude

      public static TimeSeriesContainer screenWithDurationMagnitude(TimeSeriesContainer tsc, String durationStr, double minRejectLimit, double minQuestionLimit, double maxQuestionLimit, double maxRejectLimit, boolean allowUnsafe, boolean warnUnsafe) throws ComputationException
      Flag values in time series whose accumulation over a specified period lies minimum/maximum limits values as questionable or rejected.

      Values in the time series are screened for quality. All (non-missing) values whose accumulated value for the specified duration is below minRejectLimit or above maxRejectLimit are marked with a rejected quality flag. Other whose whose accumulated value for the specified duration is below minQuestionLimit or above maxQuestionLimit are marked with a questioned quality flag. Other values are marked with an okay quality flag unless they are already marked as rejected or questioned.

      Parameters:
      tsc - The time series to derive from.
      durationStr - The time period over which to perform the test, of the form nX, where in is an integer and X is one of Minutes, Hours, or Days, which can be abbreviated to one or more characters.
      minRejectLimit - Values whose accumulated value for the specified duration is below this will be marked as rejected.
      minQuestionLimit - Values whose accumulated value for the specified duration is below this, but not below minRejectLimit will be marked as questioned.
      maxQuestionLimit - Values whose accumulated value for the specified duration is above this, but not above maxRejectLimit will be marked as questioned.
      maxRejectLimit - Values whose accumulated value for the specified duration is above this will be marked as rejected.
      allowUnsafe - flag specifying whether to allow "unsafe" math operations.
      warnUnsafe - flag specifying whether to warn about "unsafe" math operations.
      Returns:
      A copy of the time series with values with the quality set as described.
      Throws:
      ComputationException
    • screenWithDurationMagnitude

      public static TimeSeriesContainer screenWithDurationMagnitude(TimeSeriesContainer tsc, String durationStr, double minMissingLimit, double minRejectLimit, double minQuestionLimit, double maxQuestionLimit, double maxRejectLimit, double maxMissingLimit, double percentRequired, boolean allowUnsafe, boolean warnUnsafe) throws ComputationException
      Flag values in time series whose accumulation over a specified period lies minimum/maximum limits values as questionable or rejected.

      Values in the time series are screened for quality. All (non-missing) values whose accumulated value for the specified duration is below minRejectLimit or above maxRejectLimit are marked with a rejected quality flag. Other whose whose accumulated value for the specified duration is below minQuestionLimit or above maxQuestionLimit are marked with a questioned quality flag. Other values are marked with an okay quality flag unless they are already marked as rejected or questioned.

      Parameters:
      tsc - The time series to derive from.
      durationStr - The time period over which to perform the test, of the form nX, where in is an integer and X is one of Minutes, Hours, or Days, which can be abbreviated to one or more characters.
      minMissingLimit - Values whose accumulated value for the specified duration is below this will be marked as missing.
      minRejectLimit - Values whose accumulated value for the specified duration is below this will be marked as rejected.
      minQuestionLimit - Values whose accumulated value for the specified duration is below this, but not below minRejectLimit will be marked as questioned.
      maxQuestionLimit - Values whose accumulated value for the specified duration is above this, but not above maxRejectLimit will be marked as questioned.
      maxRejectLimit - Values whose accumulated value for the specified duration is above this will be marked as rejected.
      maxMissingLimit - Values whose accumulated value for the specified duration is above this will be marked as missing.
      percentRequired - Minimum percent of values in the duration that must be valid for the screening to be performed.
      allowUnsafe - flag specifying whether to allow "unsafe" math operations.
      warnUnsafe - flag specifying whether to warn about "unsafe" math operations.
      Returns:
      A copy of the time series with values with the quality set as described.
      Throws:
      ComputationException
    • screenWithConstantValue

      public static TimeSeriesContainer screenWithConstantValue(TimeSeriesContainer tsc, String durationStr, double rejectTolerance, double questionTolerance) throws ComputationException
      Flag values in time series whose values do not change more than a specified amount over a specified duation as questionable or rejected.

      Values in the time series are screened for quality. All (non-missing) values whose difference over the specified duration is below rejectTolerance are marked with a rejected quality flag. Other whose whose difference over the specified duration is below questionTolerance are marked with a questioned quality flag. Other values are marked with an okay quality flag unless they are already marked as rejected or questioned.

      Only values greater than zero are screened as described.

      Only time periods that contain no missing values are screened as described.

      Parameters:
      tsc - The time series to derive from.
      durationStr - The time period over which to perform the test, of the form nX, where in is an integer and X is one of Minutes, Hours, or Days, which can be abbreviated to one or more characters.
      rejectTolerance - Values will be marked as rejected if they do not differ by more than this amount over the specified duration. To disable marking values as rejected, set this tolerance to less than zero.
      questionTolerance - Values will be marked as questioned if they do not differ by more than this amount over the specified duration. To disable marking values as questioned, set this tolerance to less than zero.
      Returns:
      A copy of the time series with values with the quality set as described.
      Throws:
      ComputationException
    • screenWithConstantValue

      public static TimeSeriesContainer screenWithConstantValue(TimeSeriesContainer tsc, String durationStr, double rejectTolerance, double questionTolerance, double minThreshold, int maxMissing) throws ComputationException
      Flag values in time series whose values do not change more than a specified amount over a specified duation as questionable or rejected.

      Values in the time series are screened for quality. All (non-missing) values whose difference over the specified duration is below rejectTolerance are marked with a rejected quality flag. Other whose whose difference over the specified duration is below questionTolerance are marked with a questioned quality flag. Other values are marked with an okay quality flag unless they are already marked as rejected or questioned.

      Only values above the specified minThreshold value are screened as described.

      Only time periods that contain no more that maxMissing missing values are screened as described.

      Parameters:
      tsc - The time series to derive from.
      durationStr - The time period over which to perform the test, of the form nX, where in is an integer and X is one of Minutes, Hours, or Days, which can be abbreviated to one or more characters.
      rejectTolerance - Values will be marked as rejected if they do not differ by more than this amount over the specified duration. To disable marking values as rejected, set this tolerance to less than zero.
      questionTolerance - Values will be marked as questioned if they do not differ by more than this amount over the specified duration. To disable marking values as questioned, set this tolerance to less than zero.
      minThreshold - Values will be screened only if they are greater than this value.
      maxMissing - The maximum number of missing values to tolerate in the specified duration for screening purposes.
      Returns:
      A copy of the time series with values with the quality set as described.
      Throws:
      ComputationException
    • screenWithConstantValue

      public static TimeSeriesContainer screenWithConstantValue(TimeSeriesContainer tsc, String durationStr, double rejectTolerance, double questionTolerance, double minThreshold, int maxMissing, boolean allowUnsafe, boolean warnUnsafe) throws ComputationException
      Flag values in time series whose values do not change more than a specified amount over a specified duation as questionable or rejected.

      Values in the time series are screened for quality. All (non-missing) values whose difference over the specified duration is below rejectTolerance are marked with a rejected quality flag. Other whose whose difference over the specified duration is below questionTolerance are marked with a questioned quality flag. Other values are marked with an okay quality flag unless they are already marked as rejected or questioned.

      Only values above the specified minThreshold value are screened as described.

      Only time periods that contain no more that maxMissing missing values are screened as described.

      Parameters:
      tsc - The time series to derive from.
      durationStr - The time period over which to perform the test, of the form nX, where in is an integer and X is one of Minutes, Hours, or Days, which can be abbreviated to one or more characters.
      rejectTolerance - Values will be marked as rejected if they do not differ by more than this amount over the specified duration. To disable marking values as rejected, set this tolerance to less than zero.
      questionTolerance - Values will be marked as questioned if they do not differ by more than this amount over the specified duration. To disable marking values as questioned, set this tolerance to less than zero.
      minThreshold - Values will be screened only if they are greater than this value.
      maxMissing - The maximum number of missing values to tolerate in the specified duration for screening purposes.
      allowUnsafe - flag specifying whether to allow "unsafe" math operations.
      warnUnsafe - flag specifying whether to warn about "unsafe" math operations.
      Returns:
      A copy of the time series with values with the quality set as described.
      Throws:
      ComputationException
    • screenWithConstantValue

      public static TimeSeriesContainer screenWithConstantValue(TimeSeriesContainer tsc, String durationStr, double missingTolerance, double rejectTolerance, double questionTolerance, double minThreshold, int maxMissing, boolean allowUnsafe, boolean warnUnsafe) throws ComputationException
      Flag values in time series whose values do not change more than a specified amount over a specified duation as questionable or rejected.

      Values in the time series are screened for quality. All (non-missing) values whose difference over the specified duration is below rejectTolerance are marked with a rejected quality flag. Other whose whose difference over the specified duration is below questionTolerance are marked with a questioned quality flag. Other values are marked with an okay quality flag unless they are already marked as rejected or questioned.

      Only values above the specified minThreshold value are screened as described.

      Only time periods that contain no more that maxMissing missing values are screened as described.

      Parameters:
      tsc - The time series to derive from.
      durationStr - The time period over which to perform the test, of the form nX, where in is an integer and X is one of Minutes, Hours, or Days, which can be abbreviated to one or more characters.
      missingTolerance - Values will be marked as missing if they do not differ by more than this amount over the specified duration. To disable marking values as missing, set this tolerance to less than zero.
      rejectTolerance - Values will be marked as rejected if they do not differ by more than this amount over the specified duration. To disable marking values as rejected, set this tolerance to less than zero.
      questionTolerance - Values will be marked as questioned if they do not differ by more than this amount over the specified duration. To disable marking values as questioned, set this tolerance to less than zero.
      minThreshold - Values will be screened only if they are greater than this value.
      maxMissing - The maximum number of missing values to tolerate in the specified duration for screening purposes.
      allowUnsafe - flag specifying whether to allow "unsafe" math operations.
      warnUnsafe - flag specifying whether to warn about "unsafe" math operations.
      Returns:
      A copy of the time series with values with the quality set as described.
      Throws:
      ComputationException
    • screenWithForwardMovingAverage

      public static TimeSeriesContainer screenWithForwardMovingAverage(TimeSeriesContainer tsc, int numberToAverageOver, double changeLimit, boolean setInvalidValueToUndefined, String qualityFlagForInvalidValue) throws ComputationException
      Flag values in time series exceeding maximum change from a forward moving average.

      A running forward moving average of valid values is progressively computed over numberToAverageOver points. Values exceeding the moving average computed for the preceeding point location by more than changeLimit are flagged or set to the "Missing" value depending upon the settings for setInvalidToMissingValue or qualityFlagForInvalidValue parameters. Values failing the quality test are excluded from the forward moving average computation for the subsequent points. The maximum change comparison is done only when consecutive values are not flagged.

      If setInvalidToMissingValue is set to "true", values failing the screening test are set to the "Missing" value.

      If qualityFlagForInvalidValue is set to a character or string recognized as a valid quality flag, the quality flag will be set for tested values. If there is no previously existing quality available for the time series, the quality flag array will be created for the time series. Values failing the quality test are set to the user specified quality flag for invalid values. If there is existing quality data and the time series value passes the quality test, the existing quality flag for the points is unchanged. If there was no previously existing quality and the time series value passes the quality test, the quality flag for the point is set to "Okay".

      Parameters:
      tsc - The time series to derive from.
      numberToAverageOver - the number of values to average over for computing the forward moving average. Must be greater than 2.
      changeLimit - allowed deviation in the tested value from the forward moving average.
      setInvalidValueToUndefined -
      qualityFlagForInvalidValue - character string representing the quality flag setting for values failing the quality test. The accepted character strings are: "M" or "Missing", "R" or "Rejected", "Q" or "Questionable". A blank string is entered to disable the setting of the quality flag.
      Returns:
      a copy of the time series with values failing the quality test set to missing and/or with the quality flag set to the user specified quality for invalid values.
      Throws:
      ComputationException
    • estimateForMissingValues

      public static TimeSeriesContainer estimateForMissingValues(TimeSeriesContainer tsc, int maxMissingAllowed, boolean accumulation, boolean setQuestioned, boolean estimateRejected, boolean allowUnsafe, boolean warnUnsafe) throws ComputationException
      Linearly interpolate estimates for missing values in the time series.

      The function interpolates between valid values in the time series to fill in locations in time with values defined as "Missing". Linear interpolation will NOT be performed for segments of the time series where there are more than maxMissingAllowed successive bad values.

      Parameters:
      tsc - time series to interpolate on
      maxMissingAllowed - maximum number consecutive missing values between valid values in which interpolation is allowed.
      accumulation - flag specifying whether to estimate accumulated values (such as precip)
      setQuestioned - if true, sets the quality (if any) to questioned for interpolated values
      estimateRejected - if true, estimates missing AND rejected values
      allowUnsafe - flag specifying whether to allow "unsafe" math operations.
      warnUnsafe - flag specifying whether to warn about "unsafe" math operations.
      Returns:
      a copy of the current time series with missing values filled by linear interpolation.
      Throws:
      ComputationException - if the time series contains less than 3 valid values.
    • snapToRegularInterval

      public static TimeSeriesContainer snapToRegularInterval(TimeSeriesContainer tsc, String timeIntervalStr, String timeOffsetStr, String timeBackwardStr, String timeForwardStr) throws ComputationException
      Throws:
      ComputationException
    • snapToRegularInterval

      public static TimeSeriesContainer snapToRegularInterval(TimeSeriesContainer tsc, int timeIntervalMinutes, int timeOffsetMinutes, int timeBackwardMinutes, int timeForwardMinutes) throws ComputationException
      Throws:
      ComputationException
    • interpolate

      public static double interpolate(TimeSeriesContainer tsc, int time, String dataType, intContainer lastIndex)
    • transformTimeSeries

      public static void transformTimeSeries(TimeSeriesContainer currentTsc, TimeSeriesContainer newTsc, int functionType, boolean toIrregular, double missingAllowed) throws ComputationException
      Throws:
      ComputationException
    • main

      public static void main(String[] args) throws Exception
      Throws:
      Exception
    • transformWithFunction

      public static TimeSeriesContainer transformWithFunction(TimeSeriesContainer baseTsc, ScalarOperable transformer)
    • resample

      public static TimeSeriesContainer resample(TimeSeriesContainer tsc, mil.army.usace.hec.metadata.Interval interval) throws HecMathException
      Create timeseries derived from input in the specified interval. Uses source offset, pass result into SNAP or SHIFT if offset change is required
      Parameters:
      tsc - input timeseries
      interval - desired output interval
      Returns:
      new timeseries with inputs mapped to the same times in output.
      Throws:
      HecMathException
      Since:
      2022-07