=== Step 10: Read channel data from 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]] * We make a dummy shared memory and send channel data from the frame files * First, we extract a channel data from a frame cache file and make short (1 second) frame files using [[KAGRA/Subgroups/CAL/GstLAL/tutorials/step3|step3 extr]] {{{#!python import os dbin = os.path.dirname(__file__) dirn = options.dirn dirn = dirn+'/' if not dirn.endswith('/') else dirn if not os.path.exists(dirn): opt = ' --cache='+options.cache+' --channel='+options.channel+\ ' --ch-rate='+options.ch_rate+' --frame-duration=1'+\ ' --frame-type=K1_TEST --output-path='+dirn os.system('mkdir -p '+dirn) os.system(dbin+'/extr'+opt) }}} * Then, with DpushRT program at GDS software, we can write channel data to shared memory * For the details of Data Pushers, please check [[https://labcit.ligo.caltech.edu/~jzweizig/dmt/DMTProject/DMT-DD.html|LIGO DMT Data Distribution Sub-System]] {{{#!python opt = '' szm = 0 dl = os.listdir(dirn) for fn in dl: if fn.endswith('.gwf'): opt = opt+' infile '+dirn+fn sz = os.path.getsize(dirn+fn) szm = sz if sz > szm else szm bsz = 10000*int(np.floor(szm/10000.)+1) opt = opt+' partition '+options.shared_memory_partition+' lbuf '+str(bsz) if options.debug: opt = opt+' debug' os.system('DpushRT'+opt) }}} * On the receiver side, we use GstLAL to read the channel data from shared memory and dump into a file (or stdout) {{{#!python src = pp.mklvshmsrc(pipeline, shm_name = 'K1', assumed_duration = 1) demux = pp.mkframecppchanneldemux(pipeline, src,\ do_file_checksum = do_file_checksum, skip_bad_files = skip_bad_files,\ channel_list = map("%s:%s".__mod__, channel_list)) cin = cp.hook_up(pipeline, demux, chan_in, instrument, buf_length) cin = cp.caps_and_progress(pipeline, cin, caps, "input") cin = cp.mkresample(pipeline, cin, 0, False, capsr) pp.mknxydumpsink(pipeline, cin, options.output) }}} * The python scripts are available at git repository {{{ > kagra-cal/Observation/Phase1/tutorials/dpush --help Usage: dpush [options] Options: -h, --help show this help message and exit --cache=cache Set the name of the LAL cache listing the frame files (default= k1.cache) --ifo=name Name of the IFO (default= K1) --channel=name Set input channel names; numerator,denominator (default= CAL-CS_PROC_C00_STRAIN_DQ) --ch-rate=rate Set input channel data rate (default= 16384) --dirn=dir Directory name which contain output files of 1sec frames --shared-memory-partition=name Set the name of the shared memory partition to write to. --debug Show debug messages > kagra-cal/Observation/Phase1/tutorials/shmi --help Usage: shmi [options] Options: -h, --help show this help message and exit --shared-memory-partition=name Set the name of the shared memory partition to read from. --ifo=name Name of the IFO (default= K1) --channel=name Set channel name to extract (default= CAL- CS_PROC_C00_STRAIN_DQ --format=format Set input channel format (default= F64LE) --ch-rate=rate Set input channel data rate (default= 16384) --out-rate=rate Set output data rate (default= 1) --output=name Set output file name (default= /dev/stdout) }}} * This is an example to write a C00 strain channel data from k1.cache {{{ > kagra-cal/Observation/Phase1/tutorials/dpush --cache=k1.cache --debug Opening partition K1 for output. Opened frame file: 1sec/K-K1_TEST-1209288320-1.gwf Read frame: file-length/rc 68771 / 68771 Opened frame file: 1sec/K-K1_TEST-1209288321-1.gwf Waiting 999881usec. Read frame: file-length/rc 65135 / 65135 Opened frame file: 1sec/K-K1_TEST-1209288322-1.gwf Waiting 999716usec. Read frame: file-length/rc 66984 / 66984 Opened frame file: 1sec/K-K1_TEST-1209288323-1.gwf Waiting 999697usec. ... }}} * Check if the shared memory partition is created {{{ > smlist id name nBuf lBuf nTotal 32 K1 1 70000 5 }}} * This is an example to read the C00 strain channel data from the shared memory and dump on stdout {{{ > kagra-cal/Observation/Phase1/tutorials/shmi setting pipeline state to playing ... set to playing successfully 1209288326.000000000 1.882813627229751e-10 1209288327.000000000 -2.34722963288192e-10 1209288328.000000000 3.754893097840384e-12 1209288329.000000000 -1.839911834000674e-10 progress_src_input (00:00:05): 1209288330 seconds 1209288330.000000000 1.156410453506673e-10 1209288331.000000000 2.000694471204767e-10 1209288332.000000000 -9.744657164523218e-11 1209288333.000000000 2.505714385980795e-11 1209288334.000000000 -6.590048645671587e-11 progress_src_input (00:00:10): 1209288335 seconds 1209288335.000000000 6.652176726129611e-11 ... }}} * [[KAGRA/Subgroups/CAL/GstLAL/tutorials/step11|(Next) Step 11: Write channel data to shared memory]] * [[KAGRA/Subgroups/CAL/GstLAL/tutorials/step9|(Prev) Step 9: Make an ASD from a frame (cache) file]] * [[KAGRA/Subgroups/CAL/GstLAL/tutorials|Tutorials]]