|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectucar.nc2.NetcdfFile
ucar.nc2.NetcdfFileWriteable
public class NetcdfFileWriteable
Create/Write netCDF files.
Because of the limitations of the underlying implementation, netcdf files can only have Dimensions, Attributes and Variables added to it at creation time. Thus, when a file is first opened, it in is "define mode" where these may added. Once create() is called, you can no longer add, delete, or modify the Dimensions, Attributes or Variables.
After create has been called you can then write the Variables' data values.
NetcdfFile| Field Summary |
|---|
| Fields inherited from class ucar.nc2.NetcdfFile |
|---|
addedRecordStructure, cacheName, cacheState, dimensions, gattributes, id, isClosed, location, rootGroup, spi, title, variables |
| Constructor Summary | |
|---|---|
NetcdfFileWriteable()
Deprecated. use createNew(String filename, boolean fill) |
|
NetcdfFileWriteable(java.lang.String location)
Deprecated. use openExisting(String filename, boolean fill) |
|
NetcdfFileWriteable(java.lang.String location,
boolean fill)
Deprecated. use createNew(String filename, boolean fill) |
|
| Method Summary | |
|---|---|
Dimension |
addDimension(java.lang.String dimName,
int length)
Add a Dimension to the file. |
Dimension |
addDimension(java.lang.String dimName,
int length,
boolean isShared,
boolean isUnlimited,
boolean isVariableLength)
Add a Dimension to the file. |
void |
addGlobalAttribute(Attribute att)
Add a Global attribute to the file. |
void |
addGlobalAttribute(java.lang.String name,
Array values)
Add a Global attribute of type Array to the file. |
void |
addGlobalAttribute(java.lang.String name,
java.lang.Number value)
Add a Global attribute of type Number to the file. |
void |
addGlobalAttribute(java.lang.String name,
java.lang.String value)
Add a Global attribute of type String to the file. |
Variable |
addStringVariable(java.lang.String varName,
java.util.List dims,
int max_strlen)
Add a variable with DataType = String to the file. |
Dimension |
addUnlimitedDimension(java.lang.String dimName)
Add an unlimited Dimension to the file. |
Variable |
addVariable(java.lang.String varName,
java.lang.Class componentType,
Dimension[] dims)
Deprecated. use addVariable(String varName, DataType dataType, ArrayList dims); |
Variable |
addVariable(java.lang.String varName,
DataType dataType,
Dimension[] dims)
Add a variable to the file. |
Variable |
addVariable(java.lang.String varName,
DataType dataType,
java.util.List dims)
Add a variable to the file. |
Variable |
addVariable(java.lang.String varName,
DataType dataType,
java.lang.String dims)
Add a variable to the file. |
void |
addVariableAttribute(java.lang.String varName,
Attribute att)
Add an attribute to the named Variable. |
void |
addVariableAttribute(java.lang.String varName,
java.lang.String attName,
Array value)
Add an attribute of type Array to the named Variable. |
void |
addVariableAttribute(java.lang.String varName,
java.lang.String attName,
java.lang.Number value)
Add an attribute of type Number to the named Variable. |
void |
addVariableAttribute(java.lang.String varName,
java.lang.String attName,
java.lang.String value)
Add an attribute of type String to the named Variable. |
void |
close()
close the file. |
void |
create()
After you have added all of the Dimensions, Variables, and Attributes, call create() to actually create the file. |
static NetcdfFileWriteable |
createNew(java.lang.String location)
Create a new Netcdf file, with fill mode true. |
static NetcdfFileWriteable |
createNew(java.lang.String location,
boolean fill)
Create a new Netcdf file, put it into define mode. |
void |
flush()
Flush anything written to disk. |
static NetcdfFileWriteable |
openExisting(java.lang.String location)
Open an existing Netcdf file for writing data. |
static NetcdfFileWriteable |
openExisting(java.lang.String location,
boolean fill)
Open an existing Netcdf file for writing data. |
void |
setFill(boolean fill)
Set the fill flag: call before calling create() or doing any data writing. |
void |
setLength(long size)
Preallocate the file size, for efficiency. |
void |
setName(java.lang.String filename)
Deprecated. use NetcdfFileWriteable(String filename); |
void |
updateAttribute(Variable v2,
Attribute att)
Update the value of an existing attribute. |
void |
write(java.lang.String varName,
Array values)
Write data to the named variable, origin assumed to be 0. |
void |
write(java.lang.String varName,
int[] origin,
Array values)
Write data to the named variable. |
void |
writeStringData(java.lang.String varName,
Array values)
Write String data to a CHAR variable, origin assumed to be 0. |
void |
writeStringData(java.lang.String varName,
int[] origin,
Array values)
Write String data to a CHAR variable. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public NetcdfFileWriteable(java.lang.String location,
boolean fill)
public NetcdfFileWriteable()
public NetcdfFileWriteable(java.lang.String location)
throws java.io.IOException
java.io.IOException| Method Detail |
|---|
public static NetcdfFileWriteable openExisting(java.lang.String location)
throws java.io.IOException
location - name of existing file to open.
java.io.IOException
public static NetcdfFileWriteable openExisting(java.lang.String location,
boolean fill)
throws java.io.IOException
location - name of existing file to open.fill - if true, the data is first written with fill values.
java.io.IOExceptionpublic static NetcdfFileWriteable createNew(java.lang.String location)
location - name of new file to open; if it exists, will overwrite it.
public static NetcdfFileWriteable createNew(java.lang.String location,
boolean fill)
location - name of new file to open; if it exists, will overwrite it.fill - if true, the data is first written with fill values.
Leave false if you expect to write all data values, set to true if you want to be
sure that unwritten data values have the fill value in it. (default is false)public void setName(java.lang.String filename)
filename - name of new file to create.public void setFill(boolean fill)
fill - set fill mode true or falsepublic void setLength(long size)
size -
public Dimension addDimension(java.lang.String dimName,
int length)
dimName - name of dimensionlength - size of dimension.
public Dimension addDimension(java.lang.String dimName,
int length,
boolean isShared,
boolean isUnlimited,
boolean isVariableLength)
dimName - name of dimensionlength - size of dimension.isShared - if dimension is sharedisUnlimited - if dimension is unlimitedisVariableLength - if dimension is variable length
public Dimension addUnlimitedDimension(java.lang.String dimName)
dimName - name of unlimited dimension
public void addGlobalAttribute(Attribute att)
att - the attribute.
public void addGlobalAttribute(java.lang.String name,
java.lang.String value)
name - name of attribute.value - value of atribute.
public void addGlobalAttribute(java.lang.String name,
java.lang.Number value)
name - name of attribute.value - must be of type Float, Double, Integer, Short or Byte
public void addGlobalAttribute(java.lang.String name,
Array values)
name - name of attribute.values - Array of values
public Variable addVariable(java.lang.String varName,
java.lang.Class componentType,
Dimension[] dims)
varName - name of Variable, must be unique with the file.componentType - type of underlying element: String, double or Double, etc.dims - array of Dimensions for the variable, must already have been added.
public Variable addVariable(java.lang.String varName,
DataType dataType,
Dimension[] dims)
varName - name of Variable, must be unique with the file.dataType - type of underlying elementdims - array of Dimensions for the variable, must already have been added. Use an array of length 0
for a scalar variable.
public Variable addVariable(java.lang.String varName,
DataType dataType,
java.lang.String dims)
varName - name of Variable, must be unique with the file.dataType - type of underlying elementdims - names of Dimensions for the variable, blank seperated.
Must already have been added. Use an empty string for a scalar variable.
public Variable addVariable(java.lang.String varName,
DataType dataType,
java.util.List dims)
varName - name of Variable, must be unique with the file.dataType - type of underlying elementdims - list of Dimensions for the variable, must already have been added. Use a list of length 0
for a scalar variable.
public Variable addStringVariable(java.lang.String varName,
java.util.List dims,
int max_strlen)
varName - name of Variable, must be unique within the file.dims - list of Dimensions for the variable, must already have been added. Use a list of length 0
for a scalar variable. Do not include the string length dimension.max_strlen - maximum string length.
public void addVariableAttribute(java.lang.String varName,
Attribute att)
varName - name of variable. must already have been added to the file.att - Attribute to add.
public void addVariableAttribute(java.lang.String varName,
java.lang.String attName,
java.lang.String value)
varName - name of variable. must already have been added to the file.attName - name of attribute.value - String value of atribute.
public void addVariableAttribute(java.lang.String varName,
java.lang.String attName,
java.lang.Number value)
varName - name of attribute. IllegalArgumentException if not valid name.attName - name of attribute.value - must be of type Float, Double, Integer, Short or Byte
public void addVariableAttribute(java.lang.String varName,
java.lang.String attName,
Array value)
varName - name of attribute. IllegalArgumentException if not valid name.attName - name of attribute.value - Array of valkues
public void updateAttribute(Variable v2,
Attribute att)
throws java.io.IOException
v2 - variable, or null for global attributeatt - replace with this value
java.io.IOException
public void create()
throws java.io.IOException
java.io.IOException
public void write(java.lang.String varName,
Array values)
throws java.io.IOException,
InvalidRangeException
varName - name of variable. IllegalArgumentException if variable name does not exist.values - write this array; must be same type and rank as Variable
java.io.IOException
InvalidRangeException
public void writeStringData(java.lang.String varName,
Array values)
throws java.io.IOException,
InvalidRangeException
varName - name of variable, must be of type CHAR.values - write this array; must be ArrayObject of String
java.io.IOException
InvalidRangeException
public void writeStringData(java.lang.String varName,
int[] origin,
Array values)
throws java.io.IOException,
InvalidRangeException
varName - name of variable, must be of type CHAR.origin - offset to start writing, ignore the strlen dimension.values - write this array; must be ArrayObject of String
java.io.IOException
InvalidRangeException
public void write(java.lang.String varName,
int[] origin,
Array values)
throws java.io.IOException,
InvalidRangeException
varName - name of variable. IllegalArgumentException if variable name does not exist.origin - offset within the variable to start writing.values - write this array; must be same type and rank as Variable
java.io.IOException
InvalidRangeException
public void flush()
throws java.io.IOException
java.io.IOException
public void close()
throws java.io.IOException
close in class NetcdfFilejava.io.IOException - if error closing
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||