public class NetCDFServiceImpl extends loci.common.services.AbstractService implements NetCDFService, com.esotericsoftware.kryo.KryoSerializable
Modifier and Type | Field and Description |
---|---|
private java.util.Vector<java.lang.String> |
attributeList |
private java.lang.String |
currentFile |
private ucar.nc2.NetcdfFile |
netCDFFile
NetCDF file instance.
|
static java.lang.String |
NO_NETCDF_MSG |
private ucar.nc2.Group |
root
Root of the NetCDF file.
|
private java.util.Vector<java.lang.String> |
variableList |
Constructor and Description |
---|
NetCDFServiceImpl()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
private java.lang.String |
arrayToString(ucar.ma2.Array values) |
void |
close()
Closes and resets the service.
|
java.lang.Object |
getArray(java.lang.String path,
int[] origin,
int[] shape)
Retrieves an HDF path's values.
|
java.util.Vector<java.lang.String> |
getAttributeList()
Retrieves an exhaustive list of the HDF paths for all attributes in the
HDF document.
|
java.lang.String |
getAttributeValue(java.lang.String path)
Retrieves an attribute's value.
|
int |
getDimension(java.lang.String name)
Retrieves the length of a dimension.
|
private java.lang.String |
getDirectory(java.lang.String path) |
java.lang.String |
getFile()
Retrieves the current initialized file path.
|
private ucar.nc2.Group |
getGroup(java.lang.String path)
Retrieves a group based on its fully qualified path.
|
private java.lang.String |
getName(java.lang.String path) |
java.util.Hashtable<java.lang.String,java.lang.Object> |
getVariableAttributes(java.lang.String name)
Retrieves all of a variable's attributes.
|
java.util.Vector<java.lang.String> |
getVariableList()
Retrieves an exhaustive list of the HDF paths for all variables in the
HDF document.
|
java.lang.Object |
getVariableValue(java.lang.String name)
Retrieves a variable's value.
|
private void |
init() |
private void |
parseAttributesAndVariables(java.util.List<ucar.nc2.Group> groups)
Recursively parses attribute and variable paths, filling
attributeList and variableList . |
void |
read(com.esotericsoftware.kryo.Kryo kryo,
com.esotericsoftware.kryo.io.Input in) |
void |
setFile(java.lang.String file)
Initializes the service on a given file path.
|
void |
write(com.esotericsoftware.kryo.Kryo kryo,
com.esotericsoftware.kryo.io.Output out) |
public static final java.lang.String NO_NETCDF_MSG
private java.lang.String currentFile
private java.util.Vector<java.lang.String> attributeList
private java.util.Vector<java.lang.String> variableList
private ucar.nc2.NetcdfFile netCDFFile
private ucar.nc2.Group root
public void setFile(java.lang.String file) throws java.io.IOException
NetCDFService
setFile
in interface NetCDFService
file
- Path to initialize the service with.java.io.IOException
- If there is an error initializing the service
with file
.public java.lang.String getFile()
NetCDFService
getFile
in interface NetCDFService
null
if the service
has yet to be initialized or is closed.public java.util.Vector<java.lang.String> getAttributeList()
NetCDFService
getAttributeList
in interface NetCDFService
public java.util.Vector<java.lang.String> getVariableList()
NetCDFService
getVariableList
in interface NetCDFService
public java.lang.String getAttributeValue(java.lang.String path)
NetCDFService
getAttributeValue
in interface NetCDFService
path
- HDF path to the attribute.null
if the attribute is not a
string.public java.lang.Object getVariableValue(java.lang.String name) throws loci.common.services.ServiceException
NetCDFService
getVariableValue
in interface NetCDFService
name
- HDF path to the variable.loci.common.services.ServiceException
- If there is an error with the range of values
or reading from the file.Array.copyTo1DJavaArray()
public java.lang.Object getArray(java.lang.String path, int[] origin, int[] shape) throws loci.common.services.ServiceException
NetCDFService
getArray
in interface NetCDFService
path
- HDF path to the values.origin
- Array specifying the starting index. If null, assume
all zeroes.shape
- Array specifying the extents in each dimension. This
becomes the shape of the returned Array.loci.common.services.ServiceException
- If there is an error with the range of values
or reading from the file.Variable.read(int[], int[])
,
Array.copyToNDJavaArray()
public java.util.Hashtable<java.lang.String,java.lang.Object> getVariableAttributes(java.lang.String name)
NetCDFService
getVariableAttributes
in interface NetCDFService
name
- HDF path to the variable.Array.copyTo1DJavaArray()
public int getDimension(java.lang.String name)
NetCDFService
getDimension
in interface NetCDFService
name
- HDF path to the dimension.public void close() throws java.io.IOException
NetCDFService
close
in interface NetCDFService
java.io.IOException
- If there is an error closing the file.private void parseAttributesAndVariables(java.util.List<ucar.nc2.Group> groups)
attributeList
and variableList
.groups
- List of groups to recursively parse.private ucar.nc2.Group getGroup(java.lang.String path)
path
- Fully qualified path to the group.root
if the group cannot be found.private java.lang.String getDirectory(java.lang.String path)
private java.lang.String getName(java.lang.String path)
private java.lang.String arrayToString(ucar.ma2.Array values)
private void init() throws java.io.IOException
java.io.IOException
public void read(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Input in)
read
in interface com.esotericsoftware.kryo.KryoSerializable
public void write(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Output out)
write
in interface com.esotericsoftware.kryo.KryoSerializable
Copyright © 2017 Open Microscopy Environment