net.agmodel.weatherData
Class RainImpl

java.lang.Object
  |
  +--net.agmodel.physical.GeneralSequenceImpl
        |
        +--net.agmodel.weatherData.GeneralMetSequenceImpl
              |
              +--net.agmodel.weatherData.RainImpl
All Implemented Interfaces:
Cloneable, CompoundSequence, MetSequence, Rain, Sequence, Serializable

public class RainImpl
extends GeneralMetSequenceImpl
implements Rain

Stores a sequence of rainfall totals.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class net.agmodel.weatherData.GeneralMetSequenceImpl
rb
 
Fields inherited from class net.agmodel.physical.GeneralSequenceImpl
dateRange, maximumTemporalInterpolation, summaryHistory
 
Constructor Summary
RainImpl(Interval dateRange, SummaryHistory composition)
          Creates a data sequence for an element.
 
Method Summary
 JigsawQuantity getAverage(Interval interval)
          Returns the average rainfall over the interval.
 String getContentsAsString(Date time, String delimiter)
          Returns the measurement associated with a particular time as a string.
 float[] getCoverage(int index)
          Indicates which array elements returned by getData(int) are missing.
 double[] getData(int index)
          Creates a one-dimensional array containing one subcomponent of the data.
 JigsawQuantity getMaximum(Interval interval)
          Returns the maximum rainfall over the interval.
 JigsawQuantity getMinimum(Interval interval)
          Returns the minimum rainfall over the interval.
 int getNumberOfSubComponents()
          Get the number of sub-components in the sequence.
 String getSubHeading(int index)
          Returns the subheading by looking up the corresponding key in WeatherDataResources
 JigsawQuantity getTotal(Date time)
          Returns the rainfall over the period preceding or including the time specified.
 JigsawQuantity getTotal(Interval interval)
          Returns the total rainfall over the interval.
 void putRainfallOverInterval(Interval interval, float value)
          Records the rainfall over some subinterval.
protected  void setStore(Store newStore)
           
 void setSubHeading(int index, String aHeading)
          Does nothing
 MetSequence summarize(Duration longerResolution)
          Creates a lower resolution sequence which summarizes this sequence
 RainImpl total(Duration newResolution)
          Creates a new rainfall sequence, totalling rainfall to a lower resolution.
 
Methods inherited from class net.agmodel.weatherData.GeneralMetSequenceImpl
getColumnHeading, getName, getSequenceElement, getSequenceHeading, getUnitsHeading, setColumnHeading, setName, setSequenceHeading, setUnitsHeading
 
Methods inherited from class net.agmodel.physical.GeneralSequenceImpl
cancelTemporalInterpolation, clone, dumpSequence, getAllCoverage, getAllData, getCurrentResolution, getDateRange, getMaximumTemporalInterpolation, getResolution, getSubHeading, getSummaryHistory, getSummaryKind, getTemporalInterpolation, getUnitsHeading, setTemporalInterpolation
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.agmodel.weatherData.MetSequence
getSequenceElement
 
Methods inherited from interface net.agmodel.physical.CompoundSequence
cancelTemporalInterpolation, getAllCoverage, getAllData, getMaximumTemporalInterpolation, getTemporalInterpolation, getUnitsHeading, setSequenceHeading, setTemporalInterpolation, setUnitsHeading
 
Methods inherited from interface net.agmodel.physical.Sequence
clone, dumpSequence, getColumnHeading, getCurrentResolution, getDateRange, getName, getResolution, getSequenceHeading, getSubHeading, getSummaryKind, getUnitsHeading, setColumnHeading, setName
 

Constructor Detail

RainImpl

public RainImpl(Interval dateRange,
                SummaryHistory composition)
Creates a data sequence for an element.

Parameters:
dateRange - the interval for which rainfall is stored
composition - a record of how raw rainfall data has been summarised to make the sequence.
Method Detail

putRainfallOverInterval

public void putRainfallOverInterval(Interval interval,
                                    float value)
Records the rainfall over some subinterval.

Parameters:
interval - the period of time over which the measurement was taken.
value - the rainfall over that interval
Throws:
IllegalArgumentException - if the subinterval is outside the interval that the sequence was constructed to store

getMinimum

public JigsawQuantity getMinimum(Interval interval)
Description copied from interface: Rain
Returns the minimum rainfall over the interval. Rainfall readings at either end of the interval are included in the comparison if more than 50% of their duration lies within the interval of interest.

