Skip to content

Commit ed5b173

Browse files
committed
rm PDF generator functions, will put on another PR
1 parent 852ae74 commit ed5b173

3 files changed

Lines changed: 10 additions & 195 deletions

File tree

.pre-commit-config.yaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ci:
1111
submodules: false
1212
repos:
1313
- repo: https://github.com/pre-commit/pre-commit-hooks
14-
rev: v4.6.0
14+
rev: v6.0.0
1515
hooks:
1616
- id: check-yaml
1717
- id: end-of-file-fixer
@@ -21,45 +21,45 @@ repos:
2121
- id: check-toml
2222
- id: check-added-large-files
2323
- repo: https://github.com/psf/black
24-
rev: 24.4.2
24+
rev: 26.3.1
2525
hooks:
2626
- id: black
2727
- repo: https://github.com/pycqa/flake8
28-
rev: 7.0.0
28+
rev: 7.3.0
2929
hooks:
3030
- id: flake8
3131
- repo: https://github.com/pycqa/isort
32-
rev: 5.13.2
32+
rev: 8.0.1
3333
hooks:
3434
- id: isort
3535
args: ["--profile", "black"]
3636
- repo: https://github.com/kynan/nbstripout
37-
rev: 0.7.1
37+
rev: 0.9.1
3838
hooks:
3939
- id: nbstripout
4040
- repo: https://github.com/pre-commit/pre-commit-hooks
41-
rev: v4.4.0
41+
rev: v6.0.0
4242
hooks:
4343
- id: no-commit-to-branch
4444
name: Prevent Commit to Main Branch
4545
args: ["--branch", "main"]
4646
stages: [pre-commit]
4747
- repo: https://github.com/codespell-project/codespell
48-
rev: v2.3.0
48+
rev: v2.4.2
4949
hooks:
5050
- id: codespell
5151
additional_dependencies:
5252
- tomli
5353
# prettier - multi formatter for .json, .yml, and .md files
5454
- repo: https://github.com/pre-commit/mirrors-prettier
55-
rev: f12edd9c7be1c20cfa42420fd0e6df71e42b51ea # frozen: v4.0.0-alpha.8
55+
rev: v4.0.0-alpha.8
5656
hooks:
5757
- id: prettier
5858
additional_dependencies:
5959
- "prettier@^3.2.4"
6060
# docformatter - PEP 257 compliant docstring formatter
61-
- repo: https://github.com/s-weigand/docformatter
62-
rev: 5757c5190d95e5449f102ace83df92e7d3b06c6c
61+
- repo: https://github.com/PyCQA/docformatter
62+
rev: v1.7.7
6363
hooks:
6464
- id: docformatter
6565
additional_dependencies: [tomli]

src/diffpy/cmipdf/debyepdfgenerator.py

Lines changed: 0 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,9 @@
2323

2424
__all__ = ["DebyePDFGenerator"]
2525

26-
from pathlib import Path
2726

2827
from diffpy.cmipdf.basepdfgenerator import BasePDFGenerator
2928
from diffpy.srreal.pdfcalculator import DebyePDFCalculator
30-
from diffpy.structure import loadStructure
3129

3230

3331
class DebyePDFGenerator(BasePDFGenerator):
@@ -144,98 +142,6 @@ def __init__(self, name="pdf"):
144142
self._set_calculator(DebyePDFCalculator())
145143
return
146144

147-
def generate_pdf_from_structure(
148-
self,
149-
structure,
150-
rmin=0,
151-
rmax=30,
152-
qmin=0.1,
153-
qmax=25.0,
154-
qdamp=0.03,
155-
qbroad=0.0,
156-
delta1=0.0,
157-
delta2=0.0,
158-
uiso=0.007,
159-
):
160-
"""Calculate the PDF from a structure and return G vs. r.
161-
162-
This is a convenience method that allows the user to calculate
163-
the PDF from a
164-
structure without having to set up the calculator and
165-
structure ParameterSet
166-
manually. The structure can be passed as a path to a
167-
structure file or as a
168-
`diffpy.structure.Structure` object.
169-
170-
Parameters
171-
----------
172-
structure : Path, str, or diffpy.structure.Structure
173-
The structure to calculate the PDF from. Can be a path
174-
to a structure file or a diffpy.structure.Structure
175-
object.
176-
rmin : float, optional
177-
The minimum r value in Angstroms for the PDF (default 0).
178-
rmax : float, optional
179-
The maximum r value in Angstroms for the PDF (default 30).
180-
qmin : float, optional
181-
The minimum scattering vector used to generate the PDF
182-
(default 0.1).
183-
qmax : float, optional
184-
The maximum scattering vector used to generate the PDF
185-
(default 25.0).
186-
uiso : float, optional
187-
The isotropic atomic displacement parameter to use for all
188-
atoms in the structure (default 0.007).
189-
qdamp : float, optional
190-
The resolution dampening term to use in the PDF calculation
191-
(default 0.03).
192-
qbroad : float, optional
193-
The resolution broadening term to use in the PDF calculation
194-
(default 0.0).
195-
delta1 : float, optional
196-
The linear peak broadening term to use in the PDF calculation
197-
(default 0.0).
198-
delta2 : float, optional
199-
The quadratic peak broadening term to use in the PDF calculation
200-
(default 0.0).
201-
uiso : float, optional
202-
The isotropic atomic displacement parameter to use for all
203-
atoms in the structure (default 0.007).
204-
205-
Returns
206-
-------
207-
r : numpy.ndarray
208-
The r values for the PDF in units of Angstroms.
209-
G : numpy.ndarray
210-
The G values for the PDF in units of 1/Angstrom^2.
211-
212-
Example
213-
-------
214-
.. code-block:: python
215-
xyz_path = "path/to/nanoparticle.xyz"
216-
gen = PDFGenerator()
217-
r, g = gen.generate_pdf_from_structure(xyz_path)
218-
"""
219-
if isinstance(structure, Path):
220-
structure = loadStructure(str(structure))
221-
elif isinstance(structure, str):
222-
structure = loadStructure(structure)
223-
structure.Uisoequiv = uiso
224-
225-
calc = DebyePDFCalculator()
226-
calc.qmin = qmin
227-
calc.qmax = qmax
228-
calc.rstep = 0.01
229-
calc.rmin = rmin
230-
calc.rmax = rmax
231-
calc.qdamp = qdamp
232-
calc.qbroad = qbroad
233-
calc.delta1 = delta1
234-
calc.delta2 = delta2
235-
236-
r, g = calc(structure)
237-
return r, g
238-
239145

