Skip to content
GitLab
Explore
Sign in
Register
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LOFAR2.0
tango
Commits
48a9e41a
Commit
48a9e41a
authored
9 months ago
by
Jan David Mol
Browse files
Options
Downloads
Patches
Plain Diff
Fix delay compensation as well
parent
945203b7
No related branches found
Tags
Tags containing commit
1 merge request
!996
L2SS-2017: Fix rounding of input samples delay
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
tangostationcontrol/tangostationcontrol/common/calibration.py
+8
-12
8 additions, 12 deletions
...ostationcontrol/tangostationcontrol/common/calibration.py
tangostationcontrol/test/common/test_calibration.py
+14
-21
14 additions, 21 deletions
tangostationcontrol/test/common/test_calibration.py
with
22 additions
and
33 deletions
tangostationcontrol/tangostationcontrol/common/calibration.py
+
8
−
12
View file @
48a9e41a
...
...
@@ -238,8 +238,8 @@ def delay_compensation(delays_seconds: numpy.ndarray, clock: int):
# chain, while input_* are the amount of (negative) delay to apply
# to compensate.
# compute the
coarse
correction, in samples
signal_delays_samples
=
numpy
.
round
(
delays_seconds
*
clock
).
astype
(
numpy
.
uint32
)
# compute the correction, in samples
signal_delays_samples
=
delays_seconds
*
clock
# correct for the coarse delay by delaying the other signals to line up
# we cannot configure a negative number of samples, so we must delay
...
...
@@ -247,13 +247,11 @@ def delay_compensation(delays_seconds: numpy.ndarray, clock: int):
#
# This introduces a constant shift in timing for all samples,
# as we shift all of them to obtain a non-negative delay.
input_delays_samples
=
max
(
signal_delays_samples
)
-
signal_delays_samples
# compute the remainder, in seconds
signal_delays_subsample_seconds
=
delays_seconds
-
signal_delays_samples
/
clock
input_delays_subsample_seconds
=
-
signal_delays_subsample_seconds
input_delays_samples
=
numpy
.
round
(
max
(
signal_delays_samples
)
-
signal_delays_samples
)
return
input_delays_samples
,
input_delays_subsample_seconds
return
input_delays_samples
def
calibrate_input_samples_delay
(
...
...
@@ -273,7 +271,7 @@ def calibrate_input_samples_delay(
# compute the required compensation
clock
=
sdpfirmware
.
clock_RW
input_samples_delay
,
_
=
delay_compensation
(
signal_delay_seconds
,
clock
)
input_samples_delay
=
delay_compensation
(
signal_delay_seconds
,
clock
)
# read-modify-write on [fpga][(input, polarisation)]
fpga_signal_input_samples_delay
=
sdp
.
FPGA_signal_input_samples_delay_RW
...
...
@@ -341,8 +339,6 @@ def loss_compensation(losses_dB: numpy.ndarray):
signal_attenuation_integer_dB
=
numpy
.
round
(
losses_dB
).
astype
(
numpy
.
uint32
)
# correct for the coarse loss by dampening the signals to line up.
input_attenuation_integer_dB
=
numpy
.
round
(
numpy
.
max
(
losses_dB
)
-
losses_dB
)
input_attenuation_integer_dB
=
numpy
.
round
(
numpy
.
max
(
losses_dB
)
-
losses_dB
)
return
input_attenuation_integer_dB
This diff is collapsed.
Click to expand it.
tangostationcontrol/test/common/test_calibration.py
+
14
−
21
View file @
48a9e41a
...
...
@@ -239,24 +239,13 @@ class TestDelayCompensation(base.TestCase):
# compute delay compensation
return
delay_compensation
(
delays_seconds
,
clock
)
def
test_whole_sample_shifts_no_remainder
(
self
):
"""
Test whether delay compensation indeed has no remainder if we shift whole samples.
"""
# delay to compensate for, in samples
delay_samples
=
[
1
,
2
,
3
,
4
]
_
,
remainder_seconds
=
self
.
_compute_delay_compensation
(
delay_samples
)
# verify that there is no remainder
self
.
assertTrue
(
numpy
.
all
(
remainder_seconds
==
0.0
),
msg
=
f
"
{
remainder_seconds
}
"
)
def
test_sample_shifts_line_up
(
self
):
"""
Test whether signals line up after the computed delay compensation.
"""
# delay to compensate for, in samples
delay_samples
=
[
1
,
2
,
3
,
4
]
sample_shift
,
_
=
self
.
_compute_delay_compensation
(
delay_samples
)
sample_shift
=
self
.
_compute_delay_compensation
(
delay_samples
)
# sample_shift and delay_samples together should line everything up
effective_signal_delay
=
delay_samples
+
sample_shift
...
...
@@ -272,19 +261,23 @@ class TestDelayCompensation(base.TestCase):
"""
Test correctness of the delay compensation remainders.
"""
# delays in samples we want to compensate for. they all round to the same sample
delay_samples
=
[
0.7
5
,
1.0
,
1.25
]
delay_samples
=
[
0.7
6
,
1.0
,
1.25
]
sample_shift
,
remainder_seconds
=
self
.
_compute_delay_compensation
(
delay_samples
)
sample_shift
=
self
.
_compute_delay_compensation
(
delay_samples
)
# should not result in any sample shifts
self
.
assertEqual
(
0
,
sample_shift
[
0
])
self
.
assertEqual
(
0
,
sample_shift
[
1
])
self
.
assertEqual
(
0
,
sample_shift
[
2
])
# remainder should correspond with differences.
# NB: these are the remainders to apply to line up the signals.
self
.
assertAlmostEqual
(
+
0.25
,
remainder_seconds
[
0
]
/
5e-9
)
self
.
assertAlmostEqual
(
0.00
,
remainder_seconds
[
1
]
/
5e-9
)
self
.
assertAlmostEqual
(
-
0.25
,
remainder_seconds
[
2
]
/
5e-9
)
def
test_delay_round_nearest
(
self
):
"""
Test correctness of the delay compensation rounding.
"""
# delays in samples we want to compensate for. they all round to the same sample
delay_samples
=
[
0.0
,
1.6
]
sample_shift
=
self
.
_compute_delay_compensation
(
delay_samples
)
# should not result in any sample shifts
self
.
assertEqual
(
2
,
sample_shift
[
0
])
self
.
assertEqual
(
0
,
sample_shift
[
1
])
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