=== Step 11: Write channel data to shared memory === * For the initialization and running the pipeline, please refer [[KAGRA/Subgroups/CAL/GstLAL/tutorials/step1|step1]] * Access frame cache file by specifying frame_cache and instrument as in [[KAGRA/Subgroups/CAL/GstLAL/tutorials/step2|step2]] * Define a frame multiplexer(mux) to write channels into a frame as in [[KAGRA/Subgroups/CAL/GstLAL/tutorials/step3|step3]] * The only difference from [[KAGRA/Subgroups/CAL/GstLAL/tutorials/step3|(step3)writing to a frame file]] is use gds_lvshmsink instead of mkframecppfilesink {{{#!python pp.mkgeneric(pipeline, mux, "gds_lvshmsink", sync=False, async=False,\ shm_name = options.shared_memory_partition, num_buffers=10,\ blocksize = options.frame_size*frame_duration*frames_per_file,\ buffer_mode = options.buffer_mode) }}} * The python scripts are available at git repository {{{ > kagra-cal/Observation/Phase1/tutorials/shmo --help Usage: shmo [options] Options: -h, --help show this help message and exit --cache=cache Set the name of the LAL cache listing the frame files --gps-start-time=seconds Set the start time of the segment to analyze in GPS seconds. --gps-end-time=seconds Set the end time of the segment to analyze in GPS seconds. --ifo=name Name of the IFO (default= K1) --channel=name Set channel name(s) to extract (default= CAL- CS_PROC_C00_STRAIN_DQ,CAL-CS_PROC_MICH_DELTA_TM_DQ ,CAL-CS_PROC_MICH_RESIDUAL_DQ,CAL- CS_PROC_ERR_STRAIN_DQ,CAL-CS_PROC_CTRL_STRAIN_DQ,LSC- MICH1_IN1_DQ,LSC-MICH1_OUT_DQ) --format=format Set input channel(s) format (default= F64LE) --ch-rate=rate Set input channel data rate (default= 16384) --frame-duration=seconds Set the number of seconds for each frame. (Default = 4) --frame-size=bytes Approximate size in bytes of frame file images; used when writing to shared memory. (Default=500000) --shared-memory-partition=name Set the name of the shared memory partition to write to (default = K1). --buffer-mode=number Set the buffer mode for the lvshmsink element. (Default=2) }}} * Before running the script, make sure that shared memory with the same name is not running, and if so kill it with smkill {{{ > smlist id name nBuf lBuf nTotal 32 K1 1 70000 32 > smkill K1 > smlist id name nBuf lBuf nTotal }}} * This is an example to extract channel data from a cache file, k1.cache and write to a shared memory {{{ > kagra-cal/Observation/Phase1/tutorials/shmo --cache=k1.cache GPS: 1209288320 1209288352 [('K1', 'CAL-CS_PROC_C00_STRAIN_DQ'), ('K1', 'CAL-CS_PROC_MICH_DELTA_TM_DQ'), ('K1', 'CAL-CS_PROC_MICH_RESIDUAL_DQ'), ('K1', 'CAL-CS_PROC_ERR_STRAIN_DQ'), ('K1', 'CAL-CS_PROC_CTRL_STRAIN_DQ'), ('K1', 'LSC-MICH1_IN1_DQ'), ('K1', 'LSC-MICH1_OUT_DQ')] seeking GPS start and stop times ... setting pipeline state to playing ... set to playing successfully running pipeline ... progress_src_CH6 (00:00:01): 1209288352 / 32 seconds (3779026100.0 %) progress_src_CH7 (00:00:01): 1209288352 / 32 seconds (3779026100.0 %) progress_src_CH1 (00:00:01): 1209288352 / 32 seconds (3779026100.0 %) progress_src_CH5 (00:00:01): 1209288352 / 32 seconds (3779026100.0 %) progress_src_CH4 (00:00:01): 1209288352 / 32 seconds (3779026100.0 %) progress_src_CH2 (00:00:01): 1209288352 / 32 seconds (3779026100.0 %) progress_src_CH3 (00:00:01): 1209288352 / 32 seconds (3779026100.0 %) progress_sink_K1 (00:00:06): 1209288324 seconds progress_sink_K1 (00:00:12): 1209288336 seconds progress_sink_K1 (00:00:17): 1209288344 seconds progress_sink_K1 (00:00:19): 1209288352 / 32 seconds (3779026100.0 %) }}} * Check if the shared memory partition is running {{{ > smlist id name nBuf lBuf nTotal 32 K1 10 2000000 18 smdump K1 Event Manager Partition - K1 Global Control Data ------------------- version: 1.03 status: scavage global use count: 3 global sem id: 4489216 # buffers: 10 buffer length: 2000000 first full buffer: 0 last full buffer: 6 first free buffer: 7 #consumers: 1 consumer sem id: 4521985 4554754 4587523 4620292 consumer mask: 1 Buffer Status ------------- id status reserved seen use ldata link t-mask count 0 1 0 1 0 1663469 1 -1 1 1 1 0 1 0 1638044 2 -1 1 2 1 0 1 0 1635658 3 -1 1 3 1 0 1 0 1677513 4 -1 1 4 1 0 1 0 1660442 5 -1 1 5 1 0 1 0 1671079 6 -1 1 6 1 0 1 0 1626121 -1 -1 1 7 1 0 0 0 0 8 0 0 8 1 0 0 0 0 9 0 0 9 1 0 0 0 0 -1 0 0 Consumer Status --------------- id pid max-bf trig #segs read flags 0 14969 0 ffffffff 0 6 wait }}} * At the same time if you run another GstLAL script, shmi as in [[KAGRA/Subgroups/CAL/GstLAL/tutorials/step10|step 10]] you will receive the C00 strain channel data {{{ > kagra-cal/Observation/Phase1/tutorials/shmi setting pipeline state to playing ... set to playing successfully 1209288320.000000000 3.96861363216594e-11 1209288321.000000000 9.805171258259193e-11 1209288322.000000000 -6.216620274113183e-11 1209288323.000000000 -3.847490728792202e-11 1209288324.000000000 -1.028217927467878e-10 1209288325.000000000 7.444918292964786e-11 1209288326.000000000 1.882813627229751e-10 1209288327.000000000 -2.34722963288192e-10 progress_src_input (00:00:06): 1209288328 seconds 1209288328.000000000 3.754893097840384e-12 1209288329.000000000 -1.839911834000674e-10 }}} * [[KAGRA/Subgroups/CAL/GstLAL/tutorials/step12|(Next) Step 12: Link the shared memory to remote host]] * [[KAGRA/Subgroups/CAL/GstLAL/tutorials/step10|(Prev) Step 10: Read channel data from shared memory]] * [[KAGRA/Subgroups/CAL/GstLAL/tutorials|Tutorials]]