ccatkidlib.rfsoc package

Submodules

ccatkidlib.rfsoc.arg_utils module

ccatkidlib.rfsoc.arg_utils.get_com_to(R, **kwargs)

Parses a list of drone com_to and sets up these drones. The drone_list specified in the system config is used if no com_to is passed as a key word argument. If a com_to is passed as a key word argument, makes sure that the com_to is a list and that all drones are included in the system config drone_list.

Parameters:

com_to (list of str) – String or list of strings specifying drone com_to

Returns:

List of drone com_to bids (list of str): List of boards in com_to

Return type:

com_to (list of str)

ccatkidlib.rfsoc.arg_utils.get_drone_args(R, com_to, key)

Get drone arguments from drone config files

Parameters:
  • com_to (list of str) – List of drones

  • key (list of str) – List of dictionary key(s) of argument to retrieve from drone config files

Returns:

List of values from drone config files corresponding to dictionary key

Return type:

args (list of Any)

ccatkidlib.rfsoc.arg_utils.group_args(com_to, *args)
ccatkidlib.rfsoc.arg_utils.parse_args(R, com_to, arg)

Parse key word drone arguments

Parameters:
  • com_to (list of str) – List of drones

  • arg (Any | list of Any) – Arugment to parse

Returns:

List of parsed args

Return type:

args (list of Any)

ccatkidlib.rfsoc.arg_utils.set_drone_args(R, com_to, key, args)

Set drone arguments in drone config files

Parameters:
  • com_to (list of str) – List of drones

  • key (str) – Dictionary key to set value of

  • args (list of Any) – List of values to set in drone config files

Returns:

List of returns from edit_config for each drone

Return type:

rtn_list (list of bool)

ccatkidlib.rfsoc.rfsoc_daq module

This library defines the R Class used for controlling and taking data with Xilinx ZCU111 Radio Frequency System on a Chip (RFSoC) boards. The data acquisition methods are tailored for frequency-division multiplexed readout of microwave resonators: kinetic inductance detectors (KID) in particular.

class ccatkidlib.rfsoc.rfsoc_daq.R(cfg_path: str = '/home/docs/checkouts/readthedocs.org/user_builds/ccatkidlib/envs/latest/lib/python3.12/site-packages/ccatkidlib/rfsoc/system_config.yaml', init_boards: bool | None = None, init_drones: bool | None = None, **kwargs)

Bases: object

Class for data acquisition with RFSoC boards

curr_date

Date of measurement

Type:

str

timestamp

UNIX timestamp corresponding to most recently run DAQ method.

Type:

str

measurement_name

Name of measurement

Type:

str

measurement_desc

Description of measurement

Type:

str

sess_id

Unique ID of measurement

Type:

str

io_cfg

Loaded IO configuration file

Type:

dict

ext_cfg

Loaded external configuration file

Type:

dict

drone_cfg

List of loaded drone configuration files

Type:

list[dict]

drone_list

List of drones used for DAQ

Type:

list[str]

board_list

List of boards used for DAQ

Type:

list[str]

drone_num

Number of drones used for DAQ

Type:

int

board_num

Number of boards used for DAQ

Type:

int

all_boards

List of all RFSoC boards specified in IO configuration file

Type:

list[str]

parallel_boards

Number of boards to run in parallel. Positive integer or -1 to specify all boards

Type:

int

parallel_drones

Number of drones to run in parallel. One of {1, 2, 3, 4}

Type:

int

save_cfg

Whether to save configuration files

Type:

bool

save_data

Whether to save data files

Type:

bool

data_dir

Path to ccatkidlib data directory

Type:

str

drone_dir

Path to primecam_readout drone directory on RFSoC board

Type:

str

tmp_data_dir

Path to primecam_readout data directory: primecam_readout/src/tmp as of version …

Type:

str

tmp_dir

Path to ccatkidlib tmp data directory

Type:

str

g3_dir

Path to rfsoc-streamer timestream g3 data directory

Type:

str

config_dirs

List of directories where ccatkidlib configuration files are saved for each drone

Type:

list[str]

targ_dirs

