import numpy as np import matplotlib.pyplot as plt import readligo as rl start = 842656000 stop = 842670000 # ------------------------------- # Basic Use Case # Load data based on segment list # ------------------------------- segs = rl.getsegs(start, stop, 'H1') for (begin, end) in segs: strain, meta, dq = rl.getstrain(begin, end, 'H1') # -- Your analysis code goes here #---------------------------------------------------------------- # Load all LIGO data from a single file #---------------------------------------------------------------- strain, time, dq = rl.loaddata('ligo_data/H-H1_LOSC_4_V1-842653696-4096.hdf5', 'H1') # --------------------- # Constructing Segments # --------------------- # -- Construct segment list for a given flag segs = rl.getsegs(start, stop, 'H1', flag='BURST_CAT2') # -- Segment lists may be downloaded from the Timeline app # For example, download https://losc.ligo.org/timeline/segments/S5/H1_DATA/842656000/14000/ # as H1_segs.txt segs = rl.SegmentList('H1_segs.txt') # -- Construct segment list based on multiple DQ channels strain, time, dq = rl.loaddata('ligo_data/H-H1_LOSC_4_V1-842653696-4096.hdf5', 'H1') bcat3 = dq['BURST_CAT3'] cbccat3 = dq['CBCLOW_CAT3'] clean = bcat3 & cbccat3 segs = rl.dq2segs(clean, time[0]) # -- Construct segment list based on files in another directory filelist = rl.FileList(directory='./ligo_data') segs = rl.getsegs(start, stop, 'H1', flag='BURST_CAT3', filelist=filelist) # ------------------ # Making File Lists # ------------------ # Make a file list using directory option filelist = rl.FileList(directory='./ligo_data') # Write the filelist to a cache file filelist.writecache('H1.cache') # Make a file list based on an existing cache file filelist = rl.FileList(cache='H1.cache') # Identify file containing a given GPS time gps = 842656000 filename = filelist.findfile(gps, 'H1') print(f"The file {filename} contains time {gps} for IFO H1")