Package hec.hecmath

Class PairedDataMath

java.lang.Object
hec.hecmath.HecMath
hec.hecmath.PairedDataMath
All Implemented Interfaces:
IRating, IVerticalDatumOperations<PairedDataMath,HecMathException>, Constants
Direct Known Subclasses:
PairedDataMathVertDatum

public class PairedDataMath extends HecMath implements IRating, IVerticalDatumOperations<PairedDataMath,HecMathException>
The PairedDataMath class wraps around a hec.io.PairedDataContainer (paired data) and provides the user the capability to perform a set of high level operations. For example, if the PairedDataMath object contains paired data in the form of a rating table, PairedDataMath can be used to derive a flow time series from a stage time series:
      tsFlow = rtable.ratingTableInterpolation( tsStage )
 
See Also:
  • Field Details

    • _curveNumber

      protected int _curveNumber
  • Constructor Details

  • Method Details

    • setData

      public void setData(DataContainer container) throws HecMathException
      Set the PairedDataContainer data for the current PairedDataMath object. The current PairedDataMath will use a copy of container.

      Specified by:
      setData in class HecMath
      Parameters:
      container - the PairedDataContainer data to be used by this PairedDataMath object.
      Throws:
      HecMathException - if container is null or not of type PairedDataContainer.
    • getData

      public void getData(DataContainer container) throws HecMathException
      Copy the current PairedDataContainer data in the PairedDataMath object into container.

      Specified by:
      getData in class HecMath
      Parameters:
      container - the PairedDataContainer to receive the copy of paired data from this PairedDataMath object.
      Throws:
      HecMathException
    • getData

      public DataContainer getData() throws HecMathException
      Copy the current PairedDataContainer data in the PairedDataMath object into container.

      Specified by:
      getData in class HecMath
      Returns:
      a copy of the PairedDataContainer held in the current PairedDataMath object.
      Throws:
      HecMathException
    • setCurve

      public void setCurve(String curveName) throws HecMathException
      Select, by curve label, the paired data curve for performing subsequent arithmetic operations or math functions.

      A paired data set may contains more than one set of y-values. However, a user may wish to modify only one curve of the data set. For example, using the function "add( 2.0 )" would by default add 2.0 to all y-values for all curves. setCurve can be used to limit the operation to just one selected set of y-values.

      The function searches the paired data set list of curve labels for a match to curveName. If a match is found, that curve is set as the selected curve.

      Overrides:
      setCurve in class HecMath
      Parameters:
      curveName - the curve label to set as the selected curve.
      Throws:
      HecMathException
      See Also:
    • setCurve

      public void setCurve(int curveNumber) throws HecMathException
      Select, by curve number, the paired data curve for performing subsequent arithmetic operations or math functions.

      A paired data set may contains more than one set of y-values. However, a user may wish to modify only one curve of the data set. For example, using the function "add( 2.0 )" would by default add 2.0 to all y-values for all curves. setCurve can be used to limit the operation to just one selected set of y-values.

      The active curve is set to curveNumber. Curve numbering with 0. To set all curve active, set curveNumber to -1. By default, all curves are set active.

      Overrides:
      setCurve in class HecMath
      Parameters:
      curveNumber - the selected curve number
      Throws:
      HecMathException
      See Also:
    • getSelectedCurve

      public int getSelectedCurve()
      Overrides:
      getSelectedCurve in class HecMath
    • add

      public HecMath add(HecMath math) throws HecMathException
      Overrides:
      add in class HecMath
      Throws:
      HecMathException
    • subtract

      public HecMath subtract(HecMath math) throws HecMathException
      Overrides:
      subtract in class HecMath
      Throws:
      HecMathException
    • divide

      public HecMath divide(HecMath math) throws HecMathException
      Overrides:
      divide in class HecMath
      Throws:
      HecMathException
    • multiply

      public HecMath multiply(HecMath math) throws HecMathException
      Overrides:
      multiply in class HecMath
      Throws:
      HecMathException
    • add

      public HecMath add(double constant) throws HecMathException
      Add a constant value to the y-values in current paired data set.

      Overrides:
      add in class HecMath
      Parameters:
      constant - the value to be added to the y-values in the current paired data set.
      Returns:
      a new paired data set resulting from the operation.
      Throws:
      HecMathException
      See Also:
    • subtract

      public HecMath subtract(double constant) throws HecMathException
      Subtract a constant value from the y-values in current paired data set.

      Overrides:
      subtract in class HecMath
      Parameters:
      constant - the value to be subtracted from the y-values in the current paired data set.
      Returns:
      a new paired data set resulting from the operation.
      Throws:
      HecMathException
      See Also:
    • multiply

      public HecMath multiply(double constant) throws HecMathException
      Multiply the y-values in current paired data set by a constant value.

      Overrides:
      multiply in class HecMath
      Parameters:
      constant - the value to multiply the y-values in the current paired data set.
      Returns:
      a new paired data set resulting from the operation.
      Throws:
      HecMathException
      See Also:
    • divide

      public HecMath divide(double constant) throws HecMathException
      Divide the y-values in current paired data set by a constant value.

      Overrides:
      divide in class HecMath
      Parameters:
      constant - the value to divide the y-values in the current paired data set.
      Returns:
      a new paired data set resulting from the operation.
      Throws:
      HecMathException
      See Also:
    • replaceSpecificValues

      public HecMath replaceSpecificValues(HecDouble from, HecDouble to) throws HecMathException
      Overrides:
      replaceSpecificValues in class HecMath
      Throws:
      HecMathException
    • replaceValuesInRange

      public HecMath replaceValuesInRange(HecDouble min, HecDouble max, HecDouble to) throws HecMathException
      Overrides:
      replaceValuesInRange in class HecMath
      Throws:
      HecMathException
    • exponentiation

      public HecMath exponentiation(double constant) throws HecMathException
      Raise y-values in current paired data set to the power of constant.

      Overrides:
      exponentiation in class HecMath
      Parameters:
      constant - the exponent value.
      Returns:
      a new paired data set resulting from the operation.
      Throws:
      HecMathException
      See Also:
    • transformWithFunction

      public HecMath transformWithFunction(ScalarOperable transformer) throws HecMathException
      Overrides:
      transformWithFunction in class HecMath
      Throws:
      HecMathException
    • sqrt

      public HecMath sqrt() throws HecMathException
      Create a new paired data set with y-values computed from the square root of the current paired data y-values. y-values of the original data set less than 0.0 will be set to missing in the new data set.

      Overrides:
      sqrt in class HecMath
      Returns:
      A new paired data set with y-values the square root of the original y-values.
      Throws:
      HecMathException
      See Also:
    • log

      public HecMath log() throws HecMathException
      Create a new paired data set with y-values computed from the natural log of the current paired data y-values. y-values of the original data set less than or equal to 0.0 will be set to missing in the new data set.

      Overrides:
      log in class HecMath
      Returns:
      A new paired data set with y-values the natural log of the original y-values.
      Throws:
      HecMathException
      See Also:
    • log10

      public HecMath log10() throws HecMathException
      Create a new paired data set with y-values computed from the log base 10 of the current paired data y-values. y-values of the original data set less than or equal to 0.0 will be set to missing in the new data set.

      Overrides:
      log10 in class HecMath
      Returns:
      A new paired data set with y-values the log base 10 of the original y-values.
      Throws:
      HecMathException
    • abs

      public HecMath abs() throws HecMathException
      Create a new paired data set with y-values computed from the absolute values of the current paired data y-values.

      Overrides:
      abs in class HecMath
      Returns:
      A new paired data set with y-values the absolute value of the original y-values.
      Throws:
      HecMathException
    • truncate

      public HecMath truncate() throws HecMathException
      Create a new paired data set with the current paired data y-values truncated to whole numbers.

      Overrides:
      truncate in class HecMath
      Returns:
      A new paired data set with y-values truncated to whole number.
      Throws:
      HecMathException
      See Also:
    • round

      public HecMath round() throws HecMathException
      Create a new paired data set with the current paired data y-values rounded to the nearest whole number.

      Overrides:
      round in class HecMath
      Returns:
      A new paired data set with y-values rounded to the nearest whole number.
      Throws:
      HecMathException
    • sin

      public HecMath sin() throws HecMathException
      Create a new paired data set with y-values computed from the sine of the current paired data y-values.

      Overrides:
      sin in class HecMath
      Returns:
      A new paired data set with y-values the sine of the original y-values.
      Throws:
      HecMathException
    • cos

      public HecMath cos() throws HecMathException
      Create a new paired data set with y-values computed from the cosine of the current paired data y-values.

      Overrides:
      cos in class HecMath
      Returns:
      A new paired data set with y-values the cosine of the original y-values.
      Throws:
      HecMathException
      See Also:
    • tan

      public HecMath tan() throws HecMathException
      Create a new paired data set with y-values computed from the tangent of the current paired data y-values. Values of the original data set which have a cosine value of zero are set to missing in the new data set.

      Overrides:
      tan in class HecMath
      Returns:
      A new paired data set with y-values the tangent of the original y-values.
      Throws:
      HecMathException
    • inverse

      public HecMath inverse() throws HecMathException
      Create a new paired data set with y-values computed from 1 divided by current paired data y-values. Values of the original data set which are zero are set to missing in the new data set.

      Overrides:
      inverse in class HecMath
      Returns:
      A new paired data set with y-values the tangent of the original y-values.
      Throws:
      HecMathException
    • roundOff

      public HecMath roundOff(int digitsPrecision, int powerOfTensPlace) throws HecMathException
      Derive a new paired data set with y-values 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
      Overrides:
      roundOff in class HecMath
      Parameters:
      digitsPrecision - Number of digits of precision, between 1 and 8.
      powerOfTensPlace - Magnitude of ten to round to.
      Returns:
      A new paired data set composed of y-values of the current paired data set rounded to the specified precision.
      Throws:
      HecMathException
    • convertToMetricUnits

      public HecMath convertToMetricUnits() throws HecMathException
      Convert values to metric (SI) units. Determination of the unit system will be based upon the y units and parameter type. Both x-values and y-values under go conversion.

      Specified by:
      convertToMetricUnits in class HecMath
      Returns:
      A new paired data set with x and y values converted to metric units. If the original paired data set is already in metric units, will return a copy of the original paired data set.
      Throws:
      HecMathException - if the unit conversion could not be performed.
    • convertToEnglishUnits

      public HecMath convertToEnglishUnits() throws HecMathException
      Convert values to English units. Determination of the unit system will be based upon the y units and parameter type. Both x-values and y-values under go conversion.

      Specified by:
      convertToEnglishUnits in class HecMath
      Returns:
      A new paired data set with x and y values converted to English units. If the original paired data set is already in English units, will return a copy of the original paired data set.
      Throws:
      HecMathException - if the unit conversion could not be performed.
    • isMetric

      public boolean isMetric() throws HecMathException
      Determine if the paired data is in metric (SI) units. Determination of the unit system will be based upon the y units and parameter type.

      Specified by:
      isMetric in class HecMath
      Returns:
      true if the data units are English, otherwise returns false.
      Throws:
      HecMathException - if the unit system cannot be determined.
    • isEnglish

      public boolean isEnglish() throws HecMathException
      Determine if the paired data is in English units. Determination of the unit system will be based upon the y units and parameter type.

      Specified by:
      isEnglish in class HecMath
      Returns:
      true if the data units are English, otherwise returns false.
      Throws:
      HecMathException - if the unit system cannot be determined.
    • canDetermineUnitSystem

      public boolean canDetermineUnitSystem()
      See if the unit system can be successfully determined from the units string.

      Specified by:
      canDetermineUnitSystem in class HecMath
      Returns:
      true if the units system can be determined, otherwise returns false.
    • getUnits

      public String getUnits()
      Returns the units label of the y-values for the current paired data set.

      Overrides:
      getUnits in class HecMath
      Returns:
      units label for paired data set.
    • getStandardUnits

      public String getStandardUnits()
      Returns the standardized units label for the paired data y-values. The y-units label is converted to a standardized units string as defined in the file hec.heclib.util.unitConversion.def. This is done to ease comparison of units between different data sets and for unit conversions. For example, "inch", "inches" or "INCHES" are changed to "in".

      Overrides:
      getStandardUnits in class HecMath
      Returns:
      y-units label converted to the standardized form defined in hec.heclib.util.unitConversion.def
    • setUnits

      public void setUnits(String unitsString)
      Set the y-units label for the paired data set.

      Specified by:
      setUnits in class HecMath
      Parameters:
      unitsString - the y-units label for the paired data.
    • mergePairedDataSets

      public HecMath mergePairedDataSets(HecMath pdMathIn) throws HecMathException
      Merge two paired data sets.

      Will derive a new paired data set by merging curves in the current and parameter, pdMathIn, paired data sets.

      The x-ordinate values for the two data sets must be identical. Curve(s) from pdMathIn are appended on to the set of curves in the current paired data set. Either one selected curve or all curves from pdMathIn are copied over to the new paired data set. Use setCurve(int) or setCurve(String) to select the curve in pdMathIn for merging. The selection status can be checked with getSelectedCurve().

      Overrides:
      mergePairedDataSets in class HecMath
      Parameters:
      pdMathIn - a paired data set for merging with the current paired data set.
      Returns:
      A new paired data set containing the paired data curves from the two paired data sets.
      Throws:
      HecMathException - if x-ordinates for the two paired data sets are not identical.
    • conicInterpolation

      public TimeSeriesMath conicInterpolation(HecMath tsMath, String inputType, String outputType, double storageScaleFactor) throws HecMathException
      Use the conic interpolation table in the current paired data set to develop a new time series from the interpolation of tsMath.

      The paired data set represents a table of Elevation-Area. However, the first paired data values contain the initial conic depth and the storage for the first elevation in the table. If the initial conic depth is undefined, the function will calculate a value. Elevation-Area values in the table are in ascending order.

      tsMath is either a time series of reservoir elevation or storage, and is specified by setting inputType as "S(TORAGE)" or "E(LEVATION)". The desired output time series type is similarly set using outputType. The valid settings for outType are "S(TORAGE)", "E(LEVATION)" and "A(REA)". inputType and outputType must not be the same.

      storageScaleFactor is an optional parameter used to scale input (by multiplying) and output (by dividing) storage values. For example, if the area in the conic interpolation table is expressed in sq.ft., storageScaleFactor could be set to 43560 to convert the storage output to acre-ft.

      Parameter type in the new time series is set according to outputType. If the output time series values are elevation, the time series units are set to the paired data x-units label. If the output time series values are area the time series units are set to the paired data y-units label. If the output is storage, the units are not set and should be set by the user with the setUnits function.

      Overrides:
      conicInterpolation in class HecMath
      Parameters:
      tsMath - the input time series of elevation or storage.
      inputType - parameter type for input time series, "S(TORAGE)" or "E(LEVATION)".
      outputType - parameter type for output time series, "S(TORAGE)", "E(LEVATION)", or "A(REA)".
      Returns:
      The interpolated output time series
      Throws:
      HecMathException - if outType or outputType are not correctly defined.
      See Also:
    • ratingTableInterpolation

      public TimeSeriesMath ratingTableInterpolation(TimeSeriesMath tsMath) throws HecMathException
      Use the rating table in the current paired data set to develop a new time series from the rating table interpolation of tsMath. The rating table may be Log-Log.

      The paired data set should be created with the rating table option to set values for datum, shift, and offset in PairedDataContainer. By default these values are 0.0. The shift is added to, and the datum subtracted from all input time series values. If the rating table is Log-Log, the table x-values are adjusted by subtracting the offset. Units and parameter type in the new time series are set to the y-units label and parameter type of the current paired data set. All other names and labels are copied over from tsMath.

      Parameters:
      tsMath - the input time series for rating table interpolation.
      Returns:
      The interpolated output time series
      Throws:
      HecMathException
    • reverseRatingTableInterpolation

      public TimeSeriesMath reverseRatingTableInterpolation(TimeSeriesMath tsMath) throws HecMathException
      Use the rating table in the current paired data set to develop a new time series from the reverse rating table interpolation of tsMath. The rating table may be Log-Log.

      The paired data set should be created with the rating table option to set values for datum, shift, and offset in PairedDataContainer. By default these values are 0.0. The shift is subtracted from, and the datum added to all input time series values. If the rating table is Log-Log, the table x-values are adjusted by subtracting the offset. Units and parameter type in the new time series are set to the x-units label and parameter type of the current paired data set. All other names and labels are copied over from tsMath.

      Parameters:
      tsMath - the input time series for reverse rating table interpolation.
      Returns:
      The interpolated output time series
      Throws:
      HecMathException
    • translateXY

      public PairedDataMath translateXY() throws HecMathException
      Throws:
      HecMathException
    • interpolate

      public PairedDataMath interpolate(double[] xarray, boolean linear, boolean doExtrapolation) throws HecMathException
      Resample the x
      Parameters:
      xarray - double[]
      linear - boolean
      doExtrapolation - boolean
      Throws:
      HecMathException
    • twoVariableRatingTableInterpolation

      public TimeSeriesMath twoVariableRatingTableInterpolation(TimeSeriesMath tsMathX, TimeSeriesMath tsMathZ) throws HecMathException
      Use the current paired data set to create a new time series by the two-variable rating table interpolation of the time series tsMathX and tsMathZ. For two-variable rating table interpolation, the current paired data set should have more than one curve (multiple sets of y-values). The labels of the paired data curves are interpreted as values for interpolating values of tsMathZ.

      In performing the double interpolation, two bounding curves (using the label values of the curves) of the paired data set are found which bracket the time series value from tsMathZ. Interpolation between the curves is done at the x-oridinate location defined by the time series value from tsMathX.

      No extrapolation is performed. If time series values from tsMathX or tsMathZ are outside the range bounded by the paired data, the new time series value is set to missing.

      Units and paramter type in the new time series are set to the y-units label and parameter of the current paired data set. All other names and labels are copied over from tsMathX.

      Parameters:
      tsMathX - input time series interpreted as x-ordinate values
      tsMathZ - input time series interpreted as z-ordinate values, (value defined by the paired data curve labels).
      Returns:
      The interpolated output time series.
      Throws:
      HecMathException - if tsMathX and tsMathZ are not for identical times.
    • polynomialTransformation

      public TimeSeriesMath polynomialTransformation(TimeSeriesMath tsMath) throws HecMathException
      Compute a polynomial transformation of tsMath using the polynomial coefficients defined in the current paired data set. A new time series is computed using the polynomial coefficients, Bn, and the input time series, tsIn, according to:
            tsNew(i) = B1*tsIn(i) + B2*tsIn(i)**2 + ... + Bn*tsIn(i)**n
       
      Before the above equation is applied, values in tsIn are first adjusted by subtracting off the datum value for the paired data set (see PairedDataContainer). If a value in the input time series is missing, the value remains missing in the new time series.

      The units label and parameter type in the new time series are the same as in tsMath.

      Parameters:
      tsMath - the input time series.
      Returns:
      a new time series representing the polynomial transform of tsMath.
      Throws:
      HecMathException
      See Also:
    • polynomialTransformationWithIntegral

      public TimeSeriesMath polynomialTransformationWithIntegral(TimeSeriesMath tsMath) throws HecMathException
      Compute a polynomial transformation with integral of tsMath using the polynomial coefficients defined in the current paired data set. A new time series is computed using the polynomial coefficients, Bn, and the input time series, tsIn, according to:
            tsNew(i) = (B1/2)*tsIn(i)**2 + (B2/3)*tsIn(i)**3 + ... + (Bn/(n+1))*tsIn(i)**(n+1)
       
      Before the above equation is applied, values in tsIn are first adjusted by subtracting off the datum value for the paired data set (see PairedDataContainer). If a value in the input time series is missing, the value remains missing in the new time series.

      The units label and parameter type in the new time series are the same as in tsMath.

      Parameters:
      tsMath - the input time series.
      Returns:
      a new time series representing the polynomial transform of tsMath.
      Throws:
      HecMathException
      See Also:
    • applyMultipleLinearRegression

      public TimeSeriesMath applyMultipleLinearRegression(String startTimeString, String endTimeString, TimeSeriesMath[] tsMathArray, double minimumLimit, double maximumLimit) throws HecMathException
      Apply the regression coefficients contained in the paired data set to the set of time series in tsMathArray to develop a new time series.

      The regression coefficients can be used to generate a new regular interval time series based on the general linear regression equation:

            tsNew(i) = B0 + B1*TS1(i) + B2*TS2(i) + B3*TS3(i) ...
       
      where Bn are the set of regression coefficients and TSn are the time series contained in tsMathArray.

      Typically the regression coefficients are developed using the function, TimeSeriesMath.multipleRegression(HecMath[] tsMathArray, double minimumLimit, double maximumLimit). To correctly construct the new time series, the time series in tsMathArray must be in the same order as in the call to TimeSeriesMath.multipleRegression() so that the right regression coefficient is applied to the right time series.

      The time series in tsMathArray must be regular interval time series with the same time interval. Data is processed for the time period common to all the time series. While the starting and ending time for each time series need not be the same, there must be time points common to all the time series. For any given time point, if a value is missing in any time series, the value in the new time series is set to missing. If the computed time series value is less than minimumLimit or greater than maximumLimit the value is reset to missing.

      Names, parameter type and unit labels for the new time series are copied over from the first time series in tsMathArray. The "Version" in the new time series is set to "COMPUTED".

      Parameters:
      tsMathArray - an array of time series objects.
      minimumLimit - set to missing values in the new time series if the computed value is below this limit. Set to HecMath.UNDEFINED to disable this option.
      maximumLimit - set to missing values in the new time series if the computed value is above this limit. Set to HecMath.UNDEFINED to disable this option.
      Returns:
      a new time series computed from the regression coefficients and the time series in tsMathArray.
      Throws:
      HecMathException - if the time series in tsMathArray are not regular interval time series, all with the same time interval, or if there is no concurrent data between the time series; or if the number of regression coefficients in not equal to the number of time series + 1.
      See Also:
    • modifiedPulsRouting

      public TimeSeriesMath modifiedPulsRouting(TimeSeriesMath tsMath, int numberSubreaches, double muskingumX) throws HecMathException
      Use the storage-discharge function in the current paired data set to route the regular interval time series tsMath by the Modified Puls hydrologic routing method.

      Parameters:
      tsMath - the time series for routing.
      numberSubreaches - Number of routing subreaches.
      muskingumX - Muskingum "X" parameter, between 0.0 and 0.5.
      Returns:
      The routed time series
      Throws:
      HecMathException - If tsMath is not a regular interval time series, or if values for numberSubreaches or muskingumX are invalid; or if the current paired data set is not a storage-flow table with ascending x and y values.
    • pairedDataOps

      public PairedDataMath pairedDataOps(boolean reorder, int resampleSkip, boolean swapXY, int[] deleteCurves, int switchXYAxis) throws HecMathException
      Paired Data Operations -pairedDataOps packages several utility operations on paired data curves. Generally, only one operation should be preformed at a time. However, if desired, the order of the operations is: 1) Reorder in ascending; 2) Delete Curve(s); 3) Re-sample; 4) Swap parameters, and 5) Setting the parameter associated with the horizontal axis.
      Parameters:
      reorder - when true sorts primary axis ascending, removing duplicates if needed
      resampleSkip - reduces the number of points by skipping. for example if resampleSkip is 2 then skip every other point.
      swapXY - when true swaps (x,y) to (y,x) also swaps units, and labels
      deleteCurves - array of curve indexes to delete
      switchXYAxis - 0 - n/a, 1=switch , 2=no switch (for plotting)
      Returns:
      returns PairedDataMath
      Throws:
      HecMathException
    • checkPairedData

      public static boolean checkPairedData(PairedDataContainer pdc) throws HecMathException
      Perform basic checks on the PairedDataContainer pdc to ensure that there is data.

      Parameters:
      pdc - the hec.io.PairedDataContainer for testing.
      Returns:
      true if pdc is not empty.
      Throws:
      HecMathException - if pdc is empty or contains no valid data.
      See Also:
    • checkPairedDataCurve

      public static boolean checkPairedDataCurve(PairedDataContainer pdc, int curveNumber) throws HecMathException
      Perform basic checks on the PairedDataContainer pdc to ensure that data is available for the curve curveNumber.

      Parameters:
      pdc - the hec.io.TimeSeriesContainer for testing.
      Returns:
      true if there is data for curve curveNumber.
      Throws:
      HecMathException - if there is no data for curveNumber.
      See Also:
    • isValid

      public boolean isValid(int index)
      Determine if the data value at the array location index in the current paired data set is valid ( okay or not missing ). If the paired data set is comprised of more than one y-value curve, the selected curve number must first be set.

      Overrides:
      isValid in class HecMath
      Parameters:
      index - the array index of the value of interest.
      Returns:
      true if the value at the array location index is valid ( is okay or not missing ), otherwise false.
      See Also:
    • copy

      public HecMath copy() throws HecMathException
      Create a duplicate copy of the paired data set.

      Specified by:
      copy in class HecMath
      Returns:
      a duplicate copy of the paired data set
      Throws:
      HecMathException
    • getName

      public String getName()
      Description copied from interface: IRating
      Retrieves the name of the rating.
      Specified by:
      getName in interface IRating
      Returns:
      The name of the rating
    • setName

      public void setName(String name) throws RatingException
      Description copied from interface: IRating
      Sets the name of the rating
      Specified by:
      setName in interface IRating
      Parameters:
      name - The new name of the rating
      Throws:
      RatingException
    • getRatingParameters

      public String[] getRatingParameters()
      Description copied from interface: IRating
      Retrieves the rating parameters.
      Specified by:
      getRatingParameters in interface IRating
      Returns:
      The independent and dependent parameters of the rating
    • getRatingUnits

      public String[] getRatingUnits()
      Description copied from interface: IRating
      Retrieves the rating ratingUnits. These are the ratingUnits of the underlying rating, which may be different than the data ratingUnits, as long as valid unit conversions exist between rating ratingUnits and data ratingUnits.
      Specified by:
      getRatingUnits in interface IRating
      Returns:
      The ratingUnits, one unit for each parameter
    • getDataUnits

      public String[] getDataUnits()
      Description copied from interface: IRating
      Retrieves the data ratingUnits. These are the ratingUnits expected for independent parameters and the unit produced for the dependent parameter. If the underlying rating uses different ratingUnits, the rating must perform unit conversions.
      Specified by:
      getDataUnits in interface IRating
      Returns:
      The ratingUnits identifier, one unit for each parameter
    • setDataUnits

      public void setDataUnits(String[] units) throws RatingException
      Description copied from interface: IRating
      Sets the data ratingUnits. These are the ratingUnits expected for independent parameters and the unit produced for the dependent parameter. If the underlying rating uses different ratingUnits, the rating must perform unit conversions.
      Specified by:
      setDataUnits in interface IRating
      Parameters:
      units - The ratingUnits, one unit for each parameter
      Throws:
      RatingException
    • getDefaultValueTime

      public long getDefaultValueTime()
      Description copied from interface: IRating
      Retrieves the default value time. This is used for rating values that have no inherent times.
      Specified by:
      getDefaultValueTime in interface IRating
      Returns:
      The default value time
    • setDefaultValueTime

      public void setDefaultValueTime(long defaultValueTime)
      Description copied from interface: IRating
      Sets the default value time. This is used for rating values that have no inherent times.
      Specified by:
      setDefaultValueTime in interface IRating
      Parameters:
      defaultValueTime - The default value time in Java milliseconds
    • resetDefaultValuetime

      public void resetDefaultValuetime()
      Description copied from interface: IRating
      Resets the default value time. This is used for rating values that have no inherent times.
      Specified by:
      resetDefaultValuetime in interface IRating
    • getRatingTime

      public long getRatingTime()
      Description copied from interface: IRating
      Retrieves the rating time. This rate values at a time in the past. No rating information with a creation date later than the rating time will be used to rate values.
      Specified by:
      getRatingTime in interface IRating
      Returns:
      The rating time in Java milliseconds
    • setRatingTime

      public void setRatingTime(long ratingTime)
      Description copied from interface: IRating
      Sets the rating time. This rate values at a time in the past. No rating information with a creation date later than the rating time will be used to rate values.
      Specified by:
      setRatingTime in interface IRating
      Parameters:
      ratingTime - The rating time in Java milliseconds
    • resetRatingTime

      public void resetRatingTime()
      Description copied from interface: IRating
      Resets (un-sets) the rating time.
      Specified by:
      resetRatingTime in interface IRating
    • rate

      public double rate(double indVal) throws RatingException
      Description copied from interface: IRating
      Finds the dependent value for a single independent value. The rating must be for a single independent parameter.
      Specified by:
      rate in interface IRating
      Parameters:
      indVal - The independent value to rate.
      Returns:
      The dependent value
      Throws:
      RatingException
    • rateOne

      public double rateOne(double... indVals) throws RatingException
      Description copied from interface: IRating
      Finds the dependent value for a set of independent values. The rating must be for as many independent parameters as there are arguments.
      Specified by:
      rateOne in interface IRating
      Parameters:
      indVals - The independent parameters to rate
      Returns:
      The dependent value
      Throws:
      RatingException
    • rateOne2

      public double rateOne2(double[] indVals) throws RatingException
      Description copied from interface: IRating
      Finds the dependent value for a set of independent values. The rating must be for as many independent parameters as there are arguments.
      Specified by:
      rateOne2 in interface IRating
      Parameters:
      indVals - The independent parameters to rate
      Returns:
      The dependent value
      Throws:
      RatingException
    • rate

      public double[] rate(double[] indVals) throws RatingException
      Description copied from interface: IRating
      Finds multiple dependent values for multiple single independent values. The rating must be for a single independent parameter.
      Specified by:
      rate in interface IRating
      Parameters:
      indVals - The independent values to rate
      Returns:
      The dependent values
      Throws:
      RatingException
    • rate

      public double[] rate(double[][] indVals) throws RatingException
      Description copied from interface: IRating
      Finds multiple dependent values for multiple sets of independent values. The rating must be for as many independent parameters as the length of each independent parameter set.
      Specified by:
      rate in interface IRating
      Parameters:
      indVals - The independent values to rate. Each set of independent values must be the same length.
      Returns:
      The dependent values
      Throws:
      RatingException
    • rate

      public double rate(long valTime, double indVal) throws RatingException
      Description copied from interface: IRating
      Finds the dependent value for a single independent value at a specified time. The rating must be for a single independent parameter.
      Specified by:
      rate in interface IRating
      Parameters:
      valTime - The time associated with the value to rate, in Java milliseconds
      indVal - The independent value to rate
      Returns:
      The dependent value
      Throws:
      RatingException
    • rateOne

      public double rateOne(long valTime, double... indVals) throws RatingException
      Description copied from interface: IRating
      Finds the dependent value for a set of independent values. The rating must be for as many independent parameters as there are arguments.
      Specified by:
      rateOne in interface IRating
      Parameters:
      valTime - The time associated with the set of value to rate, in Java milliseconds
      indVals - The independent parameters to rate
      Returns:
      The dependent value
      Throws:
      RatingException
    • rateOne2

      public double rateOne2(long valTime, double[] indVals) throws RatingException
      Description copied from interface: IRating
      Finds the dependent value for a set of independent values. The rating must be for as many independent parameters as there are arguments.
      Specified by:
      rateOne2 in interface IRating
      Parameters:
      valTime - The time associated with the set of value to rate, in Java milliseconds
      indVals - The independent parameters to rate
      Returns:
      The dependent value
      Throws:
      RatingException
    • rate

      public double[] rate(long valTime, double[] indVals) throws RatingException
      Description copied from interface: IRating
      Finds multiple dependent values for multiple single independent values at a specified time. The rating must be for a single independent parameter.
      Specified by:
      rate in interface IRating
      Parameters:
      valTime - The time associated with the values to rate, in Java milliseconds
      indVals - The independent values to rate
      Returns:
      The dependent values
      Throws:
      RatingException
    • rate

      public double[] rate(long[] valTimes, double[] indVals) throws RatingException
      Description copied from interface: IRating
      Finds multiple dependent values for multiple single independent and times. The rating must be for a single independent parameter.
      Specified by:
      rate in interface IRating
      Parameters:
      valTimes - The times associated with the values to rate, in Java milliseconds
      indVals - The independent values to rate
      Returns:
      The dependent values
      Throws:
      RatingException
    • rate

      public double[] rate(long valTime, double[][] indVals) throws RatingException
      Description copied from interface: IRating
      Finds multiple dependent values for multiple sets of independent values at a specified time. The rating must be for as many independent parameters as the length of each independent parameter set.
      Specified by:
      rate in interface IRating
      Parameters:
      valTime - The time associated with the values to rate, in Java milliseconds
      indVals - The independent values to rate. Each set of independent values must be the same length.
      Returns:
      The dependent values
      Throws:
      RatingException
    • rate

      public double[] rate(long[] valTimes, double[][] indVals) throws RatingException
      Description copied from interface: IRating
      Finds multiple dependent values for multiple sets of independent values and times. The rating must be for as many independent parameters as the length of each independent parameter set.
      Specified by:
      rate in interface IRating
      Parameters:
      valTimes - The time associated with the values to rate, in Java milliseconds
      indVals - The independent values to rate. Each set of independent values must be the same length.
      Returns:
      The dependent values
      Throws:
      RatingException
    • rate

      Description copied from interface: IRating
      Rates the values in the specified TimeSeriesContainer to generate a resulting TimeSeriesContainer. The rating must be for a single independent parameter.
      Specified by:
      rate in interface IRating
      Parameters:
      tsc - The TimeSeriesContainer of independent values.
      Returns:
      The TimeSeriesContainer of dependent values.
      Throws:
      RatingException
    • rate

      Description copied from interface: IRating
      Rates the values in the specified TimeSeriesContainer objects to generate a resulting TimeSeriesContainer. The rating must be for as many independent parameters as the length of tscs.
      Specified by:
      rate in interface IRating
      Parameters:
      tscs - The TimeSeriesContainers of independent values, one for each independent parameter.
      Returns:
      The TimeSeriesContainer of dependent values.
      Throws:
      RatingException
    • rate

      public TimeSeriesMath rate(TimeSeriesMath tsm) throws RatingException
      Description copied from interface: IRating
      Rates the values in the specified TimeSeriesMath to generate a resulting TimeSeriesMath. The rating must be for a single independent parameter.
      Specified by:
      rate in interface IRating
      Parameters:
      tsm - The TimeSeriesMath of independent values.
      Returns:
      The TimeSeriesMath of dependent values.
      Throws:
      RatingException
    • rate

      public TimeSeriesMath rate(TimeSeriesMath[] tsms) throws RatingException
      Description copied from interface: IRating
      Rates the values in the specified TimeSeriesMath objects to generate a resulting TimeSeriesMath. The rating must be for as many independent parameters as the length of tscs.
      Specified by:
      rate in interface IRating
      Parameters:
      tsms - The TimeSeriesMaths of independent values, one for each independent parameter.
      Returns:
      The TimeSeriesMath of dependent values.
      Throws:
      RatingException
    • reverseRate

      public double reverseRate(double depVal) throws RatingException
      Description copied from interface: IRating
      Finds the independent value for a single independent value. The rating must be for a single independent parameter.
      Specified by:
      reverseRate in interface IRating
      Parameters:
      depVal - The dependent value to rate.
      Returns:
      The independent value
      Throws:
      RatingException
    • reverseRate

      public double[] reverseRate(double[] depVals) throws RatingException
      Description copied from interface: IRating
      Finds multiple independent values for multiple single independent values. The rating must be for a single independent parameter.
      Specified by:
      reverseRate in interface IRating
      Parameters:
      depVals - The dependent values to rate
      Returns:
      The independent values
      Throws:
      RatingException
    • reverseRate

      public double reverseRate(long valTime, double depVal) throws RatingException
      Description copied from interface: IRating
      Finds the independent value for a single independent value at a specified time. The rating must be for a single independent parameter.
      Specified by:
      reverseRate in interface IRating
      Parameters:
      valTime - The time associated with the value to rate, in Java milliseconds
      depVal - The dependent value to rate
      Returns:
      The independent value
      Throws:
      RatingException
    • reverseRate

      public double[] reverseRate(long valTime, double[] depVals) throws RatingException
      Description copied from interface: IRating
      Finds multiple independent values for multiple single independent values at a specified time. The rating must be for a single independent parameter.
      Specified by:
      reverseRate in interface IRating
      Parameters:
      valTime - The time associated with the values to rate, in Java milliseconds
      depVals - The dependent values to rate
      Returns:
      The independent values
      Throws:
      RatingException
    • reverseRate

      public double[] reverseRate(long[] valTimes, double[] depVals) throws RatingException
      Description copied from interface: IRating
      Finds multiple independent values for multiple single independent and times. The rating must be for a single independent parameter.
      Specified by:
      reverseRate in interface IRating
      Parameters:
      valTimes - The times associated with the values to rate, in Java milliseconds
      depVals - The dependent values to rate
      Returns:
      The independent values
      Throws:
      RatingException
    • reverseRate

      public TimeSeriesContainer reverseRate(TimeSeriesContainer tsc) throws RatingException
      Description copied from interface: IRating
      Rates the values in the specified TimeSeriesContainer to generate a resulting TimeSeriesContainer. The rating must be for a single independent parameter.
      Specified by:
      reverseRate in interface IRating
      Parameters:
      tsc - The TimeSeriesContainer of dependent values.
      Returns:
      The TimeSeriesContainer of independent values.
      Throws:
      RatingException
    • reverseRate

      public TimeSeriesMath reverseRate(TimeSeriesMath tsm) throws RatingException
      Description copied from interface: IRating
      Rates the values in the specified TimeSeriesMath to generate a resulting TimeSeriesMath. The rating must be for a single independent parameter.
      Specified by:
      reverseRate in interface IRating
      Parameters:
      tsm - The TimeSeriesMath of dependent values.
      Returns:
      The TimeSeriesMath of independent values.
      Throws:
      RatingException
    • getIndParamCount

      public int getIndParamCount() throws RatingException
      Description copied from interface: IRating
      Retrieves the number of independent parameters for this rating.
      Specified by:
      getIndParamCount in interface IRating
      Returns:
      The number of independent parameters for this rating.
      Throws:
      RatingException
    • getRatingExtents

      public double[][] getRatingExtents() throws RatingException
      Description copied from interface: IRating
      Retrieves the min and max value for each parameter of the rating, in the current ratingUnits.
      Specified by:
      getRatingExtents in interface IRating
      Returns:
      The min and max values for each parameter. The outer (first) dimension will be 2, with the first containing min values and the second containing max values. The inner (second) dimension will be the number of independent parameters for the rating plus one. The first value will be the extent for the first independent parameter, and the last value will be the extent for the dependent parameter.
      Throws:
      RatingException
    • getRatingExtents

      public double[][] getRatingExtents(long ratingTime) throws RatingException
      Description copied from interface: IRating
      Retrieves the min and max value for each parameter of the rating, in the current ratingUnits.
      Specified by:
      getRatingExtents in interface IRating
      Parameters:
      ratingTime - The time to use in determining the rating extents
      Returns:
      The min and max values for each parameter. The outer (first) dimension will be 2, with the first containing min values and the second containing max values. The inner (second) dimension will be the number of independent parameters for the rating plus one. The first value will be the extent for the first independent parameter, and the last value will be the extent for the dependent parameter.
      Throws:
      RatingException
    • getEffectiveDates

      public long[] getEffectiveDates()
      Description copied from interface: IRating
      Retrieves the effective dates of the rating in milliseconds, one for each contained rating
      Specified by:
      getEffectiveDates in interface IRating
    • getCreateDates

      public long[] getCreateDates()
      Description copied from interface: IRating
      Retrieves the creation dates of the rating in milliseconds, one for each contained rating
      Specified by:
      getCreateDates in interface IRating
    • makeTscs

      protected TimeSeriesContainer[] makeTscs(long[] valTimes, double[][] indVals) throws HecMathException
      Makes dummy TimeSeriesContainer objects bridge IRating methods to HecMath methods
      Parameters:
      valTimes - Times in java milliseconds
      indVals - values to rate
      Returns:
      an array of TimeSeriesContainer objects
      Throws:
      HecMathException
    • correlationCoefficients

      public LinearRegressionStatistics correlationCoefficients(HecMath tsMath) throws HecMathException
      Overrides:
      correlationCoefficients in class HecMath
      Throws:
      HecMathException
    • generateDataPairs

      public PairedDataMath generateDataPairs(HecMath pdMath, double buffer) throws HecMathException
      This method will compare the two paired data containers and create a PairedDataMath object that has all of the data points that are coincident in x ordinates
      Overrides:
      generateDataPairs in class HecMath
      Parameters:
      pdMath - = other time series
      buffer - - undefined units
      Returns:
      Throws:
      HecMathException
    • screenWithMaxMin

      public HecMath screenWithMaxMin(double minValueLimit, double maxValueLimit, double changeLimit, boolean setInvalidToMissingValue, String qualityFlagForInvalidValue) throws HecMathException
      strictly looks at min/max value
      Overrides:
      screenWithMaxMin in class HecMath
      Throws:
      HecMathException
    • expandVerticalDatum

      public PairedDataMath expandVerticalDatum() throws HecMathException
      Returns a new PairedDataMathVertDatum object constructed from this object if the internal data supports it, expanding the internal data in the process
      Specified by:
      expandVerticalDatum in interface IVerticalDatumOperations<PairedDataMath,HecMathException>
      Returns:
      The PairedDataMathVertDatum object as described above or this object. In either case this object is not modified. A copy of this object is returned if it is already a PairedDataMathVertDatum object. Any errors are thrown.
      Throws:
      HecMathException
    • collapseVerticalDatum

      public PairedDataMath collapseVerticalDatum() throws HecMathException
      Returns a new PairedDataMath object constructed from this object if the internal data supports it, collapsing the internal data in the process
      Specified by:
      collapseVerticalDatum in interface IVerticalDatumOperations<PairedDataMath,HecMathException>
      Returns:
      The PairedDataMath object as described above or this object. In either case this object is not modified. A copy of this object is returned if it is not a PairedDataMathVertDatum object. All errors are thrown.
      Throws:
      HecMathException