torchsig.transforms.transforms.DigitalAGC

class torchsig.transforms.transforms.DigitalAGC(initial_gain_db: tuple[float] = (0, 0), alpha_smooth: tuple[float] = (1e-07, 1e-06), alpha_track: tuple[float] = (1e-06, 1e-05), alpha_overflow: tuple[float] = (0.1, 0.3), alpha_acquire: tuple[float] = (1e-06, 1e-05), track_range_db: tuple[float] = (0.5, 2), **kwargs)[source]

Bases: SignalTransform

Automatic Gain Control performing sample-by-sample AGC algorithm.

initial_gain_db

Inital gain value in dB.

alpha_smooth

Alpha for averaging the measure signal level level_n = level_n * alpha + level_n-1(1-alpha)

alpha_track

Amount to adjust gain when in tracking state.

alpha_overflow

Amount to adjust gain when in overflow state [level_db + gain_db] >= max_level.

alpha_acquire

Amount to adjust gain when in acquire state.

track_range_db

dB range for operating in tracking state.

Methods

add_parent

Add parent Seedable object and set up RNGs accordingly.

get_distribution

Create distribution function with proper seeding.

get_second_seed

Gets second seed, usually used to seed both torch and numpy generators with slightly different seeds.

seed

Seed number generators with given seed.

setup_rngs

Initialize torch and numpy number generators, and update its children.

update_from_parent

Update numpy and torch number generators with parent seed.

__init__(initial_gain_db: tuple[float] = (0, 0), alpha_smooth: tuple[float] = (1e-07, 1e-06), alpha_track: tuple[float] = (1e-06, 1e-05), alpha_overflow: tuple[float] = (0.1, 0.3), alpha_acquire: tuple[float] = (1e-06, 1e-05), track_range_db: tuple[float] = (0.5, 2), **kwargs)[source]

Initialize the DigitalAGC transform.

Parameters:
  • initial_gain_db – Inital gain value in dB. Defaults to (0, 0).

  • alpha_smooth – Alpha for averaging the measure signal level. Defaults to (1e-7, 1e-6).

  • alpha_track – Amount to adjust gain when in tracking state. Defaults to (1e-6, 1e-5).

  • alpha_overflow – Amount to adjust gain when in overflow state. Defaults to (1e-1, 3e-1).

  • alpha_acquire – Amount to adjust gain when in acquire state. Defaults to (1e-6, 1e-5).

  • track_range_db – dB range for operating in tracking state. Defaults to (0.5, 2).

  • **kwargs – Additional keyword arguments passed to the parent class.

__call__(signal: Signal) Signal

Validates signal, performs transform, updates bookeeping, (optionally) enforces data type.

Parameters:

signal – Signal to be transformed.

Returns:

Transformed signal.

__repr__() str

Transform string representation.

Should be able to recreate class from this string.

Returns:

Transform representation.

__str__() str

String representation of the transform.

Returns:

String representation of the transform.

add_parent(parent: Seedable, register: bool = True) None

Add parent Seedable object and set up RNGs accordingly.

Parameters:
  • parent – Parent Seedable object to add.

  • register – If True (default), add self to parent.children so that future seed propagation reaches this object. Pass False for transient objects (e.g. per-sample Signal instances) that only need the parent link for metadata/RNG access during their lifetime but must not accumulate in the parent’s child list, which would otherwise cause unbounded memory growth.

get_distribution(params: list | tuple | float, scaling: str = 'linear') Distribution

Create distribution function with proper seeding.

Parameters:
  • params – Parameters for distribution.

  • scaling – Scaling param for distribution. Defaults to ‘linear’.

Returns:

Distribution function, seeded.

Return type:

Distribution

get_second_seed(seed: int) int

Gets second seed, usually used to seed both torch and numpy generators with slightly different seeds.

Parameters:

seed – Seed to use.

Returns:

New seed.

seed(seed: int) None

Seed number generators with given seed.

Parameters:

seed – Seed to use.

setup_rngs() None

Initialize torch and numpy number generators, and update its children.

update_from_parent() None

Update numpy and torch number generators with parent seed.