Exemplo n.º 1
0
    strain, time, chan_dict = rl.loaddata(fn_L1, 'H1')

    print("Contents of all the key, value pairs in chan_dict")
    for keys, values in chan_dict.items():
        print(keys)
        print(values)

    print('Total number of non-NaNs in these data = ',
          np.sum(~np.isnan(strain)))
    print('GPS start, GPS stop and length of  all data in this file = ',
          time[0], time[-1], len(strain))

    # select the level of data quality; default is "DATA" but "CBC_CAT3" is a conservative choice:
    DQflag = 'CBC_CAT3'
    # readligo.py method for computing segments (start and stop times with continuous valid data):
    segment_list = rl.dq_channel_to_seglist(chan_dict[DQflag])
    print('Number of segments with DQflag', DQflag, ' = ', len(segment_list))

    # loop over seconds and print out start, stop and length:
    iseg = 0
    for segment in segment_list:
        time_seg = time[segment]
        seg_strain = strain[segment]
        print('GPS start, GPS stop and length of segment', iseg,
              'in this file = ', time_seg[0], time_seg[-1], len(seg_strain))
        iseg = iseg + 1
        # here is where you would insert code to analyze the data in this segment.

    # now look at segments with no CBC hardware injections:
    DQflag = 'NO_CBC_HW_INJ'
    segment_list = rl.dq_channel_to_seglist(chan_dict['NO_CBC_HW_INJ'])
Exemplo n.º 2
0
print "Contents of all the key, value pairs in chan_dict"
for keys,values in chan_dict.items():
    print(keys)
    print(values)

print "We see that all keys have 32 seconds of '1', meaning the data pass all data quality flags"
print "and have no HW injections, except there are CW injections in L1."
print " "
print 'Total number of non-NaNs in these data = ',np.sum(~np.isnan(strain))
print 'GPS start, GPS stop and length of  all data in this file = ',time[0], time[-1],len(strain)

# select the level of data quality; default is "DATA" but "CBC_CAT3" is a conservative choice:
DQflag = 'CBC_CAT3'
# readligo.py method for computing segments (start and stop times with continuous valid data):
segment_list = rl.dq_channel_to_seglist(chan_dict[DQflag])
print 'Number of segments with DQflag',DQflag,' = ',len(segment_list)

# loop over seconds and print out start, stop and length:
iseg = 0
for segment in segment_list:
    time_seg = time[segment]
    seg_strain = strain[segment]
    print 'GPS start, GPS stop and length of segment',iseg,         'in this file = ',time_seg[0], time_seg[-1], len(seg_strain)
    iseg = iseg+1
    # here is where you would insert code to analyze the data in this segment.
    
# now look at segments with no CBC hardware injections:
DQflag = 'NO_CBC_HW_INJ'
segment_list = rl.dq_channel_to_seglist(chan_dict['NO_CBC_HW_INJ'])
print 'Number of segments with DQflag',DQflag,' = ',len(segment_list)
Exemplo n.º 3
0
print '* File name: ', fname
strain, time, channel_dictionary = rl.loaddata(fname)

data_len = len(time)
time_spacing = time[1] - time[0]
fs = int(1/time_spacing)

print '* Number of samples: ', data_len, ' = 2^', np.log2(data_len)
print '* Start GPS Time: ', time[0]
print '* End GPS Time: ', time[data_len - 1]
print '* Sampling Time: ', time_spacing, 'sec => ', fs, ' Hz'
print ''  # blank line

# Select a data segment without errors ("good data")
print '=== DQ good segments ==='
seglist = rl.dq_channel_to_seglist(channel_dictionary['DEFAULT'], fs)
num_seg = len(seglist)
print "* Number of uninterrupted 'good' segments: ", num_seg

seg_index = 0  # Select which good time segment to use
print '* Use segment #', seg_index
time_seg = time[seglist[seg_index]]
time_seg_min = min(time_seg)
time_seg_max = max(time_seg)
time_len = time_seg_max - time_seg_min
print '* Length of segment ', time_len, 'sec => ', time_len * fs, ' samples'
print ''

# Extract a chunk of data from the selected segment
print '=== Extracting a chunk of data from selected segment ==='
chunk_length_sec = 16  # s
Exemplo n.º 4
0
import numpy as np
import matplotlib.pyplot as plt
import readligo as rl
#----------------------------------------------------------------
# Load all GWOSC data from a single file 
#----------------------------------------------------------------
strain, time, chan_dict = rl.loaddata(
                          'H-H1_LOSC_4_V1-815411200-4096.hdf5', 'H1')
slice_list = rl.dq_channel_to_seglist(chan_dict['DATA'])
for slice in slice_list:
    time_seg = time[slice]
    strain_seg = strain[slice]
    # -- Do stuff with strain segment here
Exemplo n.º 5
0
m2 = 29.237
a1 = 0.355
a2 = -0.769
approx = 'lalsim.SEOBNRv2'
fband = [43.0, 300.0]
f_min = 10.0

strain1, time1, channel_dict1 = rl.loaddata(fn_H1, 'H1')
ts1 = time1[1] - time1[0]  #-- Time between samples
fs1 = int(1.0 / ts1)  #-- Sampling frequency

strain2, time2, channel_dict2 = rl.loaddata(fn_L1, 'L1')
ts2 = time2[1] - time2[0]  #-- Time between samples
fs2 = int(1.0 / ts2)  #-- Sampling frequency

segList1 = rl.dq_channel_to_seglist(channel_dict1['DEFAULT'], fs1)
length1 = 16  # seconds
strain_seg1 = strain1[segList1[0]][0:(length1 * fs1)]
time_seg1 = time1[segList1[0]][0:(length1 * fs1)]

segList2 = rl.dq_channel_to_seglist(channel_dict2['DEFAULT'], fs2)
length2 = 16  # seconds
strain_seg2 = strain2[segList2[0]][0:(length2 * fs2)]
time_seg2 = time2[segList2[0]][0:(length2 * fs2)]

strain_H1 = strain_seg1
time_H1 = time_seg1
chan_dict_H1 = channel_dict1

strain_L1 = strain_seg2
time_L1 = time_seg2
Exemplo n.º 6
0
import numpy as np
import h5py
import matplotlib.pyplot as plt
import matplotlib.mlab as mlab
import readligo as rl
fileName = 'V-V1_GWOSC_O2_4KHZ_R1-1185615872-4096.hdf5'
strain, time, channel_dict = rl.loaddata(fileName)
ts = time[1] - time[0]  #-- Time between samples
fs = int(1.0 / ts)  #-- Sampling frequency
segList = rl.dq_channel_to_seglist(channel_dict['DEFAULT'], fs)
length = 16  # seconds
strain_seg = strain[segList[0]][0:(length * fs)]
time_seg = time[segList[0]][0:(length * fs)]
fig = plt.figure(figsize=(10, 10))
fig.subplots_adjust(wspace=0.3, hspace=0.3)
plt.subplot(321)
plt.plot(time_seg - time_seg[0], strain_seg)
plt.xlabel('Time since GPS ' + str(time_seg[0]))
plt.ylabel('Strain')

window = np.blackman(strain_seg.size)
windowed_strain = strain_seg * window
freq_domain = np.fft.rfft(windowed_strain) / fs
freq = np.fft.rfftfreq(len(windowed_strain)) * fs

plt.subplot(322)
plt.loglog(freq, abs(freq_domain))
plt.axis([10, fs / 2.0, 1e-24, 1e-18])
plt.grid('on')
plt.xlabel('Freq (Hz)')
plt.ylabel('Strain / Hz')
Exemplo n.º 7
0
    return pxx, freq
'''''


# -- Read in the file and data
fileName = '/Users/juliabellamy/PycharmProjects/ligo_stuff/LIGO/H-H1_LOSC_C00_4_V1-1186739813-4096.hdf5'
strain, time, channel_dict = rl.loaddata(fileName)
ts = time[1] - time[0]  # Time between samples
fs = int(1.0 / ts)  # Sampling frequency
print("fs: " + str(fs))


# -- Choose a few seconds of "good data"
# this splits the time series into the sections of good data that can be used as a default analysis
# can look into the flag qualities to divide the list differently if we needed different things
segList = rl.dq_channel_to_seglist(channel_dict['DEFAULT'], fs)  # section of good data
length = 16  # seconds
# take the section of good data and get the data
strain_seg = strain[segList[0]][0:(length * fs)]
time_seg = time[segList[0]][0:(length * fs)]
print("len(strain_seg): " + str(len(strain_seg)))


# Plot the time series
plt.figure()
plt.plot(time_seg - time_seg[0], strain_seg)
plt.title("Time series")
plt.xlabel('Time since GPS ' + str(time_seg[0]))
plt.ylabel('Strain')
plt.show()