net.agmodel.weatherData
Class MultiImpl

java.lang.Object
  |
  +--net.agmodel.physical.GeneralSequenceImpl
        |
        +--net.agmodel.weatherData.GeneralMetSequenceImpl
              |
              +--net.agmodel.weatherData.MultiImpl
All Implemented Interfaces:
Cloneable, CompoundSequence, MetSequence, MultiQuantity, Sequence, Serializable
Direct Known Subclasses:
AirTempMultiImpl, LeafWetnessMultiImpl, SoilTemperatureImpl, WindProfileImpl

public abstract class MultiImpl
extends GeneralMetSequenceImpl
implements MultiQuantity

Manages a set of readings with more than one component.

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
protected MultiImpl(MetElement element, Interval dateRange, SummaryHistory composition, int nSubComponents)
          Creates a MultiImpl with space for n subcomponents, but doesn't create the stores themselves.
  MultiImpl(MetElement element, Interval dateRange, SummaryHistory composition, String[] newlabels)
          Creates a MultiImpl using an array of Strings to indicate the number and name of the subcomponents.
 
Method Summary
 Object clone()
           
 JigsawQuantity getAverage(int index, Interval interval)
          Returns the average temperature 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 new set of readings, averaging values to a lower resolution.
 JigsawQuantity getInstant(int index, Date time)
          Returns the instantaneous temperature at a particular point in time.
 JigsawQuantity getMaximum(int index, Interval interval)
          Returns the maximum temperature over the interval.
 JigsawQuantity getMinimum(int index, Interval interval)
          Returns the minimum temperature over the interval.
 int getNumberOfSubComponents()
          Get the number of sub-components in the sequence.
protected  Store getStore(int index)
           
 String getSubHeading(int index)
          Gets a brief description of the data stored in a Sequence subcomponent in the language of the default locale.
 void putInstantValue(int index, Date time, float value)
          Records an instantaneous value at a time
 void putValueOverInterval(int index, Interval interval, float value)
          Records the average value of a component over some subinterval.
protected  void setStore(int index, Store newStore)
           
 void setSubHeading(int index, String aHeading)
          Does nothing
 
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, 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, summarize
 
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
dumpSequence, getColumnHeading, getCurrentResolution, getDateRange, getName, getResolution, getSequenceHeading, getSubHeading, getSummaryKind, getUnitsHeading, setColumnHeading, setName
 

Constructor Detail

MultiImpl

protected MultiImpl(MetElement element,
                    Interval dateRange,
                    SummaryHistory composition,
                    int nSubComponents)
Creates a MultiImpl with space for n subcomponents, but doesn't create the stores themselves. Relies on subsequent calls to setStore to complete initialisation.


MultiImpl

public MultiImpl(MetElement element,
                 Interval dateRange,
                 SummaryHistory composition,
                 String[] newlabels)
Creates a MultiImpl using an array of Strings to indicate the number and name of the subcomponents. The Strings should be keys in net.agmodel.resources.WeatherDataResources, however if they are not found there the string itself will be used as the label. However, please advise that you would like the key added to WeatherDataResources.

Parameters:
newlabels - labels for the subcomponents
Method Detail

setStore

protected void setStore(int index,
                        Store newStore)

getStore

protected Store getStore(int index)

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)
Description copied from interface: CompoundSequence
Gets a brief description of the data stored in a Sequence subcomponent in the language of the default locale. This value can be used as a column sub heading if the sequence is listed. It is assumed to be in the context of an overall column heading.

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)

getMinimum

public JigsawQuantity getMinimum(int index,
                                 Interval interval)
Description copied from interface: MultiQuantity
Returns the minimum temperature over the interval. Temperatures 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 MultiQuantity
Parameters:
interval - the interval of interest
index - the component of interest (0-based)
Returns:
the minimum temperature

getMaximum

public JigsawQuantity getMaximum(int index,
                                 Interval interval)
Description copied from interface: MultiQuantity
Returns the maximum temperature over the interval. Sequence values 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 MultiQuantity
Parameters:
interval - the interval of interest
index - the component of interest (0-based)
Returns:
the maximum value

getInstant

public JigsawQuantity getInstant(int index,
                                 Date time)
Description copied from interface: MultiQuantity
Returns the instantaneous temperature at a particular point in time. If interpolation is requested, the value may be spatially and/or temporally interpolated from other data.

Specified by:
getInstant in interface MultiQuantity
Parameters:
time - the time of interest
index - the component of interest (0-based)
Returns:
the instantaneous value

getAverage

public JigsawQuantity getAverage(int index,
                                 Interval interval)
Description copied from interface: MultiQuantity
Returns the average temperature over the interval. Temperatures 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 MultiQuantity
Parameters:
interval - the interval of interest
index - the component of interest (0-based)
Returns:
the average value

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.

putInstantValue

public void putInstantValue(int index,
                            Date time,
                            float value)
Records an instantaneous value at a time

Parameters:
index - the subcomponent index
time - the point in time
value - the temperature at that time
Throws:
IllegalArgumentException - if the time is outside the interval that the period is intended to store

putValueOverInterval

public void putValueOverInterval(int index,
                                 Interval interval,
                                 float value)
Records the average value of a component over some subinterval.

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

getData

public double[] getData(int index)
Creates a new set of readings, averaging values to a lower resolution.

Specified by:
getData in interface CompoundSequence
Specified by:
getData in class GeneralSequenceImpl
Parameters:
index - the zero-based index of the subcomponent
Returns:
a new multi sequence public MultiImpl average(Duration newResolution){ if (newResolution.compareTo(getCurrentResolution())<=0) throw new IllegalArgumentException("average called with shorter resolution than current"); else { SummaryHistory history=getStore(0).getSummaryHistory(); history.addHistoryElement(new SummaryHistoryElement(newResolution, SummaryKind.AVERAGE)); MultiImpl result=new MultiImpl(getSequenceElement(),getDateRange(),history,getNumberOfSubComponents()); for (int i=0;iSee 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()

clone

public Object clone()
Specified by:
clone in interface Sequence
Overrides:
clone in class GeneralSequenceImpl