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
704ebd67
Commit
704ebd67
authored
1 year ago
by
Karim Ahmed
Browse files
Options
Downloads
Patches
Plain Diff
refactor get_gain_mode and split code
parent
1353ac35
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!901
Draft: Tests/add more agipd tests
,
!900
[Jungfrau][DARK] Validate and reorder dark runs before processing
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/cal_tools/jungfraulib.py
+18
-16
18 additions, 16 deletions
src/cal_tools/jungfraulib.py
with
18 additions
and
16 deletions
src/cal_tools/jungfraulib.py
+
18
−
16
View file @
704ebd67
from
typing
import
Optional
,
Tuple
from
logging
import
warning
from
typing
import
Tuple
import
extra_data
from
cal_tools.enums
import
JungfrauGainMode
,
JungfrauSettings
from
cal_tools.enums
import
JungfrauGainMode
as
JGM
from
cal_tools.enums
import
JungfrauSettings
def
_old_settings_to_new
(
settings
:
str
,
index
:
int
)
->
str
:
...
...
@@ -98,22 +100,22 @@ class JungfrauCtrl():
else
:
# JungfrauSettings.GAIN_0
return
0
def
get_gain_mode
(
self
)
->
int
:
"""
Get gain mode value. Fixed `1` or Adaptive `1`.
- `0` if run_mode = dynamic, forceswitchg1, forceswitchg2, or None.
- `1` if run_mode = fixg1 or fixg2.
"""
def
get_gain_mode_str
(
self
):
# Check if run_mode is of an old settings to convert
# into new mode value.
if
self
.
run_mode
in
[
m
.
value
for
m
in
J
ungfrauGainMode
]:
mode
=
self
.
run_mode
if
self
.
run_mode
in
[
m
.
value
for
m
in
J
GM
]:
return
self
.
run_mode
else
:
mode
=
_old_settings_to_new
(
self
.
run_mode
,
1
)
if
mode
in
[
JungfrauGainMode
.
FIX_GAIN_1
.
value
,
JungfrauGainMode
.
FIX_GAIN_2
.
value
,
]:
return
_old_settings_to_new
(
self
.
run_mode
,
1
)
def
get_gain_mode
(
self
)
->
int
:
"""
Get gain mode value. Fixed `1` or Adaptive `0`.
Returns:
(int): gain mode parameter condition
"""
gm_enum
=
self
.
get_gain_mode_str
()
if
gm_enum
in
[
JGM
.
FIX_GAIN_1
.
value
,
JGM
.
FIX_GAIN_2
.
value
]:
return
1
else
:
# DYNAMIC, FORCE_SWITCH_G1,
or
FORCE_SWITCH_G2
else
:
# DYNAMIC, FORCE_SWITCH_G1, FORCE_SWITCH_G2
or None
return
0
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