Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Provide a pyFAI Geometry Optimization Task #59

Draft
wants to merge 508 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
508 commits
Select commit Hold shift + click to select a range
e92f29e
[edit] Fix scaling error in converting energy_photon to wavelength
LouConreux Dec 3, 2024
f03f1e6
[test] 6 STDS
LouConreux Dec 4, 2024
8033e2d
[test] 5 STDS
LouConreux Dec 4, 2024
7aabca5
[test] 6 STDS
LouConreux Dec 4, 2024
ba7ac44
[test] 6 STDS
LouConreux Dec 4, 2024
1373113
[test] 8 STDS
LouConreux Dec 4, 2024
ad9518d
[test] 10 STDS
LouConreux Dec 4, 2024
250404a
[edit] Handle case where final residual computation is impossible sin…
LouConreux Dec 5, 2024
711f816
[edit] back to 5 STDS
LouConreux Dec 5, 2024
a2b679d
[edit] Fix unnecessary imports to pass PR tests
LouConreux Dec 6, 2024
b8fbbd1
Auto-commit black formatting
actions-user Dec 6, 2024
ae5e8f3
Merge branch 'dev' of github.com:slac-lcls/lute into dev
LouConreux Dec 6, 2024
e77c24b
Merge branch 'dev' of https://github.com/LouConreux/lute into dev
LouConreux Dec 6, 2024
4fbc029
[edit] Add type: ignore to fix mypy test
LouConreux Dec 7, 2024
1bc8498
Auto-commit black formatting
actions-user Dec 7, 2024
09d85bd
[edit] Fix mypy testing through asserting correct pydantic type
LouConreux Dec 9, 2024
a840e2a
Merge branch 'dev' of https://github.com/LouConreux/lute into dev
LouConreux Dec 9, 2024
c5a7111
[edit] Fix mypy testing through asserting correct pydantic type
LouConreux Dec 9, 2024
a2d8b67
Auto-commit black formatting
actions-user Dec 9, 2024
6dc7a00
[edit] Fix mypy testing through asserting correct pydantic type
LouConreux Dec 10, 2024
09aaa5a
[edit] Fix mypy pydantic check
LouConreux Dec 10, 2024
5b12484
[refacto] Fix unnecessary logs and set back to default mapping of mpi…
LouConreux Dec 10, 2024
9aaacf4
Auto-commit black formatting
actions-user Dec 10, 2024
5cab26d
[edit] Set --bind-to core inside mpi command for MPIExecutor
LouConreux Dec 10, 2024
79cf672
Merge branch 'dev' of https://github.com/LouConreux/lute into dev
LouConreux Dec 10, 2024
5947427
[edit] Set --map-by core inside mpi command for MPIExecutor
LouConreux Dec 10, 2024
8f4778e
[refacto] Removed surrogate map and acquisition map from bayes opt hi…
LouConreux Dec 10, 2024
9f9436c
[edit] Fix pyOpenCL after importing modules
LouConreux Dec 10, 2024
dddab65
Auto-commit black formatting
actions-user Dec 10, 2024
a9ee817
[edit] Try to compute detector edge resolution
LouConreux Dec 11, 2024
a3c1578
Merge branch 'dev' of https://github.com/LouConreux/lute into dev
LouConreux Dec 11, 2024
1493b36
Auto-commit black formatting
actions-user Dec 11, 2024
122f9ff
[edit] Set Imin lower bound to 98
LouConreux Dec 11, 2024
bdb65ee
Merge branch 'dev' of https://github.com/LouConreux/lute into dev
LouConreux Dec 11, 2024
5a4a1c7
[edit] Set Imin lower bound to 99
LouConreux Dec 11, 2024
5ea90a4
[edit] Set Imin lower bound to 99
LouConreux Dec 11, 2024
55380dd
[edit] Set Imin lower bound to 99
LouConreux Dec 11, 2024
1e2d8fe
[edit] Set Imin lower bound to 99.5
LouConreux Dec 11, 2024
a80de81
[edit] Set back to 95
LouConreux Dec 11, 2024
ee2ac0e
[edit] Add refined dist to label
LouConreux Dec 11, 2024
e8d6f7b
Auto-commit black formatting
actions-user Dec 11, 2024
336b054
[edit] Fix plots
LouConreux Dec 11, 2024
4f4a5ff
Merge branch 'dev' of https://github.com/LouConreux/lute into dev
LouConreux Dec 11, 2024
2bd18cb
[edit] Fix output on eLog
LouConreux Dec 11, 2024
9618b1d
[edit] Fix plot for Elog summary
LouConreux Dec 11, 2024
c6365e8
[edit] Include plots in the eLog summary
LouConreux Dec 11, 2024
27ea664
Auto-commit black formatting
actions-user Dec 11, 2024
dca2ccd
[edit] Set back to 98
LouConreux Dec 12, 2024
deef9f4
Merge branch 'dev' of https://github.com/LouConreux/lute into dev
LouConreux Dec 12, 2024
5e9ac77
[edit] Refine not on rotation first, only on dist cx cy, then finally…
LouConreux Dec 12, 2024
d12e239
Auto-commit black formatting
actions-user Dec 12, 2024
f75e4a6
[edit] Set back to 95
LouConreux Dec 12, 2024
1a57e9e
Merge branch 'dev' of https://github.com/LouConreux/lute into dev
LouConreux Dec 12, 2024
d868e57
[edit] Set back normal
LouConreux Dec 12, 2024
5f90f33
Auto-commit black formatting
actions-user Dec 12, 2024
09b9ef6
[edit] Set to 99
LouConreux Dec 12, 2024
a169ebb
Merge branch 'dev' of https://github.com/LouConreux/lute into dev
LouConreux Dec 12, 2024
90920fe
[edit] Set back to 95
LouConreux Dec 12, 2024
2c9f6c5
[edit] Rename python files into bayfai to match workflow name BayFAI
LouConreux Dec 17, 2024
bc229f0
[edit] Smalldata producer template change to output max of the maxs, …
LouConreux Dec 18, 2024
91a2c8c
[edit] Add a preprocessing layer before launching optimization
LouConreux Dec 19, 2024
5d6548e
Auto-commit black formatting
actions-user Dec 19, 2024
1e866bb
[edit] Filter out bad scores in taking the minimal residual
LouConreux Dec 19, 2024
f738ad0
Merge branch 'dev' of https://github.com/LouConreux/lute into dev
LouConreux Dec 19, 2024
6258b7a
Auto-commit black formatting
actions-user Dec 19, 2024
479f6ad
[edit] Filter out bad scores in taking the minimal residual + plot
LouConreux Dec 19, 2024
50a823e
Merge branch 'dev' of https://github.com/LouConreux/lute into dev
LouConreux Dec 19, 2024
576bfaf
Auto-commit black formatting
actions-user Dec 19, 2024
4c94ba0
[edit] Able to reconstruct 2D detector plot for visualizing powder
LouConreux Dec 19, 2024
582a743
Merge branch 'dev' of https://github.com/LouConreux/lute into dev
LouConreux Dec 19, 2024
5f0b373
Auto-commit black formatting
actions-user Dec 19, 2024
82db0f5
[edit] Handled rayonix case where shape is then (1, det.shape)
LouConreux Dec 19, 2024
ba49354
Merge branch 'dev' of https://github.com/LouConreux/lute into dev
LouConreux Dec 19, 2024
7d342d3
[edit] Add label on assembled powder
LouConreux Dec 19, 2024
d023489
Auto-commit black formatting
actions-user Dec 19, 2024
f51e242
[edit] Fix plot for Rayonix...
LouConreux Dec 19, 2024
051e65e
[edit] Fix plot for Rayonix...
LouConreux Dec 19, 2024
8e20d3d
Auto-commit black formatting
actions-user Dec 19, 2024
506c9cf
[edit] Fix Z coords case where Nonetype
LouConreux Dec 19, 2024
c55a4ef
Merge branch 'dev' of https://github.com/LouConreux/lute into dev
LouConreux Dec 19, 2024
8436385
[edit] Remove sigmoid in gradient powder computing
LouConreux Dec 19, 2024
239ca4d
[edit] Fix plotting for Rayonix, I hate Rayonix
LouConreux Dec 19, 2024
b1803de
[edit] Fix plotting for Rayonix, I hate Rayonix even more
LouConreux Dec 19, 2024
02ce387
[edit] Fix plotting for Rayonix, I hate Rayonix even more
LouConreux Dec 19, 2024
af57c31
[edit] Correct mypy and ruff error tests
LouConreux Dec 19, 2024
e6b4bce
Auto-commit black formatting
actions-user Dec 19, 2024
b768de2
[edit] Correct mypy and ruff error tests
LouConreux Dec 19, 2024
13832d2
Merge branch 'dev' of https://github.com/LouConreux/lute into dev
LouConreux Dec 19, 2024
650229c
Auto-commit black formatting
actions-user Dec 19, 2024
8d8bfb6
[edit] Add animation for website description of BayFAI
LouConreux Dec 20, 2024
a2aef4e
Merge branch 'dev' of https://github.com/LouConreux/lute into dev
LouConreux Dec 20, 2024
d4e2f14
Auto-commit black formatting
actions-user Dec 20, 2024
7969cd9
[edit] Add animation for website description of BayFAI
LouConreux Dec 20, 2024
6cef789
Merge branch 'dev' of https://github.com/LouConreux/lute into dev
LouConreux Dec 20, 2024
4c9ddbf
[edit] Add animation for website description of BayFAI
LouConreux Dec 20, 2024
6a9d1c8
Auto-commit black formatting
actions-user Dec 20, 2024
d51ade0
[edit] Add animation for website description of BayFAI
LouConreux Dec 20, 2024
aa5993f
Merge branch 'dev' of https://github.com/LouConreux/lute into dev
LouConreux Dec 20, 2024
b1683ca
Auto-commit black formatting
actions-user Dec 20, 2024
0cd7a37
[edit] Add animation for website description of BayFAI
LouConreux Dec 20, 2024
dfcc68e
Merge branch 'dev' of https://github.com/LouConreux/lute into dev
LouConreux Dec 20, 2024
271fc9f
Auto-commit black formatting
actions-user Dec 20, 2024
86dd4d1
[edit] Add animation for website description of BayFAI
LouConreux Dec 20, 2024
08226e7
Merge branch 'dev' of https://github.com/LouConreux/lute into dev
LouConreux Dec 20, 2024
c589cb3
Auto-commit black formatting
actions-user Dec 20, 2024
80ad520
[edit] Add animation for website description of BayFAI
LouConreux Dec 20, 2024
e65f6ba
Merge branch 'dev' of https://github.com/LouConreux/lute into dev
LouConreux Dec 20, 2024
0397ba3
[edit] Add animation for website description of BayFAI
LouConreux Dec 20, 2024
4afcd47
Auto-commit black formatting
actions-user Dec 20, 2024
5eefc84
[edit] Add animation for website description of BayFAI
LouConreux Dec 20, 2024
1f71a03
[edit] Add animation for website description of BayFAI
LouConreux Dec 20, 2024
5230c51
[edit] Add animation for website description of BayFAI
LouConreux Dec 20, 2024
0d7eebf
Auto-commit black formatting
actions-user Dec 20, 2024
106823b
[edit] Add animation for website description of BayFAI
LouConreux Dec 20, 2024
ac1231a
[edit] Add animation for website description of BayFAI
LouConreux Dec 20, 2024
f1a887b
Auto-commit black formatting
actions-user Dec 20, 2024
986ae37
[edit] Add animation for website description of BayFAI
LouConreux Dec 20, 2024
a84d559
[edit] Add animation for website description of BayFAI
LouConreux Dec 20, 2024
cd6214d
Auto-commit black formatting
actions-user Dec 20, 2024
b978ce8
[edit] Add animation for website description of BayFAI
LouConreux Dec 20, 2024
12ca503
[edit] Add animation for website description of BayFAI
LouConreux Dec 20, 2024
f410add
Auto-commit black formatting
actions-user Dec 20, 2024
d714502
[edit] Add animation for website description of BayFAI
LouConreux Dec 20, 2024
3648762
[edit] Add animation for website description of BayFAI
LouConreux Dec 20, 2024
4cca08f
Auto-commit black formatting
actions-user Dec 20, 2024
8cf6698
[edit] Add animation for website description of BayFAI
LouConreux Dec 20, 2024
7138426
[edit] Add animation for website description of BayFAI
LouConreux Dec 20, 2024
23f26c4
Auto-commit black formatting
actions-user Dec 20, 2024
af233ec
[edit] Add animation for website description of BayFAI
LouConreux Dec 20, 2024
1b38ea1
[edit] Add animation for website description of BayFAI
LouConreux Dec 20, 2024
47f7b13
Auto-commit black formatting
actions-user Dec 20, 2024
b3ce866
[edit] Change n_init and n_iter to 20 80 + trying to fix animation
LouConreux Dec 22, 2024
547576c
[edit] Change n_init and n_iter to 20 80 + trying to fix animation
LouConreux Dec 22, 2024
5345ece
Auto-commit black formatting
actions-user Dec 22, 2024
026aa9f
[edit] Finally fixed animation
LouConreux Dec 22, 2024
8a76ecd
Merge branch 'dev' of https://github.com/LouConreux/lute into dev
LouConreux Dec 22, 2024
38d057d
[edit] Change convergence plot for more visualization
LouConreux Dec 22, 2024
0226180
[edit] Format ticks on animation
LouConreux Dec 22, 2024
e9de775
Auto-commit black formatting
actions-user Dec 22, 2024
654c06a
[edit] Format ticks on animation
LouConreux Dec 22, 2024
de529f6
Merge branch 'dev' of https://github.com/LouConreux/lute into dev
LouConreux Dec 22, 2024
f317aa9
Auto-commit black formatting
actions-user Dec 22, 2024
716fd5b
[edit] Format ticks on animation
LouConreux Dec 22, 2024
d8df1f2
[edit] Format ticks on animation
LouConreux Dec 22, 2024
69ecbb7
Auto-commit black formatting
actions-user Dec 22, 2024
d1dd309
[edit] Fix error in legend plotting for convergence plot
LouConreux Dec 22, 2024
d2371d1
Merge branch 'dev' of https://github.com/LouConreux/lute into dev
LouConreux Dec 22, 2024
d13ffe2
[edit] Computation of detector resolution with plots
LouConreux Dec 22, 2024
205c127
Auto-commit black formatting
actions-user Dec 22, 2024
6b3d5c9
[edit] Computation of detector resolution with plots
LouConreux Dec 22, 2024
6052352
[edit] Computation of detector resolution with plots
LouConreux Dec 22, 2024
7b71c63
[edit] Computation of detector resolution with plots
LouConreux Dec 22, 2024
c1d1522
Auto-commit black formatting
actions-user Dec 22, 2024
239c225
[edit] Computation of detector resolution with plots
LouConreux Dec 22, 2024
e292311
[edit] Computation of detector resolution with plots
LouConreux Dec 22, 2024
29d8c1e
Auto-commit black formatting
actions-user Dec 22, 2024
6a935e2
[edit] Fix powder plot with resolution visualization
LouConreux Dec 22, 2024
af1f24c
[edit] Fix powder plot with resolution visualization
LouConreux Dec 22, 2024
92efc3e
Auto-commit black formatting
actions-user Dec 22, 2024
1741bed
[edit] Fix powder plot with resolution visualization
LouConreux Dec 22, 2024
49ef76a
Merge branch 'dev' of https://github.com/LouConreux/lute into dev
LouConreux Dec 22, 2024
d602fb6
[edit] Fix powder plot with resolution visualization
LouConreux Dec 22, 2024
e435393
[edit] Fix powder plot with resolution visualization
LouConreux Dec 22, 2024
7066d0f
Auto-commit black formatting
actions-user Dec 22, 2024
ca36c48
[edit] Fix powder plot with resolution visualization
LouConreux Dec 22, 2024
06de3a9
Merge branch 'dev' of https://github.com/LouConreux/lute into dev
LouConreux Dec 22, 2024
eff13a3
[edit] Fix powder plot with resolution visualization
LouConreux Dec 22, 2024
e5e7a9b
Auto-commit black formatting
actions-user Dec 22, 2024
58d85d4
[edit] Fix powder plot with resolution visualization
LouConreux Dec 22, 2024
47dd33f
Merge branch 'dev' of https://github.com/LouConreux/lute into dev
LouConreux Dec 22, 2024
4e8e5a4
[edit] Final edit of visualize results
LouConreux Dec 22, 2024
2b30be7
[edit] Final edit of visualize results
LouConreux Dec 22, 2024
109f03c
[edit] Fix colorbar limits for better visualization
LouConreux Jan 6, 2025
5923e1c
Auto-commit black formatting
actions-user Jan 6, 2025
e3eeb2f
[edit] Redo bayesian opt animation with correction
LouConreux Jan 6, 2025
ded5846
Merge branch 'dev' of https://github.com/LouConreux/lute into dev
LouConreux Jan 6, 2025
cc85732
Auto-commit black formatting
actions-user Jan 6, 2025
60fd06c
[edit] Redo bayesian opt animation with correction
LouConreux Jan 6, 2025
a5a617f
Merge branch 'dev' of https://github.com/LouConreux/lute into dev
LouConreux Jan 6, 2025
5358d4e
Auto-commit black formatting
actions-user Jan 6, 2025
731b511
[edit] Comment animation
LouConreux Jan 6, 2025
bdfc6da
Merge branch 'dev' of https://github.com/LouConreux/lute into dev
LouConreux Jan 6, 2025
c4c6453
[edit] Change diagnostic output plot design
LouConreux Jan 9, 2025
ccd353a
Auto-commit black formatting
actions-user Jan 9, 2025
d1d8a55
[edit] Change diagnostic output plot design + animation
LouConreux Jan 9, 2025
3ed7914
Merge branch 'dev' of https://github.com/LouConreux/lute into dev
LouConreux Jan 9, 2025
f1faee2
[edit] Change diagnostic output plot design + animation
LouConreux Jan 9, 2025
b232551
Auto-commit black formatting
actions-user Jan 9, 2025
add2230
[edit] Change diagnostic output plot design + animation
LouConreux Jan 9, 2025
d03d07e
Merge branch 'dev' of https://github.com/LouConreux/lute into dev
LouConreux Jan 9, 2025
ccdfba4
[edit] Change diagnostic output plot design + animation
LouConreux Jan 9, 2025
3a9566e
Auto-commit black formatting
actions-user Jan 9, 2025
22e09e7
[edit] Change diagnostic output plot design + animation
LouConreux Jan 9, 2025
fb3ff89
Merge branch 'dev' of https://github.com/LouConreux/lute into dev
LouConreux Jan 9, 2025
feac75c
[edit] Change diagnostic output plot design + animation
LouConreux Jan 9, 2025
b7099a3
[edit] Change diagnostic output plot design + animation
LouConreux Jan 10, 2025
58edbe4
Auto-commit black formatting
actions-user Jan 10, 2025
2916197
[edit] Comment out animation for testing
LouConreux Jan 10, 2025
ce70cdd
Merge branch 'dev' of https://github.com/LouConreux/lute into dev
LouConreux Jan 10, 2025
cca229d
[edit] Change q as usual
LouConreux Jan 10, 2025
e5dd2a6
[edit] Fix writing out of thresholding
LouConreux Jan 13, 2025
a30a78b
[edit] Change powder plot to match real lab coordinate system
LouConreux Jan 17, 2025
6ff8c98
[edit] Add animation in code
LouConreux Jan 17, 2025
8ff6e9c
Auto-commit black formatting
actions-user Jan 17, 2025
4eb1ae3
[edit] Remove animation
LouConreux Jan 17, 2025
5719fb9
[edit] Remove animation
LouConreux Jan 17, 2025
1d942cb
[edit] Set Powder plot in psana frame coordinate system
LouConreux Jan 20, 2025
19316fc
[edit] Reduced step size for minimal intensity threshold to 0.5
LouConreux Jan 20, 2025
8308f4c
[edit] Reduced step size for minimal intensity threshold to 0.25
LouConreux Jan 20, 2025
fc37e07
[edit] Reduced step size for minimal intensity threshold to 0.25
LouConreux Jan 20, 2025
ed8e826
[edit] Fix plots
LouConreux Jan 20, 2025
7d74c7e
[edit] Fix plots
LouConreux Jan 20, 2025
408934e
[edit] Plot powder in lab coordinate system
LouConreux Jan 20, 2025
365c7d6
[edit] Plot powder in lab coordinate system
LouConreux Jan 20, 2025
c9a80e6
Auto-commit black formatting
actions-user Jan 20, 2025
206ae61
[edit] Plot powder in lab coordinate system + fix centering for plott…
LouConreux Jan 20, 2025
c6414b0
Merge branch 'dev' of https://github.com/LouConreux/lute into dev
LouConreux Jan 20, 2025
1408c32
[edit] Resolution calculated using theta and not 2*theta
LouConreux Jan 23, 2025
87f1f77
[edit] Populate geometry calib folder with template geometry when no …
LouConreux Jan 24, 2025
a3ef36f
Auto-commit black formatting
actions-user Jan 24, 2025
89a4612
[edit] Populate geometry calib folder with template geometry when no …
LouConreux Jan 24, 2025
a1387ed
[edit] Populate geometry calib folder with template geometry when no …
LouConreux Jan 24, 2025
425cb42
Auto-commit black formatting
actions-user Jan 24, 2025
19a6737
[debug] Print in_file
LouConreux Jan 24, 2025
7c2aad4
[debug] Print in_file
LouConreux Jan 24, 2025
4588d57
[debug] Print in_file
LouConreux Jan 24, 2025
f27afd5
[debug] Removed print in_file path
LouConreux Jan 24, 2025
eaa3dac
[edit] blablabla
LouConreux Jan 24, 2025
a46a153
[edit] Removed print line in_file
LouConreux Jan 24, 2025
5a146ad
[edit] Clean preprocess function
LouConreux Jan 24, 2025
ff7ac84
Auto-commit black formatting
actions-user Jan 24, 2025
3b0a6f1
[edit] Add different gradient computation preprocessing techniques
LouConreux Jan 25, 2025
2a08752
[edit] Add different gradient computation preprocessing techniques
LouConreux Jan 25, 2025
edb2b2a
Auto-commit black formatting
actions-user Jan 25, 2025
730ca89
[edit] Add different gradient computations ways for testing preproces…
LouConreux Jan 26, 2025
d38e248
Merge branch 'dev' of https://github.com/LouConreux/lute into dev
LouConreux Jan 26, 2025
9b27429
[edit] Plot preprocessed powder but use raw powder to compute radial …
LouConreux Jan 26, 2025
14c1508
Auto-commit black formatting
actions-user Jan 26, 2025
39fbef6
[edit] Plot preprocessed powder but use raw powder to compute radial …
LouConreux Jan 26, 2025
24ea98d
Merge branch 'dev' of https://github.com/LouConreux/lute into dev
LouConreux Jan 26, 2025
c24b538
[edit] Fix preprocessing computations
LouConreux Jan 27, 2025
d344234
Auto-commit black formatting
actions-user Jan 27, 2025
aeb8e68
[edit] Add Diagonal preprocessing computation
LouConreux Jan 27, 2025
a99b9cb
Merge branch 'dev' of https://github.com/LouConreux/lute into dev
LouConreux Jan 27, 2025
bd03f7a
Auto-commit black formatting
actions-user Jan 27, 2025
5194eda
[edit] Fix preprocessing computations
LouConreux Jan 27, 2025
9dc3a0b
Merge branch 'dev' of https://github.com/LouConreux/lute into dev
LouConreux Jan 27, 2025
09d293a
[edit] Fix preprocessing computations
LouConreux Jan 27, 2025
66142a7
[edit] Change plots for histogram of intensities
LouConreux Jan 29, 2025
3808277
[edit] Change plots for histogram of intensities
LouConreux Jan 29, 2025
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
5 changes: 4 additions & 1 deletion config/templates/smd_producer_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,10 @@ def get_sd_file(write_dir, exp, hutch):
sumDict={'Sums': {}}
for det in dets:
for key in det.storeSum().keys():
sumData=small_data.sum(det.storeSum()[key])
if 'max' in key:
sumData=small_data.max(det.storeSum()[key])
else:
sumData=small_data.sum(det.storeSum()[key])
sumDict['Sums']['%s_%s'%(det._name, key)]=sumData
if len(sumDict['Sums'].keys())>0:
# print(sumDict)
Expand Down
2 changes: 1 addition & 1 deletion lute/execution/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1151,7 +1151,7 @@ def _submit_cmd(self, executable_path: str, params: str) -> str:
nprocs: int = max(
int(os.environ.get("SLURM_NPROCS", len(os.sched_getaffinity(0)))) - 1, 1
)
mpi_cmd: str = f"mpirun -np {nprocs}"
mpi_cmd: str = f"mpirun -np {nprocs} --map-by core"
if __debug__:
py_cmd = f"python -B -u -m mpi4py.run {executable_path} {params}"
else:
Expand Down
12 changes: 12 additions & 0 deletions lute/execution/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,22 @@ def get_logger(name: str, is_task: bool = True) -> logging.Logger:
other_logger, logging.PlaceHolder
):
other_logger.disabled = True
elif "pyFAI" in other_name and not isinstance(
other_logger, logging.PlaceHolder
):
other_logger.disabled = True
elif "goniometer" in other_name and not isinstance(
other_logger, logging.PlaceHolder
):
other_logger.disabled = True
elif "numpy" in other_name and not isinstance(
other_logger, logging.PlaceHolder
):
other_logger.setLevel(logging.CRITICAL)
elif "numexpr.utils" in other_name and not isinstance(
other_logger, logging.PlaceHolder
):
other_logger.setLevel(logging.WARNING)
logger: logging.Logger = logging.getLogger(name)
logger.propagate = False
handler: logging.Handler
Expand Down
1 change: 1 addition & 0 deletions lute/io/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
from .tests import *
from .mpi_tests import *
from .geometry import *
from .bayfai import *
165 changes: 165 additions & 0 deletions lute/io/models/bayfai.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
"""Models for optimizing detector geometry using PyFAI and Bayesian optimization.

Classes:
- OptimizePyFAIGeometryParameters(TaskParameters):
Parameters for optimizing detector geometry using PyFAI and Bayesian optimization.
"""

