Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
# Release notes

## Version 2.2.1 -- 2021-11-28

- Add quantitative phase analysis with PowderPattern.qpa(), including
an example notebook using the QPA Round-Robin data.
- Correct import of urllib.request.urllopen() when loading CIF or z-matrix
files from http urls.
- Fix blank line javascript output when updating the Crystal 3D view
- Add RefinableObj.xml() to directly get the XMLOutput() as a string
- Add example notebooks to the sphinx-generated html documentation
- Fix issue when using Crystal.XMLInput() for a non-empty structure.
Existing scattering power will be re-used when possible, and otherwise
not deleted anymore (which could lead to crashes).

## Version 2.2.0 -- 2021-06-08

Notable differences from version 2.1.0.

- Add access to Radiation class & functions to change RadiationType, wavelength in PowderPattern and ScatteringData (and hence DiffractionDataSingleCrystal) classes.
- Add access to Radiation class & functions to change RadiationType,
wavelength in PowderPattern and ScatteringData (and hence
DiffractionDataSingleCrystal) classes.

- Fix the custodian_ward when creating a PowderPatternDiffraction: PowderPatternDiffraction must persist while PowderPattern exists, and Crystal must persist while PowderPatternDiffraction exists.
- Fix the custodian_ward when creating a PowderPatternDiffraction:
PowderPatternDiffraction must persist while PowderPattern exists, and
Crystal must persist while PowderPatternDiffraction exists.

- Add 3D Crystal viewer `pyobjcryst.crystal.Crystal.widget_3d`.

Expand Down
46 changes: 45 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,26 @@ parallel jobs (-j4)::

See ``scons -h`` for description of build targets and options.

Optional graphical dependencies for jupyter notebooks
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Some of the classes can produce graphical outputs, which can be
displayed in a jupyter notebook:

* a Crystal structure can be displayed in 3D: this requires the
``py3dmol`` and ``ipywidgets`` modules. See the notebook
``examples/cystal_3d_widget.ipynb``
* a PowderPattern can be displayed (and live-updated) if
``matplotlib`` (and optionnally ``ipympl``) are installed. See the
notebook ``examples/cimetidine-structure-solution-powder.ipynb``

In short, ``pip install jupyter matplotlib ipywidgets py3dmol``
will give you all the required dependencies. Note that you can also
use this in jupyterlab.

Note that ``jupyter``, ``ipywidgets``, ``matplotlib`` and ``ipympl`` can
be installed using conda(-forge), but ``py3dmol`` should be installed using
``pip``, as the conda version is obsolete.


DEVELOPMENT
-----------
Expand Down Expand Up @@ -109,7 +129,7 @@ Anaconda environment. This can be achieved by setting the ``CPATH``,
``LIBRARY_PATH`` and ``LDFLAGS`` environment variables as follows::

# resolve the prefix directory P of the active Anaconda environment
P="$(conda info --json | grep default_prefix | cut -d\" -f4)"
P=$CONDA_PREFIX
export CPATH=$P/include
export LIBRARY_PATH=$P/lib
export LDFLAGS=-Wl,-rpath,$P/lib
Expand All @@ -120,6 +140,25 @@ Note the Anaconda package for the required libobjcryst library is built
with a C++ compiler provided by Anaconda. This may cause incompatibility
with system C++. In such case please use Anaconda C++ to build pyobjcryst.

Quick conda environment from libobjcryst and pyobjcryst sources
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

If ``conda`` is available, you can create a pyobjcryst environment
from the git repositories (downloaded in the current directory) using::
conda create --yes --name pyobjcryst numpy matplotlib ipywidgets jupyter
conda install --yes -n pyobjcryst -c conda-forge boost scons py3dmol
conda activate pyobjcryst
git clone https://github.com/diffpy/libobjcryst.git
cd libobjcryst
scons -j4 install prefix=$CONDA_PREFIX
cd ..
git clone https://github.com/diffpy/pyobjcryst.git
cd pyobjcryst
export CPATH=$CONDA_PREFIX/include
export LIBRARY_PATH=$CONDA_PREFIX/lib
export LDFLAGS=-Wl,-rpath,$CONDA_PREFIX/lib
scons -j4 install prefix=$CONDA_PREFIX


