openmmtools.storage.iodrivers.NetCDFIODriver

class openmmtools.storage.iodrivers.NetCDFIODriver(file_name, access_mode=None)[source]

Driver to handle all NetCDF IO operations, variable creation, and other operations. Can be extended to add new or modified type codecs

Attributes:
access_mode

Access mode of file on disk

file_name

File name of on hard drive

Methods

add_metadata(name, value[, path]) Add metadata to self on disk, extra bits of information that can be used for flags or other variables
check_infinite_dimension([name]) Check that the arbitrary infinite dimension exists on file and create it if not.
check_iterable_dimension([length]) Check that the dimension of appropriate size for a given iterable exists on file and create it if not
check_scalar_dimension() Check that the scalar dimension exists on file and create it if not
close() Instruct how to safely close down the file.
create_storage_variable(path, type_key) Create a new variable on the disk and at the path location and store it as the given type.
generate_infinite_dimension() Generate a new infinite dimension and return the name of that dimension
get_directory(path[, create]) Get the group (directory) on the NetCDF file, create the full path if not present
get_storage_variable(path) Get a variable IO object from disk at path.
set_codec(type_key, codec) Add new codifier to the specific driver class.
sync  
__init__(file_name, access_mode=None)[source]

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

Methods

__init__(file_name[, access_mode]) Initialize self.
add_metadata(name, value[, path]) Add metadata to self on disk, extra bits of information that can be used for flags or other variables
check_infinite_dimension([name]) Check that the arbitrary infinite dimension exists on file and create it if not.
check_iterable_dimension([length]) Check that the dimension of appropriate size for a given iterable exists on file and create it if not
check_scalar_dimension() Check that the scalar dimension exists on file and create it if not
close() Instruct how to safely close down the file.
create_storage_variable(path, type_key) Create a new variable on the disk and at the path location and store it as the given type.
generate_infinite_dimension() Generate a new infinite dimension and return the name of that dimension
get_directory(path[, create]) Get the group (directory) on the NetCDF file, create the full path if not present
get_storage_variable(path) Get a variable IO object from disk at path.
set_codec(type_key, codec) Add new codifier to the specific driver class.
sync()

Attributes

access_mode Access mode of file on disk
file_name File name of on hard drive
access_mode

Access mode of file on disk

add_metadata(name, value, path='/')[source]

Add metadata to self on disk, extra bits of information that can be used for flags or other variables

Parameters:
name : string

Name of the attribute you wish to assign

value : any, but preferred string

Extra meta data to add to the variable

path : string, optional, Default: ‘/’

Path to the object to assign metadata. If the object does not exist, an error is raised Not passing a path in attaches the data to the top level file

check_infinite_dimension(name='iteration')[source]

Check that the arbitrary infinite dimension exists on file and create it if not.

Parameters:
name : string, optional, Default: ‘iteration’

Name of the dimension

check_iterable_dimension(length=0)[source]

Check that the dimension of appropriate size for a given iterable exists on file and create it if not

Parameters:
length : int, Default: 0

Length of the dimension, leave as 0 for infinite length

check_scalar_dimension()[source]

Check that the scalar dimension exists on file and create it if not

close()[source]

Instruct how to safely close down the file.

create_storage_variable(path, type_key)[source]

Create a new variable on the disk and at the path location and store it as the given type.

Parameters:
path : string

The way to identify the variable on the storage system. This can be either a variable name or a full path (such as in NetCDF files)

type_key : Immutable object

Type specifies the key identifier in the _codec_type_maps added by the set_codec function. If type is not in _codec_type_maps variable, an error is raised.

Returns:
bound_codec : Codec which is linked to a specific reference on the disk.
file_name

File name of on hard drive

generate_infinite_dimension()[source]

Generate a new infinite dimension and return the name of that dimension

Returns:
infinite_dim_name : string

Name of the new infinite dimension on file

get_directory(path, create=True)[source]

Get the group (directory) on the NetCDF file, create the full path if not present

Parameters:
path : string

Path to group on the disk

create: boolean, default: True

Should create the directory/ies on the way down, similar function to mkdir -p in shell If False, raise KeyError if not in the stack

Returns:
group : NetCDF Group

Group object requested from file. All subsequent groups are created on the way down and can be accessed the same way.

get_storage_variable(path)[source]

Get a variable IO object from disk at path. Raises an error if no storage object exists at that level

Parameters:
path : string

Path to the variable/storage object on disk

Returns:
codec : Subclass of NCVariableCodec

The codec tied to a specific variable and bound to it on the disk

set_codec(type_key, codec)[source]

Add new codifier to the specific driver class. This coder must know how to read/write and append to disk.

This method also acts to overwrite any existing type <-> codec map, however, will not overwrite any codec already in use by a variable. E.g. Variable X of type T has codec A as the codecs have {T:A}. The maps is changed by set_codec(T,B) so now {T:B}, but X will still be on codec A. Unloading X and then reloading X will bind it to codec B.

Parameters:
type_key : Unique immutable object

Unique key that will be added to identify this de_encoder as part of the class

codec : Specific codifier class

Class to handle all of the encoding of decoding of the variables