Package ucar.nc2.dt.grid
Class GridDataset
- java.lang.Object
-
- ucar.nc2.dt.grid.GridDataset
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,GridDataset
,FeatureDataset
,FileCacheable
public class GridDataset extends Object implements GridDataset, FeatureDataset
Make a NetcdfDataset into a collection of GeoGrids with Georeferencing coordinate systems. A variable will be made into a GeoGrid if it has a Georeferencing coordinate system, using GridCoordSys.isGridCoordSys(), and it has no extra dimensions, ie GridCoordSys.isComplete( var) is true. If it has multiple Georeferencing coordinate systems, any one that is a product set will be given preference. Example:GridDataset gridDs = GridDataset.open(uriString); List grids = gridDs.getGrids(); for (int i = 0; i < grids.size(); i++) { GeoGrid grid = (Geogrid) grids.get(i); }
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GridDataset.Gridset
This is a set of GeoGrids with the same GeoCoordSys.
-
Field Summary
Fields Modifier and Type Field Description protected FileCacheIF
fileCache
-
Constructor Summary
Constructors Constructor Description GridDataset(NetcdfDataset ncd)
Create a GridDataset from a NetcdfDataset.GridDataset(NetcdfDataset ncd, Formatter parseInfo)
Create a GridDataset from a NetcdfDataset.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description AttributeContainer
attributes()
Get the global attributes.void
calcBounds()
void
close()
Close all resources associated with this dataset.static GridDataset
factory(String netcdfFileURI)
Deprecated.: use GridDataset.open().Attribute
findGlobalAttributeIgnoreCase(String name)
Return the global attribute with the given name, ignoring case.GeoGrid
findGridByName(String fullName)
find the named GeoGrid.GeoGrid
findGridByShortName(String shortName)
find the named GeoGrid.GridDatatype
findGridDatatype(String name)
find the named GridDatatype.GeoGrid
findGridDatatypeByAttribute(String attName, String attValue)
LatLonRect
getBoundingBox()
The lat/lon boundingBox for the entire dataset.CalendarDate
getCalendarDateEnd()
Ending Calendar date for the entire dataset.CalendarDateRange
getCalendarDateRange()
Calendar Date range for the entire dataset.CalendarDate
getCalendarDateStart()
Starting Calendar date for the entire dataset.VariableSimpleIF
getDataVariable(String shortName)
Get the named data Variable.List<VariableSimpleIF>
getDataVariables()
The data Variables available in this dataset.DateRange
getDateRange()
Deprecated.use getCalendarDateRangeString
getDescription()
Text information about this dataset.String
getDetailInfo()
Get Details about the dataset.void
getDetailInfo(Formatter buff)
Show debug / underlying implementation detailsDate
getEndDate()
Deprecated.use getEndCalendarDateFeatureType
getFeatureType()
Contains collections of this FeatureType.List<Attribute>
getGlobalAttributes()
List of global attributes.List<GridDatatype>
getGrids()
get the list of GridDatatype objects contained in this dataset.List<GridDataset.Gridset>
getGridsets()
Return GridDatatype objects grouped by GridCoordSys.String
getImplementationName()
Show who is implementinglong
getLastModified()
Returns the time that the underlying file(s) were last modified.String
getLocation()
The URI location of the datasetString
getName()
the name of the dataset is the last part of the locationNetcdfDataset
getNetcdfDataset()
NetcdfFile
getNetcdfFile()
Return underlying NetcdfFile, or null if none.ProjectionRect
getProjBoundingBox()
Date
getStartDate()
Deprecated.use getStartCalendarDateString
getTitle()
Title of the dataset.static GridDataset
open(String location)
Open a netcdf dataset, using NetcdfDataset.defaultEnhanceMode plus CoordSystems and turn into a GridDataset.static GridDataset
open(String location, Set<NetcdfDataset.Enhance> enhanceMode)
Open a netcdf dataset, using NetcdfDataset.defaultEnhanceMode plus CoordSystems and turn into a GridDataset.static GridDataset
openIfce(String location)
Open a netcdf dataset, using NetcdfDataset.defaultEnhanceMode plus CoordSystems and return a ucar.nc2.dt.GridDataset interface.static GridDataset
openIfce(String location, Set<NetcdfDataset.Enhance> enhanceMode)
Open a netcdf dataset, using NetcdfDataset.defaultEnhanceMode plus CoordSystems and return a ucar.nc2.dt.GridDataset interface.void
reacquire()
Deprecated.do not usevoid
release()
Deprecated.do not usevoid
setFileCache(FileCacheIF fileCache)
Deprecated.do not use
-
-
-
Field Detail
-
fileCache
protected FileCacheIF fileCache
-
-
Constructor Detail
-
GridDataset
public GridDataset(NetcdfDataset ncd) throws IOException
Create a GridDataset from a NetcdfDataset.- Parameters:
ncd
- underlying NetcdfDataset, will do Enhance.CoordSystems if not already done.- Throws:
IOException
- on read error
-
GridDataset
public GridDataset(NetcdfDataset ncd, Formatter parseInfo) throws IOException
Create a GridDataset from a NetcdfDataset.- Parameters:
ncd
- underlying NetcdfDataset, will do Enhance.CoordSystems if not already done.parseInfo
- put parse info here, may be null- Throws:
IOException
- on read error
-
-
Method Detail
-
open
public static GridDataset open(String location) throws IOException
Open a netcdf dataset, using NetcdfDataset.defaultEnhanceMode plus CoordSystems and turn into a GridDataset.- Parameters:
location
- netcdf dataset to open, using NetcdfDataset.acquireDataset().- Returns:
- GridDataset
- Throws:
IOException
- on read error- See Also:
NetcdfDataset.acquireDataset(ucar.nc2.dataset.DatasetUrl, ucar.nc2.util.CancelTask)
-
open
public static GridDataset open(String location, Set<NetcdfDataset.Enhance> enhanceMode) throws IOException
Open a netcdf dataset, using NetcdfDataset.defaultEnhanceMode plus CoordSystems and turn into a GridDataset.- Parameters:
location
- netcdf dataset to open, using NetcdfDataset.acquireDataset().enhanceMode
- open netcdf dataset with this enhanceMode- Returns:
- GridDataset
- Throws:
IOException
- on read error- See Also:
NetcdfDataset.acquireDataset(ucar.nc2.dataset.DatasetUrl, ucar.nc2.util.CancelTask)
-
openIfce
public static GridDataset openIfce(String location) throws IOException
Open a netcdf dataset, using NetcdfDataset.defaultEnhanceMode plus CoordSystems and return a ucar.nc2.dt.GridDataset interface.- Parameters:
location
- netcdf dataset to open, using NetcdfDataset.acquireDataset().- Returns:
- ucar.nc2.dt.GridDataset
- Throws:
IOException
- on read error- See Also:
NetcdfDataset.acquireDataset(ucar.nc2.dataset.DatasetUrl, ucar.nc2.util.CancelTask)
-
openIfce
public static GridDataset openIfce(String location, Set<NetcdfDataset.Enhance> enhanceMode) throws IOException
Open a netcdf dataset, using NetcdfDataset.defaultEnhanceMode plus CoordSystems and return a ucar.nc2.dt.GridDataset interface.- Parameters:
location
- netcdf dataset to open, using NetcdfDataset.acquireDataset().enhanceMode
- open netcdf dataset with this enhanceMode- Returns:
- ucar.nc2.dt.GridDataset
- Throws:
IOException
- on read error- See Also:
NetcdfDataset.acquireDataset(ucar.nc2.dataset.DatasetUrl, ucar.nc2.util.CancelTask)
-
getTitle
public String getTitle()
Description copied from interface:FeatureDataset
Title of the dataset.- Specified by:
getTitle
in interfaceFeatureDataset
- Returns:
- the title of the dataset, or null
-
getDescription
public String getDescription()
Description copied from interface:FeatureDataset
Text information about this dataset.- Specified by:
getDescription
in interfaceFeatureDataset
- Returns:
- any text information about this dataset, or null.
-
getLocation
public String getLocation()
Description copied from interface:FeatureDataset
The URI location of the dataset- Specified by:
getLocation
in interfaceFeatureDataset
- Specified by:
getLocation
in interfaceFileCacheable
- Returns:
- the URI location of the dataset, or null
-
getDateRange
public DateRange getDateRange()
Deprecated.use getCalendarDateRange
-
getStartDate
public Date getStartDate()
Deprecated.use getStartCalendarDate
-
getEndDate
public Date getEndDate()
Deprecated.use getEndCalendarDate
-
getCalendarDateRange
public CalendarDateRange getCalendarDateRange()
Description copied from interface:FeatureDataset
Calendar Date range for the entire dataset.- Specified by:
getCalendarDateRange
in interfaceFeatureDataset
- Returns:
- the date range for the entire dataset, or null if unknown
-
getCalendarDateStart
public CalendarDate getCalendarDateStart()
Description copied from interface:FeatureDataset
Starting Calendar date for the entire dataset.- Specified by:
getCalendarDateStart
in interfaceFeatureDataset
- Returns:
- the starting date for the entire dataset, or null if unknown
-
getCalendarDateEnd
public CalendarDate getCalendarDateEnd()
Description copied from interface:FeatureDataset
Ending Calendar date for the entire dataset.- Specified by:
getCalendarDateEnd
in interfaceFeatureDataset
- Returns:
- the ending date for the entire dataset, or null if unknown
-
getBoundingBox
public LatLonRect getBoundingBox()
Description copied from interface:FeatureDataset
The lat/lon boundingBox for the entire dataset.- Specified by:
getBoundingBox
in interfaceFeatureDataset
- Returns:
- the lat/lon boundingBox for the entire dataset, or null if unknown.
-
getProjBoundingBox
public ProjectionRect getProjBoundingBox()
- Specified by:
getProjBoundingBox
in interfaceGridDataset
-
calcBounds
public void calcBounds()
-
attributes
public AttributeContainer attributes()
Description copied from interface:FeatureDataset
Get the global attributes.- Specified by:
attributes
in interfaceFeatureDataset
-
getGlobalAttributes
public List<Attribute> getGlobalAttributes()
Description copied from interface:FeatureDataset
List of global attributes.- Specified by:
getGlobalAttributes
in interfaceFeatureDataset
- Returns:
- List of type ucar.nc2.Attribute, may be empty but not null
-
findGlobalAttributeIgnoreCase
public Attribute findGlobalAttributeIgnoreCase(String name)
Description copied from interface:FeatureDataset
Return the global attribute with the given name, ignoring case.- Specified by:
findGlobalAttributeIgnoreCase
in interfaceFeatureDataset
- Parameters:
name
- attribute name- Returns:
- the global attribute, or null
-
getDataVariables
public List<VariableSimpleIF> getDataVariables()
Description copied from interface:FeatureDataset
The data Variables available in this dataset. Should just be data variables others might be searching for, not metadata or coordinate system variables, etc. The shapes of the VariableSimpleIF do not necessarily match the StructureData member.- Specified by:
getDataVariables
in interfaceFeatureDataset
- Returns:
- List of subclass of VariableSimpleIF, may be empty but not null
-
getDataVariable
public VariableSimpleIF getDataVariable(String shortName)
Description copied from interface:FeatureDataset
Get the named data Variable.- Specified by:
getDataVariable
in interfaceFeatureDataset
- Parameters:
shortName
- of data Variable.- Returns:
- VariableSimpleIF or null if not found
-
getNetcdfFile
public NetcdfFile getNetcdfFile()
Description copied from interface:FeatureDataset
Return underlying NetcdfFile, or null if none.- Specified by:
getNetcdfFile
in interfaceFeatureDataset
- Returns:
- the underlying NetcdfFile, or null if none.
-
getName
public String getName()
the name of the dataset is the last part of the location- Returns:
- the name of the dataset
-
getNetcdfDataset
public NetcdfDataset getNetcdfDataset()
- Returns:
- the underlying NetcdfDataset
-
getGrids
public List<GridDatatype> getGrids()
Description copied from interface:GridDataset
get the list of GridDatatype objects contained in this dataset.- Specified by:
getGrids
in interfaceGridDataset
- Returns:
- the list of GeoGrid objects contained in this dataset.
-
findGridDatatype
public GridDatatype findGridDatatype(String name)
Description copied from interface:GridDataset
find the named GridDatatype.- Specified by:
findGridDatatype
in interfaceGridDataset
- Parameters:
name
- full unescaped name- Returns:
- the named GridDatatype, or null if not found
-
getGridsets
public List<GridDataset.Gridset> getGridsets()
Return GridDatatype objects grouped by GridCoordSys. All GridDatatype in a Gridset have the same GridCoordSystem.- Specified by:
getGridsets
in interfaceGridDataset
- Returns:
- List of type ucar.nc2.dt.GridDataset.Gridset
-
findGridByName
public GeoGrid findGridByName(String fullName)
find the named GeoGrid.- Parameters:
fullName
- find this GeoGrid by full name- Returns:
- the named GeoGrid, or null if not found
-
findGridByShortName
public GeoGrid findGridByShortName(String shortName)
find the named GeoGrid.- Specified by:
findGridByShortName
in interfaceGridDataset
- Parameters:
shortName
- find this GeoGrid by short name- Returns:
- the named GeoGrid, or null if not found
-
findGridDatatypeByAttribute
public GeoGrid findGridDatatypeByAttribute(String attName, String attValue)
-
getDetailInfo
public String getDetailInfo()
Get Details about the dataset.
-
getDetailInfo
public void getDetailInfo(Formatter buff)
Description copied from interface:FeatureDataset
Show debug / underlying implementation details- Specified by:
getDetailInfo
in interfaceFeatureDataset
- Parameters:
buff
- append info here
-
getFeatureType
public FeatureType getFeatureType()
Description copied from interface:FeatureDataset
Contains collections of this FeatureType.- Specified by:
getFeatureType
in interfaceFeatureDataset
- Returns:
- FeatureType of data
-
getImplementationName
public String getImplementationName()
Description copied from interface:FeatureDataset
Show who is implementing- Specified by:
getImplementationName
in interfaceFeatureDataset
- Returns:
- name of implementor
-
close
public void close() throws IOException
Description copied from interface:FeatureDataset
Close all resources associated with this dataset.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceFeatureDataset
- Specified by:
close
in interfaceFileCacheable
- Throws:
IOException
- on i/o error
-
release
@Deprecated public void release() throws IOException
Deprecated.do not useDescription copied from interface:FileCacheable
Release any system resources like file handles. Optional, implement only if you are able to reacquire. Used when object is made inactive in cache.- Specified by:
release
in interfaceFileCacheable
- Throws:
IOException
-
reacquire
@Deprecated public void reacquire() throws IOException
Deprecated.do not useDescription copied from interface:FileCacheable
Reacquire any resources like file handles Used when reactivating in cache.- Specified by:
reacquire
in interfaceFileCacheable
- Throws:
IOException
-
getLastModified
public long getLastModified()
Description copied from interface:FileCacheable
Returns the time that the underlying file(s) were last modified. If they've changed since they were stored in the cache, they will be closed and reopened withFileFactory
.- Specified by:
getLastModified
in interfaceFileCacheable
- Returns:
- a
long
value representing the time the file(s) were last modified or0L
if the last-modified time couldn't be determined for any reason.
-
setFileCache
@Deprecated public void setFileCache(FileCacheIF fileCache)
Deprecated.do not useDescription copied from interface:FileCacheable
If the FileCache is not null, FileCacheable.close() must call FileCache.release()public synchronized void close() throws java.io.IOException { if (cache != null) { if (cache.release(this)) return; } reallyClose(); }
- Specified by:
setFileCache
in interfaceFileCacheable
- Parameters:
fileCache
- must store this, use it on close as above.
-
factory
public static GridDataset factory(String netcdfFileURI) throws IOException
Deprecated.: use GridDataset.open().Open a netcdf dataset, parse Conventions, find all the geoGrids, return a GridDataset.- Throws:
IOException
-
-