Ejemplo n.º 1
0
def build_graph(input, output, acq_coeffs, sync_coeffs, sync_thresh, sync_window):

  # Initialize our top block
  fg = gr.top_block()

  # Source is a file
  src = gr.file_source (gr.sizeof_gr_complex, input)

  # Read coefficients for the acquisition filter (FIR filter)
  dfile = open(acq_coeffs, 'r')
  data = []
  for line in dfile:
    data.append(complex(*map(float,line.strip().strip("()").split(" "))).conjugate())
  dfile.close()
  data.reverse()
  mfilter = gr.fir_filter_ccc(1, data)    # Our matched filter!
  
  # Read coefficients for the sync block
  dfile = open(sync_coeffs, 'r')
  data = []
  for line in dfile:
    data.append(complex(*map(float,line.strip().strip("()").split(" "))).conjugate())
  dfile.close()
  sync = cmusdrg.mf_sync_ccf(data)    # Sync block!

  # Delay component, to sync the original complex with MF output
  delay = gr.delay(gr.sizeof_gr_complex, len(data)-1)

  # Acquisition filter with threshold and window
  acq = cmusdrg.acquisition_filter_ccc(sync_thresh, sync_window)

  # Connect complex input to matched filter and delay
  fg.connect(src, mfilter)
  fg.connect(src, delay)

  # Connect the mfilter and delay to the acquisition filter
  fg.connect(mfilter, (acq, 0))
  fg.connect(delay, (acq, 1))

  # Connect the acquisition filter to the sync block
  fg.connect((acq, 0), (sync, 0))
  fg.connect((acq, 1), (sync, 1))

  # Two file sinks for the output
  fsink = gr.file_sink (gr.sizeof_char, output+"_sync")
  fsink2 = gr.file_sink (gr.sizeof_gr_complex, output+"_acq")
  fg.connect((acq,0), fsink2)
  fg.connect(sync, fsink)

  return fg
Ejemplo n.º 2
0
def build_graph(input, output, acq_coeffs, sync_thresh, sync_window):

  # Initialize our top block
  fg = gr.top_block()

  # Source is a file
  src = gr.file_source (gr.sizeof_gr_complex, input)

  # Read coefficients for the acquisition filter (FIR filter)
  dfile = open(acq_coeffs, 'r')
  data = []
  for line in dfile:
    data.append(complex(*map(float,line.strip().strip("()").split(" "))).conjugate())
  dfile.close()
  data.reverse()
  
  mfilter = gr.fir_filter_ccc(1, data)    # Our matched filter!
#  delay = gr.delay(gr.sizeof_gr_complex, len(data)-1)
  acq = cmusdrg.acquisition_filter_ccc(sync_thresh, sync_window)
  power = gr.complex_to_mag(1)

  # Connect complex input to matched filter and delay
  fg.connect(src, mfilter)
#  fg.connect(src, delay)

  # Connect the mfilter and delay to the acquisition filter
  fg.connect(mfilter, (acq, 0))
  fg.connect(src, (acq, 1))
  
  # Connect the delay component to compute the power
  fg.connect((acq,1), power)

  # Two file sinks for the output
  fsink = gr.file_sink (gr.sizeof_float, output+"_power")
  fsink2 = gr.file_sink (gr.sizeof_gr_complex, output+"_acq")
  fg.connect(power, fsink)
  fg.connect((acq,0), fsink2)

  return fg