List of directories where ccatkidlib target sweep data files are saved for each drone

Type:

list[str]

vna_dirs

List of directories where ccatkidlib VNA sweep data files are saved for each drone

Type:

list[str]

timestream_dirs

List of directories where ccatkidlib timestream data files are saved for each drone

Type:

list[str]

log_dir

Directory with ccatkidlib master log files

Type:

str

rfsoc

OCS client for controlling RFSoC OCS agent

Type:

ocs.OCSClient

streamer

Streamer object used for collecting NumPy timestreams

Type:

ccatkidlib.Streamer

NCLOs

Current NCLOs of each drone. Used by rfsoc-controller OCS agent

Type:

dict

drive_attens

Current drive attenuations of each drone. Used by rfsoc-controller OCS agent

Type:

dict

sense_attens

Current sense attenuations of each drone. Used by rfsoc-controller OCS agent

Type:

dict

Constructor for R. Creates directories for data storage, configures logger, initializes RFSoC boards/drones, and starts RFSoC OCS agent.

Parameters:
  • cfg_path (str, optional) – Path to system configuration file. Defaults to system_config.yaml in ccatkidlib/rfsoc directory

  • init_boards (bool | None, optional) – Whether to (re)initialize RFSoC boards. Defaults to None - Pulls from IO configuration file

  • init_drones (bool | None, optional) – Whether to (re)initialize RFSoC drones. Defaults to None - Pulls from IO configuration file

  • kwargs – Key word arguments for passing system state information between control objects. Used by the rfsoc-controller OCS agent. See below:

  • sess_id (str) – Session ID of measurement

  • measurement_name (str) – Name of measurement

  • measurement_desc (str) – Description of measurement

  • curr_date (str) – Date of measurement

find_detectors(new_sweep: bool = True, **kwargs)

Find detectors using a VNA sweep

Note

  • The larger of peak_prom_db or peak_prom_std is used if both are specified

Parameters:
  • new_sweep (bool, optional) – Whether to take a new VNA sweep. Defaults to True

  • below (kwargs. See)

  • com_to (str | list[str], optional) – List of drones. Defaults to drone list in IO configuration file

  • sweep_steps (int | list[int], optional) – Number of steps each tone should take during sweep. Defaults to value in drone configuration files

  • write_targ_comb (bool, optional) – Whether to write target comb using found detector frequencies. Defaults to True

  • phase_filter (bool | list[bool], optional) – Whether to perform phase filtering on found detectors. Defaults to value in drone configuration files

  • filter_wn (int | list[int], optional) – Number of points around tone to use for phase filtering. Defaults to value in drone configuration files

  • peak_prom_std (float | list[float], optional) – Peak height from surroundings, in noise std multiples. Defaults to value in drone configuration files

  • peak_prom_db (float | list[float], optional) – Peak height from surroundings, in dB. Defaults to value in drone configuration files

  • peak_dis (int | list[int], optional) – Min distance between peaks. Defaults to value in drone configuration files

  • width_min (int | list[int], optional) – Min peak width. Defaults to value in drone configuration files

  • width_max (int | list[int], optional) – Max peak width. Defaults to value in drone configuration files

  • stitch (bool | list[bool], optional) – Whether to stitch comb discontinuities. Defaults to value in drone configuration files

  • stitch_sw (int | list[int], optional) – Amount of points on each end to use for stitching. Defaults to value in drone configuration files

  • remove_cont (bool | list[bool], optional) – Whether to subtract the continuum. Defaults to value in drone configuration files

  • continuum_wn (int | list[int], optional) – Continuum filter cutoff frequency in Hz. Defaults to value in drone configuration files

  • remove_noise (bool | list[bool], optional) – Whether to subtract noise. Defaults to value in drone configuration files

  • noise_wn (int | list[int], optional) – Noise filter cutoff frequency in Hz. Defaults to value in drone configuration files

get_ADC_rms(**kwargs) list[float]

Get root mean squared (RMS) power at the analog-to-digital converters (ADCs)

Parameters:
  • below (kwargs. See)

  • com_to (str | list[str], optional) – List of drones. Defaults to drone list in IO configuration file