CONTACTS
--------
Expand All @@ -129,3 +168,8 @@ For more information on pyobjcryst please visit the project web-page
http://www.diffpy.org

or email Prof. Simon Billinge at sb2896@columbia.edu.

You can also contact Vincent Favre-Nicolin (favre@esrf.fr) if you
are using pyobjcryst outside diffpy, e.g. to display structures
in a notebook, refine powder patterns or solve structures using the
global optimisation algorithms, etc..
64 changes: 64 additions & 0 deletions doc/manual/source/api/modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ pyobjcryst.crystal module
:undoc-members:
:show-inheritance:

pyobjcryst.diffractiondatasinglecrystal module
----------------------------------------------

.. automodule:: pyobjcryst.diffractiondatasinglecrystal
:members:
:undoc-members:
:show-inheritance:

pyobjcryst.general module
-------------------------

Expand All @@ -37,6 +45,22 @@ pyobjcryst.general module
:undoc-members:
:show-inheritance:

pyobjcryst.globaloptim module
-----------------------------

.. automodule:: pyobjcryst.globaloptim
:members:
:undoc-members:
:show-inheritance:

pyobjcryst.indexing module
--------------------------

.. automodule:: pyobjcryst.indexing
:members:
:undoc-members:
:show-inheritance:

pyobjcryst.io module
--------------------

Expand All @@ -45,6 +69,14 @@ pyobjcryst.io module
:undoc-members:
:show-inheritance:

pyobjcryst.lsq module
---------------------

.. automodule:: pyobjcryst.lsq
:members:
:undoc-members:
:show-inheritance:

pyobjcryst.molecule module
--------------------------

Expand All @@ -61,6 +93,22 @@ pyobjcryst.polyhedron module
:undoc-members:
:show-inheritance:

pyobjcryst.powderpattern module
-------------------------------

.. automodule:: pyobjcryst.powderpattern
:members:
:undoc-members:
:show-inheritance:

pyobjcryst.radiation module
---------------------------

.. automodule:: pyobjcryst.radiation
:members:
:undoc-members:
:show-inheritance:

pyobjcryst.refinableobj module
------------------------------

Expand All @@ -69,6 +117,14 @@ pyobjcryst.refinableobj module
:undoc-members:
:show-inheritance:

pyobjcryst.reflectionprofile module
-----------------------------------

.. automodule:: pyobjcryst.reflectionprofile
:members:
:undoc-members:
:show-inheritance:

pyobjcryst.scatterer module
---------------------------

Expand All @@ -77,6 +133,14 @@ pyobjcryst.scatterer module
:undoc-members:
:show-inheritance:

pyobjcryst.scatteringdata module
--------------------------------

.. automodule:: pyobjcryst.scatteringdata
:members:
:undoc-members:
:show-inheritance:

pyobjcryst.scatteringpower module
---------------------------------

Expand Down
6 changes: 5 additions & 1 deletion doc/manual/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import sys, os
import time
import sphinx_py3doc_enhanced_theme
# Requires sphinx >= 0.6

# If extensions (or modules to document with autodoc) are in another directory,
Expand All @@ -23,7 +24,9 @@
extensions = [
'sphinx.ext.ifconfig',
'sphinx.ext.autodoc',
'm2r',
'm2r2',
'nbsphinx',
'nbsphinx_link'
]

# Add any paths that contain templates here, relative to this directory.
Expand Down Expand Up @@ -101,6 +104,7 @@
# a list of builtin themes.
#
html_theme = 'sphinx_py3doc_enhanced_theme'
html_theme_path = [sphinx_py3doc_enhanced_theme.get_html_theme_path()]

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
Expand Down
3 changes: 3 additions & 0 deletions doc/manual/source/examples/Quantitative-phase-analysis.nblink
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"path": "../../../../examples/QPA-Quantitative phase analysis.ipynb"
}
3 changes: 3 additions & 0 deletions doc/manual/source/examples/crystal_3d_widget.nblink
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"path": "../../../../examples/crystal_3d_widget.ipynb"
}
47 changes: 47 additions & 0 deletions doc/manual/source/examples/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
####################################################
Example notebooks
####################################################

Several examples available in the pyobjcryst repository:


