Skip to content

Amplitude Look-Up Table (LUT) Support for Waveform Processing#1696

Open
bennthomsen wants to merge 6 commits intoQCoDeS:mainfrom
bennthomsen:lut
Open

Amplitude Look-Up Table (LUT) Support for Waveform Processing#1696
bennthomsen wants to merge 6 commits intoQCoDeS:mainfrom
bennthomsen:lut

Conversation

@bennthomsen
Copy link

PR Summary: Add Amplitude Look-Up Table (LUT) Support for Waveform Processing

Description

This PR adds amplitude look-up table (LUT) functionality to broadbean, enabling users to apply non-linear amplitude transformations to waveforms during sequence output generation. This is useful for compensating for DAC non-linearities or implementing custom amplitude mappings on AWG channels.

Changes

New Features

  • setAmplitudeLUT(channel, lut_input, lut_output) - New method on Sequence class to define an amplitude LUT for a specific channel. The LUT is applied after all other waveform processing (including RC filter compensation).

  • applyAmplitudeLUT(signal, lut) - New function in ripasso.py that applies the LUT using numpy interpolation.

Files Changed

File Changes
src/broadbean/sequence.py Added setAmplitudeLUT method and LUT application in forge() and _prepareForOutputting() methods
src/broadbean/ripasso.py Added applyAmplitudeLUT function
tests/test_sequence.py Added 3 comprehensive test cases (~240 lines)
docs/examples/Amplitude_LUT_Example.ipynb New example notebook demonstrating LUT usage
docs/examples/index.rst Added new example to documentation index
.gitignore Added conda-related files to ignore list

Usage Example

# Define a non-linear LUT
lut_input = [-1.0, -0.5, 0.0, 0.5, 1.0]
lut_output = [-0.8, -0.3, 0.0, 0.4, 0.9]

# Apply to channel 1
seq.setAmplitudeLUT(1, lut_input, lut_output)

Testing

Three test cases added:

  • test_setAmplitudeLUT - Basic LUT functionality and storage
  • test_setAmplitudeLUT_multiple_channels - LUT with multiple independent channels
  • test_setAmplitudeLUT_no_lut - Ensures backward compatibility when no LUT is set

Additional Notes

  • LUT is applied after RC filter compensation in the waveform processing pipeline
  • Each channel can have its own independent LUT
  • The implementation uses numpy.interp for efficient interpolation
  • A minor bug fix was included: removed .tolist() call on flags in outputForSEQXFile

Would you like me to adjust this summary or add any additional information?

return signal_filtered


def applyAmplitudeLUT(signal, lut):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pelase use type annotations. And lut argument is not a numpy array, it's a dictionary with keys LUT_input and LUT_output, right? then you can annotate it so using e.g. TypedDict

Args:
signal (np.array): The input signal. The signal is assumed to have
values in the range [-1, 1].
lut (np.array): The amplitude LUT. Should be a 1D array of length N,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lut is a dictionary, if i look at the code, right?

for pos in range(1, seqlen + 1):
if "flags" in elements[pos - 1][chan]:
flags = elements[pos - 1][chan]["flags"].tolist()
flags = elements[pos - 1][chan]["flags"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why was this change needed?

@astafan8 astafan8 changed the title Lut Amplitude Look-Up Table (LUT) Support for Waveform Processing Feb 3, 2026
@codecov
Copy link

codecov bot commented Feb 3, 2026

Codecov Report

❌ Patch coverage is 93.33333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 72.35%. Comparing base (ee22118) to head (ba075d4).

Files with missing lines Patch % Lines
src/broadbean/sequence.py 92.30% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1696      +/-   ##
==========================================
+ Coverage   72.12%   72.35%   +0.23%     
==========================================
  Files           9        9              
  Lines        1539     1552      +13     
==========================================
+ Hits         1110     1123      +13     
  Misses        429      429              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants