Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
Live integration
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Koziej Lab
X-ray Diffraction
PDF
Live integration
Commits
eee0de89
Commit
eee0de89
authored
1 month ago
by
Gröne, Tjark Leon Raphael
Browse files
Options
Downloads
Patches
Plain Diff
Update 2 files
- /maxwell_integrate_to_h5.py - /maxwell_int_to_h5.sh
parent
400c67ce
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
maxwell_int_to_h5.sh
+2
-2
2 additions, 2 deletions
maxwell_int_to_h5.sh
maxwell_integrate_to_h5.py
+26
-21
26 additions, 21 deletions
maxwell_integrate_to_h5.py
with
28 additions
and
23 deletions
maxwell_int_to_h5.sh
+
2
−
2
View file @
eee0de89
...
...
@@ -18,7 +18,7 @@ plarization=0.99
number_of_points
=
4500
unit
=
"q_A^-1"
error
=
"azimuthal"
forbidden
=(
"0p2"
)
#forbidden subdirectories, if you want to integrate all subdirs, set this to ()
module load maxwell
...
...
@@ -26,4 +26,4 @@ module load conda
module load pyFAI
activate FlyPDF
cd
/asap3/petra3/gpfs/p21.1/2025/data/11021216/shared/Integration/
python3 maxwell_integrate_with_subdirs.py
$path_raw_data
$path_integrated_data
$fpath_poni
$fpath_mask
$NPROCS
$plarization
$number_of_points
$unit
$error
$format
#Start python script
python3 maxwell_integrate_with_subdirs.py
$path_raw_data
$path_integrated_data
$fpath_poni
$fpath_mask
$NPROCS
$plarization
$number_of_points
$unit
$error
$format
$forbidden
#Start python script
This diff is collapsed.
Click to expand it.
maxwell_integrate_to_h5.py
+
26
−
21
View file @
eee0de89
...
...
@@ -28,12 +28,12 @@ def integrate_ims_in_dir(path_im, path_int, dtype_im=".tif", dtype_int=".dat"):
:param
'
str
'
dtype_int: data type/filename ending of pattern file
"""
global
NPROC
global
FORBIDDEN
fnames_ims
=
[]
#= glob(os.path.join(path_im, "*" + dtype_im))
path_int_list
=
[]
for
path
,
subdirs
,
files
in
os
.
walk
(
path_im
):
for
name
in
files
:
if
(
"
cu
"
not
in
name
)
or
(
"
Cu
"
not
in
name
)
or
(
"
np
"
not
in
name
):
if
"
sdd500
"
not
in
name
and
"
sdd750
"
not
in
name
and
"
sdd1000
"
not
in
name
:
if
FORBIDDEN
not
in
name
:
fnames_ims
.
append
(
os
.
path
.
join
(
path
,
name
))
if
path_im
!=
str
(
path
):
path_new
=
str
(
path
).
replace
(
path_im
,
''
)
...
...
@@ -96,24 +96,28 @@ def integrate_ims_in_dir(path_im, path_int, dtype_im=".tif", dtype_int=".dat"):
results_df
=
pd
.
concat
([
results_df
,
pd
.
DataFrame
(
data
)],
ignore_index
=
True
)
pool
=
Pool
(
int
(
NPROC
))
for
subdir
in
set
(
os
.
path
.
dirname
(
fname
)
for
fname
in
fnames_ims
):
subdir_fnames
=
[
fname
for
fname
in
fnames_ims
if
os
.
path
.
dirname
(
fname
)
==
subdir
]
subdir_path_int
=
path_int_list
[
fnames_ims
.
index
(
subdir_fnames
[
0
])]
for
i
,
fname_im
in
enumerate
(
fnames
_ims
)
:
pool
.
apply_async
(
integration_thread
,
(
fname_im
,
path_int
_list
[
i
]
))
for
fname_im
in
subdir_
fnames
:
pool
.
apply_async
(
integration_thread
,
(
fname_im
,
subdir_
path_int
))
# Export the DataFrame to a CSV file with the name of the directory
pool
.
close
()
pool
.
join
()
# Export the DataFrame to a CSV file with the name of the subdirectory
if
'
results_df
'
in
globals
():
results_df
=
results_df
.
sort_values
(
by
=
"
filename
"
,
key
=
lambda
col
:
col
.
str
.
lower
())
dir
ectory
_name
=
os
.
path
.
basename
(
os
.
path
.
normpath
(
path_int
))
results_df
.
to_csv
(
os
.
path
.
join
(
path_int
,
f
"
{
dir
ectory
_name
}
.csv
"
),
index
=
False
)
results_df
.
to_hdf
(
os
.
path
.
join
(
path_int
,
f
"
{
dir
ectory
_name
}
.h5
"
),
key
=
'
data
'
,
mode
=
'
w
'
)
sub
dir_name
=
os
.
path
.
basename
(
os
.
path
.
normpath
(
subdir_
path_int
))
results_df
.
to_csv
(
os
.
path
.
join
(
subdir_
path_int
,
f
"
{
sub
dir_name
}
.csv
"
),
index
=
False
)
results_df
.
to_hdf
(
os
.
path
.
join
(
subdir_
path_int
,
f
"
{
sub
dir_name
}
.h5
"
),
key
=
'
data
'
,
mode
=
'
w
'
)
del
results_df
else
:
print
(
"
No images were integrated. No results DataFrame created.
"
)
print
(
f
"
No images were integrated in subdirectory
{
subdir
}
. No results DataFrame created.
"
)
pool
.
close
()
pool
.
join
()
# Reset the pool for the next subdirectory
pool
=
Pool
(
int
(
NPROC
))
def
integrate_on_created
(
event
,
path_int
,
dtype_im
=
"
.tif
"
,
dtype_int
=
"
.dat
"
):
...
...
@@ -231,6 +235,7 @@ if __name__ == '__main__':
UNIT
=
str
(
sys
.
argv
[
8
])
ERRORMODE
=
str
(
sys
.
argv
[
9
]).
lower
()
DATATYPE
=
str
(
sys
.
argv
[
10
]).
lower
()
FORBIDDEN
=
sys
.
argv
[
11
].
split
(
'
,
'
)
if
len
(
sys
.
argv
)
>
11
else
[]
if
DATATYPE
not
in
{
"
tif
"
,
"
tiff
"
,
"
TIF
"
,
"
TIFF
"
}:
raise
ValueError
(
f
"
Unsupported data type:
{
DATATYPE
}
"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment