Interface for reading and writing to AMBER NetCDF files. This is a file-like object, that supports both reading or writing depending on the mode flag. It implements the context manager protocol, so you can also use it with the python ‘with’ statement.
Parameters: | filename : str
mode : {‘r’, ‘w’}, default=’r’
force_overwrite : bool, default=False
|
---|
Methods
__init__(filename[, mode, force_overwrite]) | |
close() | Close the NetCDF file handle |
flush() | Write all buffered data in the to the disk file. |
read([n_frames, stride, atom_indices]) | Read data from a molecular dynamics trajectory in the AMBER NetCDF format. |
read_as_traj(topology[, n_frames, stride, ...]) | Read a trajectory from a NetCDF file |
seek(offset[, whence]) | Move to a new file position |
tell() | Current file position |
write(coordinates[, time, cell_lengths, ...]) | Write one or more frames of a molecular dynamics trajectory to disk in the AMBER NetCDF format. |
Attributes
distance_unit | |
n_atoms | |
n_frames |
Read a trajectory from a NetCDF file
Parameters: | topology : Topology
n_frames : int, optional
stride : np.ndarray, optional
atom_indices : array_like, optional
|
---|---|
Returns: | trajectory : Trajectory
|
Read data from a molecular dynamics trajectory in the AMBER NetCDF format.
Parameters: | n_frames : int, optional
stride : int, optional
atom_indices : np.ndarray, dtype=int, optional
|
---|---|
Returns: | coordinates : np.ndarray, shape=(n_frames, n_atoms, 3)
time : np.ndarray, None
cell_lengths : np.ndarray, None
cell_angles : np.ndarray, None
|
Write one or more frames of a molecular dynamics trajectory to disk in the AMBER NetCDF format.
Parameters: | coordinates : np.ndarray, dtype=np.float32, shape=(n_frames, n_atoms, 3)
time : np.ndarray, dtype=np.float32, shape=(n_frames), optional
cell_lengths : np.ndarray, dtype=np.double, shape=(n_frames, 3)
cell_angles : np.ndarray, dtype=np.double, shape=(n_frames, 3)
|
---|
Notes
If the input arrays are of dimension deficient by one, for example if the coordinates array is two dimensional, the time is a single scalar or cell_lengths and cell_angles are a 1d array of length three, that is okay. You’ll simply be saving a single frame.
Write all buffered data in the to the disk file.
Move to a new file position
Parameters: | offset : int
whence : {0, 1, 2}
|
---|
Current file position
Returns: | offset : int
|
---|
Close the NetCDF file handle