Returns:

ADC RMS values (sorted by drone)

Return type:

return (list[float])

get_atten(**kwargs) tuple[list[float], list[float]]

Get drive/sense attenuations of frontend attenuators connected to RFSoC board

Note

  • Drive attenuations refer to attenuators on the digital-to-analog (DAC) side and sense attenuations refer to attenuators on the analog-to-digital (ADC) side

Parameters:
  • below (kwargs. See)

  • com_to (str | list[str], optional) – List of drones. Defaults to drone list in IO configuration file

Returns:

Current drive and sense attenuations

Return type:

return (tuple[list[float], list[float]])

get_avail_space(**kwargs) list[float]

Check available storage space and clean drone directories on RFSoCs

Parameters:
  • below (kwargs. See)

  • com_to (str | list[str], optional) – List of drones. Defaults to drone list in IO configuration file

  • threshold (float) – Storage space threshold after which to automatically clean directories on RFSoCs

  • olderThanDaysAgo (int | str) – Number of days old a file must be in order to be deleted by automatic cleaning

  • ftype (str) – Type of file to be deleted by automatic cleaning

Returns:

Available space left on each board (sorted by board)

Return type:

return (list[float])

get_stats(space: bool = True, temps: bool = True, ADC_rms: bool = True, **kwargs) tuple[list[float], tuple[list[float], list[float]], list[float]]

Get RFSoC storage space, temperatures, and RMS power at drone analog-to-digital converters (ADCs).

Parameters:
  • space (bool, optional) – Whether to get RFSoC storage space. Defaults to True

  • temps (bool, optional) – Whether to get RFSoC fabric and processor temperatures. Defaults to True

  • ADC_rms (bool, optional) – Whether to get root mean squared (RMS) power at ADCs. Defaults to True

  • below (kwargs. See)

  • com_to (str | list[str], optional) – List of drones. Defaults to drone list in IO configuration file

Returns:

Stoarge space, temperatures, and RMS power at ADCs

Return type:

return tuple[list[float], tuple[list[float], list[float]], list[float]]

get_temps(**kwargs) tuple[list[float], list[float]]

Get fabric and processor temperatures of RFSoCs

Parameters:
  • below (kwargs. See)

  • com_to (str | list[str], optional) – List of drones. Defaults to drone list in IO configuration file

Returns:

Processor and fabric temperatures of RFSoCs

Return type:

return (tuple[list[float], list[float]])

set_NCLO(NCLO: int | list[int] | None = None, **kwargs) list[float]

Set the numerically controlled local oscillator (NCLO) frequencies for each drone

Note

If a single NCLO value is specified, it will be used for all drones.

Parameters:
  • NCLO (int | list[int] | None, optional) – NCLO frequencies for each drone in MHz. Defaults to NCLOs in drone configuration files

  • below (kwargs. See)

  • com_to (str | list[str], optional) – List of drones. Defaults to drone list in IO configuration file

Returns:

Set NCLOs

Return type:

return (list[float])

set_atten(drive: float | list[float] | None = None, sense: float | list[float] | None = None, **kwargs) tuple[list[float], list[float]]

Set drive/sense attenuations of frontend attenuators connected to RFSoC board

Note

  • Drive attenuations refer to attenuators on the digital-to-analog (DAC) side and sense attenuations refer to attenuators on the analog-to-digital (ADC) side

  • If a single drive/sense attenuation value is specified, it will be used for all drones.

Parameters:
  • drive (float | list[float] | None, optional) – Drive attenuations for each drone in dB. Must be between 0 and 31.75. Defaults to drive attenuations in drone configuration files

  • sense (float | list[float] | None, optional) – Sense attenuations for each drone in dB. Must be between 0 and 31.75. Defaults to sense attenuations in drone configuration files

  • below (kwargs. See)

  • com_to (str | list[str], optional) – List of drones. Defaults to drone list in IO configuration file

Returns:

Current drive and sense attenuations

Return type:

return (tuple[list[float], list[float]])

setup_boards(**kwargs) None

(Re)initialize RFSoC boards one at time

