public class NetcdfFormatWriter
extends java.lang.Object
implements java.io.Closeable
NetcdfFormatWriter.Builder writerb = NetcdfFormatWriter.createNewNetcdf3(testFile.getPath());
writerb.addDimension(Dimension.builder().setName("vdim").setIsUnlimited(true).build());
writerb.addVariable("v", DataType.BYTE, "vdim");
try (NetcdfFormatWriter writer = writerb.build()) {
writer.write("v", dataArray);
}
| Modifier and Type | Class and Description |
|---|---|
static class |
NetcdfFormatWriter.Builder |
| Modifier and Type | Method and Description |
|---|---|
void |
abort()
Abort writing to this file.
|
int |
appendStructureData(Structure s,
StructureData sdata) |
static NetcdfFormatWriter.Builder |
builder()
Obtain a Builder to set custom options
|
long |
calcSize() |
void |
close()
close the file.
|
static NetcdfFileFormat |
convertToNetcdfFileFormat(NetcdfFileWriter.Version version) |
static NetcdfFileWriter.Version |
convertToNetcdfFileWriterVersion(NetcdfFileFormat format) |
static NetcdfFormatWriter.Builder |
createNewNetcdf3(java.lang.String location)
Create a new Netcdf3 file.
|
static NetcdfFormatWriter.Builder |
createNewNetcdf4(NetcdfFileFormat format,
java.lang.String location,
Nc4Chunking chunker)
Create a new Netcdf4 file.
|
Dimension |
findDimension(java.lang.String dimName) |
Attribute |
findGlobalAttribute(java.lang.String attName) |
Variable |
findVariable(java.lang.String fullNameEscaped) |
void |
flush()
Flush anything written to disk.
|
NetcdfFileFormat |
getFormat() |
NetcdfFile |
getOutputFile() |
static NetcdfFormatWriter.Builder |
openExisting(java.lang.String location)
Open an existing Netcdf file for writing data.
|
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 |
write(Variable v,
Array values)
Write data to the given variable, origin assumed to be 0.
|
void |
write(Variable v,
int[] origin,
Array values)
Write data to the given variable.
|
void |
writeStringDataToChar(Variable v,
Array values)
Write String data to a CHAR variable, origin assumed to be 0.
|
void |
writeStringDataToChar(Variable v,
int[] origin,
Array values)
Write String data to a CHAR variable.
|
public static NetcdfFormatWriter.Builder openExisting(java.lang.String location)
location - name of existing file to open.java.io.IOException - on I/O errorpublic static NetcdfFormatWriter.Builder createNewNetcdf3(java.lang.String location)
location - name of new file to open; if it exists, will overwrite it.public static NetcdfFormatWriter.Builder createNewNetcdf4(NetcdfFileFormat format, java.lang.String location, Nc4Chunking chunker)
format - One of the netcdf-4 NetcdfFileFormat.location - name of new file to open; if it exists, will overwrite it.chunker - used only for netcdf4, or null for default chunking algorithmpublic static NetcdfFormatWriter.Builder builder()
public static NetcdfFileWriter.Version convertToNetcdfFileWriterVersion(NetcdfFileFormat format)
public static NetcdfFileFormat convertToNetcdfFileFormat(NetcdfFileWriter.Version version)
public NetcdfFile getOutputFile()
public NetcdfFileFormat getFormat()
@Nullable public Variable findVariable(java.lang.String fullNameEscaped)
@Nullable public Dimension findDimension(java.lang.String dimName)
@Nullable public Attribute findGlobalAttribute(java.lang.String attName)
public long calcSize()
public void write(Variable v, Array values) throws java.io.IOException, InvalidRangeException
v - variable to write tovalues - 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 varName,
Array values)
throws java.io.IOException,
InvalidRangeException
java.io.IOExceptionInvalidRangeExceptionpublic void write(Variable v, int[] origin, Array values) throws java.io.IOException, InvalidRangeException
v - variable to write toorigin - 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 write(java.lang.String varName,
int[] origin,
Array values)
throws java.io.IOException,
InvalidRangeException
varName - name of variable to write toorigin - 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 writeStringDataToChar(Variable v, Array values) throws java.io.IOException, InvalidRangeException
v - variable to write tovalues - write this array; must be ArrayObject of Stringjava.io.IOException - if I/O errorInvalidRangeException - if values Array has illegal shapepublic void writeStringDataToChar(Variable v, int[] origin, Array values) throws java.io.IOException, InvalidRangeException
v - variable to write toorigin - 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 int appendStructureData(Structure s, StructureData sdata) throws java.io.IOException, InvalidRangeException
java.io.IOExceptionInvalidRangeExceptionpublic 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 flush()
throws java.io.IOException
java.io.IOExceptionpublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOExceptionpublic void abort()
throws java.io.IOException
java.io.IOException