Debian Codegraph @

mrcfile/__init__.py

raw
1 # Copyright (c) 2016, Science and Technology Facilities Council
2 # This software is distributed under a BSD licence. See LICENSE.txt.
3
4 """
5 mrcfile
6 =======
7
8 A pure Python implementation of the MRC2014 file format.
9
10 For a full introduction and documentation, see http://mrcfile.readthedocs.io/
11
12 Functions
13 ---------
14
15 * :func:`new`: Create a new MRC file.
16 * :func:`open`: Open an MRC file.
17 * :func:`open_async`: Open an MRC file asynchronously.
18 * :func:`mmap`: Open a memory-mapped MRC file (fast for large files).
19 * :func:`new_mmap`: Create a new empty memory-mapped MRC file (fast for large files).
20 * :func:`validate`: Validate an MRC file
21
22 Basic usage
23 -----------
24
25 Examples assume that this package has been imported as ``mrcfile`` and numpy
26 has been imported as ``np``.
27
28 To open an MRC file and read a slice of data:
29
30 >>> with mrcfile.open('tests/test_data/EMD-3197.map') as mrc:
31 ... mrc.data[10,10]
32 ...
33 array([ 2.58179283, 3.1406002 , 3.64495397, 3.63812137, 3.61837363,
34 4.0115056 , 3.66981959, 2.07317996, 0.1251585 , -0.87975615,
35 0.12517013, 2.07319379, 3.66982722, 4.0115037 , 3.61837196,
36 3.6381247 , 3.64495087, 3.14059472, 2.58178973, 1.92690361], dtype=float32)
37
38 To create a new file with a 2D data array, and change some values:
39
40 >>> with mrcfile.new('tmp.mrc') as mrc:
41 ... mrc.set_data(np.zeros((5, 5), dtype=np.int8))
42 ... mrc.data[1:4,1:4] = 10
43 ... mrc.data
44 ...
45 array([[ 0, 0, 0, 0, 0],
46 [ 0, 10, 10, 10, 0],
47 [ 0, 10, 10, 10, 0],
48 [ 0, 10, 10, 10, 0],
49 [ 0, 0, 0, 0, 0]], dtype=int8)
50
51 Background
52 ----------
53
54 The MRC2014 format was described in the Journal of Structural Biology:
55 http://dx.doi.org/10.1016/j.jsb.2015.04.002
56
57 The format specification is available on the CCP-EM website:
58 http://www.ccpem.ac.uk/mrc_format/mrc2014.php
59
60 """
61
62 # Import Python 3 features for future-proofing
63 from __future__ import (absolute_import, division, print_function,
64 unicode_literals)
65
66 from .load_functions import new, open, read, write, open_async, mmap, new_mmap
67 from .validator import validate
68 from .version import __version__