net.agmodel.weatherData
Class WindImpl

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

public class WindImpl
extends GeneralMetSequenceImpl
implements Wind

Stores a sequence of wind readings including speed and/or direction. Wind speeds are stored internally in m/s.

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
WindImpl(Interval dateRange, SummaryHistory composition, double height, String heightUnits)
          Creates a wind sequence which can store speed and/or direction.
 
Method Summary
 WindImpl average(Duration newResolution)
          Creates a new wind sequence, averaging wind to a lower resolution.
 Object clone()
           
 JigsawQuantity getAverageSpeed(Interval interval)
          Returns the average wind speed over the interval.
 String getColumnHeading()
          Returned a localized label for the Sequence
 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.
 String getHeightUnits()
          Gets the units for the wind measurement height.
 JigsawQuantity getInstantDirection(Date time)
          Returns the instantaneous wind speed at a particular point in time.
 JigsawQuantity getInstantSpeed(Date time)
          Returns the instantaneous wind speed at a particular point in time.
 JigsawQuantity getMaxSpeed(Interval interval)
          Returns the maximum wind speed over the interval.
 double getMeasurementHeight()
          Gets the height of the wind measurement
 JigsawQuantity getMinSpeed(Interval interval)
          Returns the minimum wind speed over the interval.
 int getNumberOfSubComponents()
          Get the number of sub-components in the sequence.
 float[] getRose(Interval interval, int divisions)
          Returns the distribution of wind directions as an array.
 String getSubHeading(int index)
          Returns windspeed as element 0, if available
 String getUnitsHeading(int index)
          Gets a string representation of the measurement units of the column.
 JigsawQuantity getWindRun(Interval interval)
          Returns the total windrun over the interval.
 boolean hasDirection()
          Returns whether wind direction data are stored in the sequence
 boolean hasSpeed()
          Returns whether wind speed data are stored in the sequence
static float NSEWtoDegrees(String octString)
          Converts a string of the form "N" (North) or "NW" (NorthWest) or "WNW" (West Northwest) into the corresponding bearing in degrees.
 void putDirectionOverInterval(Interval interval, float value)
          Records the wind direction over some subinterval.
 void putDirectionOverInterval(Interval interval, String value)
          Records the wind direction over some subinterval.
 void putInstantDirection(Date time, float value)
          Records the instantaneous wind direction.
 void putInstantDirection(Date time, String value)
          Records the instantaneous wind direction.
 void putInstantSpeed(Date time, float value)
          Records the instantaneous wind speed at a particular time
 void putSpeedOverInterval(Interval interval, float value)
          Records the average wind speed over some subinterval.
 void putWindRun(Interval interval, float valuekm)
          Records the wind run over some subinterval.
protected  void setDirectionStore(Store newDir)
           
protected  void setSpeedStore(Store newSpeed)
           
 void setSubHeading(int index, String aHeading)
          Does nothing
 void setUnitsHeading(int index, String aHeading)
          Does nothing
 MetSequence summarize(Duration longerResolution)
          Creates a lower resolution sequence which summarizes this sequence
 
Methods inherited from class net.agmodel.weatherData.GeneralMetSequenceImpl
getName, getSequenceElement, getSequenceHeading, setColumnHeading, setName, setSequenceHeading
 
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
 
Methods inherited from interface net.agmodel.physical.CompoundSequence
cancelTemporalInterpolation, getAllCoverage, getAllData, getMaximumTemporalInterpolation, getTemporalInterpolation, setSequenceHeading, setTemporalInterpolation
 
Methods inherited from interface net.agmodel.physical.Sequence
dumpSequence, getCurrentResolution, getDateRange, getName, getResolution, getSequenceHeading, getSubHeading, getSummaryKind, getUnitsHeading, setColumnHeading, setName
 

Constructor Detail

WindImpl

public WindImpl(Interval dateRange,
                SummaryHistory composition,
                double height,
                String heightUnits)
Creates a wind sequence which can store speed and/or direction.

Parameters:
dateRange - the interval over which wind speeds can be stored
composition - a record of how raw wind data has been summarised to make the sequence.
Method Detail

NSEWtoDegrees

public static float NSEWtoDegrees(String octString)
Converts a string of the form "N" (North) or "NW" (NorthWest) or "WNW" (West Northwest) into the corresponding bearing in degrees. In this version the string must use the characters NSEW or the unified kanji for North, South, East and West. The method is not strict about order when it doesn't change the meaning - eg WN is considered the same as NW. Code developed by Yamakawa Atsushi.

Parameters:
octString -
Returns:
the bearing in degress
Throws:
IllegalArgumentException - if the string cannot be recognized as a valid direction.

setSpeedStore

protected void setSpeedStore(Store newSpeed)

setDirectionStore

protected void setDirectionStore(Store newDir)

hasSpeed

public boolean hasSpeed()
Description copied from interface: Wind
Returns whether wind speed data are stored in the sequence

Specified by:
hasSpeed in interface Wind
Returns:
true if wind speed data are stored, false otherwise

hasDirection

public boolean hasDirection()
Description copied from interface: Wind
Returns whether wind direction data are stored in the sequence

Specified by:
hasDirection in interface Wind
Returns:
true if wind direction data are stored, false otherwise

