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(ucar.nc2.NetcdfFileWriter.Version version) |
static ucar.nc2.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 void abort() throws java.io.IOException
java.io.IOException
public int appendStructureData(Structure s, StructureData sdata) throws java.io.IOException, InvalidRangeException
java.io.IOException
InvalidRangeException
public static NetcdfFormatWriter.Builder builder()
public long calcSize()
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
java.io.IOException
public static NetcdfFileFormat convertToNetcdfFileFormat(ucar.nc2.NetcdfFileWriter.Version version)
public static ucar.nc2.NetcdfFileWriter.Version convertToNetcdfFileWriterVersion(NetcdfFileFormat format)
public 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 algorithm@Nullable public Dimension findDimension(java.lang.String dimName)
@Nullable public Attribute findGlobalAttribute(java.lang.String attName)
@Nullable public Variable findVariable(java.lang.String fullNameEscaped)
public void flush() throws java.io.IOException
java.io.IOException
public NetcdfFileFormat getFormat()
public NetcdfFile getOutputFile()
public static NetcdfFormatWriter.Builder openExisting(java.lang.String location)
location
- name of existing file to open.java.io.IOException
- on I/O errorpublic 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 write(java.lang.String varName, Array values) throws java.io.IOException, InvalidRangeException
java.io.IOException
InvalidRangeException
public 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 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(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 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 shape