def FT1D(numb1, ppm_offset=0, autoph=True, ph0=0, ph1=0): "Performs FT and corrections of experiment 'numb1' and returns data" def phase_from_param(): "read the proc parame file, and returns phase parameters ok for spike" #print( proc['$PHC0'], proc['$PHC1'] ) ph1 = -float(proc['$PHC1']) # First-order phase correction ph0 = -float(proc['$PHC0']) + ph1 / 2 # Zero-order phase correction zero = -360 * d.axis1.zerotime #print (ph0, ph1) return (ph0, ph1 + zero) proc = bk.read_param(numb1[:-3] + 'pdata/1/procs') d = bk.Import_1D(numb1) d.apod_em(1, 1).zf(2).ft_sim() if not autoph: p0, p1 = phase_from_param() d.phase(p0 + ph0, p1 + ph1) # Performs the stored phase correction else: d.bruker_corr().apmin() # automatic phase correction d.unit = 'ppm' d.axis1.offset += ppm_offset * d.axis1.frequency spec = np.real(as_cpx(d.buffer)) # the following is a bit convoluted baseline correction, bl = correctbaseline(spec, iterations=BC_ITER, nbchunks=d.size1 // 1000) dd = d.copy() dd.set_buffer(bl) dd.unit = 'ppm' d.real() d -= dd # Equal to d=d-dd; Used instead of (spec-bl) return d
def plot_2D(d, scale, numb2, resdir): fiddir = op.dirname(numb2) basedir, fidname = op.split(fiddir) base, manip = op.split(basedir) exptype = bk.read_param(bk.find_acqu(fiddir))['$PULPROG'] exptype = exptype[1:-1] # removes the <...> d.display(scale=scale) plt.savefig( op.join(resdir, '2D', exptype + '_' + fidname + '.pdf')) # Creates a PDF of the 2D spectrum without peaks d.display_peaks(color="g") plt.savefig( op.join(resdir, '2D', exptype + '_' + fidname + '_pp.pdf')) # Creates a PDF of the 2D spectrum with peaks plt.close() return d
def Dprocess_2D(numb2, resdir): "Performs DOSY processing of experiment 'numb2' and produces the spectrum with and without peaks" fiddir = op.dirname(numb2) basedir, fidname = op.split(fiddir) base, manip = op.split(basedir) exptype = bk.read_param(bk.find_acqu(fiddir))['$PULPROG'] exptype = exptype[1:-1] # removes the <...> ppm_offset, ph0, ph1 = get_config(base, manip, fidname) d = bk.Import_2D(numb2) d.unit = 'ppm' if 'ste' in exptype or 'led' in exptype: print("DOSY") d = process_DOSY(numb2, ppm_offset, lazy=DOSY_LAZY) scale = 50.0 else: raise Exception("This is not a DOSY: " + numb2) dd = analyze_2D(d, name=op.join(resdir, '2D', exptype + '_' + fidname)) d.save(op.join(fiddir, "processed.gs2")) return dd, scale
def process_2D(xarg): "Performs all processing of experiment 'numb2' and produces the spectrum with and without peaks" numb2, resdir = xarg fiddir = op.dirname(numb2) basedir, fidname = op.split(fiddir) base, manip = op.split(basedir) exptype = bk.read_param(bk.find_acqu(fiddir))['$PULPROG'] exptype = exptype[1:-1] # removes the <...> ppm_offset, ph0, ph1 = get_config(base, manip, fidname) d = bk.Import_2D(numb2) d.unit = 'ppm' scale = 10.0 sanerank = SANERANK #1. If TOCSY if 'dipsi' in exptype: print("TOCSY") # print exptype if 'dipsi2ph' in exptype: d.apod_sin(maxi=0.5, axis=2).zf(zf2=2).ft_sim() if sanerank != 0: d.sane(rank=sanerank, axis=1) d.apod_sin(maxi=0.5, axis=1).zf(zf1=4).ft_sh_tppi().modulus().rem_ridge() elif 'dipsi2etgpsi' in exptype: d.apod_sin(maxi=0.5, axis=2).zf(zf2=2).ft_sim() if sanerank != 0: d.sane(rank=sanerank, axis=1) d.apod_sin(maxi=0.5, axis=1).zf(zf1=4).ft_n_p().modulus().rem_ridge() scale = 50.0 d.axis2.offset += ppm_offset * d.axis2.frequency if TMS: d = autozero(d) #2. If COSY DQF elif 'cosy' in exptype: print("COSY DQF") d.apod_sin(maxi=0.5, axis=2).zf(zf2=2).ft_sim() if sanerank != 0: d.sane(rank=sanerank, axis=1) d.apod_sin(maxi=0.5, axis=1).zf(zf1=4).ft_sh_tppi().modulus().rem_ridge() scale = 20.0 d.axis2.offset += ppm_offset * d.axis2.frequency if TMS: d = autozero(d) #3. If HSQC elif 'hsqc' in exptype: print("HSQC") if 'ml' in exptype: print("TOCSY-HSQC") d.apod_sin(maxi=0.5, axis=2).zf(zf2=2).ft_sim().conv_n_p() if sanerank != 0: d.sane(rank=sanerank, axis=1) d.apod_sin(maxi=0.5, axis=1).zf(zf1=4).ft_sh().modulus().rem_ridge() scale = 10.0 d.axis2.offset += ppm_offset * d.axis2.frequency if TMS: d = autozero(d, z1=(5, -5)) #4. If HMBC elif 'hmbc' in exptype: print("HMBC") if 'hmbc' in exptype: print("HMBC") d.apod_sin(maxi=0.5, axis=2).zf(zf2=2).ft_sim() if 'et' in exptype: d.conv_n_p() if sanerank != 0: d.sane(rank=sanerank, axis=1) d.apod_sin(maxi=0.5, axis=1).zf( zf1=4).bk_ftF1().modulus().rem_ridge() # For Pharma MB1-X-X series scale = 10.0 d.axis2.offset += ppm_offset * d.axis2.frequency if TMS: d = autozero(d, z1=(5, -5)) #5. If DOSY - Processed in process_DOSY elif 'ste' in exptype or 'led' in exptype: print("DOSY") d = process_DOSY(numb2, ppm_offset, lazy=DOSY_LAZY) scale = 50.0 analyze_2D(d, name=op.join(resdir, '2D', exptype + '_' + fidname)) d.save(op.join(fiddir, "processed.gs2")) return d, scale