__all__ = ["OptimizePyFAIGeometryParameters"]
__author__ = "Louis Conreux"

from typing import Any, Dict, Optional, Union, Tuple

from pydantic import BaseModel, Field, validator

from lute.io.models.base import TaskParameters
from lute.io.models.validators import validate_smd_path, validate_calib_path


class OptimizePyFAIGeometryParameters(TaskParameters):
"""Parameters for optimizing detector geometry using PyFAI and Bayesian optimization.

The Bayesian Optimization has default hyperparameters that can be overriden by the user.
"""

class Config(TaskParameters.Config):
set_result: bool = True
"""Whether the Executor should mark a specified parameter as a result."""

class BayesGeomOptParameters(BaseModel):
"""Bayesian optimization hyperparameters."""

bounds: Dict[str, Union[float, Tuple[float, float]]] = Field(
{
"dist": (0.02, 0.6),
"poni1": (-0.01, 0.01),
"poni2": (-0.01, 0.01),
},
description="Bounds defining the parameter search space for the Bayesian optimization.",
)

res: float = Field(
None,
description="Resolution of the grid used to discretize the parameter search space.",
)

max_rings: int = Field(
5,
description="Maximum number of rings to be used for the Bayesian optimization.",
)

n_samples: Optional[int] = Field(
20,
description="Number of random starts to initialize the Bayesian optimization.",
)

