public class NetcdfFormatWriter extends Object implements 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(String location)
Create a new Netcdf3 file.
|
static NetcdfFormatWriter.Builder |
createNewNetcdf4(NetcdfFileFormat format,
String location,
Nc4Chunking chunker)
Create a new Netcdf4 file.
|
Dimension |
findDimension(String dimName) |
Attribute |
findGlobalAttribute(String attName) |
Variable |
findVariable(String fullNameEscaped) |
void |
flush()
Flush anything written to disk.
|
NetcdfFileFormat |
getFormat() |
NetcdfFile |
getOutputFile() |
static NetcdfFormatWriter.Builder |
openExisting(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(String varName,
Array values)
Write data to the named variable, origin assumed to be 0.
|
void |
write(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(String location)
location
- name of existing file to open.IOException
- on I/O errorpublic static NetcdfFormatWriter.Builder createNewNetcdf3(String location)
location
- name of new file to open; if it exists, will overwrite it.public static NetcdfFormatWriter.Builder createNewNetcdf4(NetcdfFileFormat format, 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()
public long calcSize()
public void write(Variable v, Array values) throws IOException, InvalidRangeException
v
- variable to write tovalues
- write this array; must be same type and rank as VariableIOException
- if I/O errorInvalidRangeException
- if values Array has illegal shapepublic void write(String varName, Array values) throws IOException, InvalidRangeException
IOException
InvalidRangeException
public void write(Variable v, int[] origin, Array values) throws 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 VariableIOException
- if I/O errorInvalidRangeException
- if values Array has illegal shapepublic void write(String varName, int[] origin, Array values) throws 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 VariableIOException
- if I/O errorInvalidRangeException
- if values Array has illegal shapepublic void writeStringDataToChar(Variable v, Array values) throws IOException, InvalidRangeException
v
- variable to write tovalues
- write this array; must be ArrayObject of StringIOException
- if I/O errorInvalidRangeException
- if values Array has illegal shapepublic void writeStringDataToChar(Variable v, int[] origin, Array values) throws IOException, InvalidRangeException
v
- variable to write toorigin
- offset to start writing, ignore the strlen dimension.values
- write this array; must be ArrayObject of StringIOException
- if I/O errorInvalidRangeException
- if values Array has illegal shapepublic int appendStructureData(Structure s, StructureData sdata) throws IOException, InvalidRangeException
IOException
InvalidRangeException
public void updateAttribute(Variable v2, Attribute att) throws IOException
v2
- variable, or null for global attributeatt
- replace with this valueIOException
- if I/O errorpublic void flush() throws IOException
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public void abort() throws IOException
IOException