Skip to content

Commit

Permalink
Minor bugfix and minor logging message updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
RemingtonRohel committed Nov 6, 2024
1 parent f55a5c1 commit fdb221a
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 41 deletions.
6 changes: 3 additions & 3 deletions src/data_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def output_data(
log.info(
"wrote record",
write_time=write_time * 1e3,
time_units="ms",
time_unit="ms",
dataset_name=self.timestamp,
)

Expand Down Expand Up @@ -670,7 +670,7 @@ def main():
expected_type=int,
)
log.debug(
"Received CFS sequence, increasing expected_sqn_num",
"received CFS sequence, increasing expected_sqn_num",
cfs_sqn_num=cfs_sqn_num,
)
cfs_nums.append(cfs_sqn_num)
Expand Down Expand Up @@ -750,7 +750,7 @@ def main():
log.info(
f"parsed sequence {pd.sequence_num}",
parse_time=parse_time * 1e3,
time_units="ms",
time_unit="ms",
slice_ids=[dset.slice_id for dset in pd.output_datasets],
)

Expand Down
68 changes: 33 additions & 35 deletions src/radar_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,8 +437,8 @@ def make_next_samples(radctrl_params):
new_sequence_time = datetime.utcnow() - radctrl_params.start_time
log.verbose(
"make new sequence time",
new_sequence_time=new_sequence_time,
new_sequence_time_units="s",
time=new_sequence_time,
time_unit="s",
)


Expand Down Expand Up @@ -499,10 +499,21 @@ def create_dw_message(radctrl_params):
message.experiment_name = radctrl_params.experiment.experiment_name
message.experiment_comment = radctrl_params.experiment.comment_string
message.rx_ctr_freq = radctrl_params.experiment.slice_dict[0].rxctrfreq
if radctrl_params.aveperiod.cfs_flag:
if isinstance(radctrl_params.aveperiod, CFSAveragingPeriod):
message.num_sequences = (
radctrl_params.num_sequences - 1
) # first sequence was CFS
message.cfs_freqs = radctrl_params.cfs_params.cfs_freq
message.cfs_noise = [
x[radctrl_params.aveperiod.beam_iter]
for x in radctrl_params.cfs_params.cfs_mags.values()
]
message.cfs_range = radctrl_params.cfs_params.cfs_range
message.cfs_masks = [
x[radctrl_params.aveperiod.beam_iter]
for x in radctrl_params.cfs_params.cfs_masks.values()
]
message.cfs_slice_ids = radctrl_params.aveperiod.cfs_slice_ids
else:
message.num_sequences = radctrl_params.num_sequences
message.last_sqn_num = radctrl_params.last_sequence_num
Expand All @@ -513,17 +524,6 @@ def create_dw_message(radctrl_params):
lambda x, y: x * y, radctrl_params.decimation_scheme.filter_scaling_factors
) # multiply all
message.scheduling_mode = radctrl_params.experiment.scheduling_mode
message.cfs_freqs = radctrl_params.cfs_params.cfs_freq
message.cfs_noise = [
x[radctrl_params.aveperiod.beam_iter]
for x in radctrl_params.cfs_params.cfs_mags.values()
]
message.cfs_range = radctrl_params.cfs_params.cfs_range
message.cfs_masks = [
x[radctrl_params.aveperiod.beam_iter]
for x in radctrl_params.cfs_params.cfs_masks.values()
]
message.cfs_slice_ids = radctrl_params.aveperiod.cfs_slice_ids

for sequence_index, sequence in enumerate(radctrl_params.aveperiod.sequences):
sequence_add = messages.Sequence()
Expand Down Expand Up @@ -704,12 +704,13 @@ def cfs_block(ave_params, cfs_sockets):
ave_params.num_sequences += 1
ave_params.cfs_scan_flag = False
aveperiod.cfs_freq = processed_cfs_packet.cfs_freq
ave_params.cfs_params.cfs_freq = processed_cfs_packet.cfs_freq

for ind, dset in enumerate(processed_cfs_packet.output_datasets):
aveperiod.cfs_mags[aveperiod.cfs_slice_ids[ind]][beam] = dset.cfs_data

if (
not all([x[beam] for x in aveperiod.set_new_freq.values()])
not any([x[beam] for x in aveperiod.set_new_freq.values()])
and aveperiod.cfs_pwr_threshold is not None
):
# If using a user set power threshold to trigger CFS freq setting, check if any
Expand Down Expand Up @@ -984,8 +985,8 @@ def main():
averaging_period_start_time = datetime.utcnow() # ms
log.verbose(
"averaging period start time",
averaging_period_start_time=averaging_period_start_time,
averaging_period_start_time_units="",
time=averaging_period_start_time,
time_unit="s",
)
if aveperiod.intt is not None:
intt_break = True
Expand All @@ -1002,16 +1003,16 @@ def main():
if first_aveperiod:
log.verbose(
"seconds to next avg period",
time_until_avg_period=time_diff.total_seconds(),
time_until_avg_period_units="s",
time=time_diff.total_seconds(),
time_unit="s",
scan_iter=scan_iter,
beam_scanbound=beam_scanbound,
)
else:
log.debug(
"seconds to next avg period",
time_until_avg_period=time_diff.total_seconds(),
time_until_avg_period_units="s",
time=time_diff.total_seconds(),
time_unit="s",
scan_iter=scan_iter,
beam_scanbound=beam_scanbound,
)
Expand All @@ -1030,8 +1031,8 @@ def main():
averaging_period_start_time = datetime.utcnow()
log.verbose(
"avg period start time",
avg_period_start_time=averaging_period_start_time,
avg_period_start_time_units="s",
time=averaging_period_start_time,
time_unit="s",
scan_iter=scan_iter,
beam_scanbound=beam_scanbound,
)
Expand Down Expand Up @@ -1059,8 +1060,8 @@ def main():

log.verbose(
"bound time remaining",
bound_time_remaining=bound_time_remaining,
bound_time_remaining_units="s",
time=bound_time_remaining,
time_unit="s",
scan_num=scan_num,
scan_iter=scan_iter, # scan_iter is averaging period number for some reason
beam_scanbound=beam_scanbound,
Expand Down Expand Up @@ -1099,8 +1100,8 @@ def main():
aveperiod_prep_time = datetime.utcnow() - time_start_of_aveperiod
log.verbose(
"time to prep aveperiod",
aveperiod_prep_time=aveperiod_prep_time,
aveperiod_prep_time_units="",
time=aveperiod_prep_time,
time_unit="",
)

# Time to start averaging in the below loop
Expand Down Expand Up @@ -1216,8 +1217,8 @@ def main():
avg_period_end_time = datetime.utcnow()
log.verbose(
"avg period end time",
avg_period_end_time=avg_period_end_time,
avg_period_end_time_units="s",
time=avg_period_end_time,
time_unit="s",
)

log.info(
Expand All @@ -1234,11 +1235,8 @@ def main():
ave_params.scan_flag = False

ave_params.last_sequence_num = (
ave_params.seqnum_start + ave_params.num_sequences
ave_params.seqnum_start + ave_params.num_sequences - 1
)
if ave_params.cfs_scan_flag:
ave_params.last_sequence_num -= 1

dw_message = create_dw_message(ave_params)
dw_comms_socket.send_pyobj(dw_message)
# Send metadata to dw_comms_thread, so it can package into a message for data write
Expand All @@ -1252,8 +1250,8 @@ def main():
time_to_finish_aveperiod = datetime.utcnow() - avg_period_end_time
log.verbose(
"time to finish avg period",
avg_period_elapsed_time=time_to_finish_aveperiod,
avg_period_elapsed_time_units="s",
time=time_to_finish_aveperiod,
time_unit="s",
)

aveperiod.beam_iter += 1
Expand Down
6 changes: 3 additions & 3 deletions src/rx_signal_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def sequence_worker(options, ringbuffer):
processed_socket = sequence_worker_sockets[2]

# Generate a timer dict for a uniform log
log_dict = {"time_units": "ms"}
log_dict = {"time_unit": "ms"}
start_timer = time.perf_counter()

# Copy samples from ring buffer
Expand Down Expand Up @@ -330,7 +330,7 @@ def sequence_worker(options, ringbuffer):
)

# Generate a new timer dict for a uniform log
log_dict = {"time_units": "ms"}
log_dict = {"time_unit": "ms"}
start_timer = time.perf_counter()

# Extract outputs from processing into groups that will be put into message fields.
Expand Down Expand Up @@ -487,7 +487,7 @@ def debug_data_in_shm(holder, data_array, array_name):
"done with sequence",
sequence_num=rx_params.sequence_num,
processing_time=total_processing_time,
time_units="ms",
time_unit="ms",
slice_ids=[d["slice_id"] for d in rx_params.slice_details],
)
log.verbose("sequence timing", sequence_num=rx_params.sequence_num, **log_dict)
Expand Down

0 comments on commit fdb221a

Please sign in to comment.