|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectucar.nc2.NetcdfFile
ucar.nc2.dataset.NetcdfDataset
public class NetcdfDataset
NetcdfDataset extends the netCDF API, adding standard attribute parsing such as scale and offset, and explicit support for Coordinate Systems. A NetcdfDataset either wraps a NetcdfFile, or is defined by an NcML document.
Be sure to close the dataset when done, best practice is to enclose in a try/finally block:
NetcdfDataset ncd = null;
try {
ncd = NetcdfDataset.openDataset(fileName);
...
} finally {
ncd.close();
}
NetcdfFile| Constructor Summary | |
|---|---|
NetcdfDataset()
No-arg Constructor |
|
NetcdfDataset(NetcdfFile ncfile)
Transform a NetcdfFile into a NetcdfDataset. |
|
NetcdfDataset(NetcdfFile ncfile,
boolean enhance)
Transform a NetcdfFile into a NetcdfDataset, optionally add Coordinates. |
|
| Method Summary | |
|---|---|
static NetcdfDataset |
acquireDataset(java.lang.String location,
CancelTask cancelTask)
Same as openDataset, but file is acquired through the NetcdfFileCache, and its always enhanced. |
static NetcdfFile |
acquireFile(java.lang.String location,
CancelTask cancelTask)
Same as openFile, but file is acquired through the NetcdfFileCache. |
CoordinateAxis |
addCoordinateAxis(VariableDS v)
Add a CoordinateAxis. |
void |
addCoordinateSystem(CoordinateSystem cs)
Add a CoordinateSystem to the dataset. |
void |
addCoordinateSystem(VariableEnhanced v,
CoordinateSystem cs)
Add a CoordinateSystem to a variable. |
void |
addCoordinateTransform(CoordinateTransform ct)
Add a CoordinateTransform to the dataset. |
boolean |
addRecordStructure()
If there is an unlimited dimension, make all variables that use it into an array of structures. |
void |
close()
Close all resources (files, sockets, etc) associated with this dataset. |
static void |
debugDump(java.io.PrintStream out,
NetcdfDataset ncd)
debugging |
void |
enhance()
recalc any enhancement info |
CoordinateAxis |
findCoordinateAxis(java.lang.String fullName)
Retrieve the CoordinateAxis with the specified name. |
CoordinateSystem |
findCoordinateSystem(java.lang.String name)
Retrieve the CoordinateSystem with the specified name. |
CoordinateTransform |
findCoordinateTransform(java.lang.String name)
Retrieve the CoordinateTransform with the specified name. |
Variable |
findStandardVariable(java.lang.String name)
Retrieve a "standard" Variable with the specified name, that handles scale, offset, etc. |
ucar.nc2.ncml.Aggregation |
getAggregation()
If its an NcML aggregation, it has an Aggregation object associated. |
java.util.List |
getCoordinateAxes()
Get the list of all CoordinateAxis objects used by this dataset. |
java.util.List |
getCoordinateSystems()
Get the list of all CoordinateSystem objects used by this dataset. |
java.util.List |
getCoordinateTransforms()
Get the list of all CoordinateTransform objects used by this dataset. |
boolean |
getCoordSysWereAdded()
Has Coordinate System metadata been added. |
static boolean |
getFillValueIsMissing()
Get if _FillValue attribute is considered isMissing() |
NetcdfDatasetInfo |
getInfo()
Debugging: get the information from parsing |
static boolean |
getInvalidDataIsMissing()
Get if valid_range attribute is considered isMissing() |
static boolean |
getMissingDataIsMissing()
Get if missing_data attribute is considered isMissing() |
NetcdfFile |
getReferencedFile()
Often a NetcdfDataset wraps a NetcdfFile. |
static boolean |
getUseNaNs()
Get whether to use NaNs for missing values, for efficiency |
boolean |
isEnhanced()
Get whether the dataset was enhanced. |
static void |
main(java.lang.String[] arg)
debug |
static Array |
makeArray(DataType dtype,
java.util.ArrayList stringValues)
Make an 1D array from a list of strings. |
static Array |
makeArray(DataType dtype,
int npts,
double start,
double incr)
Make a 1D array from a start and inccr. |
static NetcdfDataset |
openDataset(java.lang.String location)
Factory method for opening a dataset through the netCDF API, and identifying its coordinate variables. |
static NetcdfDataset |
openDataset(java.lang.String location,
boolean enhance,
CancelTask cancelTask)
Factory method for opening a dataset through the netCDF API, and identifying its coordinate variables. |
static NetcdfDataset |
openDataset(java.lang.String location,
boolean enhance,
int buffer_size,
CancelTask cancelTask,
java.lang.Object spiObject)
Factory method for opening a dataset through the netCDF API, and identifying its coordinate variables. |
static NetcdfFile |
openFile(java.lang.String location,
CancelTask cancelTask)
Factory method for opening a NetcdfFile through the netCDF API. |
static NetcdfFile |
openFile(java.lang.String location,
int buffer_size,
CancelTask cancelTask,
java.lang.Object spiObject)
Factory method for opening a NetcdfFile through the netCDF API. |
Array |
readData(Variable v,
java.util.List section)
do not call this directly, use Variable.read() !! |
Array |
readMemberData(Variable v,
java.util.List section,
boolean flatten)
do not call this directly, use Variable.readSection() !! |
void |
setAggregation(ucar.nc2.ncml.Aggregation agg)
Set the Aggregation object associated with this NcML dataset |
void |
setCoordSysWereAdded(boolean coordSysWereAdded)
Set whether Coordinate System metadata has been added. |
static void |
setFillValueIsMissing(boolean b)
Set if _FillValue attribute is considered isMissing() |
static void |
setInvalidDataIsMissing(boolean b)
Set if valid_range attribute is considered isMissing() |
static void |
setMissingDataIsMissing(boolean b)
Set if missing_data attribute is considered isMissing() |
void |
setReferencedFile(NetcdfFile ncfile)
Set underlying file. |
static void |
setUseNaNs(boolean b)
Set whether to use NaNs for missing values, for efficiency |
void |
setValues(Variable v,
java.util.ArrayList values)
Set the data values from a list of Strings. |
void |
setValues(Variable v,
int npts,
double start,
double incr)
Generate the list of values from a starting value and an increment. |
void |
sort()
Sort Variables, CoordAxes by name. |
boolean |
sync()
Check if file has changed, and reread metadata if needed. |
boolean |
syncExtend()
Extend the file if needed in a way that is compatible with the current metadata, that is, does not invalidate structural metadata held by the application. |
void |
writeNcML(java.io.OutputStream os,
java.lang.String uri)
Write the NcML representation. |
void |
writeNcMLG(java.io.OutputStream os,
boolean showCoords,
java.lang.String uri)
Write the NcML-G representation. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public NetcdfDataset(NetcdfFile ncfile)
throws java.io.IOException
ncfile - NetcdfFile to transform.
java.io.IOException
public NetcdfDataset(NetcdfFile ncfile,
boolean enhance)
throws java.io.IOException
ncfile - NetcdfFile to transform.enhance - if true, process scale/offset/missing and add Coordinate Systems
java.io.IOExceptionpublic NetcdfDataset()
| Method Detail |
|---|
public static void setUseNaNs(boolean b)
public static boolean getUseNaNs()
public static void setFillValueIsMissing(boolean b)
public static boolean getFillValueIsMissing()
public static void setInvalidDataIsMissing(boolean b)
public static boolean getInvalidDataIsMissing()
public static void setMissingDataIsMissing(boolean b)
public static boolean getMissingDataIsMissing()
public static NetcdfDataset openDataset(java.lang.String location)
throws java.io.IOException
location - location of file
java.io.IOExceptionopenDataset(String location, boolean enhance, ucar.nc2.util.CancelTask cancelTask)
public static NetcdfDataset openDataset(java.lang.String location,
boolean enhance,
CancelTask cancelTask)
throws java.io.IOException
location - location of fileenhance - if true, process scale/offset/missing and add Coordinate SystemscancelTask - allow task to be cancelled; may be null.
java.io.IOException
public static NetcdfDataset openDataset(java.lang.String location,
boolean enhance,
int buffer_size,
CancelTask cancelTask,
java.lang.Object spiObject)
throws java.io.IOException
location - location of fileenhance - if true, process scale/offset/missing and add Coordinate Systemsbuffer_size - RandomAccessFile buffer size, if <= 0, use default sizecancelTask - allow task to be cancelled; may be null.spiObject - sent to iosp.setSpecial() if not null
java.io.IOException
public static NetcdfDataset acquireDataset(java.lang.String location,
CancelTask cancelTask)
throws java.io.IOException
java.io.IOExceptionfor meaning of parameters
public static NetcdfFile acquireFile(java.lang.String location,
CancelTask cancelTask)
throws java.io.IOException
java.io.IOExceptionopenFile(java.lang.String, ucar.nc2.util.CancelTask)
public static NetcdfFile openFile(java.lang.String location,
CancelTask cancelTask)
throws java.io.IOException
location - location of dataset.cancelTask - use to allow task to be cancelled; may be null.
java.io.IOException
public static NetcdfFile openFile(java.lang.String location,
int buffer_size,
CancelTask cancelTask,
java.lang.Object spiObject)
throws java.io.IOException
This does not necessarily turn it into a NetcdfDataset (it may), use NetcdfDataset.open() method for that. It definitely does not add coordinate systems
location - location of dataset. This may be a
buffer_size - RandomAccessFile buffer size, if <= 0, use default sizecancelTask - allow task to be cancelled; may be null.spiObject - sent to iosp.setSpecial() if not null
java.io.IOExceptionpublic Variable findStandardVariable(java.lang.String name)
name - String which //identifies the desired variable
public ucar.nc2.ncml.Aggregation getAggregation()
public void setAggregation(ucar.nc2.ncml.Aggregation agg)
public java.util.List getCoordinateSystems()
public boolean isEnhanced()
public java.util.List getCoordinateTransforms()
public java.util.List getCoordinateAxes()
public boolean getCoordSysWereAdded()
public void setCoordSysWereAdded(boolean coordSysWereAdded)
public CoordinateAxis findCoordinateAxis(java.lang.String fullName)
fullName - full name of the coordinate axis
public CoordinateSystem findCoordinateSystem(java.lang.String name)
name - String which identifies the desired CoordinateSystem
public CoordinateTransform findCoordinateTransform(java.lang.String name)
name - String which identifies the desired CoordinateSystem
public void close()
throws java.io.IOException
close in class NetcdfFilejava.io.IOException
public boolean sync()
throws java.io.IOException
sync in class NetcdfFilejava.io.IOException
public boolean syncExtend()
throws java.io.IOException
NetcdfFile
syncExtend in class NetcdfFilejava.io.IOException
public void writeNcML(java.io.OutputStream os,
java.lang.String uri)
throws java.io.IOException
writeNcML in class NetcdfFileos - write to this Output Stream.uri - use this for the uri attribute; if null use getLocation().
java.io.IOException
public void writeNcMLG(java.io.OutputStream os,
boolean showCoords,
java.lang.String uri)
throws java.io.IOException
os - write to this Output Stream.showCoords - uri - use this for the uri attribute; if null use getLocation().
java.io.IOExceptionpublic boolean addRecordStructure()
NetcdfFile
addRecordStructure in class NetcdfFilepublic void sort()
public NetcdfFile getReferencedFile()
public void setReferencedFile(NetcdfFile ncfile)
public Array readMemberData(Variable v,
java.util.List section,
boolean flatten)
throws java.io.IOException,
InvalidRangeException
NetcdfFile
readMemberData in class NetcdfFilejava.io.IOException
InvalidRangeException
public Array readData(Variable v,
java.util.List section)
throws java.io.IOException,
InvalidRangeException
NetcdfFile
readData in class NetcdfFilejava.io.IOException
InvalidRangeExceptionpublic void addCoordinateSystem(CoordinateSystem cs)
public void addCoordinateTransform(CoordinateTransform ct)
public void addCoordinateSystem(VariableEnhanced v,
CoordinateSystem cs)
public CoordinateAxis addCoordinateAxis(VariableDS v)
public void enhance()
throws java.io.IOException
java.io.IOException
public void setValues(Variable v,
int npts,
double start,
double incr)
npts - number of valuesstart - starting valueincr - increment
public void setValues(Variable v,
java.util.ArrayList values)
throws java.lang.NumberFormatException
values - list of Strings
java.lang.NumberFormatException
public static Array makeArray(DataType dtype,
java.util.ArrayList stringValues)
dtype - data type of the array.stringValues - list of strings.
public static Array makeArray(DataType dtype,
int npts,
double start,
double incr)
dtype - data type of result. must be convertible to double.npts - number of pointsstart - starting valuesincr - increment
public NetcdfDatasetInfo getInfo()
public static void debugDump(java.io.PrintStream out,
NetcdfDataset ncd)
public static void main(java.lang.String[] arg)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||