Skip to content

feat(smurf_util): Add keep_channels_subset helper#980

Open
ruck314 wants to merge 1 commit into
mainfrom
issues-27
Open

feat(smurf_util): Add keep_channels_subset helper#980
ruck314 wants to merge 1 commit into
mainfrom
issues-27

Conversation

@ruck314
Copy link
Copy Markdown
Contributor

@ruck314 ruck314 commented May 1, 2026

Summary

  • Adds SmurfUtilMixin.keep_channels_subset(band, subbands=None, freq_min_mhz=None, freq_max_mhz=None, channels_to_keep=None) in python/pysmurf/client/util/smurf_util.py, sitting next to band_off / channel_off.
  • Disables currently-on channels (per which_on) that fail any supplied filter; filters combine with logical AND; no-op when no filters are supplied.
  • Composes existing helpers (which_on, get_subband_from_channel, channel_to_freq, channel_off); no new low-level API introduced.
  • Mirrors the caller-supplies-the-metric pattern of turn_off_noisy_channels and check_lock.

Closes #27.

Usage

The three examples from the original issue:

S.keep_channels_subset(band, subbands=range(13, 16))               # subbands 13-15
S.keep_channels_subset(band, freq_min_mhz=5100, freq_max_mhz=5200) # 5.1-5.2 GHz
S.keep_channels_subset(band, channels_to_keep=tes_like_chs)        # external IV/TES filter

The IV/TES-quality criterion is intentionally left to the caller — analyze_iv already returns metrics, so policy (which R_n / p_trans is "TES-like") stays in calling code:

iv = S.analyze_iv_from_file(...)
good = [ch for ch in iv[band] if iv[band][ch]['R_n'] > 5e-3]
S.keep_channels_subset(band, channels_to_keep=good)

Test plan

  • flake8 --count python/ clean (matches CI)
  • AST parse confirms signature, @set_action() decorator, and docstring
  • python -m py_compile clean
  • Hardware smoke test: tune a band, call S.keep_channels_subset(band, subbands=range(13, 16)), verify S.which_on(band) afterward returns only channels whose S.get_subband_from_channel(band, ch) is in {13, 14, 15}
  • Hardware smoke test: cross-check freq_min_mhz / freq_max_mhz against S.channel_to_freq(band)
  • Confirm band_off / channel_off behavior unchanged

…y criteria (#27)

Adds SmurfUtilMixin.keep_channels_subset, a single-call helper that
disables currently-on channels in a band that fail user-supplied
criteria. Filters combine with logical AND:

  - subbands: iterable of subband numbers to keep
  - freq_min_mhz / freq_max_mhz: resonator frequency band-pass
  - channels_to_keep: explicit allow-list (e.g. TES-like channels
    surviving an external analyze_iv pass)

With no filters supplied the call is a no-op. Composes existing
helpers (which_on, get_subband_from_channel, channel_to_freq,
channel_off); no new low-level API is introduced. Mirrors the
caller-supplies-the-metric pattern of turn_off_noisy_channels and
check_lock.
@ruck314 ruck314 requested review from swh76 and tristpinsm as code owners May 1, 2026 21:51
@github-actions github-actions Bot added the client Changes to the client code label May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

client Changes to the client code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ability to drop the channels that are on and tracking to a subset based on some criterion

1 participant