xrdPlanner 2.3.0__tar.gz → 2.4.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: xrdPlanner
3
- Version: 2.3.0
3
+ Version: 2.4.0
4
4
  Summary: A tool to project X-ray diffraction cones on a detector screen at different geometries (tilt, rotation, offset) and X-ray energies
5
5
  Author-email: Lennard Krause <lkrause@chem.au.dk>
6
6
  Project-URL: Homepage, https://github.com/LennardKrause/xrdPlanner
@@ -21,57 +21,49 @@ Requires-Dist: PyQt6>=6.5
21
21
  Requires-Dist: pyFAI>=2023.5
22
22
 
23
23
  # xrdPlanner
24
+ ## Version 2.4.0 (released 04.03.2025)
24
25
  #### A tool to project X-ray diffraction cones on a detector screen at different geometries (tilt, rotation, offset) and X-ray energies
25
26
  - Article published in [_J. Synchrotron Rad._ (2024). **31**](https://doi.org/10.1107/S1600577523011086).
26
27
  - Main application is to visualize the maximum achievable resolution at a given geometry.
27
28
  - Is able to project diffraction cones for standard samples or directly from cif files.
28
29
  - Can turn out valuable when planning beamtimes at synchrotron facilities (e.g. [DanMAX](https://www.maxiv.lu.se/beamlines-accelerators/beamlines/danmax/)).
29
30
  - Helps in deciding on the geometry of an experiment.
30
- - Meant to run standalone but is readily [insertable](#example-code-for-adding-xrdplanner-as-a-widget-into-an-existing-gui) as a widget into an existing PyQt6 GUI.
31
+ - Has a 1D [PXRD plot window](#pxrd-pattern-plot) for cif files to show the diffraction pattern and [intrumental peak broadening](#instrumental-broadening).
32
+ - Meant to run standalone but is readily [insertable](#example-code) as a widget into an existing PyQt6 GUI.
31
33
  - The math used is not meant to bring people to the moon but to provide a quick and simple preview.
32
34
  - This is not meant to accurately simulate a diffraction experiment, the step sizes are integer values in mm or degrees.
33
35
  - The module building code is designed for [Dectris](https://www.dectris.com) [PILATUS3](https://www.dectris.com/detectors/x-ray-detectors/pilatus3/) / [EIGER2](https://www.dectris.com/detectors/x-ray-detectors/eiger2/) or [SACLA](https://sacla.xfel.jp/?lang=en) MPCCD Detectors (central hole geometry) but one-module systems like the [Bruker](https://www.bruker.com/en.html) [Photon II](https://www.bruker.com/en/products-and-solutions/diffractometers-and-scattering-systems/single-crystal-x-ray-diffractometers/sc-xrd-components/detectors.html) and [Rayonix](https://www.rayonix.com/) [MX-HS](https://www.rayonix.com/rayonix-mx-hs-series/) are possible as well.
34
36
  - It uses [python3](https://www.python.org), [numpy](https://numpy.org), [pyqt6](https://www.riverbankcomputing.com/software/pyqt/), [pyqtgraph](https://pyqtgraph.readthedocs.io/en/latest/), [pyFAI](https://pyfai.readthedocs.io/en/v2023.1/) and [Dans_Diffraction](https://github.com/DanPorter/Dans_Diffraction).
35
37
 
36
- ## Update to Version 2.0.0 (released 23.09.2024)
37
- - The definition of detector modules was changed from mm to px to be more accurate and consistent.
38
- - Consequently, custom detectors added to the detector_db file are no longer available.
39
- - A new detector editor was added (_Settings_ > _Detector db editor_) to make the addition of custom detectors more feasible.
40
- - Define and add whatever detector you collect your data with, now more easily.
41
- - If something goes wrong use _Settings_ > _Reset detector db_.
42
- - There is a backup of your _custom_ detector_db (detector_db.json.bak) in the xrdPlanner folder (_Help_ > _xrdPlanner_).
43
- - A new parameter was added to allow for detector screen padding (geo.plot_padding), default is 0.
44
-
45
- ## Short how-to:
46
- - (python3 -m) pip install xrdPlanner.
47
- - Type _xrdPlanner_ in a terminal and hit enter.
48
- - Choose a detector and a model from the _Detector_ menu.
49
- - Plot diffraction cone contours:
50
- - Pick a reference from the _Reference_ menu ([pyFAI](https://pyfai.readthedocs.io/en/v2023.1/)), no hkl tooltip available.
51
- - Drop a .cif file onto the window ([Dans_Diffraction](https://github.com/DanPorter/Dans_Diffraction)), click a contour to get a hkl tooltip.
52
- - Enter custom unit cell dimensions, click a contour to get a hkl tooltip.
53
- - Use the units from the _Units_ menu you are the most comfortable with.
54
- - Hover over the grey line at the top to show the sliders. Click it to make it stay open.
55
- - Drag the sliders to change energy and geometry.
56
-
57
- ## Customisation:
58
- - Use the [export window](#export-window) from the settings menu.
59
- - Build up the available detector and beamstop bank.
60
- - Review and change the parameters.
61
- - Tooltips should help you along the way.
62
- - Use the detector db editor.
63
- - Define the detector you collect your data with.
64
- - Add all the different sizes and versions.
65
- - Use _Preview_ to play around and _Save_ to update the data bank.
66
- - Or edit the _settings.json_ file and the _detector_db.json_ files directly.
67
- - Use _Settings_ -> _Edit files_ to edit the _current settings_ or _Detector db_ file.
68
- - Reload the settings file to see the difference.
69
- - _geo_ determines the startup defaults.
70
- - _plo_ customises the general layout and visuals.
71
- - _thm_ makes it look the way you want.
72
- - _lmt_ sets the limiting values of the geometry/energy sliders.
73
- - Check the [settings file documentation](#settings-file-documentation) to get started.
74
- - Add all the missing detectors to the _detector_db.json_, see the [detector db entries](#detector-db-entries).
38
+ >[!TIP]
39
+ >## Short how-to:
40
+ > - (python3 -m) pip install xrdPlanner.
41
+ > - Type _xrdPlanner_ in a terminal and hit enter.
42
+ > - Choose a detector and a model from the _Detector_ menu.
43
+ > - Plot diffraction cone contours:
44
+ > - Pick a reference from the _Reference_ menu ([pyFAI](https://pyfai.readthedocs.io/en/v2023.1/)), no hkl tooltip available.
45
+ > - Drop a .cif file onto the window ([Dans_Diffraction](https://github.com/DanPorter/Dans_Diffraction)), click a contour to get a hkl tooltip.
46
+ > - Enter custom unit cell dimensions, click a contour to get a hkl tooltip.
47
+ > - Use the units from the _Units_ menu you are the most comfortable with.
48
+ > - Hover over the grey line at the top to show the sliders. Click it to make it stay open.
49
+ > - Drag the sliders to change energy and geometry.
50
+ > - Use [hotkeys](#hotkeys) to streamline your experience.
51
+ >
52
+ >## Customisation:
53
+ > - Use the [export window](#export-window) from the settings menu.
54
+ > - Build up the available detector and beamstop bank.
55
+ > - Review and change the parameters.
56
+ > - Tooltips should help you along the way.
57
+ > - Use the [detector db editor](#detector-db-editor).
58
+ > - Define the detector you collect your data with.
59
+ > - Add all the different sizes and versions.
60
+ > - Use _Preview_ to play around and _Save_ to update the data bank.
61
+ > - Or edit the _settings.json_ file and the _detector_db.json_ files directly.
62
+ > - Use _Settings_ -> _Edit files_ to edit the _current settings_ or _Detector db_ file.
63
+ > - Check the [settings file documentation](#settings-file-documentation) to get started.
64
+ > - Use pre-set beamline settings files:
65
+ > - Download a settings file from here (e.g. settings/DanMAX.json).
66
+ > - Use the import settings function from the GUI to import.
75
67
 
76
68
  ## Conventions
77
69
  The geometry is defined with the center of rotation at the sample position, such that the radius of the rotation circle is equal to the sample to detector distance (SDD). That is, the rotation moves the detector along the goniometer circle, keeping the point of normal incidence (PONI) at the same position relative to the detector surface. At 0° the detector is vertical and at 90° the detector is horizontal with the detector normal pointing down.
@@ -118,25 +110,41 @@ S_{ij} = \left(\frac{|\vec{v}_{ij}|}{SDD}\right)^{-3}
118
110
  ```
119
111
  where $SDD$ is the sample to detector distance.
120
112
 
121
- ## Use pre-set beamline settings files:
122
- - Download a settings file from here (e.g. settings/DanMAX.json).
123
- - Use the import settings function from the GUI to import.
124
- - You can switch between all imported settings.
125
- - Use the export window to customise and export your settings.
126
-
127
- ## Known bugs and limitations:
128
- - On Windows: Switching Dark/Light mode requires restart to change the window frame color.
129
- - As of now, there is no consistency check performed on the imported .json file.
130
- - The projections fail at a combined angle (rotation + tilt) of 90 degrees and beyond.
131
- - If the program crashes (libc++abi) when opening the export window (on a Mac) please update PyQt6 to the latest version.
132
-
133
- ## After the update:
134
- Sometimes I might change the name of a parameter and you will get a warning message upon startup looking something like this: _WARNING: "conic_ref_min_int" is not a valid key_! Either that key is no longer in use or its name got changed and is now reset to the default value. The settings file is updated and the warning should no longer appear after restart. Apart from this, your edited settings file will not be altered after updating.
113
+ >[!NOTE]
114
+ >## Update to Version 2.0.0 and later (released 23.09.2024)
115
+ > - The definition of detector modules was changed from mm to px to be more accurate and consistent.
116
+ > - Consequently, custom detectors added to the detector_db file pre 2.0.0 are no longer working.
117
+ > - A new [detector db editor](#detector-db-editor) was added (_Settings_ > _Detector db editor_) to make the addition of custom detectors more feasible.
118
+ > - Define and add whatever detector you collect your data with, now more easily.
119
+ > - If something goes wrong use _Settings_ > _Reset detector db_.
120
+ > - There is a backup of your _custom_ detector_db (detector_db.json.bak) in the xrdPlanner folder (_Help_ > _xrdPlanner_).
121
+ > - A new parameter was added to allow for detector screen padding (plo.plot_padding), default is 0.
135
122
 
136
123
  ## Latest updates:
137
- - 2024-09-23 Update: Added a detector editor to define and add whatever detector you collect your data with, now more easily.
138
- - 2024-09-23 Update: Changed the detector module definition from mm to px (added custom detectors won't be available!).
124
+ - 2025-03-04 Update: Added pxrd ghost lines to play with and compare the scattering using different parameters.
125
+ - 2025-03-04 Update: Made some improvements to the highlighting.
126
+ - 2025-03-04 Update: Trained most sub-windows to remember their place.
127
+ - 2025-03-04 Update: Started to declutter the code.
128
+ - 2025-03-04 Bugfix: Resynchronized the menu button for the angular grid (Thanks Frederik).
129
+ - 2025-02-12 Bugfix: Fixed f-string SyntaxError crash on startup (python version < 3.12).
130
+ - 2025-02-10 Update: Added the option to estimate Thomas-Cox-Hastings parameters (gaussian) from the estimated instrumental broadening.
131
+ - 2025-02-10 Update: Reworked the hkl display and cone highlighting to make identification and location of hkl more straightforward.
132
+ - 2025-02-10 Update: Highlighting is now linked between the main window and the pxrd viewer.
133
+ - 2024-12-05 Update: Added the option to export the FWHM grid as a compressed numpy .npz file (View > Functions > Export FWHM).
134
+ - 2024-11-08 Update: Added a visual indicators for azimuthal bins (View > Overlay > Grid or hotkey G).
135
+ - 2024-11-08 Bugfix: Fixed invisible menus on windows os.
136
+ - 2024-10-29 Update: Added a menu action to invert the coloring of the resolution and reference conics (_View_ > _Invert cone colors_) to increase visibility, when needed.
137
+ - 2024-10-28 Update: Added a [PXRD plot window](#pxrd-pattern-plot) for cif files to show the diffraction pattern (gaussian peak shape) including [intrumental peak broadening](#instrumental-broadening) (setup FWHM).
138
+ - 2024-10-28 Update: cif files are stored now (name and link-to-file).
139
+ - 2024-10-28 Update: Added somewhat useful doc-strings to all functions (Thanks Github Copilot).
140
+ - 2024-10-01 Bugfix: Fixed an error crashing the detector db editor on python < 3.12 (Thanks Lise).
141
+ - 2024-09-23 Update: Added a [detector db editor](#detector-db-editor) to define and add whatever detector you collect your data with, now more easily.
142
+ - 2024-09-23 Update: Changed the detector module definition from mm to px (pre 2.0.0 custom detectors won't work!).
139
143
  - 2024-09-23 Update: Added a preview plot to the FWHM setup window.
144
+
145
+ <details>
146
+ <summary>Older updates</summary>
147
+
140
148
  - 2024-06-20 Update: Added highlighting of a clicked contour.
141
149
  - 2024-06-20 Bugfix: Incorrect removal of beamstop contour.
142
150
  - 2024-05-30 Update: Added support for custom unit cells to calculate and plot conics.
@@ -145,10 +153,6 @@ where $SDD$ is the sample to detector distance.
145
153
  - 2024-05-02 Update: Automatic label placement (conic_label_auto, default=True).
146
154
  - 2024-05-02 Update: Dynamic cones try to keep the number of visible conics constant (conic_tth_auto, default=True).
147
155
  - 2024-05-02 Update: Current colors are displayed in the export window and a colorpicker is used.
148
-
149
- <details>
150
- <summary>Older updates</summary>
151
-
152
156
  - 2024-02-17 Bugfix: Fixed crash on importing settings files (Thanks Andy).
153
157
  - 2024-02-16 Update: Added a unit value at mouse position (hover) to the overlay.
154
158
  - 2024-02-09 Update: Updated the About window with links to github and the publication.
@@ -193,22 +197,61 @@ where $SDD$ is the sample to detector distance.
193
197
  - 2022-04-25 Bugfix: Calculation of the beamcenter (rotation and tilt).
194
198
  </details>
195
199
 
200
+ <details>
201
+ <summary>After the update</summary>
202
+
203
+ - Sometimes I might change the name of a parameter and you will get a warning message upon startup looking something like this: _WARNING: "conic_ref_min_int" is not a valid key_! Either that key is no longer in use or its name got changed and is now reset to the default value. The settings file is updated and the warning should no longer appear after restart. Apart from this, your edited settings file will not be altered after updating.
204
+ </details>
205
+
206
+ >[!IMPORTANT]
207
+ >## Known bugs and limitations:
208
+ > - On Windows: Switching Dark/Light mode requires restart to change the window frame color.
209
+ > - As of now, there is no consistency check performed on the imported .json file.
210
+ > - The projections fail at a combined angle (rotation + tilt) of 90 degrees and beyond.
211
+ > - If the program crashes (libc++abi) when opening the export window (on a Mac) please update PyQt6 to the latest version.
212
+ > - A crash on startup due to an f-string SyntaxError can be circumvented by upgrading python to version 3.12 or later.
213
+
196
214
  ## Examples
197
215
  #### A PILATUS3 300K detector and a Rubrene sample.
198
- ![Preview](https://github.com/LennardKrause/xrdPlanner/blob/main/examples/Figure_2_example_light.png)
216
+ <img src="https://github.com/LennardKrause/xrdPlanner/blob/main/examples/Figure_2_example_light.png" width="50%">
199
217
 
200
218
  #### A rotated EIGER2 9M detector and a Rubrene sample (darkmode).
201
- ![Preview](https://github.com/LennardKrause/xrdPlanner/blob/main/examples/Figure_1_example_dark.png)
219
+ <img src="https://github.com/LennardKrause/xrdPlanner/blob/main/examples/Figure_1_example_dark.png" width="50%">
202
220
 
203
221
  #### Export window
204
222
  ##### Use the export window to select and build up the available detector / beamstop bank and review/change parameters.
205
- ![Preview](https://github.com/LennardKrause/xrdPlanner/blob/main/examples/Figure_3_export_window.png)
223
+ <img src="https://github.com/LennardKrause/xrdPlanner/blob/main/examples/Figure_3_export_window.png" width="50%">
224
+
225
+ #### Detector db editor
226
+ ##### Define and add the detector you collect your data with.
227
+ <img src="https://github.com/LennardKrause/xrdPlanner/blob/main/examples/Figure_4_detector_db_editor.png" width="50%">
228
+
229
+ #### PXRD pattern plot
230
+ ##### Look at a 1D PXRD pattern plot of the calculated intensities (cif-file), displayed using gaussian peak shapes and the estimated peak broadening (FWHM).
231
+ <img src="https://github.com/LennardKrause/xrdPlanner/blob/main/examples/Figure_5_PXRD.png" width="50%">
232
+
233
+ #### Instrumental broadening
234
+ ##### Estimate FWHM (H, in degrees) using the following parameters:
235
+ - Estimated effective thickness of the detector absorption layer depending on sensor material and incident wavelength
236
+ - Detector sensor layer material
237
+ - Estimated beam divergence
238
+ - Expected bandwidth of the incident X-ray beam
239
+ - Intersection of the sample size and the beam size as the diameter
240
+
241
+ > **The interested user is referred to the article:<br>**
242
+ > <i>On the resolution function for powder diffraction with area detectors</i><br>
243
+ > [D. Chernyshov <i> et al., Acta Cryst.</i> (2021). <b>A77</b>, 497-505](https://doi.org/10.1107/S2053273321007506)
244
+ <img src="https://github.com/LennardKrause/xrdPlanner/blob/main/examples/Figure_6_FWHM.png" width="50%">
206
245
 
207
246
  ## Hotkeys
208
247
 
209
248
  | Key | Action |
210
249
  | ---------- | ------------------------- |
211
250
  | F1 | Show About window |
251
+ | F2 | Show Geometry conventions |
252
+ | F3 | Show Hotkeys |
253
+ | x | Show PXRD pattern |
254
+ | f | Show FWHM window |
212
255
  | # | *Display units* |
213
256
  | t | 2-Theta |
214
257
  | d | d-spacing |
@@ -227,8 +270,9 @@ where $SDD$ is the sample to detector distance.
227
270
  | Shift + c | Previous |
228
271
 
229
272
  ## Settings file documentation
230
-
231
- #### geo - startup defaults
273
+ <details>
274
+ <summary>geo - startup defaults</summary>
275
+
232
276
  det_type = 'EIGER2' # [str] Pilatus3 / Eiger2 / etc.
233
277
  # -> Detector menu entry
234
278
  det_size = '4M' # [str] 300K 1M 2M 6M / 1M 4M 9M 16M
@@ -255,8 +299,11 @@ where $SDD$ is the sample to detector distance.
255
299
  2.5,
256
300
  3.0,
257
301
  5.0]
302
+ </details>
258
303
 
259
- #### plo - plot settings
304
+ <details>
305
+ <summary>plo - plot settings</summary>
306
+
260
307
  # - geometry contour section -
261
308
  conic_tth_min = 5 # [int] Minimum 2-theta contour line
262
309
  conic_tth_max = 100 # [int] Maximum 2-theta contour line
@@ -326,7 +373,11 @@ where $SDD$ is the sample to detector distance.
326
373
  # - debug/testing -
327
374
  set_debug = False # [bool] Debug mode
328
375
 
329
- #### thm - theme
376
+ </details>
377
+
378
+ <details>
379
+ <summary>thm - theme</summary>
380
+
330
381
  color_dark = '#404040' # [color] Global dark color
331
382
  color_light = '#EEEEEE' # [color] Global light color
332
383
 
@@ -360,7 +411,10 @@ where $SDD$ is the sample to detector distance.
360
411
  dark_slider_bg_hover = '#303030' # [color] Slider frame hover color
361
412
  dark_slider_label_color = '#C0C0C0' # [color] Slider frame label color
362
413
 
363
- #### lmt - limits
414
+ </details>
415
+
416
+ <details>
417
+ <summary>lmt - limits</summary>
364
418
 
365
419
  # energy [keV]
366
420
  ener_min = 5 # [int] Energy minimum [keV]
@@ -396,7 +450,10 @@ where $SDD$ is the sample to detector distance.
396
450
  bsdx_max = 1000 # [int] Beamstop distance maximum [mm]
397
451
  bsdx_stp = 1 # [int] Beamstop distance step size [mm]
398
452
 
399
- ## Detector db entries
453
+ </details>
454
+
455
+ <details>
456
+ <summary>Detector db entries</summary>
400
457
 
401
458
  The detector_db.json is stored as a dictionary
402
459
  - key: detector name e.g. PILATUS3
@@ -404,12 +461,12 @@ The detector_db.json is stored as a dictionary
404
461
 
405
462
  | Entry | Value | Hint |
406
463
  |-------|---------|------|
407
- | hms | 83.8 | [mm] Module size (horizontal)
408
- | vms | 33.5 | [mm] Module size (vertical)
409
- | pxs | 172e-3 | [mm] Pixel size
410
- | hgp | 7 | [pix] Gap between modules (horizontal)
411
- | vgp | 17 | [pix] Gap between modules (vertical)
412
- | cbh | 0 | [mm] Central beam hole
464
+ | pxs | 172e-3 | [mm] Pixel size
465
+ | hmp | 487 | [px] Module size (horizontal)
466
+ | vmp | 195 | [px] Module size (vertical)
467
+ | hgp | 7 | [px] Gap between modules (horizontal)
468
+ | vgp | 17 | [px] Gap between modules (vertical)
469
+ | cbh | 0 | [px] Central beam hole
413
470
 
414
471
  The size Entry is a dictionary {key:value,}
415
472
  - key: detector size / type, e.g. 300K
@@ -419,9 +476,9 @@ The size Entry is a dictionary {key:value,}
419
476
 
420
477
  #### Example of the PILATUS3 entry
421
478
  "PILATUS3": {
422
- "hms": 83.8,
423
- "vms": 33.5,
424
479
  "pxs": 0.172,
480
+ "hmp": 487,
481
+ "vmp": 195,
425
482
  "hgp": 7,
426
483
  "vgp": 17,
427
484
  "cbh": 0,
@@ -433,7 +490,12 @@ The size Entry is a dictionary {key:value,}
433
490
  }
434
491
  },
435
492
 
436
- ## Example code for adding xrdPlanner as a widget into an existing GUI
493
+ </details>
494
+
495
+ ## Example code
496
+ <details>
497
+ <summary>Example code for adding xrdPlanner as a widget into an existing GUI</summary>
498
+
437
499
  #### xrdPlanner uses its own menu bar, setting the GUI as the parent for xrdPlanner makes it add its menus to the parents menu bar, and likely more in the future.
438
500
 
439
501
  import sys
@@ -457,5 +519,6 @@ The size Entry is a dictionary {key:value,}
457
519
  window = MainWindow()
458
520
  window.show()
459
521
  app.exec()
522
+ </details>
460
523
 
461
- #### I hope this turns out to be useful for someone!
524
+ ## I hope this turns out to be useful for someone!