ucar.nc2.dt.grid
Class GridDataset

java.lang.Object
  extended by ucar.nc2.dt.grid.GridDataset
All Implemented Interfaces:
GridDataset, TypedDataset, 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);
 }
 

Author:
caron

Nested Class Summary
 class GridDataset.Gridset
          This is a set of GeoGrids with the same GeoCoordSys.
 
Field Summary
protected  FileCache fileCache
           
 
Constructor Summary
GridDataset(NetcdfDataset ds)
          Create a GridDataset from a NetcdfDataset.
GridDataset(NetcdfDataset ds, Formatter parseInfo)
          Create a GridDataset from a NetcdfDataset.
 
Method Summary
 void calcBounds()
          Caclulate date range and bounding box, even if the data has to be scanned.
 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.
 GridDatatype findGridDatatype(String name)
          find the named GridDatatype.
 LatLonRect getBoundingBox()
          The boundingBox 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()
          Date range for the entire dataset.
 String getDescription()
          Text information about this dataset.
 String getDetailInfo()
          Get Details about the dataset.
 void getDetailInfo(Formatter buff)
          Show debug / underlying implementation details
 Date getEndDate()
          Ending date for the entire dataset.
 FeatureType 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 implementing
 String getLocation()
          The URI location of the dataset
 String getLocationURI()
           
 String getName()
           
 NetcdfDataset getNetcdfDataset()
           
 NetcdfFile getNetcdfFile()
          Return underlying NetcdfFile, or null if none.
 Date getStartDate()
          Starting date for the entire dataset.
 String getTitle()
          Title of the dataset.
static void main(String[] arg)
          testing
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.
 void setFileCache(FileCache fileCache)
          If the FileCache is set, the FileCacheable object must store it and call FileCache.release() on FileCacheable.close():
 boolean sync()
          Sync() is called when the FileCacheable is found in the cache, before returning the object to the application.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fileCache

protected FileCache fileCache
Constructor Detail

GridDataset

public GridDataset(NetcdfDataset ds)
            throws IOException
Create a GridDataset from a NetcdfDataset.

Parameters:
ds - underlying NetcdfDataset, will do Enhance.CoordSystems if not already done.
Throws:
IOException - on read error

GridDataset

public GridDataset(NetcdfDataset ds,
                   Formatter parseInfo)
            throws IOException
Create a GridDataset from a NetcdfDataset.

