pycsamt.iot.sim#

Synthetic IoT/AMT field-network simulator.

These generators make the IoT subpackage easy to demo, document, and test without hardware. They produce realistic-looking channel time series (with configurable SNR, powerline contamination, and dropouts), station/device configs, telemetry packets, GPS-drift clock pairs, and battery-decay curves.

Randomness is controlled through a seed argument for reproducibility.

Functions

simulate_amt_channel(n_samples, sample_rate, *)

Simulate one AMT channel: band-limited signal + noise + artefacts.

simulate_amt_station(station_id, *[, ...])

Simulate a full AMT station: config, channel data, and packets.

simulate_battery_decay(n_samples, *[, ...])

Simulate a monotonic-ish battery discharge curve with noise.

simulate_gps_drift(n_samples, *[, ...])

Simulate paired reference/local clocks with drift, jitter, dropout.

simulate_iot_network([n_stations, profiles, ...])

Simulate a network of AMT stations across one or more profiles.

simulate_packet_loss(packets[, ...])

Return packets with a fraction randomly dropped.

simulate_powerline_noise(n_samples, ...[, ...])

Return a powerline-noise time series (fundamental + harmonics).

pycsamt.iot.sim.simulate_powerline_noise(n_samples, sample_rate, *, mains_hz=50.0, amplitude=1.0, n_harmonics=3, seed=None)[source]#

Return a powerline-noise time series (fundamental + harmonics).

Parameters:
Return type:

ndarray

pycsamt.iot.sim.simulate_amt_channel(n_samples, sample_rate, *, snr_db=20.0, mains_hz=50.0, powerline_amplitude=0.0, dropout_rate=0.0, seed=None)[source]#

Simulate one AMT channel: band-limited signal + noise + artefacts.

Parameters:
Return type:

ndarray

pycsamt.iot.sim.simulate_amt_station(station_id, *, channels=('ex', 'ey', 'hx', 'hy'), sample_rate=128.0, n_samples=1024, mains_hz=50.0, snr_db=20.0, powerline_amplitude=0.2, dropout_rate=0.0, survey_id=None, profile=None, position_m=None, lat=None, lon=None, timestamp=None, seed=None)[source]#

Simulate a full AMT station: config, channel data, and packets.

Returns:

Keys: station (StationConfig), device (DeviceConfig), data ({channel: ndarray}), and packets (list of TelemetryPacket: one health, one QC).

Return type:

dict

Parameters:
pycsamt.iot.sim.simulate_iot_network(n_stations=10, *, profiles=('L1',), channels=('ex', 'ey', 'hx', 'hy'), sample_rate=128.0, n_samples=512, mains_hz=50.0, snr_db=20.0, dropout_rate=0.05, survey_id='SIM', station_spacing_m=50.0, seed=None, detail=False)[source]#

Simulate a network of AMT stations across one or more profiles.

Parameters:
  • n_stations (int) – Total number of stations to generate.

  • profiles (sequence of str) – Profile/line labels; stations are round-robin assigned to them.

  • detail (bool) – When True return a dict with stations and packets. When False (default) return just the flat list of packets, as in the documented example.

  • channels (Sequence[str])

  • sample_rate (float)

  • n_samples (int)

  • mains_hz (float)

  • snr_db (float)

  • dropout_rate (float)

  • survey_id (str)

  • station_spacing_m (float)

  • seed (int | None)

Return type:

list of TelemetryPacket, or dict when detail=True.

pycsamt.iot.sim.simulate_packet_loss(packets, dropout_rate=0.05, *, seed=None)[source]#

Return packets with a fraction randomly dropped.

Parameters:
Return type:

list[TelemetryPacket]

pycsamt.iot.sim.simulate_gps_drift(n_samples, *, sample_interval_s=1.0, drift_ppm=5.0, jitter_ms=0.2, offset_ms=0.0, dropout_rate=0.0, start_time=1700000000.0, seed=None)[source]#

Simulate paired reference/local clocks with drift, jitter, dropout.

Returns:

Keys reference and local (POSIX-second arrays) and gps_lock (bool array). Feed local/reference straight into estimate_clock_drift_ppm() etc.

Return type:

dict

Parameters:
pycsamt.iot.sim.simulate_battery_decay(n_samples, *, initial_v=13.2, final_v=10.5, noise_v=0.05, seed=None)[source]#

Simulate a monotonic-ish battery discharge curve with noise.

Parameters:
Return type:

ndarray