Specified by:
getMinimum in interface Rain
Returns:
the minimum rainfall

getMaximum

public JigsawQuantity getMaximum(Interval interval)
Description copied from interface: Rain
Returns the maximum rainfall over the interval. Rainfall readings at either end of the interval are included in the comparison if more than 50% of their duration lies within the interval of interest.

Specified by:
getMaximum in interface Rain
Returns:
the maximum rainfall

getAverage

public JigsawQuantity getAverage(Interval interval)
Description copied from interface: Rain
Returns the average rainfall over the interval. Rainfall readings at either end of the interval are included by weighting their values according to the proportion of their duration that lies in the period of interest.

Specified by:
getAverage in interface Rain
Returns:
the average value

getTotal

public JigsawQuantity getTotal(Interval interval)
Description copied from interface: Rain
Returns the total rainfall over the interval. Rainfall readings at either end of the interval are included by weighting their values according to the proportion of their duration that lies in the period of interest.

Specified by:
getTotal in interface Rain
Returns:
the total value

getTotal

public JigsawQuantity getTotal(Date time)
Description copied from interface: Rain
Returns the rainfall over the period preceding or including the time specified.

Specified by:
getTotal in interface Rain
Returns:
the total value

setStore

protected void setStore(Store newStore)

total

public RainImpl total(Duration newResolution)
Creates a new rainfall sequence, totalling rainfall to a lower resolution.

Parameters:
newResolution - the target resolution required.
Returns:
a new rainfall sequence

getContentsAsString

public String getContentsAsString(Date time,
                                  String delimiter)
Description copied from interface: Sequence
Returns the measurement associated with a particular time as a string. Used by dumpSequence.

Specified by:
getContentsAsString in interface Sequence
Specified by:
getContentsAsString in class GeneralSequenceImpl
Parameters:
time - the time of interest.
delimiter - a string to use between values if required.

summarize

public MetSequence summarize(Duration longerResolution)
Description copied from interface: MetSequence
Creates a lower resolution sequence which summarizes this sequence

Specified by:
summarize in interface MetSequence
Parameters:
longerResolution - the new resolution to summarize to
Returns:
a summarized sequence.

getNumberOfSubComponents

public int getNumberOfSubComponents()
Description copied from interface: Sequence
Get the number of sub-components in the sequence. This indicates how many "columns" the sequence output will occupy.

Specified by:
getNumberOfSubComponents in interface Sequence
Specified by:
getNumberOfSubComponents in class GeneralMetSequenceImpl
Returns:
the number of sub-components
See Also:
Sequence.getSequenceHeading(String)

getSubHeading

public String getSubHeading(int index)
Returns the subheading by looking up the corresponding key in WeatherDataResources

Specified by:
getSubHeading in interface CompoundSequence
Specified by:
getSubHeading in class GeneralMetSequenceImpl
See Also:
Sequence.getNumberOfSubComponents(), Sequence.getSequenceHeading(String)

setSubHeading

public void setSubHeading(int index,
                          String aHeading)
Does nothing

Specified by:
setSubHeading in interface CompoundSequence
Specified by:
setSubHeading in class GeneralMetSequenceImpl
Parameters:
aHeading - the new heading
index - the zero-based index of the heading
See Also:
Sequence.getNumberOfSubComponents(), Sequence.getSequenceHeading(String)

getData

public double[] getData(int index)
Description copied from interface: CompoundSequence
Creates a one-dimensional array containing one subcomponent of the data. Use CompoundSequence.getCoverage(int) to test for missing values (at present these are returned as Double.NaN but don't rely on this).
Note that the first element of the array corresponds to getStart() and is therefore empty in most cases.

Specified by:
getData in interface CompoundSequence
Specified by:
getData in class GeneralSequenceImpl
Parameters:
index - the zero-based index of the subcomponent
Returns:
the subcomponent as a timeseries array.
See Also:
Sequence.getNumberOfSubComponents()

getCoverage

public float[] getCoverage(int index)
Description copied from interface: CompoundSequence
Indicates which array elements returned by CompoundSequence.getData(int) are missing. Coverage values are in the range JigsawQuantity.DEVOID to JigsawQuantity.COMPLETE.
Note that the first element of the array corresponds to getStart() and is therefore empty in most cases.

Specified by:
getCoverage in interface CompoundSequence
Specified by:
getCoverage in class GeneralSequenceImpl
Parameters:
index - the zero-based index of the subcomponent
Returns:
a array of the same length as that returned by getData()