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(ucar.nc2.NetcdfFileWriter.Version version) |
static ucar.nc2.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 void abort() throws IOException
IOException
public int appendStructureData(Structure s, StructureData sdata) throws IOException, InvalidRangeException
IOException
InvalidRangeException
public static NetcdfFormatWriter.Builder builder()
public long calcSize()
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public static NetcdfFileFormat convertToNetcdfFileFormat(ucar.nc2.NetcdfFileWriter.Version version)
public static ucar.nc2.NetcdfFileWriter.Version convertToNetcdfFileWriterVersion(NetcdfFileFormat format)
public 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 void flush() throws IOException
IOException
public NetcdfFileFormat getFormat()
public NetcdfFile getOutputFile()
public static NetcdfFormatWriter.Builder openExisting(String location)
location
- name of existing file to open.IOException
- on I/O errorpublic void updateAttribute(Variable v2, Attribute att) throws IOException
v2
- variable, or null for global attributeatt
- replace with this valueIOException
- if I/O errorpublic void write(String varName, Array values) throws IOException, InvalidRangeException
IOException
InvalidRangeException
public 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 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(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 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 shape