Parameters:
  • below (kwargs. See)

  • com_to (str | list[str], optional) – List of drones. Drones are used to determine which boards to initialize. Defaults to drone list in IO configuration file

setup_drones(**kwargs) None

(Re)initialize drones

Parameters:
  • below (kwargs. See)

  • com_to (str | list[str], optional) – List of drones to setup. Defaults to drone list in IO configuration file

  • restart (bool, optional) – Whether to restart already running drones. Defaults to value in IO configuration file

take_target_sweep(**kwargs) list[str]

Take a vector network analyzer (VNA) style sweep with a specified set of tones.

Note

  • The ccatkidlib data file paths are returned if save_data is True otherwise the primecam_readout data file paths are returned

  • If a single sweep_steps or chan_bw value is specified, it will be used for all drones.

Parameters:
  • below (kwargs. See)

  • com_to (str | list[str], optional) – List of drones. Defaults to drone list in IO configuration file

  • chan_bw (float | list[float], optional) – Bandwidth of sweep around each tone in MHz. Defaults to value in drone configuration files

  • sweep_steps (int | list[int], optional) – Number of steps each tone should take during sweep. Defaults to value in drone configuration files

  • (list[list[float]] (tone_freqs) – optional): Frequencies at which to place tones in Hz

  • tone_powers (str | list[str] | float | list[float] | list[list[float]], optional) – Tone powers in digital-to-analog (DAC) units (proportional to voltage). Use ‘gen’ to generate powers

  • tone_phis (str | list[str] | float | list[float] | list[list[float]], optional) – Tone phases in radians. Use ‘gen’ to generate phases

  • write_comb (bool, optional) – Whether to write a new target sweep comb. Defaults to True if any of tone_freqs, tone_powers, or tone_phis is specified

Returns:

List of target sweep file paths

Return type:

return (list[str])

take_timestream(t_sec: float, **kwargs) list[str]

Take timestream data with a specified set of tones

Note

  • Saving timestream data as g3 files requires integration with the rfsoc-streamer software

  • Use of the rfsoc-streamer software is recommended when streaming with large numbers of drones

Parameters:
  • t_sec (float) – Length of timestream in seconds

  • below (kwargs. See)

  • com_to (str | list[str], optional) – List of drones. Defaults to drone list in IO configuration file

  • g3 (bool, optional) – Whether to save timestream data as g3 files. Defaults to value in IO configuration file

  • save_data (bool, optional) – Whether to save data to ccatkidlib data directory. Defaults to value in IO configuration file

  • (list[list[float]] (tone_freqs) – optional): Frequencies at which to place tones in Hz

  • tone_powers (str | list[str] | float | list[float] | list[list[float]], optional) – Tone powers in digital-to-analog (DAC) units (proportional to voltage). Use ‘gen’ to generate powers

  • tone_phis (str | list[str] | float | list[float] | list[list[float]], optional) – Tone phases in radians. Use ‘gen’ to generate phases

  • write_comb (bool, optional) – Whether to write a new target sweep comb. Defaults to True if any of tone_freqs, tone_powers, or tone_phis is specified

Returns:

List of timestream file paths or None if save_data is False

Return type:

return (list[str] | None)

take_vna_sweep(**kwargs) list[str]

Take a vector network analyzer (VNA) style sweep covering the full 512 MHz available bandwidth

Note

  • The ccatkidlib data file paths are returned if save_data is True otherwise the primecam_readout data file paths are returned

  • If a single sweep_steps value is specified, it will be used for all drones.

Parameters:
  • below (kwargs. See)

  • com_to (str | list[str], optional) – List of drones. Defaults to drone list in IO configuration file

  • write_comb (bool, optional) – Whether to write a new VNA comb. Defaults to True

  • sweep_steps (int | list[int], optional) – Number of steps each tone should take during sweep. Defaults to value in drone configuration files

Returns:

List of VNA sweep file paths

Return type:

return (list[str])

tune_tone_placement(new_sweep: bool = True, **kwargs)

Find detectors using a target sweep

