Skip to content

Commit a8486a6

Browse files
Yuchen XiaoYuchen Xiao
authored andcommitted
docs: add tutorial about how to use diffpy.batchpdfsuite
1 parent 0b25216 commit a8486a6

15 files changed

Lines changed: 121 additions & 114 deletions

.pre-commit-config.yaml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ repos:
2020
- id: check-merge-conflict
2121
- id: check-toml
2222
- id: check-added-large-files
23+
exclude: ^docs/examples/example\.zip$
2324
- repo: https://github.com/psf/black
2425
rev: 26.3.1
2526
hooks:
@@ -58,9 +59,10 @@ repos:
5859
additional_dependencies:
5960
- "prettier@^3.2.4"
6061
types: [yaml, markdown, json]
61-
# ruff - An extremely fast Python linter and code formatter, written in Rust.
62-
- repo: https://github.com/astral-sh/ruff-pre-commit
63-
rev: v0.15.12
62+
# docformatter - PEP 257 compliant docstring formatter
63+
- repo: https://github.com/PyCQA/docformatter
64+
rev: v1.7.8
6465
hooks:
65-
- id: ruff-check
66-
args: [--fix, --config=pyproject.toml]
66+
- id: docformatter
67+
additional_dependencies: [tomli]
68+
args: [--in-place, --config, ./pyproject.toml]

cookiecutter.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"author_names": "Yuchen Xiao, Simon Billinge",
33
"author_emails": "yx2924@columbia.edu, sbillinge@ucsb.edu",
4-
"maintainer_names": "Yuchen Xiao, Simon Billinge",
5-
"maintainer_emails": "yx2924@columbia.edu, sbillinge@ucsb.edu",
4+
"maintainer_names": "Simon Billinge",
5+
"maintainer_emails": "sbillinge@ucsb.edu",
66
"maintainer_github_usernames": "sbillinge",
77
"contributors": "Yuchen Xiao and members of the diffpy.batchpdfsuite community",
88
"license_holders": "contributors to the diffpy.batchpdfsuite community",

docs/examples/example.zip

2.43 MB
Binary file not shown.

docs/source/api/diffpy.batchpdfsuite.example_package.rst

Lines changed: 0 additions & 31 deletions
This file was deleted.

docs/source/api/diffpy.batchpdfsuite.rst

Lines changed: 0 additions & 30 deletions
This file was deleted.

docs/source/getting-started.rst

Lines changed: 88 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -8,72 +8,117 @@
88
Getting started
99
================
1010

11-
Here are some example templates provided to help you get started with writing your documentation. You can use these templates to create your own documentation.
11+
``diffpy.batchpdfsuite`` is a GUI for batch refinements of multiple PDF
12+
datasets. It is built on top of the
13+
`diffpy.srfit <https://github.com/diffpy/diffpy.srfit>`_ and
14+
`diffpy.apps <https://github.com/diffpy/diffpy.apps>`_ libraries.
1215

13-
Reuse ``.rst`` files across multiple pages
14-
------------------------------------------
16+
This tutorial will guide you through the interface and usage of ``diffpy.batchpdfsuite``.
17+
For installation, please refer to the `README <https://github.com/diffpy/diffpy.batchpdfsuite#installation>`_
1518

16-
Here is how you can reuse a reusable block of ``.rst`` files across multiple pages:
1719

18-
.. include:: snippets/example-table.rst
20+
``diffpy.batchpdfsuite`` Interface
21+
----------------------------------
1922

20-
.. warning::
23+
Here is the main interface of ``diffpy.batchpdfsuite``.
2124

22-
Ensure that the ``.rst`` file you are including is not too long. If it is too long, it may be better to split it into multiple files and include them separately.
25+
.. image:: img/bpdfsuite_gui.png
26+
:width: 100%
27+
:align: center
2328

24-
Refer to a specific section in the documentation
25-
------------------------------------------------
29+
- *a* - **Settings**: To be implemented in the future for user settings.
30+
- *b* - **Log**: The panel containing the runtime output during the refinement process.
31+
- *c* - **Help**: To be implemented in the future for help and documentation.
32+
- *d* - **Experiment Data Panel**: The panel to load and display the loaded experiment data profile.
33+
- *e* - **Structure Data Panel**: The panel to load and display the structure file to be used for refinement.
34+
- *f* - **Control Panel**: The panel to control the refinement process.
35+
- *g* - **Task Panel**: The panel to view the status of the refinement tasks. Each task is created automatically when the corresponding experiment data is loaded.
36+
37+
38+
A Walkthrough Example
39+
----------------------
40+
41+
Download the example data from :download:`here <../examples/example.zip>`
42+
43+
1. Unzip the downloaded file.
44+
2. Launch the ``diffpy.batchpdfsuite`` GUI.
45+
46+
.. code-block:: bash
47+
48+
bpdfsuite
49+
50+
51+
3. Load the experiment data by clicking **Select Folder** in the **Experiment Data Panel** and choosing the ``data`` folder in the unzipped example data.
52+
53+
Besides the experiment data profile, the refinement tasks will also be generated automatically.
54+
55+
56+
.. image:: img/bpdfsuite_gui_folder_selected.png
57+
:width: 100%
58+
:align: center
2659

