Code for parsing the CCP-NC ab-initio magnetic resonance file format as used in the latest version of CASTEP, coming soon to other codes such as Quantum ESPRESSO. See more on this page
Documentation for the Python API is available here.
A few IPython notebooks have been written using the library as examples. You can see them here.
IPython is an enhanced interpreter for Python and offers an excellent in-browser workbook experience, similar to Matlab or Mathematica. This is particularly useful when developing code using this library to process your magnetic resonance calculations. You can read instructions for installing it here.
A calculated J-coupling network in ethanol.
Clone the repository or download and extract the .zip file somewhere. From the command line, run:
sudo python setup.py install
to install it globally, or
python setup.py install --user
to install it just for your user account (read more here), and the Python module and associated scripts should now be installed.
If you have installed it locally with --user, you may have to add ~/.local/bin to your PATH. You can do this by adding
export PATH=$HOME/.local/bin:$PATH
to your ~/.bashrc and restarting your session or running "source ~/.bashrc". If you use tcsh you do
setenv PATH $HOME/.local/bin:$PATH
and then restart your session.
The convertoldmagres.py script installed by the above command will convert an old-style Castep magres file to the new-style format for use with the new tools. You use it from the command line like:
convertoldmagres.py sample.magres > sample.new.magres
and optionally with the associated job's .castep file, to capture the lattice information,
convertoldmagres.py sample.magres sample.castep > sample.new.magres
The magres.format
and magres.atoms
modules contain code for, respectively, a low level parser of the CCPNC ab-initio
magres format and a high-level collection of objects to represent its contents.
The module also include the useful magres.constants
module, which gives the best-known gamma constants and quadrupole
moments for all isotopes, the most common isotopes used in experiments.
More documentation is available here. Also, see the IPython notebooks linked at the top of this document.
We use the JSONschema definition to provide a specification for the internal datastructure used by the parser and the format of the JSON emitted and consumed by .as_json() and .load_json() on MagresFile.
To dump the JSON representation of a .magres simply do
magresjson.py sample.magres > sample.magres.json
and sample.magres.json should now contain a schema-compliant JSON representation of sample.magres.