SMuRF Stream Simulator
The SMuRF Stream Simulator is meant to mock a SMuRF streamer, for cases when you want to test something and you do not have access to a SMuRF. It establishes a G3NetworkSender and sends simulated timestreams over it. You can connect the timestream aggregator to it and simulate recording data to disk in .g3 files.
usage: python3 agent.py [-h] [--auto-start AUTO_START]
[--target-host TARGET_HOST] [--port PORT]
[--num-chans NUM_CHANS] [--stream-id STREAM_ID]
Agent Options
- --auto-start
Automatically start streaming at Agent startup.
Default: False
- --target-host
Target remote host.
Default: “*”
- --port
Port to listen on.
Default: 50000
- --num-chans
Number of detector channels to simulate.
Default: 528
- --stream-id
Stream ID for the simulator.
Default: “stream_sim”
Configuration File Examples
Below are configuration examples for the ocs config file and for running the simulator in a docker container.
ocs-config
To configure the simulator we need to add a SmurfStreamSimulator block to our ocs configuration file. Here is an example configuration block using all of the available arguments:
{'agent-class': 'SmurfStreamSimulator',
'instance-id': 'smurf-stream',
'arguments': [['--auto-start', True],
['--port', '50000'],
['--num-chans', '528'],
['--stream-id', 'stream_sim']]},
Docker
The simulator should be configured to run in a Docker container. An example docker-compose service configuration is shown here:
smurf-stream-sim:
image: simonsobs/socs:latest
hostname: ocs-docker
ports:
- "50000:50000"
volumes:
- ${OCS_CONFIG_DIR}:/config:ro
command:
- "--instance-id=smurf-stream"
Agent API
- class socs.agents.smurf_stream_simulator.agent.SmurfStreamSimulator(agent, target_host='*', port=4536, num_chans=528, stream_id='stream_sim')[source]
OCS Agent to simulate data streaming without connection to a SMuRF.
- Parameters:
agent (OCSAgent) – OCSAgent object which forms this Agent
target_host (str) – Target remote host address
port (int) – Port to send data over
num_chans (int) – Number of channels to simulate
stream_id (str) – Stream ID to put into G3Frames. Defaults to “stream_sim”
- agent
OCSAgent object which forms this Agent
- Type:
OCSAgent
- log
txaio logger ojbect, created by the OCSAgent
- Type:
txaio.tx.Logger
- target_host
Target remote host address
- Type:
str
- port
Port to send data over
- Type:
int
- writer
G3 writer for sending frames to, in this case a G3NetworkSender
- Type:
spt3g.core.G3NetworkSender
- is_streaming
flag to track if we’re currently streaming, used in stop task to stop the streaming process. If stopped then keep alive flow control frames are still being sent.
- Type:
bool
- running_in_background
flag to track if the streaming process is running in the background,
- Type:
bool
- channels
List of simulated channels to stream
- Type:
list
- start_background_streamer(params=None)[source]
Process to run streaming process. A data stream is started automatically. It can be stopped and started by the start and stop tasks. Either way keep alive flow control frames are being sent.
- Parameters:
frame_rate (float, optional) – Frequency [Hz] at which G3Frames are sent over the network. Defaults to 1 frame pers sec.
sample_rate (float, optional) – Sample rate [Hz] for each channel. Defaults to 10 Hz.
- stop_background_streamer(params=None)[source]
Stop method associated with start_background_streamer process.
The design here sets a flag that is checked in the main background_streamer process, that way we keep the G3Writer writing from a single thread.
- set_stream_on(params=None)[source]
Task to start the stream of actual data frames from the background streaming process.
The design here sets a flag that is checked in the main background_streamer process, that way we keep the G3Writer writing from a single thread.
- Parameters:
force (bool) – Whether to force a start frame or not, defaults to False
- set_stream_off(params=None)[source]
Task to stop the stream of actual data frames from the background streaming process. Keep alive flow control frames will still be sent.
The design here sets a flag that is checked in the main background_streamer process, that way we keep the G3Writer writing from a single thread.
- Parameters:
force (bool) – Whether to force a start frame or not, defaults to False