public class NetcdfFileWriteable extends NetcdfFile
When a file is first created, it is in is "define mode", where the header objects (Dimensions, Attributes and Variables) may be added, deleted and modified, but no data may be written. Once create() is called, you can no longer modify the header, but you can now write data. An existing file is opened in write mode.
If setRedefine(true) is called, the file goes into define mode, and header objects can be changed. When setRedefine(false) is called, the new header is written, and the old file data is copied to the new file. This can be quite costly.
NetcdfFile
cache, cacheName, debugCompress, debugSPI, dimensions, gattributes, id, IOSP_MESSAGE_ADD_RECORD_STRUCTURE, IOSP_MESSAGE_CONVERT_RECORD_STRUCTURE, IOSP_MESSAGE_RANDOM_ACCESS_FILE, IOSP_MESSAGE_REMOVE_RECORD_STRUCTURE, location, reservedCdl, reservedFullName, reservedSectionSpec, rootGroup, showRequest, spi, title, variables
Modifier | Constructor and Description |
---|---|
|
NetcdfFileWriteable()
Deprecated.
use createNew(String filename, boolean fill)
|
protected |
NetcdfFileWriteable(IOServiceProviderWriter iospw,
RandomAccessFile raf,
java.lang.String location,
boolean fill,
boolean isExisting)
Deprecated.
Open or create a new Netcdf file, put it into define mode to allow
writing, using the provided IOSP and RAF.
|
|
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)
|
Modifier and Type | Method and Description |
---|---|
Dimension |
addDimension(java.lang.String dimName,
int length)
Deprecated.
Add a Dimension to the file.
|
Dimension |
addDimension(java.lang.String dimName,
int length,
boolean isShared,
boolean isUnlimited,
boolean isVariableLength)
Deprecated.
Add a Dimension to the file.
|
Attribute |
addGlobalAttribute(Attribute att)
Deprecated.
Add a Global attribute to the file.
|
Attribute |
addGlobalAttribute(java.lang.String name,
Array values)
Deprecated.
Add a Global attribute of type Array to the file.
|
Attribute |
addGlobalAttribute(java.lang.String name,
java.lang.Number value)
Deprecated.
Add a Global attribute of type Number to the file.
|
Attribute |
addGlobalAttribute(java.lang.String name,
java.lang.String value)
Deprecated.
Add a Global attribute of type String to the file.
|
Variable |
addStringVariable(java.lang.String varName,
java.util.List<Dimension> dims,
int max_strlen)
Deprecated.
Add a variable with DataType = String to the file.
|
Dimension |
addUnlimitedDimension(java.lang.String dimName)
Deprecated.
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)
Deprecated.
Add a variable to the file.
|
Variable |
addVariable(java.lang.String shortName,
DataType dataType,
java.util.List<Dimension> dims)
Deprecated.
Add a variable to the file.
|
Variable |
addVariable(java.lang.String varName,
DataType dataType,
java.lang.String dims)
Deprecated.
Add a variable to the file.
|
void |
addVariableAttribute(java.lang.String varName,
Attribute att)
Deprecated.
Add an attribute to the named Variable.
|
void |
addVariableAttribute(java.lang.String varName,
java.lang.String attName,
Array value)
Deprecated.
Add an attribute of type Array to the named Variable.
|
void |
addVariableAttribute(java.lang.String varName,
java.lang.String attName,
java.lang.Number value)
Deprecated.
Add an attribute of type Number to the named Variable.
|
void |
addVariableAttribute(java.lang.String varName,
java.lang.String attName,
java.lang.String value)
Deprecated.
Add an attribute of type String to the named Variable.
|
void |
close()
Deprecated.
close the file.
|
void |
create()
Deprecated.
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)
Deprecated.
Create a new Netcdf file, with fill mode true.
|
static NetcdfFileWriteable |
createNew(java.lang.String location,
boolean fill)
Deprecated.
Create a new Netcdf file, put it into define mode.
|
Attribute |
deleteGlobalAttribute(java.lang.String attName)
Deprecated.
Delete a global Attribute.
|
Attribute |
deleteVariableAttribute(java.lang.String varName,
java.lang.String attName)
Deprecated.
Delete a variable Attribute.
|
void |
flush()
Deprecated.
Flush anything written to disk.
|
java.lang.String |
getFileTypeDescription()
Deprecated.
Get a human-readable description for this file type.
|
java.lang.String |
getFileTypeId()
Deprecated.
Get the file type id for the underlying data source.
|
boolean |
isDefineMode()
Deprecated.
Is the file in define mode, which allows objects to be added and changed?
|
static NetcdfFileWriteable |
openExisting(java.lang.String location)
Deprecated.
Open an existing Netcdf file for writing data.
|
static NetcdfFileWriteable |
openExisting(java.lang.String location,
boolean fill)
Deprecated.
Open an existing Netcdf file for writing data.
|
Dimension |
renameDimension(java.lang.String oldName,
java.lang.String newName)
Deprecated.
Rename a Dimension.
|
Attribute |
renameGlobalAttribute(java.lang.String oldName,
java.lang.String newName)
Deprecated.
Rename a global Attribute.
|
Variable |
renameVariable(java.lang.String oldName,
java.lang.String newName)
Deprecated.
Rename a Variable.
|
Attribute |
renameVariableAttribute(java.lang.String varName,
java.lang.String attName,
java.lang.String newName)
Deprecated.
Rename a variable Attribute.
|
void |
setExtraHeaderBytes(int extraHeaderBytes)
Deprecated.
Set extra bytes to reserve in the header.
|
void |
setFill(boolean fill)
Deprecated.
Set the fill flag: call before calling create() or doing any data writing.
|
void |
setLargeFile(boolean isLargeFile)
Deprecated.
Set if this should be a "large file" (64-bit offset) format.
|
void |
setLength(long size)
Deprecated.
Preallocate the file size, for efficiency.
|
void |
setName(java.lang.String filename)
Deprecated.
use NetcdfFileWriteable.createNew(String filename);
|
boolean |
setRedefineMode(boolean redefineMode)
Deprecated.
Set the redefine mode.
|
void |
updateAttribute(Variable v2,
Attribute att)
Deprecated.
Update the value of an existing attribute.
|
void |
write(java.lang.String fullNameEsc,
Array values)
Deprecated.
Write data to the named variable, origin assumed to be 0.
|
void |
write(java.lang.String fullNameEsc,
int[] origin,
Array values)
Deprecated.
Write data to the named variable.
|
void |
writeStringData(java.lang.String varName,
Array values)
Deprecated.
Write String data to a CHAR variable, origin assumed to be 0.
|
void |
writeStringData(java.lang.String fullNameEsc,
int[] origin,
Array values)
Deprecated.
Write String data to a CHAR variable.
|
addAttribute, addAttribute, addDimension, addGroup, addStringVariable, addVariable, addVariable, addVariableAttribute, canonicalizeUriString, canOpen, empty, findAttribute, findAttValueIgnoreCase, findDimension, findGlobalAttribute, findGlobalAttributeIgnoreCase, findGroup, findVariable, findVariable, findVariableByAttribute, finish, getCacheName, getDetailInfo, getDetailInfo, getDimensions, getFileTypeVersion, getGlobalAttributes, getId, getIosp, getLastModified, getLocation, getRootGroup, getStructureIterator, getTitle, getUnlimitedDimension, getVariables, hasUnlimitedDimension, iospRegistered, main, makeFullName, makeFullName, makeFullNameSectionSpec, makeFullNameWithString, makeNameUnescaped, makeRecordStructure, makeRootGroup, makeValidCDLName, makeValidCdmObjectName, makeValidPathName, makeValidSectionSpecName, open, open, open, open, open, open, openInMemory, openInMemory, openInMemory, openInMemory, reacquire, read, readArrays, readAttributeDouble, readAttributeInteger, readData, readSection, readToByteChannel, readToOutputStream, registerIOProvider, registerIOProvider, registerIOProvider, release, removeDimension, removeRecordStructure, removeVariable, sendIospMessage, setCacheName, setDebugFlags, setFileCache, setId, setImmutable, setLocation, setProperty, setTitle, showCached, showProxies, syncExtend, toString, toStringDebug, toStringEnd, toStringStart, toStringStart, writeCDL, writeCDL, writeCDL, writeNcML, writeNcML
protected NetcdfFileWriteable(IOServiceProviderWriter iospw, RandomAccessFile raf, java.lang.String location, boolean fill, boolean isExisting) throws java.io.IOException
iospw
- IO service provider to use, if null use standardraf
- Random access file to use, may be null if iospw islocation
- open a new file at this locationfill
- set fill modeisExisting
- true if file already existsjava.io.IOException
- on I/O errorpublic NetcdfFileWriteable(java.lang.String location, boolean fill)
location
- open a new file at this locationfill
- set fill modepublic NetcdfFileWriteable()
public NetcdfFileWriteable(java.lang.String location) throws java.io.IOException
location
- open an existing file at this locationjava.io.IOException
- on read errorpublic static NetcdfFileWriteable openExisting(java.lang.String location) throws java.io.IOException
location
- name of existing file to open.java.io.IOException
- on I/O errorpublic 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.IOException
- on I/O errorpublic static NetcdfFileWriteable createNew(java.lang.String location) throws java.io.IOException
location
- name of new file to open; if it exists, will overwrite it.java.io.IOException
- on I/O errorpublic static NetcdfFileWriteable createNew(java.lang.String location, boolean fill) throws java.io.IOException
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)java.io.IOException
- on I/O errorpublic void setFill(boolean fill)
fill
- set fill mode true or falsepublic void setLength(long size)
size
- if set to > 0, set length of file to this upon creation - this (usually) pre-allocates contiguous storage.public void setLargeFile(boolean isLargeFile)
isLargeFile
- true if large filepublic void setExtraHeaderBytes(int extraHeaderBytes)
extraHeaderBytes
- # bytes extra for the headerpublic boolean isDefineMode()
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 lengthpublic Dimension addUnlimitedDimension(java.lang.String dimName)
dimName
- name of unlimited dimensionpublic Dimension renameDimension(java.lang.String oldName, java.lang.String newName)
oldName
- existing dimension has this namenewName
- rename to thispublic Attribute addGlobalAttribute(Attribute att)
att
- the attribute.public Attribute addGlobalAttribute(java.lang.String name, java.lang.String value)
name
- name of attribute.value
- value of atribute.public Attribute addGlobalAttribute(java.lang.String name, java.lang.Number value)
name
- name of attribute.value
- must be of type Float, Double, Integer, Short or Bytepublic Attribute addGlobalAttribute(java.lang.String name, Array values)
name
- name of attribute.values
- Array of valuespublic Attribute deleteGlobalAttribute(java.lang.String attName)
attName
- existing Attribute has this namepublic Attribute renameGlobalAttribute(java.lang.String oldName, java.lang.String newName)
oldName
- existing Attribute has this namenewName
- rename to thispublic 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 shortName, DataType dataType, java.util.List<Dimension> dims)
shortName
- 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<Dimension> 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 Variable renameVariable(java.lang.String oldName, java.lang.String newName)
oldName
- existing Variable has this namenewName
- rename to thispublic 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 variable. IllegalArgumentException if not valid name.attName
- name of attribute.value
- must be of type Float, Double, Integer, Short or Bytepublic void addVariableAttribute(java.lang.String varName, java.lang.String attName, Array value)
varName
- name of variable. IllegalArgumentException if not valid name.attName
- name of attribute.value
- Array of valkuespublic Attribute deleteVariableAttribute(java.lang.String varName, java.lang.String attName)
varName
- existing Variable nameattName
- existing Attribute has this namepublic Attribute renameVariableAttribute(java.lang.String varName, java.lang.String attName, java.lang.String newName)
varName
- existing Variable nameattName
- existing Attribute has this namenewName
- rename to thispublic void updateAttribute(Variable v2, Attribute att) throws java.io.IOException
v2
- variable, or null for global attributeatt
- replace with this valuejava.io.IOException
- if I/O errorpublic void create() throws java.io.IOException
java.io.IOException
- if I/O errorpublic boolean setRedefineMode(boolean redefineMode) throws java.io.IOException
redefineMode
- start or end define modejava.io.IOException
- on read/write errorpublic void write(java.lang.String fullNameEsc, Array values) throws java.io.IOException, InvalidRangeException
fullNameEsc
- name of variable. IllegalArgumentException if variable name does not exist.values
- write this array; must be same type and rank as Variablejava.io.IOException
- if I/O errorInvalidRangeException
- if values Array has illegal shapepublic void write(java.lang.String fullNameEsc, int[] origin, Array values) throws java.io.IOException, InvalidRangeException
fullNameEsc
- full, escaped 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 Variablejava.io.IOException
- if I/O errorInvalidRangeException
- if values Array has illegal shapepublic 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 Stringjava.io.IOException
- if I/O errorInvalidRangeException
- if values Array has illegal shapepublic void writeStringData(java.lang.String fullNameEsc, int[] origin, Array values) throws java.io.IOException, InvalidRangeException
fullNameEsc
- 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 Stringjava.io.IOException
- if I/O errorInvalidRangeException
- if values Array has illegal shapepublic void flush() throws java.io.IOException
java.io.IOException
- if I/O errorpublic void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in interface FileCacheable
close
in class NetcdfFile
java.io.IOException
- if I/O errorpublic java.lang.String getFileTypeId()
NetcdfFile
getFileTypeId
in class NetcdfFile
public java.lang.String getFileTypeDescription()
NetcdfFile
getFileTypeDescription
in class NetcdfFile
public void setName(java.lang.String filename)
filename
- name of new file to create.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.