Package uk.ac.rdg.resc.edal.dataset
Class HorizontallyDiscreteDataset<DS extends DataSource>
- java.lang.Object
-
- uk.ac.rdg.resc.edal.dataset.AbstractDataset
-
- uk.ac.rdg.resc.edal.dataset.HorizontallyDiscreteDataset<DS>
-
- Type Parameters:
DS
- The type ofDataSource
which will be used to read the underlying data
- All Implemented Interfaces:
Serializable
,Dataset
- Direct Known Subclasses:
DiscreteLayeredDataset
public abstract class HorizontallyDiscreteDataset<DS extends DataSource> extends AbstractDataset implements Serializable
A partial implementation of a 4-dimensionalDataset
which handles the use of plugins to generate values.- Author:
- Guy Griffiths, Jon Blower
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
HorizontallyDiscreteDataset.PointSeriesLocation
protected class
HorizontallyDiscreteDataset.ProfileLocation
-
Field Summary
-
Fields inherited from class uk.ac.rdg.resc.edal.dataset.AbstractDataset
id, plugins, vars
-
-
Constructor Summary
Constructors Constructor Description HorizontallyDiscreteDataset(String id, Collection<? extends VariableMetadata> vars)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description List<MapFeature>
extractMapFeatures(Set<String> varIds, MapDomain domain)
ExtractsMapFeature
s ready to be plotted on a mapPointCollectionFeature
extractPointCollection(Set<String> varIds, PointCollectionDomain domain)
Extracts aPointCollectionFeature
containing data from the given variable IDsList<? extends ProfileFeature>
extractProfileFeatures(Set<String> varIds, BoundingBox bbox, Extent<Double> zExtent, Extent<org.joda.time.DateTime> tExtent, HorizontalPosition targetPos, org.joda.time.DateTime targetTime)
ExtractsProfileFeature
(s) from theDataset
List<? extends PointSeriesFeature>
extractTimeseriesFeatures(Set<String> varIds, BoundingBox bbox, Extent<Double> zExtent, Extent<org.joda.time.DateTime> tExtent, HorizontalPosition targetPos, Double targetZ)
ExtractsPointSeriesFeature
(s) from theDataset
TrajectoryFeature
extractTrajectoryFeature(Set<String> varIds, TrajectoryDomain domain)
Extracts aTrajectoryFeature
containing data from the given variable IDsSet<String>
getFeatureIds()
By default we have one feature per variable.protected static int
getTimeIndex(org.joda.time.DateTime time, TimeAxis tAxis, String varId)
protected static int
getVerticalIndex(Double zPos, VerticalAxis zAxis, String varId)
protected abstract DS
openDataSource()
Number
readSinglePoint(String variableId, HorizontalPosition position, Double zVal, org.joda.time.DateTime time)
protected abstract Array2D<Number>
readUnderlyingHorizontalData(String varId, MapDomain domain, DS dataSource)
Reads horizontal data for a non-derived variableprotected abstract Number
readUnderlyingPointData(String variableId, HorizontalPosition position, Double zVal, org.joda.time.DateTime time, DS dataSource)
Reads a single point for a non-derived variableprotected abstract Map<HorizontallyDiscreteDataset.PointSeriesLocation,Array1D<Number>>
readUnderlyingTemporalData(String varId, TimeAxis tAxis, BoundingBox bbox, Double targetZ, Extent<Double> zExtent, DS dataSource)
Reads timeseries data for a given non-derived variableprotected abstract Map<HorizontallyDiscreteDataset.ProfileLocation,Array1D<Number>>
readUnderlyingVerticalData(String varId, VerticalAxis zAxis, BoundingBox bbox, org.joda.time.DateTime targetT, Extent<org.joda.time.DateTime> tExtent, DS dataSource)
Reads profile data for a given non-derived variableboolean
supportsProfileFeatureExtraction(String varId)
boolean
supportsTimeseriesExtraction(String varId)
-
Methods inherited from class uk.ac.rdg.resc.edal.dataset.AbstractDataset
addVariablePlugin, getId, getTopLevelVariables, getVariableIds, getVariableMetadata, isDerivedVariable
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface uk.ac.rdg.resc.edal.dataset.Dataset
getFeatureType, getMapFeatureType, readFeature
-
-
-
-
Constructor Detail
-
HorizontallyDiscreteDataset
public HorizontallyDiscreteDataset(String id, Collection<? extends VariableMetadata> vars)
-
-
Method Detail
-
getFeatureIds
public Set<String> getFeatureIds()
By default we have one feature per variable. Subclasses can override this method to implement a different scheme.- Specified by:
getFeatureIds
in interfaceDataset
- Returns:
- the IDs of features which are present in this Dataset
-
extractMapFeatures
public final List<MapFeature> extractMapFeatures(Set<String> varIds, MapDomain domain) throws DataReadingException, VariableNotFoundException
ExtractsMapFeature
s ready to be plotted on a map- Parameters:
varIds
- The IDs of the variables to extract from the datasetdomain
- The domain on which to extract the data.- Returns:
- A
List
ofMapFeature
s on the supplied domain - Throws:
DataReadingException
- if there is a problem reading the underlying dataVariableNotFoundException
- if one or more of the supplied variable IDs does not exist in the dataset
-
supportsProfileFeatureExtraction
public boolean supportsProfileFeatureExtraction(String varId)
- Specified by:
supportsProfileFeatureExtraction
in interfaceDataset
- Parameters:
varId
- The ID of the variable to extract- Returns:
true
if this dataset supports the extraction of the given variable toProfileFeature
s via theDataset.extractProfileFeatures(Set, BoundingBox, Extent, Extent, HorizontalPosition, DateTime)
method
-
extractProfileFeatures
public List<? extends ProfileFeature> extractProfileFeatures(Set<String> varIds, BoundingBox bbox, Extent<Double> zExtent, Extent<org.joda.time.DateTime> tExtent, HorizontalPosition targetPos, org.joda.time.DateTime targetTime) throws DataReadingException, UnsupportedOperationException, VariableNotFoundException
Description copied from interface:Dataset
ExtractsProfileFeature
(s) from theDataset
- Specified by:
extractProfileFeatures
in interfaceDataset
- Parameters:
varIds
- The variable IDs to extract. If this isnull
then all variable IDs will be plotted. Any non-scalar parent variables will have all of their child variables extracted.bbox
-- If this
BoundingBox
is non-null
, all measurements falling within it will be returned. - If it is
null
, only measurements which match the horizontal position given bytargetPos
will be extracted. - If both
bbox
andtargetPos
arenull
no constraint is placed on horizontal positions - e.g. for a gridded field a profile will be returned for every horizontal grid point.
- If this
zExtent
-- If this is non-
null
, allProfileFeature
s whose domains have any intersection with this vertical extent will be extracted. The domains of the extractedProfileFeature
s will be the entire available domains, not just the intersection. - If this is
null
, no constraint will be placed on the vertical domain of theProfileFeature
s to extract.
- If this is non-
tExtent
-- If this is non-
null
, all measurements which fall entirely within its extent will be extracted - If it is
null
only profiles matching the time specified bytargetT
will be extracted. - If
tExtent
andtargetT
are bothnull
,ProfileFeature
s for all available time values will be extracted.
- If this is non-
targetPos
-- If the
bbox
argument isnull
, only measurements which match this horizontal position will be extracted. In the case of a gridded feature, this will be the profile of the grid cell which the position falls into, but for a dataset with a continuousHorizontalDomain
only exact matches will be extracted - If both
bbox
andtargetPos
arenull
no constraint is placed on horizontal positions - e.g. for a gridded field a profile will be returned for every horizontal grid point. - If this is non-
null
, the resultingCollection
will be sorted according to distance (in co-ordinate units) from the target position
- If the
targetTime
-- If
tExtent
isnull
only profiles matching the time specified by this parameter will be extracted. In the case of a gridded dataset a time is considered to match if the methodTimeAxis#contains(DateTime)
on its time axis returnstrue
for the target time. For a non-gridded dataset, the feature time must exactly match the target time. - If
tExtent
andtargetT
are bothnull
,ProfileFeature
s for all available time values will be extracted.
- If
- Returns:
- A
Collection
ofProfileFeature
s, sorted by their distance from the target horizontal position, if it exists. - Throws:
DataReadingException
- if there is a problem reading the underlying dataUnsupportedOperationException
- if not all of the requested variables have a vertical domainVariableNotFoundException
- if one or more of the specified variables are not present in this dataset
-
supportsTimeseriesExtraction
public boolean supportsTimeseriesExtraction(String varId)
- Specified by:
supportsTimeseriesExtraction
in interfaceDataset
- Parameters:
varId
- The ID of the variable to extract- Returns:
true
if this dataset supports the extraction of the given variable toPointSeriesFeature
s via theDataset.extractTimeseriesFeatures(Set, BoundingBox, Extent, Extent, HorizontalPosition, Double)
method
-
extractTimeseriesFeatures
public List<? extends PointSeriesFeature> extractTimeseriesFeatures(Set<String> varIds, BoundingBox bbox, Extent<Double> zExtent, Extent<org.joda.time.DateTime> tExtent, HorizontalPosition targetPos, Double targetZ) throws DataReadingException, UnsupportedOperationException, VariableNotFoundException
Description copied from interface:Dataset
ExtractsPointSeriesFeature
(s) from theDataset
- Specified by:
extractTimeseriesFeatures
in interfaceDataset
- Parameters:
varIds
- The variable IDs to extract. If this isnull
then all variable IDs will be plotted. Any non-scalar parent variables will have all of their child variables extracted.bbox
-- If this
BoundingBox
is non-null
, all measurements falling within it will be returned. - If it is
null
, only measurements which match the horizontal position given bytargetPos
will be extracted. - If both
bbox
andtargetPos
arenull
no constraint is placed on horizontal positions - e.g. for a gridded field a profile will be returned for every horizontal grid point.
- If this
zExtent
-- If this is non-
null
, all measurements which fall entirely within its extent will be extracted - If it is
null
only timeseries matching the depth specified bytargetZ
will be extracted. - If
zExtent
andtargetZ
are bothnull
,PointSeriesFeature
s for all available depth values will be extracted.
- If this is non-
tExtent
-- If this is non-
null
, allPointSeriesFeature
s whose domains have any intersection with this time extent will be extracted. The domains of the extractedPointSeriesFeature
s will be the entire available domains, not just the intersection. - If this is
null
, no constraint will be placed on the time domain of thePointSeriesFeature
s to extract.
- If this is non-
targetPos
-- If the
bbox
argument isnull
, only measurements which match this horizontal position will be extracted. In the case of a gridded feature, this will be the profile of the grid cell which the position falls into, but for a dataset with a continuousHorizontalDomain
only exact matches will be extracted - If both
bbox
andtargetPos
arenull
no constraint is placed on horizontal positions - e.g. for a gridded field a profile will be returned for every horizontal grid point. - If this is non-
null
, the resultingCollection
will be sorted according to distance (in co-ordinate units) from the target position
- If the
targetZ
-- If
zExtent
isnull
only timeseries matching the depth specified by this parameter will be extracted. In the case of a gridded dataset a depth is considered to match if the methodVerticalAxis#contains(Double)
on its vertical axis returnstrue
for the target depth. For a non-gridded dataset, the feature depth must exactly match the target depth. - If
zExtent
andtargetZ
are bothnull
,PointSeriesFeature
s for all available time values will be extracted.
- If
- Returns:
- A
Collection
ofPointSeriesFeature
s, sorted by their distance from the target horizontal position, if it exists. - Throws:
DataReadingException
- if there is a problem reading the underlying dataUnsupportedOperationException
- if not all of the requested variables have a time domainVariableNotFoundException
- if one or more of the specified variables are not present in this dataset
-
extractPointCollection
public PointCollectionFeature extractPointCollection(Set<String> varIds, PointCollectionDomain domain) throws DataReadingException, VariableNotFoundException
Extracts aPointCollectionFeature
containing data from the given variable IDs- Parameters:
varIds
- The variables to extract data from. Ifnull
, all available variables will be present in the returnedPointCollectionFeature
domain
- ThePointCollectionDomain
over which to extract data- Returns:
- A
PointCollectionFeature
containing the extracted data - Throws:
DataReadingException
- If there is a problem reading the underlying dataVariableNotFoundException
- If one or more of the supplied variable IDs is not present in thisHorizontallyDiscreteDataset
-
extractTrajectoryFeature
public TrajectoryFeature extractTrajectoryFeature(Set<String> varIds, TrajectoryDomain domain) throws DataReadingException, VariableNotFoundException
Extracts aTrajectoryFeature
containing data from the given variable IDs- Parameters:
varIds
- The variables to extract data from. Ifnull
, all available variables will be present in the returnedTrajectoryFeature
domain
- TheTrajectoryDomain
over which to extract data- Returns:
- A
TrajectoryFeature
containing the extracted data - Throws:
DataReadingException
- If there is a problem reading the underlying dataVariableNotFoundException
- If one or more of the supplied variable IDs is not present in thisHorizontallyDiscreteDataset
-
readSinglePoint
public final Number readSinglePoint(String variableId, HorizontalPosition position, Double zVal, org.joda.time.DateTime time) throws DataReadingException, VariableNotFoundException
-
getTimeIndex
protected static int getTimeIndex(org.joda.time.DateTime time, TimeAxis tAxis, String varId)
-
getVerticalIndex
protected static int getVerticalIndex(Double zPos, VerticalAxis zAxis, String varId)
-
readUnderlyingPointData
protected abstract Number readUnderlyingPointData(String variableId, HorizontalPosition position, Double zVal, org.joda.time.DateTime time, DS dataSource) throws DataReadingException, VariableNotFoundException
Reads a single point for a non-derived variable- Parameters:
variableId
- The ID of the variable to readposition
- TheHorizontalPosition
at which to read the datazVal
- The z-position to read attime
- The time to read atdataSource
- TheDataSource
to read from- Returns:
- The value of the data, or
null
if there is no data there - Throws:
DataReadingException
- If there is a problem reading the dataVariableNotFoundException
- If the requested variable is not present in theDataset
-
readUnderlyingHorizontalData
protected abstract Array2D<Number> readUnderlyingHorizontalData(String varId, MapDomain domain, DS dataSource) throws DataReadingException, VariableNotFoundException
Reads horizontal data for a non-derived variable- Parameters:
varId
- The ID of the variable to readdomain
- TheMapDomain
on which to read datadataSource
- TheHorizontallyDiscreteDataset
to read data from- Returns:
- An
Array2D
containing the data corresponding to the suppliedMapDomain
- Throws:
DataReadingException
- If there is a problem reading the dataVariableNotFoundException
- If the requested variable is not present in theDataset
-
readUnderlyingVerticalData
protected abstract Map<HorizontallyDiscreteDataset.ProfileLocation,Array1D<Number>> readUnderlyingVerticalData(String varId, VerticalAxis zAxis, BoundingBox bbox, org.joda.time.DateTime targetT, Extent<org.joda.time.DateTime> tExtent, DS dataSource) throws DataReadingException, VariableNotFoundException
Reads profile data for a given non-derived variable- Parameters:
varId
- The of the variable to read data forzAxis
- The desired vertical axis of the databbox
- TheBoundingBox
within which to read profilestargetT
- The target time at which to read profilestExtent
- The timeExtent
within which to read profilesdataSource
- TheDataSource
to read from- Returns:
- A
Map
of unique profile locations to data for each - Throws:
DataReadingException
- If there was a problem reading data from theDataSource
VariableNotFoundException
- If the requested variable is not present in theDataset
-
readUnderlyingTemporalData
protected abstract Map<HorizontallyDiscreteDataset.PointSeriesLocation,Array1D<Number>> readUnderlyingTemporalData(String varId, TimeAxis tAxis, BoundingBox bbox, Double targetZ, Extent<Double> zExtent, DS dataSource) throws DataReadingException, VariableNotFoundException
Reads timeseries data for a given non-derived variable- Parameters:
varId
- The of the variable to read data fortAxis
- The desired time axis of the databbox
- TheBoundingBox
within which to read timeseriestargetZ
- The target depth to read timeseries atzExtent
- The verticalExtent
within which to read timeseriesdataSource
- TheDataSource
to read from- Returns:
- A
Map
of unique profile locations to data for each - Throws:
DataReadingException
- If there was a problem reading data from theDataSource
VariableNotFoundException
- If the requested variable is not present in theDataset
-
openDataSource
protected abstract DS openDataSource() throws DataReadingException
- Returns:
- The
DataSource
from which to read data - Throws:
DataReadingException
- if there is a problem opening theDataSource
-
-