27-
You can use the ``ref`` tag to refer to a specific section in the documentation. For example, you can refer to the section below using the ``:ref:`` tag as shown :ref:`here <attach-image>`.
2860

2961
.. note::
3062

31-
Please check the raw ``.rst`` file of this page to see the exact use of the ``:ref:`` tag.
63+
The **Watch** option allows ``diffpy.batchpdfsuite`` to monitor the
64+
selected folder in real time and create new refinement tasks automatically
65+
when new experiment data is added to the folder. For simplicity, we will
66+
not use this option in this tutorial.
3267

33-
Embed your code snippets in the documentation
34-
---------------------------------------------
68+
4. Load the structure file by clicking **Select File** in the **Structure Data Panel** and choosing ``refinement/Ni.cif``
3569

36-
Here is how you can write a block of code in the documentation. You can use the ``code-block`` directive to write a block of code in the documentation. For example, you can write a block of code as shown below:
70+
To load the structure file, you need to set the name for the structure file to be
71+
referenced in the refinement process and then click **Add File**. You can also
72+
accepts the default name and click **Add File** directly.
3773

38-
.. code-block:: bash
74+
5. Load the refinement settings. You can either
75+
- Set **Type** to be ``Code`` and load the file ``refinement/template_2.py``. Or
76+
- Set **Type** to be ``Macro`` and load the file ``refinement/single-phase.dp-in``
77+
78+
.. note::
79+
80+
To learn how to write the Python script for ``diffpy.batchpdfsuite``, please
81+
find the available parameters during the refinement process in the ``refinement/template_2.py``
82+
file, and write the script according to your needs.
3983

40-
# Create a new environment, without build dependencies (pure Python package)
41-
conda create -n <package_name>-env python=3.14 \
42-
--file requirements/tests.txt \
43-
--file requirements/conda.txt
84+
To learn how to write the Diffpy macro file for ``diffpy.batchpdfsuite``, please
85+
refer to the ``diffpy.apps``
86+
`documentation <https://www.diffpy.org/diffpy.apps/getting-started.html#how-to-write-macro>`_
4487

45-
# Create a new environment, with build dependencies (non-pure Python package)
46-
conda create -n <package_name>-env python=3.14 \
47-
--file requirements/tests.txt \
48-
--file requirements/conda.txt \
49-
--file requirements/build.txt
5088

51-
# Activate the environment
52-
conda activate <package_name>_env
89+
5. Check the ``Sequential`` option in the **Control Panel**.
5390

54-
# Install your package locally
55-
# `--no-deps` to NOT install packages again from `requirements.pip.txt`
56-
pip install -e . --no-deps
91+
.. note::
5792

58-
# Run pytest locally
59-
pytest
93+
The ``Sequential`` option allows the parameters in the following tasks to take
94+
their previous task's refined values as their initial values.
95+
96+
97+
6. Set the sorting regex to be ``(\d+)(?=K)`` and click **Apply** in the **Task Panel**.
98+
99+
Sequential refinement requires the tasks to be sorted in a specific order, i.e. for
100+
temperature-dependent refinement, the tasks should be sorted in ascending/descending order of temperature.
101+
102+
.. note::
60103

61-
# ... run example tutorials
104+
The sorting regex ``(\d+)(?=K)`` is used to extract the temperature value
105+
from the experiment data file name. ``\d`` means any numeric digit,
106+
and ``+`` means the previous character, ``\d`` in this case, should be repeated one or more times.
107+
The ``(?=K)`` ensures that the previous matched group, ``(\d+)`` in this case,
108+
must be followed by the character ``K``.
62109

63-
.. _attach-image:
110+
To learn more about regex, please refer to the `Python regex documentation <https://docs.python.org/3/library/re.html>`_
64111

65-
Attach an image to the documentation
66-
------------------------------------
67112

68-
Here is how you attach an image to the documentation. The ``/docs/source/img/scikit-package-logo-text.png`` example image is provided in the template.
113+
7. Select the tasks you want to begin the process and click **Start** in the **Control Panel**.
69114

70-
.. image:: ./img/scikit-package-logo-text.png
71-
:alt: codecov-in-pr-comment
72-
:width: 400px
73-
:align: center
115+
.. image:: img/bpdfsuite_gui_before_start.png
116+
:width: 100%
117+
:align: center
74118

119+
8. Click the **Log** Icon to view the runtime output during the refinement process.
75120

76-
Other useful directives
77-
-----------------------
121+
9. Double click the finished tasks in the **Task Panel** to view the refined results.
78122

79-
Here is how you can do menu selection :menuselection:`Admin --> Settings` and display labels for buttons like :guilabel:`Privacy level`.
123+
10. (Optional) Click **Save to** in the **Task Panel** to save the result in another place. By default, they are
124+
stored in ``fit_results`` under the experiment data folder.

docs/source/img/.placeholder

Whitespace-only changes.

docs/source/img/bpdfsuite_gui.png

74.8 KB
Loading
279 KB
Loading
55.8 KB
Loading

0 commit comments

Comments
 (0)