Parameters:
  • new_sweep (bool, optional) – Whether to take a new target sweep. Defaults to True

  • below (kwargs. See)

  • com_to (str | list[str], optional) – List of drones. Defaults to drone list in IO configuration file

  • chan_bw (float | list[float], optional) – Bandwidth of sweep around each tone in MHz. Defaults to value in drone configuration files

  • sweep_steps (int | list[int], optional) – Number of steps each tone should take during sweep. Defaults to value in drone configuration files

  • write_targ_comb (bool, optional) – Whether to write target comb using found detector frequencies. Defaults to True

  • (list[list[float]] (tone_freqs) – optional): Frequencies at which to place tones in Hz

  • tone_powers (str | list[str] | float | list[float] | list[list[float]], optional) – Tone powers in digital-to-analog (DAC) units (proportional to voltage). Use ‘gen’ to generate powers

  • tone_phis (str | list[str] | float | list[float] | list[list[float]], optional) – Tone phases in radians. Use ‘gen’ to generate phases

  • write_comb (bool, optional) – Whether to write a new target sweep comb. Defaults to True if any of tone_freqs, tone_powers, or tone_phis is specified

Returns:

Returns an array of the found detector frequencies

Return type:

output (arr of floats)

tune_tone_power(**kwargs)
write_config_comb(**kwargs)

Write a custom set of radio frequency tones (comb)

Parameters:
  • below (kwargs. See)

  • com_to (str | list[str], optional) – List of drones. Defaults to drone list in IO configuration file

  • (list[list[float]] (tone_freqs) – optional): Frequencies at which to place tones in Hz

  • tone_powers (str | list[str] | float | list[float] | list[list[float]], optional) – Tone powers in digital-to-analog (DAC) units (proportional to voltage). Use ‘gen’ to generate powers

  • tone_phis (str | list[str] | float | list[float] | list[list[float]], optional) – Tone phases in radians. Use ‘gen’ to generate phases

  • rescale_power (bool | list[bool]) – Whether to rescale tone powers if DAC maximum power is exceeded. Defaults to value in drone configuration files

  • gen_attempts (int | list[int]) – Number of attempts to randomize phases so that the resulting comb does not exceed DAC maximum power. Defaults to value in drone configuration files

Returns:

List of OCSReply objects for RFSoC OCS agent writeTargCombFromCustomList command

Return type:

return (list[ocs.OCSReply])

ccatkidlib.rfsoc.rfsoc_timestream module

class ccatkidlib.rfsoc.rfsoc_timestream.Streamer(udp_ip, udp_port, timeout=1)

Bases: object

Class for capturing UDP packets of timestreams taken with a radio frequency system on a chip (RFSoC).

Initialize Streamer object by creating udp_ip, udp_port, and timestamp attributes.

Parameters:
  • udp_ip (str) – UDP IP address

  • udp_port (int) – UPD port

capture_packets(t_sec, buffer_size=9000, q=None)

Capture N UDP packets from the timestream.

Parameters:
  • N (int) – Number of packages to capture

  • buffer_size (int) – Maximum buffer size of each packet

Returns:

Packet data (as a bytearray) of each captured packet ips: Source IP of each captured packet ports: Source port of each captured packet

Return type:

packs

get_utc(d, offset=0)

Convert PTP timestamp stored as three 4 byte integers into UTC.

Parameters:
  • d – Array of three 4 byte integers storing PTP timestamp

  • offset – Offset between TAI and UTC

Returns:

PTP timestamp in UTC

Return type:

UTC

parse_packets(packets, timestamp=None, time_diff=None)

Parse the bytearray data contents of UPD packets.

Parameters:

packets – Array of packet bytearray data

Returns:

Array of timestream I and Q (main data) aux: Array of auxiliary data: packet info, channel count, packet count, and packet PTP timestamp

Return type:

data

take_timestream(t_sec, offset=10)

Take a timestream of N packets.

Parameters:

N (int) – Number of packets to capture

Returns:

Timestream I data Q: Timstream Q data aux: Auxiliary data: packet info, channel count, packet count, and packet PTP timestamp ips: Packet source IP addresses ports: Packet sourc ports offset: Number of packets to drop from beginning of timestream

Return type:

I

Module contents