getMeasurementHeight

public double getMeasurementHeight()
Description copied from interface: Wind
Gets the height of the wind measurement

Specified by:
getMeasurementHeight in interface Wind
Returns:
the height, in units expressed by Wind.getHeightUnits()

getHeightUnits

public String getHeightUnits()
Description copied from interface: Wind
Gets the units for the wind measurement height.

Specified by:
getHeightUnits in interface Wind
Returns:
the height units

putInstantSpeed

public void putInstantSpeed(Date time,
                            float value)
Records the instantaneous wind speed at a particular time

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

putSpeedOverInterval

public void putSpeedOverInterval(Interval interval,
                                 float value)
Records the average wind speed over some subinterval.

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

putWindRun

public void putWindRun(Interval interval,
                       float valuekm)
Records the wind run over some subinterval.

Parameters:
interval - the period of time over which the measurement was taken.
valuekm - the wind run in km over that interval
Throws:
IllegalArgumentException - if the subinterval is outside the interval that the sequence was constructed to store

getMinSpeed

public JigsawQuantity getMinSpeed(Interval interval)
Description copied from interface: Wind
Returns the minimum wind speed over the interval. Wind speeds 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:
getMinSpeed in interface Wind
Returns:
the minimum wind speed (m/s)

getMaxSpeed

public JigsawQuantity getMaxSpeed(Interval interval)
Description copied from interface: Wind
Returns the maximum wind speed 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:
getMaxSpeed in interface Wind
Returns:
the maximum wind speed (m/s)

getInstantSpeed

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

Specified by:
getInstantSpeed in interface Wind
Returns:
the instantaneous wind speed (m/s)

getAverageSpeed

public JigsawQuantity getAverageSpeed(Interval interval)
Description copied from interface: Wind
Returns the average wind speed over the interval. Wind speeds 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:
getAverageSpeed in interface Wind
Returns:
the average wind speed (m/s)

getWindRun

public JigsawQuantity getWindRun(Interval interval)
Description copied from interface: Wind
Returns the total windrun over the interval. Wind speeds 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:
getWindRun in interface Wind
Returns:
the total wind run (km)

putInstantDirection

public void putInstantDirection(Date time,
                                String value)
Records the instantaneous wind direction.

Parameters:
time - the that the direction was measured.
value - the wind direction at that time represented as a string using NSEW or the corresponding kanji.
Throws:
IllegalArgumentException - if the subinterval is outside the interval that the sequence was constructed to store, or the direction string is wrong.

putDirectionOverInterval

public void putDirectionOverInterval(Interval interval,
                                     String value)
Records the wind direction over some subinterval. It is assumed that the direction is relatively constant during the interval.

Parameters:
interval - the period of time over which the measurement was taken.
value - the average wind speed over that interval represented as a string using NSEW or the corresponding kanji.
Throws:
IllegalArgumentException - if the subinterval is outside the interval that the sequence was constructed to store, or the direction string is wrong.

putInstantDirection

public void putInstantDirection(Date time,
                                float value)
Records the instantaneous wind direction.

Parameters:
time - the that the direction was measured.
value - the wind direction at that time.
Throws:
IllegalArgumentException - if the subinterval is outside the interval that the sequence was constructed to store

putDirectionOverInterval

public void putDirectionOverInterval(Interval interval,
                                     float value)
Records the wind direction over some subinterval. It is assumed that the direction is relatively constant during the interval.

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

getRose

public float[] getRose(Interval interval,
                       int divisions)
Description copied from interface: Wind
Returns the distribution of wind directions as an array. The first array element indicates the proportion of time (0-1) that the wind was coming from a direction between 0 and 360/(number of classes) ) The range is one sided, including 0 but not 360/n.

Specified by:
getRose in interface Wind
Parameters:
interval - the period of interest.
divisions - the number of classes in the resulting array
Returns:
the instantaneous value

getInstantDirection

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

Specified by:
getInstantDirection in interface Wind
Returns:
the instantaneous direction (in degrees)

getColumnHeading

public String getColumnHeading()
Deprecated.  

Description copied from interface: Sequence
Returned a localized label for the Sequence

Specified by:
getColumnHeading in interface Sequence
Overrides:
getColumnHeading in class GeneralMetSequenceImpl

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 windspeed as element 0, if available

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

getUnitsHeading

public String getUnitsHeading(int index)
Description copied from interface: CompoundSequence
Gets a string representation of the measurement units of the column. This value is typically used as part of the column heading when the sequence is listed. It is assumed to be in the context of an overall column heading.

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

setUnitsHeading

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

Specified by:
setUnitsHeading in interface CompoundSequence
Overrides:
setUnitsHeading in class GeneralMetSequenceImpl
Parameters:
index - the zero-based index of the heading
aHeading - the new heading
See Also:
Sequence.getNumberOfSubComponents(), CompoundSequence.setSequenceHeading(String), CompoundSequence.setSubHeading(int,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)

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.

average

public WindImpl average(Duration newResolution)
Creates a new wind sequence, averaging wind to a lower resolution. The instaneous wind direction at the end of the subinterval is used in the new sequence.

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

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.

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()

clone

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