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 ofDataSourcewhich 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-dimensionalDatasetwhich 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 classHorizontallyDiscreteDataset.PointSeriesLocationprotected classHorizontallyDiscreteDataset.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)ExtractsMapFeatures ready to be plotted on a mapPointCollectionFeatureextractPointCollection(Set<String> varIds, PointCollectionDomain domain)Extracts aPointCollectionFeaturecontaining 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 theDatasetList<? extends PointSeriesFeature>extractTimeseriesFeatures(Set<String> varIds, BoundingBox bbox, Extent<Double> zExtent, Extent<org.joda.time.DateTime> tExtent, HorizontalPosition targetPos, Double targetZ)ExtractsPointSeriesFeature(s) from theDatasetTrajectoryFeatureextractTrajectoryFeature(Set<String> varIds, TrajectoryDomain domain)Extracts aTrajectoryFeaturecontaining data from the given variable IDsSet<String>getFeatureIds()By default we have one feature per variable.protected static intgetTimeIndex(org.joda.time.DateTime time, TimeAxis tAxis, String varId)protected static intgetVerticalIndex(Double zPos, VerticalAxis zAxis, String varId)protected abstract DSopenDataSource()NumberreadSinglePoint(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 NumberreadUnderlyingPointData(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 variablebooleansupportsProfileFeatureExtraction(String varId)booleansupportsTimeseriesExtraction(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:
getFeatureIdsin 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
ExtractsMapFeatures 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
ListofMapFeatures 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:
supportsProfileFeatureExtractionin interfaceDataset- Parameters:
varId- The ID of the variable to extract- Returns:
trueif this dataset supports the extraction of the given variable toProfileFeatures 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:DatasetExtractsProfileFeature(s) from theDataset- Specified by:
extractProfileFeaturesin interfaceDataset- Parameters:
varIds- The variable IDs to extract. If this isnullthen all variable IDs will be plotted. Any non-scalar parent variables will have all of their child variables extracted.bbox-- If this
BoundingBoxis non-null, all measurements falling within it will be returned. - If it is
null, only measurements which match the horizontal position given bytargetPoswill be extracted. - If both
bboxandtargetPosarenullno 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, allProfileFeatures whose domains have any intersection with this vertical extent will be extracted. The domains of the extractedProfileFeatures will be the entire available domains, not just the intersection. - If this is
null, no constraint will be placed on the vertical domain of theProfileFeatures 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
nullonly profiles matching the time specified bytargetTwill be extracted. - If
tExtentandtargetTare bothnull,ProfileFeatures for all available time values will be extracted.
- If this is non-
targetPos-- If the
bboxargument 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 continuousHorizontalDomainonly exact matches will be extracted - If both
bboxandtargetPosarenullno 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 resultingCollectionwill be sorted according to distance (in co-ordinate units) from the target position
- If the
targetTime-- If
tExtentisnullonly 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 returnstruefor the target time. For a non-gridded dataset, the feature time must exactly match the target time. - If
tExtentandtargetTare bothnull,ProfileFeatures for all available time values will be extracted.
- If
- Returns:
- A
CollectionofProfileFeatures, 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:
supportsTimeseriesExtractionin interfaceDataset- Parameters:
varId- The ID of the variable to extract- Returns:
trueif this dataset supports the extraction of the given variable toPointSeriesFeatures 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:DatasetExtractsPointSeriesFeature(s) from theDataset- Specified by:
extractTimeseriesFeaturesin interfaceDataset- Parameters:
varIds- The variable IDs to extract. If this isnullthen all variable IDs will be plotted. Any non-scalar parent variables will have all of their child variables extracted.bbox-- If this
BoundingBoxis non-null, all measurements falling within it will be returned. - If it is
null, only measurements which match the horizontal position given bytargetPoswill be extracted. - If both
bboxandtargetPosarenullno 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
nullonly timeseries matching the depth specified bytargetZwill be extracted. - If
zExtentandtargetZare bothnull,PointSeriesFeatures for all available depth values will be extracted.
- If this is non-
tExtent-- If this is non-
null, allPointSeriesFeatures whose domains have any intersection with this time extent will be extracted. The domains of the extractedPointSeriesFeatures will be the entire available domains, not just the intersection. - If this is
null, no constraint will be placed on the time domain of thePointSeriesFeatures to extract.
- If this is non-
targetPos-- If the
bboxargument 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 continuousHorizontalDomainonly exact matches will be extracted - If both
bboxandtargetPosarenullno 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 resultingCollectionwill be sorted according to distance (in co-ordinate units) from the target position
- If the
targetZ-- If
zExtentisnullonly 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 returnstruefor the target depth. For a non-gridded dataset, the feature depth must exactly match the target depth. - If
zExtentandtargetZare bothnull,PointSeriesFeatures for all available time values will be extracted.
- If
- Returns:
- A
CollectionofPointSeriesFeatures, 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 aPointCollectionFeaturecontaining data from the given variable IDs- Parameters:
varIds- The variables to extract data from. Ifnull, all available variables will be present in the returnedPointCollectionFeaturedomain- ThePointCollectionDomainover which to extract data- Returns:
- A
PointCollectionFeaturecontaining 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 aTrajectoryFeaturecontaining data from the given variable IDs- Parameters:
varIds- The variables to extract data from. Ifnull, all available variables will be present in the returnedTrajectoryFeaturedomain- TheTrajectoryDomainover which to extract data- Returns:
- A
TrajectoryFeaturecontaining 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- TheHorizontalPositionat which to read the datazVal- The z-position to read attime- The time to read atdataSource- TheDataSourceto read from- Returns:
- The value of the data, or
nullif 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- TheMapDomainon which to read datadataSource- TheHorizontallyDiscreteDatasetto read data from- Returns:
- An
Array2Dcontaining 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- TheBoundingBoxwithin which to read profilestargetT- The target time at which to read profilestExtent- The timeExtentwithin which to read profilesdataSource- TheDataSourceto read from- Returns:
- A
Mapof unique profile locations to data for each - Throws:
DataReadingException- If there was a problem reading data from theDataSourceVariableNotFoundException- 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- TheBoundingBoxwithin which to read timeseriestargetZ- The target depth to read timeseries atzExtent- The verticalExtentwithin which to read timeseriesdataSource- TheDataSourceto read from- Returns:
- A
Mapof unique profile locations to data for each - Throws:
DataReadingException- If there was a problem reading data from theDataSourceVariableNotFoundException- If the requested variable is not present in theDataset
-
openDataSource
protected abstract DS openDataSource() throws DataReadingException
- Returns:
- The
DataSourcefrom which to read data - Throws:
DataReadingException- if there is a problem opening theDataSource
-
-