Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/check-news-item.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Check for News
on:
pull_request_target:
branches:
- main # GitHub does not evaluate expressions in trigger filters; edit this value if your base branch is not main
- main # GitHub does not evaluate expressions in trigger filters; edit this value if your base branch is not main

jobs:
check-news-item:
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/tests-on-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ jobs:
project: diffpy.cmirietveld
c_extension: false
headless: false
run: python -m pip install git+https://github.com/diffpy/pyobjcryst.git@d6a1279a26b9b1e6e303d103935b4469c5a62e41 --no-deps
run: |
python -m pip install git+https://github.com/diffpy/pyobjcryst.git@main --no-deps
python -m pip install diffpy.cmistructure --no-deps
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
2 changes: 1 addition & 1 deletion cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"project_short_description": "A pack for diffpy.cmi that allows it to do Rietveld refinement of powder diffraction data",
"project_keywords": "diffraction, PDF, X-ray, neutron, Rietveld",
"minimum_supported_python_version": "3.12",
"maximum_supported_python_version": "3.14",
"maximum_supported_python_version": "3.13",
"project_needs_c_code_compiled": "No",
"project_has_gui_tests": "No"
}
4 changes: 2 additions & 2 deletions docs/source/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ Here is how you can write a block of code in the documentation. You can use the
.. code-block:: bash

# Create a new environment, without build dependencies (pure Python package)
conda create -n <package_name>-env python=3.14 \
conda create -n <package_name>-env python=3.13 \
--file requirements/tests.txt \
--file requirements/conda.txt

# Create a new environment, with build dependencies (non-pure Python package)
conda create -n <package_name>-env python=3.14 \
conda create -n <package_name>-env python=3.13 \
--file requirements/tests.txt \
--file requirements/conda.txt \
--file requirements/build.txt
Expand Down
26 changes: 26 additions & 0 deletions news/powder-diffraction-generator.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
**Added:**

* Add ``PowderDiffractionGenerator``, which calculates one phase's Bragg intensity with pyobjcryst from a structure set with ``set_structure`` (a pyobjcryst ``Crystal``, the path to a CIF file or a ParameterSet), a peak profile set with ``set_peak_profile`` and an instrument set with ``set_instrument``, and a refinable ``scale``. It has no default peak profile or instrument, so all three must be set before a pattern is calculated.
* Add ``PowderDiffractionGenerator.print_info``, which prints the generator's structure, instrument and peak profile with their settings and Parameter values.
* Add ``Component.get_settings``, which returns a component's settings for showing to a user, and its ``ConstantWavelengthInstrument`` version, which lists the radiation type, the x-ray source or Kalpha1/Kalpha2 wavelengths, and the polarization rate.
* Warn when ``set_structure``, ``set_peak_profile`` or ``set_instrument`` replaces a structure or component whose Parameters are used in a fit recipe.

**Changed:**

* <news item>

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* <news item>

**Security:**

* <news item>
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ maintainers = [
description = "A pack for diffpy.cmi that allows it to do Rietveld refinement of powder diffraction data"
keywords = ['diffraction', 'PDF', 'X-ray', 'neutron', 'Rietveld']
readme = "README.rst"
requires-python = ">=3.12, <3.15"
requires-python = ">=3.12, <3.14"
classifiers = [
'Development Status :: 5 - Production/Stable',
'Environment :: Console',
Expand All @@ -29,7 +29,6 @@ classifiers = [
'Operating System :: Unix',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: 3.13',
'Programming Language :: Python :: 3.14',
'Topic :: Scientific/Engineering :: Physics',
'Topic :: Scientific/Engineering :: Chemistry',
]
Expand Down
1 change: 1 addition & 0 deletions requirements/pip.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
numpy
diffpy.srfit
diffpy.cmistructure
pyobjcryst
6 changes: 4 additions & 2 deletions src/diffpy/cmirietveld/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@
# (c) 2026 diffpy.cmirietveld contributors.
# All rights reserved.
#
# File coded by: Caden Myers, members of the Billinge group, and contributors to the diffpy.cmirietveld project.
# File coded by: Caden Myers, members of the Billinge group, and
# contributors to the diffpy.cmirietveld project.
#
# See GitHub contributions for a more detailed list of contributors.
# https://github.com/diffpy/diffpy.cmirietveld/graphs/contributors
#
# See LICENSE.rst for license information.
#
##############################################################################
"""A pack for diffpy.cmi that allows it to do Rietveld refinement of powder diffraction data"""
"""A pack for diffpy.cmi that allows it to do Rietveld refinement of
powder diffraction data."""

# package version
from diffpy.cmirietveld.version import __version__ # noqa
Expand Down
17 changes: 17 additions & 0 deletions src/diffpy/cmirietveld/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,23 @@ def mark_settings_changed(self):
self._settings_version += 1
self._flush(other=(self,))

def get_settings(self):
"""Return the settings of the component, for showing to a user.

A generator's ``print_info`` shows them next to the Parameters.
A component with settings overrides this to list the settings in
use, each under the name of the setter argument that sets it, so
a user sees what to pass to change it.

Returns
-------
dict of str to object
The value of each setting in use, by name. It is empty for a
component without settings.
"""
settings = {}
return settings

def install(self, pattern, diffraction):
"""Set the model up in one generator.

Expand Down
27 changes: 27 additions & 0 deletions src/diffpy/cmirietveld/instruments.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,33 @@ def set_polarization(self, polarization_rate):
self._polarization_rate = polarization_rate
self.mark_settings_changed()

def get_settings(self):
"""Return the settings in use, for showing to a user.

The radiation type and the polarization rate are always listed.
A tube adds ``xray_source`` and ``kalpha2_ratio``, and explicit
wavelengths add ``kalpha1``, ``kalpha2`` and ``kalpha2_ratio``.
A single wavelength adds nothing, since it is the ``wavelength``
Parameter.

Returns
-------
dict of str to object
The value of each setting in use, by the name of the setter
argument that sets it.
"""
settings = {"radiation_type": self._radiation_type}
if self._xray_source is not None:
settings["xray_source"] = self._xray_source
settings["kalpha2_ratio"] = self._kalpha2_ratio
elif self._kalpha_wavelengths is not None:
kalpha1, kalpha2 = self._kalpha_wavelengths
settings["kalpha1"] = kalpha1
settings["kalpha2"] = kalpha2
settings["kalpha2_ratio"] = self._kalpha2_ratio
settings["polarization_rate"] = self._polarization_rate
return settings

def install(self, pattern, diffraction):
"""Set the radiation, wavelengths and polarization of one
generator.
Expand Down
Loading
Loading