ucar.nc2.dt.point
Class DapperDataset

java.lang.Object
  extended by ucar.nc2.dt.TypedDatasetImpl
      extended by ucar.nc2.dt.point.PointObsDatasetImpl
          extended by ucar.nc2.dt.point.DapperDataset
All Implemented Interfaces:
PointCollection, PointObsDataset, TypedDataset, TypedDatasetFactoryIF

public class DapperDataset
extends PointObsDatasetImpl
implements TypedDatasetFactoryIF

Handles datasets using Dapper doubley nested sequences.

Author:
caron

Nested Class Summary
 class DapperDataset.SeqPointObs
           
 class DapperDataset.SeqStationObs
           
 
Field Summary
protected  Variable altVar
           
protected  DODSNetcdfFile dodsFile
           
protected  boolean fatal
           
protected  StructureDS innerSequence
           
protected  boolean isProfile
           
protected  Variable latVar
           
protected  Variable lonVar
           
protected  StructureDS outerSequence
           
protected  Variable timeVar
           
 
Fields inherited from class ucar.nc2.dt.point.PointObsDatasetImpl
formatter, timeUnit
 
Fields inherited from class ucar.nc2.dt.TypedDatasetImpl
boundingBox, dataVariables, desc, endDate, location, ncfile, parseInfo, startDate, title
 
Constructor Summary
DapperDataset()
           
DapperDataset(NetcdfDataset ds)
           
 
Method Summary
static PointObsDataset factory(NetcdfDataset ds)
           
 List getData(CancelTask cancel)
          Get all data, allow user to cancel.
 List getData(LatLonRect boundingBox, CancelTask cancel)
          Get all data within the specified bounding box, allow user to cancel.
 List getData(LatLonRect boundingBox, Date start, Date end, CancelTask cancel)
          Get all data within the specified bounding box and date range, allow user to cancel.
 int getDataCount()
          Get estimate of number of data records (may not be exact).
 DataIterator getDataIterator(int bufferSize)
          Get an efficient iterator over all the data in the Collection.
 boolean isMine(NetcdfDataset ds)
          Determine if this dataset belongs to you
static boolean isValidFile(NetcdfFile ds)
           
static void main(String[] args)
           
 TypedDataset open(NetcdfDataset ncd, CancelTask task, StringBuilder errlog)
          Open a NetcdfDataset as a TypedDataset.
 List readStationData(Station s, CancelTask cancel)
           
 void readStations(List stations)
           
protected  void setBoundingBox()
           
protected  void setEndDate()
           
protected  void setStartDate()
           
protected  void setTimeUnits()
           
 
Methods inherited from class ucar.nc2.dt.point.PointObsDatasetImpl
getData, getData, getData, getDataClass, getDetailInfo, getMetersConversionFactor, getScientificDataType, getTime, getTimeUnits
 
Methods inherited from class ucar.nc2.dt.TypedDatasetImpl
close, findGlobalAttributeIgnoreCase, getBoundingBox, getDataVariable, getDataVariables, getDescription, getEndDate, getGlobalAttributes, getLocation, getLocationURI, getNetcdfFile, getStartDate, getTitle, removeDataVariable, setDescription, setLocationURI, setTitle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface ucar.nc2.dt.TypedDatasetFactoryIF
getScientificDataType
 
Methods inherited from interface ucar.nc2.dt.TypedDataset
close, findGlobalAttributeIgnoreCase, getBoundingBox, getDataVariable, getDataVariables, getDescription, getEndDate, getGlobalAttributes, getLocationURI, getNetcdfFile, getStartDate, getTitle
 

Field Detail

dodsFile

protected DODSNetcdfFile dodsFile

latVar

protected Variable latVar

lonVar

protected Variable lonVar

altVar

protected Variable altVar

timeVar

protected Variable timeVar

innerSequence

protected StructureDS innerSequence

outerSequence

protected StructureDS outerSequence

isProfile

protected boolean isProfile

fatal

protected boolean fatal
Constructor Detail

DapperDataset

public DapperDataset()

DapperDataset

public DapperDataset(NetcdfDataset ds)
              throws IOException
Throws:
IOException
Method Detail

isValidFile

public static boolean isValidFile(NetcdfFile ds)

factory

public static PointObsDataset factory(NetcdfDataset ds)
                               throws IOException
Throws:
IOException

isMine

public boolean isMine(NetcdfDataset ds)
Description copied from interface: TypedDatasetFactoryIF
Determine if this dataset belongs to you

