Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pycalibration
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
calibration
pycalibration
Commits
28a16411
Commit
28a16411
authored
3 years ago
by
Karim Ahmed
Browse files
Options
Downloads
Patches
Plain Diff
keep using pulse range instead of pulse_list
parent
5609b5f4
No related branches found
No related tags found
1 merge request
!557
Fix/select max pulses
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/cal_tools/agipdlib.py
+44
-57
44 additions, 57 deletions
src/cal_tools/agipdlib.py
with
44 additions
and
57 deletions
src/cal_tools/agipdlib.py
+
44
−
57
View file @
28a16411
...
@@ -252,7 +252,7 @@ class AgipdCorrections:
...
@@ -252,7 +252,7 @@ class AgipdCorrections:
self
.
gain_mode
=
gain_mode
self
.
gain_mode
=
gain_mode
self
.
comp_threads
=
comp_threads
self
.
comp_threads
=
comp_threads
self
.
pulses_lst
=
self
.
_validate_selected_pulses
(
max_pulses
,
max_cells
)
self
.
_validate_selected_pulses
(
max_pulses
,
max_cells
)
# Correction parameters
# Correction parameters
self
.
baseline_corr_noise_threshold
=
-
1000
self
.
baseline_corr_noise_threshold
=
-
1000
...
@@ -871,9 +871,6 @@ class AgipdCorrections:
...
@@ -871,9 +871,6 @@ class AgipdCorrections:
:param max_pulses: a list of at most 3 elements defining the
:param max_pulses: a list of at most 3 elements defining the
range of pulses to calibrate.
range of pulses to calibrate.
:param max_cells: operating memory cells.
:param max_cells: operating memory cells.
:return :
- pulses_list: a list of pulses to calibrate.
"""
"""
# Validate selected pulses range:
# Validate selected pulses range:
...
@@ -888,41 +885,41 @@ class AgipdCorrections:
...
@@ -888,41 +885,41 @@ class AgipdCorrections:
"
maximum pulse.
"
"
maximum pulse.
"
)
)
# Create list of pulses out of selected range.
value_error
=
False
try
:
if
len
(
pulses_range
)
==
1
:
pulses_lst
=
(
self
.
start
=
0
list
(
range
(
*
pulses_range
))
self
.
last
=
pulses_range
[
0
]
if
pulses_range
!=
[
0
]
self
.
step
=
1
else
pulses_range
elif
len
(
pulses_range
)
==
2
:
)
self
.
start
=
pulses_range
[
0
]
except
TypeError
as
e
:
self
.
last
=
pulses_range
[
1
]
print
(
self
.
step
=
1
f
"
ERROR: Wrong type for
\"
max_pulses
\"
:
{
max_pulses
}
.
"
if
pulses_range
[
0
]
>
pulses_range
[
1
]:
f
"
\n
{
traceback
.
format_exc
()
}
"
value_error
=
True
)
elif
len
(
pulses_range
)
==
3
:
self
.
start
=
pulses_range
[
0
]
self
.
last
=
pulses_range
[
1
]
self
.
step
=
pulses_range
[
2
]
if
pulses_range
[
0
]
>
pulses_range
[
1
]:
value_error
=
True
else
:
value_error
=
True
try
:
if
value_error
:
if
len
(
pulses_lst
)
>
1
:
raise
ValueError
(
print
(
"
ERROR: Wrong given range of pulse indices to correct.
"
f
"
A range of
{
len
(
pulses_lst
)
}
pulse indices
"
"
Please check the given range for
\"
max_pulses
\"
:
"
f
"
is selected: from
{
pulses_lst
[
0
]
}
to
"
f
"
{
max_pulses
}
.
\"
max_pulses
\"
needs to be a list of
"
f
"
{
pulses_lst
[
-
1
]
+
(
pulses_lst
[
1
]
-
pulses_lst
[
0
])
}
"
"
3 elements, [start, last, step]
"
)
f
"
with a step of
{
pulses_lst
[
1
]
-
pulses_lst
[
0
]
}
.
"
)
if
not
np
.
all
([
isinstance
(
p
,
int
)
for
p
in
max_pulses
]):
else
:
raise
TypeError
(
print
(
"
ERROR:
\"
max_pulses
\"
elements needs to be integers:
"
"
One pulse is selected: a pulse of idx
"
f
"
{
max_pulses
}
.
"
)
f
"
{
pulses_lst
[
0
]
}
.
"
)
except
ValueError
as
e
:
print
(
f
"
ERROR: A list of pulses:
{
pulses_lst
}
, is given to
"
"
calibrate. Please check the given value for
"
f
"
\"
max_pulses
\"
:
{
max_pulses
}
.
\n
"
f
"
{
traceback
.
format_exc
()
}
.
"
)
return
pulses_lst
print
(
"
A range of pulse indices is selected to correct:
"
f
"
{
pulses_range
}
"
)
def
choose_selected_pulses
(
self
,
allpulses
:
np
.
array
,
def
choose_selected_pulses
(
self
,
allpulses
:
np
.
array
,
can_calibrate
:
np
.
array
)
->
np
.
array
:
can_calibrate
:
np
.
array
)
->
np
.
array
:
...
@@ -939,27 +936,17 @@ class AgipdCorrections:
...
@@ -939,27 +936,17 @@ class AgipdCorrections:
selected pulses
selected pulses
"""
"""
# collect the pulses to be calibrated
# Check interesection between array of booleans and
cal_pulses
=
allpulses
[
self
.
pulses_lst
]
# array of pulses to calibrate.
can_calibrate
=
np
.
logical_and
(
# Check if a non-contiguous pulses list will be calibrated.
np
.
logical_and
(
if
(
len
(
self
.
pulses_lst
)
>
1
and
self
.
pulses_lst
[
1
]
-
self
.
pulses_lst
[
0
]
>
1
):
can_calibrate
=
np
.
logical_and
(
can_calibrate
,
np
.
isin
(
allpulses
,
cal_pulses
),
)
else
:
# Check interesection between array of booleans and
# array of pulses to calibrate.
can_calibrate
=
np
.
logical_and
(
can_calibrate
,
can_calibrate
,
(
allpulses
<=
np
.
max
(
cal_pulses
)),
np
.
logical_and
(
(
allpulses
>=
np
.
min
(
cal_pulses
)),
allpulses
>=
allpulses
[
self
.
start
],
)
allpulses
<=
allpulses
[
self
.
last
-
1
]),
),
((
allpulses
-
allpulses
[
self
.
start
])
%
allpulses
[
self
.
step
])
==
0
,
)
return
can_calibrate
return
can_calibrate
def
gen_valid_range
(
self
,
first_index
:
int
,
last_index
:
int
,
def
gen_valid_range
(
self
,
first_index
:
int
,
last_index
:
int
,
...
...
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