n_iterations: Optional[int] = Field(
80,
description="Number of iterations to run the Bayesian optimization.",
)

prior: Optional[bool] = Field(
True,
description="Whether to use a gaussian prior centered on the search space for the Bayesian optimization or randomly pick samples.",
)

af: Optional[str] = Field(
"ucb",
description="Acquisition function to be used by the Bayesian optimization.",
)

hyperparams: Optional[Dict[str, float]] = Field(
{
"beta": 1.96,
"epsilon": 0.01,
},
description="Hyperparameters for the acquisition function.",
)

seed: Optional[int] = Field(
None,
description="Seed for the random number generator for potential reproducibility.",
)

_find_smd_path = validate_smd_path("powder")

_find_in_file_path = validate_calib_path("in_file")

exp: str = Field(
"",
description="Experiment name.",
)

run: Union[str, int] = Field(
None,
description="Run number.",
)

det_type: str = Field(
"",
description="Detector type. Currently supported: 'ePix10k2M', 'ePix10kaQuad', 'Rayonix', 'Jungfrau1M', 'Jungfrau4M'",
)

work_dir: str = Field(
"",
description="Main working directory for LUTE.",
)

in_file: str = Field(
"",
description="Path to the input .data file containing the detector geometry info to be calibrated.",
)

powder: str = Field(
"",
description="Powder diffraction pattern to be used for the calibration.",
)

preprocess: Optional[str] = Field(
None,
description="Preprocessing method to be used for the calibration.",
)

calibrant: str = Field(
"",
description="Calibrant used for the calibration supported by pyFAI: https://github.com/silx-kit/pyFAI/tree/main/src/pyFAI/resources/calibration",
)

out_file: str = Field(
"",
description="Path to the output .data file containing the optimized detector geometry.",
is_result=True,
)

bo_params: BayesGeomOptParameters = Field(
BayesGeomOptParameters(),
description="Bayesian optimization parameters containing bounds and resolution for defining space search and hyperparameters.",
)

@validator("exp", always=True)
def validate_exp(cls, exp: str, values: Dict[str, Any]) -> str:
if not exp:
exp = values["lute_config"].experiment
return exp

@validator("run", always=True)
def validate_run(
cls, run: Union[str, int], values: Dict[str, Any]
) -> Union[str, int]:
if not run:
run = values["lute_config"].run
return run

@validator("work_dir", always=True)
def validate_work_dir(cls, work_dir: str, values: Dict[str, Any]) -> str:
if not work_dir:
work_dir = values["lute_config"].work_dir
return work_dir

@validator("out_file", always=True)
def validate_out_file(cls, out_file: str, values: Dict[str, Any]) -> str:
if not out_file:
in_file = values["in_file"]
run = values["run"]
out_file = in_file.replace("0-end.data", f"{run}-end.data")
return out_file
32 changes: 30 additions & 2 deletions lute/io/models/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
parameters for validation.
"""

__all__ = ["template_parameter_validator", "validate_smd_path"]
__author__ = "Gabriel Dorlhiac"
__all__ = ["template_parameter_validator", "validate_smd_path", "validate_calib_path"]
__author__ = ["Gabriel Dorlhiac", "Louis Conreux"]

import os
from typing import Dict, Any, Optional
Expand All @@ -15,6 +15,9 @@

from lute.io.db import read_latest_db_entry

import psana # type: ignore
from PSCalib.CalibFileFinder import find_calib_file # type: ignore


def template_parameter_validator(template_params_name: str):
"""Populates a TaskParameters model with a set of validated TemplateParameters.
Expand Down Expand Up @@ -68,3 +71,28 @@ def _validate_smd_path(cls, smd_path: str, values: Dict[str, Any]) -> str:
return smd_path

return validator(smd_path_name, always=True, allow_reuse=True)(_validate_smd_path)


def validate_calib_path(calib_path_name: str):
"""Finds the path to a valid calibration file or raises an error."""

def _validate_calib_path(cls, calib_path: str, values: Dict[str, Any]) -> str:
if calib_path == "":
exp: str = values["lute_config"].experiment
run: int = int(values["lute_config"].run)
try:
det_type: str = values["det_type"]
except KeyError:
det_type = values["detname"]
cdir = f"/sdf/data/lcls/ds/{exp[:3]}/{exp}/calib"
ds_args = f"exp={exp}:run={run}:idx"
ds = psana.DataSource(ds_args)
det = psana.Detector(det_type, ds.env())
src = str(det.name)
type = "geometry"
calib_path = find_calib_file(cdir, src, type, run, pbits=1)
return calib_path

return validator(calib_path_name, always=True, allow_reuse=True)(
_validate_calib_path
)
5 changes: 5 additions & 0 deletions lute/managed_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,8 @@

PeakFinderPsocake: Executor = Executor("FindPeaksPsocake")
"""Performs Bragg peak finding using psocake - *DEPRECATED*."""

# PyFAI
#######
PyFAIGeometryOptimizer: MPIExecutor = MPIExecutor("OptimizePyFAIGeometry")
"""Optimize detector geometry using PyFAI coupled with Bayesian Optimization."""
5 changes: 5 additions & 0 deletions lute/tasks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ def import_task(task_name: str) -> Type[Task]:

return TestMultiNodeCommunication

if task_name == "OptimizePyFAIGeometry":
from .bayfai import OptimizePyFAIGeometry

return OptimizePyFAIGeometry

if task_name == "OptimizeAgBhGeometryExhaustive":
from .geometry import OptimizeAgBhGeometryExhaustive

Expand Down
Loading