pdfanalysis 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Nicolas Ratel-Ramond
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,282 @@
1
+ Metadata-Version: 2.4
2
+ Name: pdfanalysis
3
+ Version: 0.1.0
4
+ Summary: Automated PDF structure analysis for nanoparticles
5
+ Home-page: https://github.com/nicoratel/pdfanalysis
6
+ Author: Nicolas Ratel-Ramond
7
+ Author-email: Nicolas Ratel-Ramond <nicolas.ratel-ramond@insa-toulouse.fr>
8
+ License: MIT
9
+ Project-URL: Homepage, https://github.com/nicoratel/pdfanalysis
10
+ Project-URL: Repository, https://github.com/nicoratel/pdfanalysis.git
11
+ Project-URL: Bug Tracker, https://github.com/nicoratel/pdfanalysis/issues
12
+ Keywords: PDF,pair distribution function,nanoparticles,structure analysis,crystallography
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: Topic :: Scientific/Engineering :: Chemistry
16
+ Classifier: Topic :: Scientific/Engineering :: Physics
17
+ Classifier: License :: OSI Approved :: MIT License
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.8
20
+ Classifier: Programming Language :: Python :: 3.9
21
+ Classifier: Programming Language :: Python :: 3.10
22
+ Classifier: Programming Language :: Python :: 3.11
23
+ Requires-Python: >=3.8
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: numpy>=1.20.0
27
+ Requires-Dist: scipy>=1.7.0
28
+ Requires-Dist: matplotlib>=3.3.0
29
+ Requires-Dist: ase>=3.22.0
30
+ Requires-Dist: diffpy-cmi>=3.0.0
31
+ Requires-Dist: tqdm>=4.60.0
32
+ Requires-Dist: psutil>=5.8.0
33
+ Provides-Extra: app
34
+ Requires-Dist: streamlit>=1.20.0; extra == "app"
35
+ Requires-Dist: plotly>=5.0.0; extra == "app"
36
+ Provides-Extra: notebook
37
+ Requires-Dist: ipython>=7.0.0; extra == "notebook"
38
+ Requires-Dist: jupyter>=1.0.0; extra == "notebook"
39
+ Requires-Dist: py3Dmol>=2.0.0; extra == "notebook"
40
+ Provides-Extra: dev
41
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
42
+ Requires-Dist: pytest-cov>=3.0.0; extra == "dev"
43
+ Requires-Dist: black>=22.0.0; extra == "dev"
44
+ Requires-Dist: flake8>=4.0.0; extra == "dev"
45
+ Requires-Dist: mypy>=0.950; extra == "dev"
46
+ Provides-Extra: all
47
+ Requires-Dist: streamlit>=1.20.0; extra == "all"
48
+ Requires-Dist: plotly>=5.0.0; extra == "all"
49
+ Requires-Dist: ipython>=7.0.0; extra == "all"
50
+ Requires-Dist: jupyter>=1.0.0; extra == "all"
51
+ Requires-Dist: py3Dmol>=2.0.0; extra == "all"
52
+ Requires-Dist: pytest>=7.0.0; extra == "all"
53
+ Requires-Dist: pytest-cov>=3.0.0; extra == "all"
54
+ Requires-Dist: black>=22.0.0; extra == "all"
55
+ Requires-Dist: flake8>=4.0.0; extra == "all"
56
+ Requires-Dist: mypy>=0.950; extra == "all"
57
+ Dynamic: author
58
+ Dynamic: home-page
59
+ Dynamic: license-file
60
+ Dynamic: requires-python
61
+
62
+ # PDFanalysis
63
+
64
+ Automated PDF (Pair Distribution Function) structure analysis for small metallic nanoparticles.
65
+
66
+ ## Description
67
+
68
+ PDFanalysis is a comprehensive Python package for analyzing nanoparticle structures using pair distribution function (PDF) analysis. It provides tools for:
69
+
70
+ - **PDF extraction** from experimental data
71
+ - **Structure generation** (icosahedra, decahedra, octahedra, spheres)
72
+ - **Structure customization** (zoomscale, element substitution)
73
+ - **PDF refinement** using diffpy.srfit
74
+ - **Structure screening** against experimental PDFs
75
+ - **Report generation** with detailed analysis results
76
+
77
+ The recommended workflow for a single pdf is the following:
78
+ - **Estimation of particle size** from experimental pdf data. Determines the r value at which the pdf signal is dominated by noise
79
+ - **Structure generation**: icosahedra, octahedra, spheres and decahedra are generated with the size determined above (or specified by the user)
80
+ - **Fast structure screening**: each structure is roughly refined against experimental data. Best results within a given confidence interval are considered for the fine refinement
81
+ - **Fine strucutre screening**: structures who have passed the first refinement cycle are refined against experimental pdf.
82
+
83
+
84
+ ## Installation
85
+
86
+ ### Install from PyPI (recommended)
87
+
88
+ ```bash
89
+ pip install pdfanalysis
90
+ ```
91
+
92
+ ### Install with optional dependencies
93
+
94
+ ```bash
95
+ # For Streamlit web app
96
+ pip install pdfanalysis[app]
97
+
98
+ # For Jupyter notebooks
99
+ pip install pdfanalysis[notebook]
100
+
101
+ # For development tools
102
+ pip install pdfanalysis[dev]
103
+
104
+ # Install everything
105
+ pip install pdfanalysis[all]
106
+ ```
107
+
108
+ ### Install from source
109
+
110
+ ```bash
111
+ git clone https://github.com/nicoratel/pdfanalysis.git
112
+ cd pdfanalysis
113
+ pip install .
114
+ ```
115
+
116
+ ### Development installation (editable mode)
117
+
118
+ ```bash
119
+ git clone https://github.com/nicoratel/pdfanalysis.git
120
+ cd pdfanalysis
121
+ pip install -e .
122
+ ```
123
+
124
+ ## Dependencies
125
+
126
+ ### Core dependencies
127
+ - `numpy` - Numerical computations
128
+ - `scipy` - Scientific computing and optimization
129
+ - `matplotlib` - Plotting and visualization
130
+ - `ase` - Atomic Simulation Environment
131
+ - `diffpy-cmi` - DiffPy suite (structure manipulation + PDF refinement)
132
+ - `tqdm` - Progress bars
133
+ - `psutil` - CPU/memory management
134
+
135
+ ### Optional dependencies
136
+ - `streamlit` - Web application framework
137
+ - `plotly` - Interactive plots
138
+ - `ipython` - Enhanced Python shell
139
+ - `jupyter` - Notebook interface
140
+ - `py3Dmol` - 3D molecular visualization
141
+
142
+ ## Quick Start
143
+
144
+ ### Using the main analysis function
145
+
146
+ ```python
147
+ from pdfanalysis import perform_automatic_pdf_analysis
148
+
149
+ results = perform_automatic_pdf_analysis(
150
+ pdf_file="path/to/data.gr",
151
+ cif_file="path/to/structure.cif",
152
+ r_coh=30.0, # Coherence length in Angstroms
153
+ tolerance_size_structure=3.0,
154
+ n_spheres=2
155
+ )
156
+ ```
157
+
158
+ ### Using individual classes
159
+
160
+ ```python
161
+ from pdfanalysis import (
162
+ PDFExtractor,
163
+ StructureGenerator,
164
+ PDFRefinement,
165
+ StructureScreener
166
+ )
167
+
168
+ # Generate structures
169
+ generator = StructureGenerator(
170
+ pdfpath="output_dir",
171
+ cif_file="structure.cif",
172
+ auto_mode=True,
173
+ pdf_file="data.gr"
174
+ )
175
+ strufile_dir = generator.run()
176
+
177
+ # Screen structures
178
+ screener = StructureScreener(
179
+ strufile_dir=strufile_dir,
180
+ pdffile_dir="pdf_directory",
181
+ fast_screening=True
182
+ )
183
+ best_results, candidates = screener.run()
184
+
185
+ # Refine best structure
186
+ refinement = PDFRefinement(
187
+ pdffile="data.gr",
188
+ strufile=best_results["data.gr"]["strufile"],
189
+ save_tag=True
190
+ )
191
+ rw = refinement.refine()
192
+ ```
193
+
194
+ ### Running the Streamlit app
195
+
196
+ After installing with the `app` extras:
197
+
198
+ ```bash
199
+ streamlit run app_pdf_analysis.py
200
+ ```
201
+
202
+ ## Package Structure
203
+
204
+ ```
205
+ app_pdf_analysis.py # Streamlit web interface
206
+ pdfanalysis/
207
+ ├── __init__.py # Package initialization
208
+ ├── pdf_extractor.py # PDF extraction from experimental data
209
+ ├── structure_generator.py # Nanoparticle structure generation
210
+ ├── structure_custom.py # Structure transformation
211
+ ├── structure_report_generator.py # PDF report generation
212
+ ├── pdf_refinement.py # Full PDF refinement
213
+ ├── pdf_refinement_fast.py # Fast refinement for screening
214
+ ├── structure_screener.py # Structure screening
215
+ ├── pdfanalysis.py # Main analysis workflow
216
+ ```
217
+
218
+ ## Features
219
+
220
+ ### Automatic Structure Generation
221
+ - Auto-detection of coherence length from PDF
222
+ - Multiple structure types: icosahedra, decahedra, octahedra, spheres
223
+ - Parallel processing for fast generation
224
+ - Automatic filtering based on size range
225
+
226
+ ### Fast Screening
227
+ - Two-pass screening: fast initial screening + full refinement
228
+ - Automatic candidate selection (min(Rw) ± threshold%)
229
+ - Progress tracking with tqdm
230
+ - Multiprocessing support
231
+
232
+ ### Comprehensive Reports
233
+ - PDF reports with fit curves, structure thumbnails
234
+ - Top N results tables
235
+ - 3D structure visualizations
236
+ - Complete refinement statistics
237
+
238
+ ## Examples
239
+
240
+ See the `examples/` directory for Jupyter notebooks demonstrating:
241
+ - Basic PDF analysis workflow
242
+ - Custom structure generation
243
+ - Advanced refinement options
244
+ - Batch processing
245
+
246
+ ## Citation
247
+
248
+ If you use this package in your research, please cite:
249
+
250
+ ```
251
+ @software{pdfanalysis,
252
+ author = {Ratel-Ramond, Nicolas},
253
+ title = {PDFanalysis: Automated PDF structure analysis for nanoparticles},
254
+ year = {2026},
255
+ url = {https://github.com/nicoratel/pdfanalysis}
256
+ }
257
+ ```
258
+
259
+ ## License
260
+
261
+ MIT License - see LICENSE file for details
262
+
263
+ ## Contributing
264
+
265
+ Contributions are welcome! Please:
266
+ 1. Fork the repository
267
+ 2. Create a feature branch
268
+ 3. Make your changes
269
+ 4. Add tests if applicable
270
+ 5. Submit a pull request
271
+
272
+ ## Support
273
+
274
+ For bugs and feature requests, please open an issue on GitHub:
275
+ https://github.com/nicoratel/pdfanalysis/issues
276
+
277
+ ## Acknowledgments
278
+
279
+ This package uses:
280
+ - DiffPy-CMI for PDF refinement
281
+ - ASE for structure manipulation
282
+ - The Scientific Python ecosystem (NumPy, SciPy, Matplotlib)
@@ -0,0 +1,221 @@
1
+ # PDFanalysis
2
+
3
+ Automated PDF (Pair Distribution Function) structure analysis for small metallic nanoparticles.
4
+
5
+ ## Description
6
+
7
+ PDFanalysis is a comprehensive Python package for analyzing nanoparticle structures using pair distribution function (PDF) analysis. It provides tools for:
8
+
9
+ - **PDF extraction** from experimental data
10
+ - **Structure generation** (icosahedra, decahedra, octahedra, spheres)
11
+ - **Structure customization** (zoomscale, element substitution)
12
+ - **PDF refinement** using diffpy.srfit
13
+ - **Structure screening** against experimental PDFs
14
+ - **Report generation** with detailed analysis results
15
+
16
+ The recommended workflow for a single pdf is the following:
17
+ - **Estimation of particle size** from experimental pdf data. Determines the r value at which the pdf signal is dominated by noise
18
+ - **Structure generation**: icosahedra, octahedra, spheres and decahedra are generated with the size determined above (or specified by the user)
19
+ - **Fast structure screening**: each structure is roughly refined against experimental data. Best results within a given confidence interval are considered for the fine refinement
20
+ - **Fine strucutre screening**: structures who have passed the first refinement cycle are refined against experimental pdf.
21
+
22
+
23
+ ## Installation
24
+
25
+ ### Install from PyPI (recommended)
26
+
27
+ ```bash
28
+ pip install pdfanalysis
29
+ ```
30
+
31
+ ### Install with optional dependencies
32
+
33
+ ```bash
34
+ # For Streamlit web app
35
+ pip install pdfanalysis[app]
36
+
37
+ # For Jupyter notebooks
38
+ pip install pdfanalysis[notebook]
39
+
40
+ # For development tools
41
+ pip install pdfanalysis[dev]
42
+
43
+ # Install everything
44
+ pip install pdfanalysis[all]
45
+ ```
46
+
47
+ ### Install from source
48
+
49
+ ```bash
50
+ git clone https://github.com/nicoratel/pdfanalysis.git
51
+ cd pdfanalysis
52
+ pip install .
53
+ ```
54
+
55
+ ### Development installation (editable mode)
56
+
57
+ ```bash
58
+ git clone https://github.com/nicoratel/pdfanalysis.git
59
+ cd pdfanalysis
60
+ pip install -e .
61
+ ```
62
+
63
+ ## Dependencies
64
+
65
+ ### Core dependencies
66
+ - `numpy` - Numerical computations
67
+ - `scipy` - Scientific computing and optimization
68
+ - `matplotlib` - Plotting and visualization
69
+ - `ase` - Atomic Simulation Environment
70
+ - `diffpy-cmi` - DiffPy suite (structure manipulation + PDF refinement)
71
+ - `tqdm` - Progress bars
72
+ - `psutil` - CPU/memory management
73
+
74
+ ### Optional dependencies
75
+ - `streamlit` - Web application framework
76
+ - `plotly` - Interactive plots
77
+ - `ipython` - Enhanced Python shell
78
+ - `jupyter` - Notebook interface
79
+ - `py3Dmol` - 3D molecular visualization
80
+
81
+ ## Quick Start
82
+
83
+ ### Using the main analysis function
84
+
85
+ ```python
86
+ from pdfanalysis import perform_automatic_pdf_analysis
87
+
88
+ results = perform_automatic_pdf_analysis(
89
+ pdf_file="path/to/data.gr",
90
+ cif_file="path/to/structure.cif",
91
+ r_coh=30.0, # Coherence length in Angstroms
92
+ tolerance_size_structure=3.0,
93
+ n_spheres=2
94
+ )
95
+ ```
96
+
97
+ ### Using individual classes
98
+
99
+ ```python
100
+ from pdfanalysis import (
101
+ PDFExtractor,
102
+ StructureGenerator,
103
+ PDFRefinement,
104
+ StructureScreener
105
+ )
106
+
107
+ # Generate structures
108
+ generator = StructureGenerator(
109
+ pdfpath="output_dir",
110
+ cif_file="structure.cif",
111
+ auto_mode=True,
112
+ pdf_file="data.gr"
113
+ )
114
+ strufile_dir = generator.run()
115
+
116
+ # Screen structures
117
+ screener = StructureScreener(
118
+ strufile_dir=strufile_dir,
119
+ pdffile_dir="pdf_directory",
120
+ fast_screening=True
121
+ )
122
+ best_results, candidates = screener.run()
123
+
124
+ # Refine best structure
125
+ refinement = PDFRefinement(
126
+ pdffile="data.gr",
127
+ strufile=best_results["data.gr"]["strufile"],
128
+ save_tag=True
129
+ )
130
+ rw = refinement.refine()
131
+ ```
132
+
133
+ ### Running the Streamlit app
134
+
135
+ After installing with the `app` extras:
136
+
137
+ ```bash
138
+ streamlit run app_pdf_analysis.py
139
+ ```
140
+
141
+ ## Package Structure
142
+
143
+ ```
144
+ app_pdf_analysis.py # Streamlit web interface
145
+ pdfanalysis/
146
+ ├── __init__.py # Package initialization
147
+ ├── pdf_extractor.py # PDF extraction from experimental data
148
+ ├── structure_generator.py # Nanoparticle structure generation
149
+ ├── structure_custom.py # Structure transformation
150
+ ├── structure_report_generator.py # PDF report generation
151
+ ├── pdf_refinement.py # Full PDF refinement
152
+ ├── pdf_refinement_fast.py # Fast refinement for screening
153
+ ├── structure_screener.py # Structure screening
154
+ ├── pdfanalysis.py # Main analysis workflow
155
+ ```
156
+
157
+ ## Features
158
+
159
+ ### Automatic Structure Generation
160
+ - Auto-detection of coherence length from PDF
161
+ - Multiple structure types: icosahedra, decahedra, octahedra, spheres
162
+ - Parallel processing for fast generation
163
+ - Automatic filtering based on size range
164
+
165
+ ### Fast Screening
166
+ - Two-pass screening: fast initial screening + full refinement
167
+ - Automatic candidate selection (min(Rw) ± threshold%)
168
+ - Progress tracking with tqdm
169
+ - Multiprocessing support
170
+
171
+ ### Comprehensive Reports
172
+ - PDF reports with fit curves, structure thumbnails
173
+ - Top N results tables
174
+ - 3D structure visualizations
175
+ - Complete refinement statistics
176
+
177
+ ## Examples
178
+
179
+ See the `examples/` directory for Jupyter notebooks demonstrating:
180
+ - Basic PDF analysis workflow
181
+ - Custom structure generation
182
+ - Advanced refinement options
183
+ - Batch processing
184
+
185
+ ## Citation
186
+
187
+ If you use this package in your research, please cite:
188
+
189
+ ```
190
+ @software{pdfanalysis,
191
+ author = {Ratel-Ramond, Nicolas},
192
+ title = {PDFanalysis: Automated PDF structure analysis for nanoparticles},
193
+ year = {2026},
194
+ url = {https://github.com/nicoratel/pdfanalysis}
195
+ }
196
+ ```
197
+
198
+ ## License
199
+
200
+ MIT License - see LICENSE file for details
201
+
202
+ ## Contributing
203
+
204
+ Contributions are welcome! Please:
205
+ 1. Fork the repository
206
+ 2. Create a feature branch
207
+ 3. Make your changes
208
+ 4. Add tests if applicable
209
+ 5. Submit a pull request
210
+
211
+ ## Support
212
+
213
+ For bugs and feature requests, please open an issue on GitHub:
214
+ https://github.com/nicoratel/pdfanalysis/issues
215
+
216
+ ## Acknowledgments
217
+
218
+ This package uses:
219
+ - DiffPy-CMI for PDF refinement
220
+ - ASE for structure manipulation
221
+ - The Scientific Python ecosystem (NumPy, SciPy, Matplotlib)
@@ -0,0 +1,33 @@
1
+ """
2
+ PDFanalysis package for automated PDF structure analysis.
3
+
4
+ This package provides tools for:
5
+ - PDF extraction from experimental data
6
+ - Structure generation (nanoparticles)
7
+ - Structure customization
8
+ - PDF refinement
9
+ - Structure screening
10
+ - Report generation
11
+ """
12
+
13
+ from .pdf_extractor import PDFExtractor
14
+ from .structure_generator import StructureGenerator
15
+ from .structure_custom import StructureCustom
16
+ from .structure_report_generator import StructureReportGenerator
17
+ from .pdf_refinement import PDFRefinement
18
+ from .pdf_refinement_fast import PDFRefinementFast
19
+ from .structure_screener import StructureScreener
20
+ from .pdfanalysis import perform_automatic_pdf_analysis
21
+
22
+ __all__ = [
23
+ 'PDFExtractor',
24
+ 'StructureGenerator',
25
+ 'StructureCustom',
26
+ 'StructureReportGenerator',
27
+ 'PDFRefinement',
28
+ 'PDFRefinementFast',
29
+ 'StructureScreener',
30
+ 'perform_automatic_pdf_analysis',
31
+ ]
32
+
33
+ __version__ = '1.0.0'
@@ -0,0 +1,106 @@
1
+ """
2
+ PDF Extractor module for extracting PDFs from experimental data.
3
+ """
4
+ import subprocess
5
+ import os
6
+ import numpy as np
7
+ from matplotlib import pyplot as plt
8
+
9
+
10
+ class PDFExtractor:
11
+ def __init__(self,
12
+ datafilelist,
13
+ composition,
14
+ qmin,
15
+ qmax,
16
+ qmaxinst,
17
+ wavelength=0.7107,
18
+ dataformat='QA',
19
+ rmin=0,
20
+ rmax=50,
21
+ rstep=0.01,
22
+ bgscale=1,
23
+ rpoly=0.9,
24
+ emptyfile=None):
25
+ self.datafilelist=datafilelist
26
+ self.emptyfile=emptyfile
27
+ self.composition=composition
28
+ self.qmin=qmin
29
+ self.qmax=qmax
30
+ self.qmaxinst=qmaxinst
31
+ self.wl=wavelength
32
+ self.dataformat=dataformat
33
+ self.rmin=rmin
34
+ self.rmax=rmax
35
+ self.rstep=rstep
36
+ self.bgscale=bgscale
37
+ self.rpoly=rpoly
38
+
39
+
40
+ def writecfg(self):
41
+ """
42
+ datafilelist: list of paths to data files from wich PDF should be extracted
43
+ """
44
+
45
+ self.datapath=os.path.dirname(self.datafilelist[0])
46
+ self.pdfpath=self.datapath+'/extracted_PDF'
47
+
48
+ os.makedirs(self.pdfpath,exist_ok=True)
49
+
50
+ cfg=open(self.pdfpath+'/pdfgetX3_GUI.cfg','w')
51
+ cfg.write('[DEFAULT] \n')
52
+ cfg.write('dataformat = %s' %self.dataformat +' \n')
53
+
54
+
55
+
56
+ cfg.write('inputfile='+''.join(os.path.basename(i) +'\n' +'\t'
57
+ for i in self.datafilelist[:-1]))
58
+ cfg.write('\t %s' %os.path.basename(self.datafilelist[-1])+'\n')
59
+ cfg.write('datapath = %s' % os.path.dirname(self.datafilelist[0])+'/' +'\n')
60
+ if self.emptyfile is not None:
61
+ cfg.write('\t %s' %os.path.dirname(self.emptyfile)+'\n')
62
+
63
+ cfg.write('bgscale=%f \n' %self.bgscale)
64
+ cfg.write('backgroundfile=%s' % os.path.basename(self.emptyfile)+'\n')
65
+
66
+
67
+ cfg.write('composition= %s \n'%str(self.composition))
68
+ cfg.write('qmin=%f \n' %self.qmin)
69
+ cfg.write('qmax=%f \n' %self.qmax)
70
+ cfg.write('qmaxinst=%f \n' %self.qmaxinst)
71
+ cfg.write('wavelength=%f \n' %self.wl)
72
+ cfg.write('mode = xray \n')
73
+ cfg.write('rpoly=%f \n' %self.rpoly)
74
+ cfg.write('rmin=%f \n' %self.rmin)
75
+ cfg.write('rstep=%f \n' %self.rstep)
76
+ cfg.write('rmax=%f \n' %self.rmax)
77
+ cfg.write('output=%s' %self.pdfpath +'/@b.@o \n')
78
+ cfg.write('outputtype = sq,gr \n')
79
+ #cfg.write('plot = iq,fq,gr \n' )
80
+ cfg.write('force = yes \n')
81
+
82
+ cfg.close()
83
+ return
84
+
85
+
86
+ def extractpdf(self):
87
+ self.writecfg()
88
+ command = 'conda run -n py36 pdfgetx3 -c' +self.pdfpath+'/pdfgetX3_GUI.cfg'
89
+
90
+ # Use subprocess to execute the command
91
+ subprocess.run(command, shell=True)
92
+ print(f'PDF file(s) extracted in {self.pdfpath}')
93
+ # Plot pdf
94
+
95
+ fig,ax=plt.subplots()
96
+ for file in self.datafilelist:
97
+ rootname=(os.path.basename(file).split('/')[-1]).split('.')[0]
98
+ pdffile=self.pdfpath+f'/{rootname}.gr'
99
+ r,g=np.loadtxt(pdffile,skiprows=27,unpack=True)
100
+ ax.plot(r,g,label=rootname)
101
+ ax.set_xlabel('r ($\\AA$)')
102
+ ax.set_ylabel('G(r)')
103
+ fig.legend()
104
+ fig.tight_layout()
105
+
106
+ return self.pdfpath