Parameters:
ds - 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(java.lang.String, 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(java.lang.String, ucar.nc2.util.CancelTask)

getTitle

public String getTitle()
Description copied from interface: FeatureDataset
Title of the dataset.

Specified by:
getTitle in interface TypedDataset
Specified by:
getTitle in interface FeatureDataset
Returns:
Title of the dataset.

getDescription

public String getDescription()
Description copied from interface: FeatureDataset
Text information about this dataset.

Specified by:
getDescription in interface TypedDataset
Specified by:
getDescription in interface FeatureDataset
Returns:
Text information about this dataset.

getLocation

public String getLocation()
Description copied from interface: FeatureDataset
The URI location of the dataset

Specified by:
getLocation in interface FeatureDataset
Specified by:
getLocation in interface FileCacheable
Returns:
the URI location of the dataset, or null

getLocationURI

public String getLocationURI()
Specified by:
getLocationURI in interface TypedDataset
Returns:
The URI location of the dataset

getStartDate

public Date getStartDate()
Description copied from interface: FeatureDataset
Starting date for the entire dataset.

Specified by:
getStartDate in interface TypedDataset
Specified by:
getStartDate in interface FeatureDataset
Returns:
Start date for the entire dataset.

getEndDate

public Date getEndDate()
Description copied from interface: FeatureDataset
Ending date for the entire dataset.

Specified by:
getEndDate in interface TypedDataset
Specified by:
getEndDate in interface FeatureDataset
Returns:
End date for the entire dataset.

getBoundingBox

public LatLonRect getBoundingBox()
Description copied from interface: FeatureDataset
The boundingBox for the entire dataset.

Specified by:
getBoundingBox in interface TypedDataset
Specified by:
getBoundingBox in interface FeatureDataset
Returns:
the boundingBox for the entire dataset.

calcBounds

public void calcBounds()
                throws IOException
Description copied from interface: FeatureDataset
Caclulate date range and bounding box, even if the data has to be scanned. This ensures that getDateRange() and getBoundingBox() return non-null. If the collection already knows its date range and bounding box, then this has no effect.

Specified by:
calcBounds in interface FeatureDataset
Throws:
IOException - or read error.

getGlobalAttributes

public List<Attribute> getGlobalAttributes()
Description copied from interface: TypedDataset
List of global attributes.

Specified by:
getGlobalAttributes in interface TypedDataset
Specified by:
getGlobalAttributes in interface FeatureDataset
Returns:
List of type ucar.nc2.Attribute

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 interface TypedDataset
Specified by:
findGlobalAttributeIgnoreCase in interface FeatureDataset
Parameters:
name - attribute name
Returns:
the global attribute with the given name, ingnoring case.

getDataVariables

public List<VariableSimpleIF> getDataVariables()
Description copied from interface: TypedDataset
The data Variables available in this dataset. Should just be data variable others might be searching for, not metadata or coordinate system variables, etc. The shape of this VariableSimpleIF does not necessarily match the

Specified by:
getDataVariables in interface TypedDataset
Specified by:
getDataVariables in interface FeatureDataset
Returns:
List of type VariableSimpleIF

getDataVariable

public VariableSimpleIF getDataVariable(String shortName)
Description copied from interface: TypedDataset
Get the named data Variable.

Specified by:
getDataVariable in interface TypedDataset
Specified by:
getDataVariable in interface FeatureDataset
Parameters:
shortName - of data Variable.
Returns:
VariableSimpleIF or null.

getNetcdfFile

public NetcdfFile getNetcdfFile()
Description copied from interface: FeatureDataset
Return underlying NetcdfFile, or null if none.

Specified by:
getNetcdfFile in interface TypedDataset
Specified by:
getNetcdfFile in interface FeatureDataset
Returns:
underlying NetcdfFile, or null if none.

getName

public String getName()
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 interface GridDataset
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 interface GridDataset
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 interface GridDataset
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

getDetailInfo

public String getDetailInfo()
Get Details about the dataset.

Specified by:
getDetailInfo in interface TypedDataset
Returns:
debug / underlying implementation details

getDetailInfo

public void getDetailInfo(Formatter buff)
Description copied from interface: FeatureDataset
Show debug / underlying implementation details

Specified by:
getDetailInfo in interface FeatureDataset
Parameters:
buff - append info here

getFeatureType

public FeatureType getFeatureType()
Description copied from interface: FeatureDataset
Contains collections of this FeatureType.

Specified by:
getFeatureType in interface FeatureDataset
Returns:
FeatureType of data

getDateRange

public DateRange getDateRange()
Description copied from interface: FeatureDataset
Date range for the entire dataset.

Specified by:
getDateRange in interface FeatureDataset
Returns:
the date range for the entire dataset, or null if unknown

getImplementationName

public String getImplementationName()
Description copied from interface: FeatureDataset
Show who is implementing

Specified by:
getImplementationName in interface FeatureDataset
Returns:
name of implementor

close

public void close()
           throws IOException
Description copied from interface: TypedDataset
Close all resources associated with this dataset.

Specified by:
close in interface TypedDataset
Specified by:
close in interface FeatureDataset
Specified by:
close in interface FileCacheable
Throws:
IOException

sync

public boolean sync()
             throws IOException
Description copied from interface: FileCacheable
Sync() is called when the FileCacheable is found in the cache, before returning the object to the application. FileCacheable has an opportunity to freshen itself. FileCacheable mag ignore this call.

Specified by:
sync in interface FileCacheable
Returns:
true if FileCacheable was changed
Throws:
IOException - on i/o error.

setFileCache

public void setFileCache(FileCache fileCache)
Description copied from interface: FileCacheable
If the FileCache is set, the FileCacheable object must store it and call FileCache.release() on FileCacheable.close():
  public synchronized void close() throws java.io.IOException {
    if (isClosed) return;
    if (cache != null) {
      cache.release(this);
    } else {
      reallyClose();
    }
    isClosed = true;
   

Specified by:
setFileCache in interface FileCacheable
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

main

public static void main(String[] arg)
testing



Copyright © 1999-2011 UCAR/Unidata. All Rights Reserved.