Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tango
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira issues
Open Jira
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LOFAR2.0
tango
Commits
633d7984
Commit
633d7984
authored
4 years ago
by
Jan David Mol
Browse files
Options
Downloads
Patches
Plain Diff
L2SS-192
: Improved naming & comments of extract_bits.
parent
f82b7bde
No related branches found
No related tags found
1 merge request
!45
L2SS-192: Provide interface for raw header fields, add example packet (needs...
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
devices/SDP_statistics.py
+17
-17
17 additions, 17 deletions
devices/SDP_statistics.py
with
17 additions
and
17 deletions
devices/SDP_statistics.py
+
17
−
17
View file @
633d7984
...
...
@@ -4,19 +4,19 @@ import numpy
__all__
=
[
"
StatisticsPacket
"
]
def
extract_bits
(
value
:
bytes
,
first
:
int
,
last
:
int
=
None
)
->
int
:
"""
Return bits [first
:las
t] from value, and return their integer value. Bit 0 = LSB.
def
get_bit_value
(
value
:
bytes
,
first
_bit
:
int
,
last
_bit
:
int
=
None
)
->
int
:
"""
Return bits [first
_bit:last_bi
t] from value, and return their integer value. Bit 0 = LSB.
For example, extracting bits 2-3 from b
'
01100
'
returns 11 binary = 3 decimal:
extract_bits
(b
'
01100
'
, 2, 3) == 3
get_bit_value
(b
'
01100
'
, 2, 3) == 3
If last is not given, just the value of bit
'
first
'
is returned.
"""
If
'
last
_bit
'
is not given, just the value of bit
'
first
_bit
'
is returned.
"""
# default last to first
if
last
is
None
:
last
=
first
# default last
_bit
to first
_bit
if
last
_bit
is
None
:
last
_bit
=
first
_bit
return
value
>>
first
&
((
1
<<
(
last
-
first
+
1
))
-
1
)
return
value
>>
first
_bit
&
((
1
<<
(
last
_bit
-
first
_bit
+
1
))
-
1
)
class
StatisticsPacket
(
object
):
"""
...
...
@@ -71,15 +71,15 @@ class StatisticsPacket(object):
return
{
"
_raw
"
:
bits
,
"
antenna_band_index
"
:
extract_bits
(
bits
,
15
),
"
nyquist_zone_index
"
:
extract_bits
(
bits
,
13
,
14
),
"
t_adc
"
:
extract_bits
(
bits
,
12
),
"
fsub_type
"
:
extract_bits
(
bits
,
11
),
"
payload_error
"
:
extract_bits
(
bits
,
10
),
"
beam_repositioning_flag
"
:
extract_bits
(
bits
,
9
),
"
subband_calibrated_flag
"
:
extract_bits
(
bits
,
8
),
"
reserved
"
:
extract_bits
(
bits
,
5
,
7
),
"
gn_index
"
:
extract_bits
(
bits
,
0
,
4
),
"
antenna_band_index
"
:
get_bit_value
(
bits
,
15
),
"
nyquist_zone_index
"
:
get_bit_value
(
bits
,
13
,
14
),
"
t_adc
"
:
get_bit_value
(
bits
,
12
),
"
fsub_type
"
:
get_bit_value
(
bits
,
11
),
"
payload_error
"
:
get_bit_value
(
bits
,
10
),
"
beam_repositioning_flag
"
:
get_bit_value
(
bits
,
9
),
"
subband_calibrated_flag
"
:
get_bit_value
(
bits
,
8
),
"
reserved
"
:
get_bit_value
(
bits
,
5
,
7
),
"
gn_index
"
:
get_bit_value
(
bits
,
0
,
4
),
}
@property
...
...
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