openmmtools.storage.iodrivers.NCVariableCodec

class openmmtools.storage.iodrivers.NCVariableCodec(parent_driver, target, storage_object=None)[source]

Pointer class which provides instructions on how to handle a given nc_variable

Bind to a given nc_storage_object on ncfile with given final_target_name, If no nc_storage_object is None, it defaults to the top level ncfile

Parameters:
parent_driver : Parent NetCDF driver

Class which can manipulate the NetCDF file at the top level for dimension creation and meta handling

target : string

String of the name of the object. Not explicitly a variable nor a group since the object could be either

storage_object : NetCDF file or NetCDF group, optional, Default to ncfile on parent_driver

Object the variable/object will be written onto

Attributes:
dtype

Define the Python data type for this variable

storage_type

Tell the Codec what NetCDF storage type this Codec treats the data as.

Methods

add_metadata(name, value) Add metadata to self on disk, extra bits of information that can be used for flags or other variables This is NOT a staticmethod of the top data set since you can buffer this before binding
append(data) Tell this writer how to write to the NetCDF file given the final object that it is bound to
dtype_string() Short name of variable for strings and errors
read() Return the property read from the ncfile
write(data[, at_index]) Tell this writer how to write to the NetCDF file given the final object that it is bound to
__init__(parent_driver, target, storage_object=None)[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__(parent_driver, target[, storage_object]) Initialize self.
add_metadata(name, value) Add metadata to self on disk, extra bits of information that can be used for flags or other variables This is NOT a staticmethod of the top data set since you can buffer this before binding
append(data) Tell this writer how to write to the NetCDF file given the final object that it is bound to
dtype_string() Short name of variable for strings and errors
read() Return the property read from the ncfile
write(data[, at_index]) Tell this writer how to write to the NetCDF file given the final object that it is bound to

Attributes

dtype Define the Python data type for this variable
storage_type Tell the Codec what NetCDF storage type this Codec treats the data as.
add_metadata(name, value)[source]

Add metadata to self on disk, extra bits of information that can be used for flags or other variables This is NOT a staticmethod of the top data set since you can buffer this before binding

Parameters:
name : string

Name of the attribute you wish to assign

value : any, but preferred string

Extra meta data to add to the variable

append(data)[source]

Tell this writer how to write to the NetCDF file given the final object that it is bound to

To overwrite data at a specific index of the already appended data, use the .write(data, at_index=X) method

Parameters:
data :
dtype

Define the Python data type for this variable

Returns:
dtype : type
static dtype_string()[source]

Short name of variable for strings and errors

Returns:
string
read()[source]

Return the property read from the ncfile

Returns:
Given property read from the nc file and cast into the correct Python data type
storage_type

Tell the Codec what NetCDF storage type this Codec treats the data as. This is explicitly either ‘variables’ or ‘groups’ so the driver knows which property to call on the NetCDF storage object

Returns:
storage_type: string of either ‘variables’ or ‘groups’
write(data, at_index=None)[source]

Tell this writer how to write to the NetCDF file given the final object that it is bound to

Alternately, tell a variable which is normally appended to to write a specific entry on the index at_index

Parameters:
data : any data you wish to write
at_index : None or Int, optional, default=None

Specify the index of a variable created by append to write specific data at the index entry. When None, this option is ignored The integer of at_index must be <= to the size of the appended data