def step_when_2(context): """ When I create a new TwoDResponse object """ context.twod = qr.TwoDResponse()
def step_given_9(context): """ And I create a new TwoDResponse object """ context.twod = qr.TwoDResponse()
def get_resp_object(respR, respN, time_ax, rwa, time_t2): onetwod = qr.TwoDResponse() tstart = int(time_ax[0]) tlen = int(len(time_ax)) tstep = int(time_ax[1]-time_ax[0]) t13 = qr.TimeAxis(tstart, tlen, tstep) t13.atype = 'complete' oa13 = t13.get_FrequencyAxis() oa13.data += rwa oa13.start += rwa onetwod.set_axis_1(oa13) onetwod.set_axis_3(oa13) ftresp = np.fft.fft(respR,axis=1) ftresp = np.fft.ifft(ftresp,axis=0) reph2D = np.fft.fftshift(ftresp) ftresp = np.fft.ifft(respN,axis=1) ftresp = np.fft.ifft(ftresp,axis=0)*ftresp.shape[1] nonr2D = np.fft.fftshift(ftresp) onetwod.set_resolution("signals") onetwod._add_data(reph2D, dtype=qr.signal_REPH) onetwod._add_data(nonr2D, dtype=qr.signal_NONR) onetwod.set_t2(time_t2) return onetwod
def _container(context, N, cls): import numpy Nn = int(N) spectra = [] def func(x, y, t): Delta = 10.0 omega = 2.0 * 3.14159 / 20.0 gamma = 1.0 / 100.0 data = numpy.zeros((len(x), len(y))) for i_x in range(len(x)): data[i_x, :] = numpy.exp(-((x[i_x]+y)/Delta)**2)* \ numpy.cos(omega*t)*numpy.exp(-t/gamma) return data time = cls(0.0, Nn, 2.0) xrange = qr.ValueAxis(-50.0, 100, 1.0) yrange = qr.ValueAxis(-50.0, 100, 1.0) cont = qr.TwoDResponseContainer() cont.use_indexing_type(time) for k_n in range(Nn): tt = time.data[k_n] data = func(xrange.data, yrange.data, tt) spect = qr.TwoDResponse() spect.set_resolution("off") spect.set_data_flag(qr.signal_TOTL) #spect.set_data(data) spect._add_data(data, dtype=qr.signal_TOTL) spect.set_axis_1(xrange) spect.set_axis_3(yrange) spectra.append(spect) cont.set_spectrum(spect, tt) context.container = cont
def step_given_1(context, N): """ Given that I have {N} TwoDResponse objects """ spectra = [] ids = [] for i_n in range(int(N)): spec = qr.TwoDResponse() itsid = id(spec) spectra.append(spec) ids.append(itsid) context.spectra = spectra context.ids = ids
def get_spectrum_from_data(xax, yax, data, timestamp): x_ax_n = len(xax) x_ax_start = xax[0] x_ax_fin = xax[-1] x_ax_len = x_ax_fin - x_ax_start x_ax_step = x_ax_len / x_ax_n x_ax = qr.FrequencyAxis(x_ax_start, x_ax_n, x_ax_step) y_ax_n = len(yax) y_ax_start = yax[0] y_ax_fin = yax[-1] y_ax_len = y_ax_fin - y_ax_start y_ax_step = y_ax_len / y_ax_n y_ax = qr.FrequencyAxis(y_ax_start, y_ax_n, y_ax_step) onetwod = qr.TwoDResponse() onetwod.set_axis_1(x_ax) onetwod.set_axis_3(y_ax) onetwod._add_data(data, resolution="off") onetwod.set_t2(timestamp) return onetwod