:doc:`3D Crystal structure display <crystal_3d_widget>`
=======================================================

Example of importing a CIF file from a file or the
`Crystallography Open Database <http://crystallography.net/cod/>`_
and displaying it in a widget using
`3dmol.js <https://3dmol.csb.pitt.edu/>`_.

:doc:`Solving the cimetidine structure from its powder pattern <structure-solution-powder-cimetidine>`
======================================================================================================

In this example, a powder pattern is used to solve the crystal
structure of Cimetidine. This covers all the steps: loading the
data, indexing the pattern (determining the unit cell), finding
the spacegroup, profile fitting, and solving the structure
using a global optimisation algorithm.

:doc:`Solving the PbSO4 structure from its X and N powder patterns <structure-solution-powder-pbso4>`
=====================================================================================================

In this example, two powder patterns (X-ray and neutron) are used to solve
the crystal structure of PbSO4. This covers all the steps: loading the
data, indexing the pattern (determining the unit cell), finding
the spacegroup, profile fitting for the two patterns, and solving the
structure using a global optimisation algorithm.

:doc:`Meta-structure solution using multi-processing <structure-solution-multiprocessing>`
==========================================================================================

This is a more advanced example where 8 different spacegroups are
tested in parallel to determine which one is correct. The solutions
can then be compared and displayed individually.

:doc:`Quantitative phase analysis (QPA) <Quantitative-phase-analysis>`
______________________________________________________________________

Example of QPA based on the data available from the `1999 Round Robin
<https://www.iucr.org/__data/iucr/powder/QARR/samples.htm>`_,
in the case where all present crystalline structures are known
and there is no preferred orientation.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"path": "../../../../examples/structure-solution-multiprocessing.ipynb"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"path": "../../../../examples/structure-solution-powder-cimetidine.ipynb"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"path": "../../../../examples/structure-solution-powder-pbso4.ipynb"
}
26 changes: 26 additions & 0 deletions doc/manual/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ Christopher Farrow, Pavol Juhás, and Simon J.L. Billinge.
The sources are now maintained as a part of the DiffPy-CMI complex
modeling initiative at the Brookhaven National Laboratory.

Further developments including the ability to index and refine
powder patterns, solve and display crystal structures, using the
global optimisation and least squares algorithms (see the
:doc:`examples/index`) are provided by Vincent Favre-Nicolin (ESRF).

For a complete list of contributors, see
https://github.com/diffpy/pyobjcryst/graphs/contributors.

Expand All @@ -29,6 +34,26 @@ Installation
See the `README <https://github.com/diffpy/pyobjcryst#requirements>`_
file included with the distribution.

======================================
Usage
======================================

pyobjcryst can be used in different ways:

* as a backend library to manage crystal structures description in an application
like `DiffPy-CMI <https://www.diffpy.org/products/diffpycmi/index.html>`_
* in python scripts or notebooks, allowing to display crystal structures,
index and refine powder diffraction patterns, solve crystal structures
from diffraction data using global optimisation algorithms, etc.. The
functionality is similar to what is available in `Fox <http://fox.vincefn.net>`_.
See the :doc:`examples/index`:

* :doc:`3D Crystal structure display <examples/crystal_3d_widget>`
* :doc:`Solving the cimetidine structure from its powder pattern <examples/structure-solution-powder-cimetidine>`
* :doc:`Solving the PbSO4 structure from its X and N powder patterns <examples/structure-solution-powder-pbso4>`
* :doc:`Meta-structure solution using multi-processing <examples/structure-solution-multiprocessing>`
* :doc:`Quantitative phase analysis (QPA) <examples/Quantitative-phase-analysis>`

======================================
Table of contents
======================================
Expand All @@ -39,6 +64,7 @@ Table of contents
license
release
api/modules
examples/index

========================================================================
Indices
Expand Down
2 changes: 1 addition & 1 deletion doc/manual/source/license.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ OPEN SOURCE LICENSE AGREEMENT
the City of New York
| Copyright (c) 2014-2019, Brookhaven Science Associates,
Brookhaven National Laboratory

| Copyright (c) 2015-, ESRF-European Synchrotron Radiation Facility

The "DiffPy-CMI" is distributed subject to the following license conditions:

Expand Down
Loading