Package uk.ac.rdg.resc.edal.dataset.cdm
Class CdmDatasetFactory
- java.lang.Object
-
- uk.ac.rdg.resc.edal.dataset.DatasetFactory
-
- uk.ac.rdg.resc.edal.dataset.cdm.CdmDatasetFactory
-
- Direct Known Subclasses:
CdmGridDatasetFactory
public abstract class CdmDatasetFactory extends DatasetFactory
DatasetFactory
that createsDataset
s representing gridded data read through the Unidata Common Data Model. Although multiple instances of thisDatasetFactory
can be created, all share a common cache of NetcdfDataset objects to speed up operations where the same dataset is accessed multiple times. To avoid excess file handles being open, this is a LRU cache which closes the datasets when they expire.- Author:
- Guy Griffiths
-
-
Field Summary
-
Fields inherited from class uk.ac.rdg.resc.edal.dataset.DatasetFactory
workingDir
-
-
Constructor Summary
Constructors Constructor Description CdmDatasetFactory()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description DiscreteLayeredDataset<? extends DataSource,? extends DiscreteLayeredVariableMetadata>
createDataset(String id, String location)
Returns a Dataset object representing the data at the given location.DiscreteLayeredDataset<? extends DataSource,? extends DiscreteLayeredVariableMetadata>
createDataset(String id, String location, boolean forceRefresh)
Returns a Dataset object representing the data at the given location.protected abstract DiscreteLayeredDataset<? extends DataSource,? extends DiscreteLayeredVariableMetadata>
generateDataset(String id, String location, ucar.nc2.dataset.NetcdfDataset nc)
Generate aDiscreteLayeredDataset
for the given ID, location, andNetcdfDataset
.protected ucar.nc2.dataset.NetcdfDataset
getNetcdfDatasetFromLocation(String location, boolean forceRefresh)
protected Parameter
getParameter(ucar.nc2.Variable variable)
Generates aParameter
object, correctly parsing categorical flags and creating theParameter.Category
s associated with theParameter
.protected static String
getVariableName(ucar.nc2.Variable var)
-
Methods inherited from class uk.ac.rdg.resc.edal.dataset.DatasetFactory
forName, setDefaultDatasetFactoryClass, setWorkingDirectory
-
-
-
-
Method Detail
-
createDataset
public DiscreteLayeredDataset<? extends DataSource,? extends DiscreteLayeredVariableMetadata> createDataset(String id, String location) throws IOException, EdalException
Description copied from class:DatasetFactory
Returns a Dataset object representing the data at the given location.- Overrides:
createDataset
in classDatasetFactory
- Parameters:
id
- The ID to assign to this datasetlocation
- The location of the source data: this may be a file, database connection string or a remote server address.- Throws:
EdalException
- If there is a problem creating the datasetIOException
-
createDataset
public DiscreteLayeredDataset<? extends DataSource,? extends DiscreteLayeredVariableMetadata> createDataset(String id, String location, boolean forceRefresh) throws EdalException
Description copied from class:DatasetFactory
Returns a Dataset object representing the data at the given location.- Specified by:
createDataset
in classDatasetFactory
- Parameters:
id
- The ID to assign to this datasetlocation
- The location of the source data: this may be a file, database connection string or a remote server address.forceRefresh
- Set totrue
to ensure that any cached information is not used- Throws:
EdalException
- If there is a problem creating the dataset
-
getNetcdfDatasetFromLocation
protected ucar.nc2.dataset.NetcdfDataset getNetcdfDatasetFromLocation(String location, boolean forceRefresh) throws IOException, EdalException
- Throws:
IOException
EdalException
-
getParameter
protected Parameter getParameter(ucar.nc2.Variable variable)
Generates aParameter
object, correctly parsing categorical flags and creating theParameter.Category
s associated with theParameter
. Subclasses should use this method to generateParameter
s.- Parameters:
variable
- TheVariable
object representing the variable in the NetCDF file- Returns:
- The resulting
Parameter
-
generateDataset
protected abstract DiscreteLayeredDataset<? extends DataSource,? extends DiscreteLayeredVariableMetadata> generateDataset(String id, String location, ucar.nc2.dataset.NetcdfDataset nc) throws IOException
Generate aDiscreteLayeredDataset
for the given ID, location, andNetcdfDataset
. Subclasses should use this to generate a simpleDiscreteLayeredDataset
- i.e. one with no additional plugins etc. All requiredVariablePlugin
s will be detected and handled by this class.- Parameters:
id
- The ID of theDataset
location
- The location of theDataset
(either on disk or online)nc
- TheNetcdfDataset
representing theDataset
- Returns:
- A
DiscreteLayeredDataset
- Throws:
IOException
- If there is a problem reading the underlyingNetcdfDataset
-
getVariableName
protected static String getVariableName(ucar.nc2.Variable var)
- Returns:
- the name of the phenomenon that the given variable represents. This name will be, in order of preference: The long name The standard name The variable name
-
-