mrc — the MRC/CCP4 volumetric data format
Added in version 0.7.0.
Reading of MRC/CCP4 volumetric files (MRC2014 file format) using the mrcfile library [Burnley2017].
References
Burnley T, Palmer C and Winn M (2017) Recent developments in the CCP-EM software suite. Acta Cryst. D73:469-477. doi: 10.1107/S2059798317007859
Classes
- class gridData.mrc.MRC(filename=None, assume_volumetric=False)[source]
Represent a MRC/CCP4 file.
Load MRC/CCP4 2014 3D volumetric data with the mrcfile library.
- Parameters:
- Raises:
ValueError – If the unit cell is not orthorhombic or if the data are not volumetric.
- header
Header data from the MRC file as a numpy record array.
- Type:
- array
Data as a 3-dimensional array where axis 0 corresponds to X, axis 1 to Y, and axis 2 to Z. This order is always enforced, regardless of the order in the mrc file.
- Type:
- delta
Diagonal matrix with the voxel size in X, Y, and Z direction (taken from the
mrcfile.mrcfile.voxel_sizeattribute)- Type:
- origin
numpy array with coordinates of the coordinate system origin (computed from
header.origin, the offsetsheader.origin.nxstart,header.origin.nystart,header.origin.nzstartand the spacingdelta)- Type:
Notes
Only volumetric (3D) densities are read.
Only orthorhombic unitcells supported (other raise
ValueError)Reading and writing are supported.
Added in version 0.7.0.
- property edges
Edges of the grid cells, origin at centre of 0,0,0 grid cell.
Only works for regular, orthonormal grids.
- classmethod from_grid(grid, **kwargs)[source]
Create MRC object from a Grid.
If the Grid was originally created from an mrcfile (and thus has the
Grid._mrc_headerattribute), the MRC header will be copied into the returned MRC instance.- Parameters:
grid (Grid) – Grid object to convert
**kwargs – Additional keyword arguments (currently unused)
- Returns:
MRC wrapper object
- Return type:
Added in version 1.2.0.
- property native
Return a native
MrcInterpreterobject.The object is
MrcObjectthat is connected to a stream. It is implemented as a managed property and regenerated whenevernativeis used. In order to re-use the object, assign it to a variable:mrc = gdfMRC.native
In order to write to a file, open the file and assign it to the
_iostreamattribute and call theflush()method:mrc = gdfMRC.native # important: assign to variable mrc! with open("new.mrc", "wb") as f: mrc._iostream = f mrc.flush()
- Returns:
mrcfile.mrcinterpreter.MrcInterpreter – Native mrcfile object
SeeAlso
——-
write
Added in version 1.2.0.
- read(filename, assume_volumetric=False)[source]
Populate the instance from the MRC/CCP4 file filename.
- write(filename)[source]
Write grid data to MRC/CCP4 file format.
- Parameters:
filename (str) – Output filename for the MRC file
Notes
The data array should be in xyz order (axis 0=X, axis 1=Y, axis 2=Z).
If the MRC object was created by reading an existing file, the original header information (including mapc, mapr, maps ordering) is preserved. Otherwise, standard ordering (mapc=1, mapr=2, maps=3) is used.
Currently, only uncompressed files are supported for writing. (For reading, gzip and bzip2-compressed files are supported.)
Added in version 1.1.0.