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
DatasetFactorythat createsDatasets representing gridded data read through the Unidata Common Data Model. Although multiple instances of thisDatasetFactorycan 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 aDiscreteLayeredDatasetfor the given ID, location, andNetcdfDataset.protected ucar.nc2.dataset.NetcdfDatasetgetNetcdfDatasetFromLocation(String location, boolean forceRefresh)protected ParametergetParameter(ucar.nc2.Variable variable)Generates aParameterobject, correctly parsing categorical flags and creating theParameter.Categorys associated with theParameter.protected static StringgetVariableName(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:DatasetFactoryReturns a Dataset object representing the data at the given location.- Overrides:
createDatasetin 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:DatasetFactoryReturns a Dataset object representing the data at the given location.- Specified by:
createDatasetin 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 totrueto 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:
IOExceptionEdalException
-
getParameter
protected Parameter getParameter(ucar.nc2.Variable variable)
Generates aParameterobject, correctly parsing categorical flags and creating theParameter.Categorys associated with theParameter. Subclasses should use this method to generateParameters.- Parameters:
variable- TheVariableobject 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 aDiscreteLayeredDatasetfor the given ID, location, andNetcdfDataset. Subclasses should use this to generate a simpleDiscreteLayeredDataset- i.e. one with no additional plugins etc. All requiredVariablePlugins will be detected and handled by this class.- Parameters:
id- The ID of theDatasetlocation- The location of theDataset(either on disk or online)nc- TheNetcdfDatasetrepresenting 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
-
-