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.TwoDSpectrumContainer() 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.TwoDSpectrum() spect.set_resolution("off") spect.set_data_flag("total") #spect.set_data(data) spect._add_data(data, dtype="total") spect.set_axis_1(xrange) spect.set_axis_3(yrange) spectra.append(spect) cont.set_spectrum(spect, tt) context.container = cont
def step_given_7(context, N, step): """ And I have a ValueAxis of lenght {N} starting from zero with certain {step} """ length = int(N) step = float(step) vaxis = qr.ValueAxis(0.0, length, step) context.vaxis = vaxis context.length = length context.step = step
def step_then_28(context): """ And the TwoDSpectrum container will be indexed by ValueAxis with frequencies corresponding to the original ValueAxis """ fft = context.new_container oldaxis = context.container.axis axis = fft.axis freq = (2.0 * numpy.pi) * numpy.fft.fftfreq(oldaxis.length, oldaxis.step) freq = numpy.fft.fftshift(freq) # this has to be done to get desired precision vax = qr.ValueAxis(freq[0], len(freq), freq[1] - freq[0]) # # Asserting the value axis has the right values # numpy.testing.assert_allclose(axis.data, vax.data)
def get_peak_cross_sections(V, twod_p): cut_long = twod_p.get_cut_along_line(V[0], V[1]) cut_short1 = twod_p.get_cut_along_line(V[3], V[2]) cut_short2 = twod_p.get_cut_along_line(V[2], V[3]) data1 = np.array(cut_short1.data) data2 = np.flip(np.array(cut_short2.data)) data3 = np.hstack((data1, data2)) shift = cut_short1.axis.data[1] + cut_short1.axis.data[-1] cut_short2.axis.data = cut_short2.axis.data + shift new_axis = np.hstack((cut_short1.axis.data, cut_short2.axis.data)) qr_axis = qr.ValueAxis(0.0, len(new_axis), new_axis[1]) short_final = qr.DFunction(qr_axis, data3) data_max = (np.amax(twod_p.data))/2 long_p_1 = next(x for x, val in enumerate(cut_long.data) if val > (data_max)) for_lp2 = np.flip(cut_long.data) long_p_2 = next(x for x, val in enumerate(for_lp2) if val > (data_max)) long_width = cut_long.axis.data[-long_p_2-1] - cut_long.axis.data[long_p_1] short_p_1 = next(x for x, val in enumerate(short_final.data) if val > (data_max)) for_sp2 = np.flip(short_final.data) short_p_2 = next(x for x, val in enumerate(for_sp2) if val > (data_max)) short_width = short_final.axis.data[-short_p_2-1] - short_final.axis.data[short_p_1] fig, ax = plt.subplots(2) ax[0].plot(cut_long.axis.data, cut_long.data) ax[0].set_title('long') ax[1].plot(short_final.axis.data, short_final.data) ax[1].set_title('short') plt.show() return short_width, long_width
t2_save_pathways = INP.t2_save_pathways #[50.0, 100.0, 200.0, 300.0] # # Here we construct a path through parameters space # center = INP.center #600.0 step = INP.step #2.0 max_available_fwhm = INP.max_available_fwhm #100.0 how_many_fwhm = INP.how_many_fwhm #2 #step = 2 Ns_d = int(2.0 * how_many_fwhm * max_available_fwhm / step) # 50 Ns_u = int(2.0 * how_many_fwhm * max_available_fwhm / step) # 50 vax = qr.ValueAxis(center - Ns_d * step, Ns_d + Ns_u + 1, step) trimer = INP.trimer use_trimer = trimer["useit"] trimer_disorder = False # trimer["disorder"] #if use_trimer: # vax2 = qr.ValueAxis(trimer["center2"]-Ns_d*step, Ns_d+Ns_u+1, step) print("\nSummary of simulation parameters\n") print("Energy gap values:") print("Minimal gap =", vax.min) print("Maximum gap =", vax.max) #if use_trimer and trimer_disorder: # print("Minimal gap (2nd dim) =", vax2.min) # print("Maximum gap (2nd dim) =", vax2.max) print("Number of steps =", vax.length)
spects.append(sp) #print("dE =", dE) de_min = cont.get_spectrum(0).get_log_params()["dE"] de2 = cont.get_spectrum(1).get_log_params()["dE"] de_step = de2 - de_min de_N = cont.length() print("de_min:", de_min) print("de_step:", de_step) print("de_N", de_N) # # These are the values of energy gap that the spectra represent # des = qr.ValueAxis(de_min, de_N, de_step) #print(des.data) # # parameters of the disorder # width_dis = numpy.zeros(2, dtype=qr.REAL) width_dis[0] = INP.width_dis[0] #50.0 # cm-1 width_dis[1] = INP.width_dis[1] #50.0 # cm-1 how_many_fwhm = INP.how_many_fwhm # # Average values of the monomer energies # if INP.use_default_values: