af2rave.colvar module
This class handles a PLUMED style COLVAR file.
- class Colvar(header=[], time=None, data=array([], dtype=float64))[source]
Bases:
object- choose(columns: list) Colvar[source]
Choose the columns from the data. Returns a copy including the time.
- property data
Return the data of the Colvar.
- classmethod from_file(filename: str) Colvar[source]
Construct a Colvar object from a file. Same as Colvar().read(filename).
- Parameters:
filename (str) – The filename to read.
- property header: list[str]
The header of the Colvar. Note that time is not considered one of the fields.
- Returns:
The header of the Colvar.
- Return type:
list[str]
- kappend(data: Colvar | str) Colvar[source]
Append the data along the column axis in place. The incoming data should have the same number of rows as the base data.
- Parameters:
data (Colvar | str) – The incoming data. Either a colvar object or a filename.
- Returns:
Self
- map(func: callable, insitu=True) Colvar[source]
Apply a function to the data. The function should take in a numpy array and return a numpy array.
- read(filename: str, stride: int = 1) Colvar[source]
Read a PLUMED-style colvar file into the object.
- Parameters:
filename (str) – The filename to read.
stride (int) – The stride to apply to the data. (Optional, default=1)
- Returns:
Self
- Raises:
FileNotFoundError – If the file does not exist.
ValueError – If the number of columns in the file does not match the number of headers.
- property shape: tuple[int]
The shape of the header. The first dimension is the number of fields, the second dimension is the number of rows.
- Returns:
The shape of the data.
- Return type:
tuple[int]
- stride(interval: int) Colvar[source]
In-place stride the data with a given interval.
- Parameters:
interval (int) – The interval to stride the data.
- Returns:
Self
- tappend(data: Colvar | str, stride: int = None) Colvar[source]
Append the data along the time axis in place. The incoming data should contain all columns in the base data. If the Colvar to append to is empty, the header will be copied from the incoming data.
- Parameters:
data (Colvar) – The incoming data. Either a colvar object or a filename.
stride (int) – The stride to apply to the incoming data.
- Returns:
Self
- Raises:
ValueError – If the incoming data does not have all columns in the base data.
- property time
Return the time data of the Colvar. Can be None if the data does not have time.
- Returns:
The time data.
- Return type:
numpy.ndarray | None