240146
# End class DebyePDFGenerator
241147

src/diffpy/cmipdf/pdfgenerator.py

Lines changed: 0 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,9 @@
2525

2626
__all__ = ["PDFGenerator"]
2727

28-
from pathlib import Path
2928

3029
from diffpy.cmipdf.basepdfgenerator import BasePDFGenerator
3130
from diffpy.srreal.pdfcalculator import PDFCalculator
32-
from diffpy.structure import loadStructure
3331

3432

3533
class PDFGenerator(BasePDFGenerator):
@@ -94,94 +92,5 @@ def __init__(self, name="pdf"):
9492
self._set_calculator(PDFCalculator())
9593
return
9694

97-
def generate_pdf_from_structure(
98-
self,
99-
structure,
100-
rmin=0,
101-
rmax=30,
102-
qmin=0.1,
103-
qmax=25.0,
104-
qdamp=0.03,
105-
qbroad=0.0,
106-
delta1=0.0,
107-
delta2=0.0,
108-
uiso=0.007,
109-
):
110-
"""Calculate the PDF from a structure and return G vs. r.
111-
112-
This is a convenience method that allows the user to calculate
113-
the PDF from a
114-
structure without having to set up the calculator and
115-
structure ParameterSet
116-
manually. The structure can be passed as a path to a
117-
structure file or as a
118-
`diffpy.structure.Structure` object.
119-
120-
Parameters
121-
----------
122-
structure : Path, str, or diffpy.structure.Structure
123-
The structure to calculate the PDF from. Can be a path
124-
to a structure file or a diffpy.structure.Structure
125-
object.
126-
rmin : float, optional
127-
The minimum r value in Angstroms for the PDF (default 0).
128-
rmax : float, optional
129-
The maximum r value in Angstroms for the PDF (default 30).
130-
qmin : float, optional
131-
The minimum scattering vector used to generate the PDF
132-
(default 0.1).
133-
qmax : float, optional
134-
The maximum scattering vector used to generate the PDF
135-
(default 25.0).
136-
qdamp : float, optional
137-
The resolution dampening term to use in the PDF calculation
138-
(default 0.03).
139-
qbroad : float, optional
140-
The resolution broadening term to use in the PDF calculation
141-
(default 0.0).
142-
delta1 : float, optional
143-
The linear peak broadening term to use in the PDF calculation
144-
(default 0.0).
145-
delta2 : float, optional
146-
The quadratic peak broadening term to use in the PDF calculation
147-
(default 0.0).
148-
uiso : float, optional
149-
The isotropic atomic displacement parameter to use for all
150-
atoms in the structure (default 0.007).
151-
152-
Returns
153-
-------
154-
r : numpy.ndarray
155-
The r values for the PDF in units of Angstroms.
156-
G : numpy.ndarray
157-
The G values for the PDF in units of 1/Angstrom^2.
158-
159-
Example
160-
-------
161-
.. code-block:: python
162-
cif_path = "path/to/ni.cif"
163-
gen = PDFGenerator()
164-
r, g = gen.generate_pdf_from_structure(cifpath)
165-
"""
166-
if isinstance(structure, Path):
167-
structure = loadStructure(str(structure))
168-
elif isinstance(structure, str):
169-
structure = loadStructure(structure)
170-
structure.Uisoequiv = uiso
171-
172-
calc = PDFCalculator()
173-
calc.qmin = qmin
174-
calc.qmax = qmax
175-
calc.rstep = 0.01
176-
calc.rmin = rmin
177-
calc.rmax = rmax
178-
calc.qdamp = qdamp
179-
calc.qbroad = qbroad
180-
calc.delta1 = delta1
181-
calc.delta2 = delta2
182-
183-
r, g = calc(structure)
184-
return r, g
185-
18695

18796
# End class PDFGenerator

0 commit comments

Comments
 (0)