Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ixstools
xrstools
Commits
07373fc5
Commit
07373fc5
authored
Dec 01, 2020
by
myron
Browse files
reorganised volume fit
parent
2a4b7d42
Changes
2
Hide whitespace changes
Inline
Side-by-side
XRStools/XRS_swissknife.py
View file @
07373fc5
...
...
@@ -2333,7 +2333,7 @@ def superR_getVolume_fullfit(mydata):
niter : 20
beta : 1.0e-8
eps : 0.000002
eps :
0.000002
###################################
# optional
...
...
@@ -3929,6 +3929,9 @@ def superR_recreate_rois(mydata):
original_roi_path : None
"""
allowed_keys
=
[
"old_scan_address"
,
"original_roi_path"
,
"responsefilename"
,
"nex"
,
"target_filename"
,
"filter_rois"
,
"recenterings_refined"
,
"filter_path"
,]
check_allowed_keys
(
mydata
,
allowed_keys
)
foil_scan_address
=
mydata
[
"old_scan_address"
]
foil_filename
,
foil_groupname
=
split_hdf5_address
(
foil_scan_address
)
...
...
@@ -4081,6 +4084,10 @@ def superR_fit_responses(mydata):
"""
allowed_keys
=
[
"foil_scan_address"
,
"ref_scan_number"
,
"response_scan_address"
,
"nref"
,
"niter_optical"
,
"beta_optical"
,
"beta_pixel"
,
"niter_pixel"
,
"niter_global"
,
"pixel_dim"
,
"simmetrizza"
,
"do_refine_trajectory"
,
"target_file"
,
"trajectory_reference_scansequence_address"
,
"trajectory_threshold"
,
"reload_trajectories_file"
,
"filter_rois"
,
"fit_lines"
,]
check_allowed_keys
(
mydata
,
allowed_keys
)
if
"foil_scan_address"
in
mydata
:
foil_scan_address
=
mydata
[
"foil_scan_address"
]
else
:
...
...
nonregressions/volumes/interpola_1/batch_extraction_esynth1.py
View file @
07373fc5
...
...
@@ -4,6 +4,7 @@ import glob
import
json
import
os
import
h5py
import
math
BATCH_PARALLELISM
=
4
...
...
@@ -57,9 +58,11 @@ def main():
selected_rois
=
list
(
range
(
0
,
24
))
+
list
(
range
(
36
,
60
)
)
scal_prod_use_optional_solution
=
False
scal_prod_load_factors
=
False
scal_prod_load_factors_from
=
"factors.json"
scal_prod_use_optional_solution
=
True
volume_retrieval_beta
=
6.0e-20
volume_retrieval_niter
=
100
scalar_products_and_volume_target_file
=
"results/scalar_products_and_volume.h5"
...
...
@@ -72,7 +75,8 @@ def main():
"do_step_fit_reference_response"
:
False
,
"do_step_resynthetise_reference"
:
False
,
"do_step_scalars"
:
True
"do_step_scalars"
:
True
,
"do_step_volume_retrieval"
:
False
,
}
...
...
@@ -120,9 +124,12 @@ def main():
selected_rois
=
selected_rois
,
scal_prod_use_optional_solution
=
scal_prod_use_optional_solution
,
scal_prod_load_factors
=
scal_prod_load_factors
,
scal_prod_load_factors_from
=
scal_prod_load_factors_from
,
scalar_products_and_volume_target_file
=
scalar_products_and_volume_target_file
scalar_products_and_volume_target_file
=
scalar_products_and_volume_target_file
,
volume_retrieval_beta
=
volume_retrieval_beta
,
volume_retrieval_niter
=
volume_retrieval_niter
)
...
...
@@ -470,7 +477,7 @@ def get_scalars( Start = None, Thickness = None ,
"""
if
scal_prod_use_optional_solution
:
input_string
=
input_string
+
"""
optional_solution : {target_file}:/_{start}_{end}/volume
optional_solution : {target_file}:/_{start}_{end}/volume
"""
if
True
:
...
...
@@ -479,7 +486,7 @@ def get_scalars( Start = None, Thickness = None ,
"""
if
scal_prod_load_factors
:
input_string
=
input_string
+
"""
load_factors_from : %s
load_factors_from : %s
"""
%
scal_prod_load_factors_from
...
...
@@ -494,6 +501,57 @@ def get_scalars( Start = None, Thickness = None ,
process_input
(
input_string
,
exploit_slurm_mpi
=
0
)
def
get_volume
(
Start
=
None
,
Thickness
=
None
,
volumes_file
=
None
,
niter
=
None
,
beta
=
None
,
):
inputstring
=
"""
superR_getVolume :
scalprods_address : {volumes_file}:/_{start}_{end}/scal_prods
target_address : {volumes_file}:/_{start}_{end}/volume
niter : {niter}
beta : {beta}
eps : 2e-07
debin : [1, 1]
"""
s
=
inputstring
.
format
(
start
=
Start
,
end
=
Start
+
Thickness
,
volumes_file
=
volumes_file
,
niter
=
niter
,
beta
=
beta
)
process_input
(
s
,
exploit_slurm_mpi
=
0
)
def
collect_factors
(
pattern
=
"factors_*_*"
,
newfile
=
"newfactors.json"
):
files
=
glob
.
glob
(
pattern
)
indexes
=
[
int
(
s
.
split
(
"_"
)[
1
])
for
s
in
files
]
order
=
np
.
argsort
(
indexes
)
files
=
[
files
[
i
]
for
i
in
order
]
print
(
files
)
files
=
files
[
1
:
-
1
]
result
=
{}
result2
=
{}
Nkeys
=
None
for
f
in
files
:
factors
=
json
.
load
(
open
(
f
,
"r"
))
if
Nkeys
is
None
:
Nkeys
=
len
(
list
(
factors
.
keys
()))
assert
(
Nkeys
==
len
(
list
(
factors
.
keys
()))
)
for
k
,
val
in
factors
.
items
():
if
k
not
in
result
:
result
[
k
]
=
0.0
result2
[
k
]
=
0.0
result
[
k
]
+=
factors
[
k
]
/
len
(
files
)
result2
[
k
]
+=
(
factors
[
k
]
*
factors
[
k
])
/
len
(
files
)
json
.
dump
(
result
,
open
(
newfile
,
"w"
)
)
keys
=
list
(
result
.
keys
()
)
keys
.
sort
(
key
=
int
)
for
k
in
keys
:
print
(
k
,
" "
,
result
[
k
]
,
" "
,
math
.
sqrt
(
result2
[
k
]
-
result
[
k
]
*
result
[
k
]
)
/
result
[
k
]
)
...
...
@@ -530,9 +588,10 @@ def tools_sequencer( peaks_shifts = None,
selected_rois
=
None
,
scal_prod_use_optional_solution
=
False
,
scal_prod_load_factors
=
False
,
scal_prod_load_factors_from
=
None
,
scalar_products_and_volume_target_file
=
None
scalar_products_and_volume_target_file
=
None
,
volume_retrieval_beta
=
None
,
volume_retrieval_niter
=
None
)
:
if
roi_path
is
None
:
...
...
@@ -631,13 +690,39 @@ def tools_sequencer( peaks_shifts = None,
signals_file
=
interpolated_signals_file
,
target_file
=
scalar_products_and_volume_target_file
,
selected_rois
=
selected_rois
,
scal_prod_use_optional_solution
=
False
,
scal_prod_use_optional_solution
=
scal_prod_use_optional_solution
,
scal_prod_load_factors
=
False
,
scal_prod_load_factors_from
=
None
)
if
(
scal_prod_use_optional_solution
):
collect_factors
(
pattern
=
"factors_*_*.json"
,
newfile
=
"newfactors.json"
)
for
start
in
range
(
first_scan_num
,
(
first_scan_num
+
Edim
*
Zdim
),
Zdim
):
get_scalars
(
Start
=
start
,
Thickness
=
Zdim
,
reference_address
=
resynthetised_reference_and_roi_target_file
+
":/rois_and_reference/scans/ScansSum"
,
signals_file
=
interpolated_signals_file
,
target_file
=
scalar_products_and_volume_target_file
,
selected_rois
=
selected_rois
,
scal_prod_use_optional_solution
=
False
,
scal_prod_load_factors
=
False
,
scal_prod_load_factors_from
=
"newfactors.json"
)
if
(
steps_to_do
[
"do_step_volume_retrieval"
]):
for
start
in
range
(
first_scan_num
,
(
first_scan_num
+
Edim
*
Zdim
),
Zdim
):
get_volume
(
Start
=
start
,
Thickness
=
Zdim
,
volumes_file
=
scalar_products_and_volume_target_file
,
beta
=
volume_retrieval_beta
,
niter
=
volume_retrieval_niter
,
)
main
()
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment