def main(self, input_rings, output_rings): """ @param[in] input_rings First ring in this list will be used for data @param[out] output_rings First ring in this list will be used for data output.""" data_accumulate = None for ispan in self.iterate_ring_read(input_rings[0]): if self.nbit < 8: unpacked_data = unpack(ispan.data_view(self.dtype), self.nbit) else: unpacked_data = ispan.data_view(self.dtype) if data_accumulate is not None: data_accumulate = np.concatenate( (data_accumulate, unpacked_data[0])) else: data_accumulate = unpacked_data[0] if self.shape != [1, 1]: data_accumulate = np.reshape(data_accumulate, (self.shape[0], -1)) data_accumulate = data_accumulate.astype(np.complex64) self.out_gulp_size = data_accumulate.nbytes outspan_generator = self.iterate_ring_write(output_rings[0]) ospan = outspan_generator.next() result = np.fft.fft(data_accumulate).astype(np.complex64) ospan.data_view(np.complex64)[0] = result.ravel()
def main(self, input_ring): """Initiate the writing to filename @param[in] input_rings First ring in this list will be used for data @param[out] output_rings This list of rings won't be used.""" span_generator = self.iterate_ring_read(input_ring) data_accumulate = None for span in span_generator: if self.nbit < 8: unpacked_data = unpack(span.data_view(self.dtype), self.nbit) else: if self.dtype == np.complex64: unpacked_data = span.data_view(self.dtype).view(np.float32) elif self.dtype == np.complex128: unpacked_data = span.data_view(self.dtype).view(np.float64) else: unpacked_data = span.data_view(self.dtype) if data_accumulate is not None: data_accumulate = np.concatenate( (data_accumulate, unpacked_data[0])) else: data_accumulate = unpacked_data[0] text_file = open(self.filename, 'a') np.savetxt(text_file, data_accumulate.reshape((1, -1))) text_file.close()