Specified by:
isMine in interface TypedDatasetFactoryIF
Parameters:
ds - examine this NetcdfDataset to see if it belongs to this class.
Returns:
true if this class knows how to create a TypedDataset out of this NetcdfDataset.

open

public TypedDataset open(NetcdfDataset ncd,
                         CancelTask task,
                         StringBuilder errlog)
                  throws IOException
Description copied from interface: TypedDatasetFactoryIF
Open a NetcdfDataset as a TypedDataset.

Specified by:
open in interface TypedDatasetFactoryIF
Parameters:
ncd - already opened NetcdfDataset.
task - use may cancel
errlog - place errors here
Returns:
a subclass of TypedDataset
Throws:
IOException - on error

setTimeUnits

protected void setTimeUnits()
Specified by:
setTimeUnits in class PointObsDatasetImpl

setStartDate

protected void setStartDate()
Specified by:
setStartDate in class TypedDatasetImpl

setEndDate

protected void setEndDate()
Specified by:
setEndDate in class TypedDatasetImpl

setBoundingBox

protected void setBoundingBox()
Specified by:
setBoundingBox in class TypedDatasetImpl

getDataCount

public int getDataCount()
Description copied from interface: PointCollection
Get estimate of number of data records (may not be exact). Return -1 if not able to estimate.

Specified by:
getDataCount in interface PointCollection
Returns:
number of data records or -1

getData

public List getData(CancelTask cancel)
             throws IOException
Description copied from interface: PointCollection
Get all data, allow user to cancel. Return null if too expensive to implement. Call getDataCount() to get estimate of size. This will return a list of getDataClass(), but the actual data may or may not already be read in to memory. In any case, you call dataType.getData() to get the data.

Specified by:
getData in interface PointCollection
Parameters:
cancel - allow user to cancel. Implementors should return ASAP.
Returns:
List of type getDataClass()
Throws:
IOException - on io error
See Also:
as a (possibly) more efficient alternative

getData

public List getData(LatLonRect boundingBox,
                    CancelTask cancel)
             throws IOException
Description copied from interface: PointCollection
Get all data within the specified bounding box, allow user to cancel.

Specified by:
getData in interface PointCollection
Parameters:
boundingBox - restrict data to this bounding nox
cancel - allow user to cancel. Implementors should return ASAP.
Returns:
List of type getDataClass()
Throws:
IOException - on io error
See Also:
as a (possibly) more efficient alternative

getData

public List getData(LatLonRect boundingBox,
                    Date start,
                    Date end,
                    CancelTask cancel)
             throws IOException
Description copied from interface: PointCollection
Get all data within the specified bounding box and date range, allow user to cancel.

Specified by:
getData in interface PointCollection
Parameters:
boundingBox - restrict data to this bounding nox
start - restrict data to after this time
end - restrict data to before this time
cancel - allow user to cancel. Implementors should return ASAP.
Returns:
List of type getDataClass()
Throws:
IOException - on io error
See Also:
as a (possibly) more efficient alternative

readStations

public void readStations(List stations)
                  throws IOException
Throws:
IOException

readStationData

public List readStationData(Station s,
                            CancelTask cancel)
                     throws IOException
Throws:
IOException

getDataIterator

public DataIterator getDataIterator(int bufferSize)
                             throws IOException
Description copied from interface: PointCollection
Get an efficient iterator over all the data in the Collection. You must fully process the data, or copy it out of the StructureData, as you iterate over it. DO NOT KEEP ANY REFERENCES to the dataType object or the StructureData object.

This is the efficient way to get all the data, it can be 100 times faster than getData(). This will return an iterator over type getDataClass(), and the actual data has already been read into memory, that is, dataType.getData() will not incur any I/O. This is accomplished by buffering bufferSize amount of data at once.

We dont need a cancelTask, just stop the iteration if the user want to cancel.

Example for point observations:
 

Iterator iter = pointObsDataset.getDataIterator(); while (iter.hasNext()) { PointObsDatatype pobs = (PointObsDatatype) iter.next(); StructureData sdata = pobs.getData(); // process fully }

Specified by:
getDataIterator in interface PointCollection
Parameters:
bufferSize - if > 0, the internal buffer size, else use the default. Typically 100k - 1M for best results.
Returns:
iterator over type getDataClass(), no guarenteed order.
Throws:
IOException - on io error

main

public static void main(String[] args)
                 throws IOException
Throws:
IOException


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