def makeplot(self): """ Runs the kendrick analysis on a single of the mass distributions in self.datalist set by self.pos. Plots the results in 1D and 2D. :return: None """ self.getfromgui() self.data1d, data2d, m1grid, m2grid, igrid = ud.kendrick_analysis( self.datalist[self.pos], self.m0, centermode=self.centermode, nbins=self.nbins, transformmode=self.transformmode, xaxistype=self.xtype) if self.yvals is not None: title = str(self.yvals[self.pos]) spacer = "_" else: title = "" spacer = "" try: save_path2d = os.path.join(self.directory, title + spacer + "2D_Mass_Defects.txt") np.savetxt(save_path2d, data2d) save_path1d = os.path.join(self.directory, title + spacer + "1D_Mass_Defects.txt") np.savetxt(save_path1d, self.data1d) print 'Saved: ', save_path2d, save_path1d except Exception, e: print "Failed save", e
def makeplottotal(self, e=None): """ Runs the kendrick analysis on all of the mass distributions in self.datalist. Assumes they are all the same dimensions, which is why we run mergedata when it is loaded. Sums the results and plots the sums in 1D and 2D. :param e: Unused event :return: None """ self.getfromgui() # Run on all igrids = [] m1grid, m2grid = None, None for i, dat in enumerate(self.datalist): self.data1d, data2d, m1grid, m2grid, igrid = ud.kendrick_analysis( dat, self.m0, centermode=self.centermode, nbins=self.nbins, transformmode=self.transformmode, xaxistype=self.xtype) igrids.append(igrid) # Sum and reshape igrids = np.array(igrids) igrids /= np.amax(igrids) sumgrid = np.sum(igrids, axis=0) self.igrids = igrids data2d = np.transpose([ np.ravel(m1grid), np.ravel(m2grid), np.ravel(sumgrid) / np.amax(sumgrid) ]) self.data1d = np.transpose( [np.unique(m2grid), np.sum(sumgrid, axis=0)]) # Save Results save_path2d = os.path.join(self.directory, "Total_2D_Mass_Defects.txt") np.savetxt(save_path2d, data2d) save_path1d = os.path.join(self.directory, "Total_1D_Mass_Defects.txt") np.savetxt(save_path1d, self.data1d) print 'Saved: ', save_path2d, save_path1d # Plots try: self.plot2.contourplot(data2d, self.config, xlab=self.xlab, ylab=self.ylab, title="Total", normflag=1) except Exception, e: self.plot2.clear_plot() print "Failed Plot2", e
def makeplottotal(self, e=None): """ Runs the kendrick analysis on all of the mass distributions in self.datalist. Assumes they are all the same dimensions, which is why we run mergedata when it is loaded. Sums the results and plots the sums in 1D and 2D. :param e: Unused event :return: None """ self.getfromgui() # Run on all igrids = [] m1grid, m2grid = None, None for i, dat in enumerate(self.datalist): self.data1d, data2d, m1grid, m2grid, igrid = ud.kendrick_analysis( dat, self.m0, centermode=self.centermode, nbins=self.nbins, transformmode=self.transformmode, xaxistype=self.xtype) igrids.append(igrid) if self.xtype == 0: factor = 1.0 else: factor = self.m0 # Sum and reshape igrids = np.array(igrids) igrids /= np.amax(igrids) sumgrid = np.sum(igrids, axis=0) self.igrids = igrids data2d = np.transpose([ np.ravel(m1grid), np.ravel(m2grid), np.ravel(sumgrid) / np.amax(sumgrid) ]) self.data1d = np.transpose( [np.unique(m2grid), np.sum(sumgrid, axis=0)]) # Save Results save_path2d = os.path.join(self.directory, self.outfname + "Total_2D_Mass_Defects.txt") np.savetxt(save_path2d, data2d) save_path1d = os.path.join(self.directory, self.outfname + "Total_1D_Mass_Defects.txt") np.savetxt(save_path1d, self.data1d) print('Saved: ', save_path2d, save_path1d) # Plots try: self.plot2.contourplot(data2d, self.config, xlab=self.xlab, ylab=self.ylab, title="Total", normflag=1) except Exception as e: self.plot2.clear_plot() print("Failed Plot2", e) try: self.plot1.colorplotMD(self.datasum[:, 0], self.datasum[:, 1], self.datasum[:, 0] / float(self.m0) % 1.0 * factor, title="Zero-Charge Mass Spectrum", max=factor, xlabel="Mass", ylabel="Intensity") except Exception as e: self.plot1.clear_plot() print("Failed Plot1", e) try: self.plot3.plotrefreshtop(self.data1d[:, 0], self.data1d[:, 1], "Total Projection Black", self.ylab, "Total Intensity", "", self.config) except Exception as e: self.plot3.clear_plot() print("Failed Plot 3", e) try: self.plot4.colorplotMD(self.data1d[:, 0], self.data1d[:, 1], self.data1d[:, 0], title="Total Projection Color", xlabel=self.ylab, cmap="hsv", max=factor, ylabel="Total Intensity", config=self.config) except Exception as e: self.plot4.clear_plot() print("Failed Plot 4", e) if self.flag2: self.make_list_plots()
def makeplot(self): """ Runs the kendrick analysis on a single of the mass distributions in self.datalist set by self.pos. Plots the results in 1D and 2D. :return: None """ self.getfromgui() self.data1d, data2d, m1grid, m2grid, igrid = ud.kendrick_analysis( self.datalist[self.pos], self.m0, centermode=self.centermode, nbins=self.nbins, transformmode=self.transformmode, xaxistype=self.xtype) if self.xtype == 0: factor = 1.0 else: factor = self.m0 if self.yvals is not None: title = self.outfname + str(self.yvals[self.pos]) spacer = "_" else: title = self.outfname spacer = "" try: save_path2d = os.path.join(self.directory, title + spacer + "2D_Mass_Defects.txt") np.savetxt(save_path2d, data2d) save_path1d = os.path.join(self.directory, title + spacer + "1D_Mass_Defects.txt") np.savetxt(save_path1d, self.data1d) print('Saved: ', save_path2d, save_path1d) except Exception as e: print("Failed save", e) try: self.plot2.contourplot(data2d, self.config, xlab=self.xlab, ylab=self.ylab, title=title, normflag=1) except Exception as e: self.plot2.clear_plot() print("Failed Plot2", e) try: self.plot3.plotrefreshtop(self.data1d[:, 0], self.data1d[:, 1], title, self.ylab, "Total Intensity", "", self.config) except Exception as e: self.plot3.clear_plot() print("Failed Plot 3", e) try: if self.m0 == 0: return self.plot1.colorplotMD(self.datalist[self.pos, :, 0], self.datalist[self.pos, :, 1], self.datalist[self.pos, :, 0] / float(self.m0) % 1.0 * factor, max=factor, title="Zero-Charge Mass Spectrum", xlabel="Mass", ylabel="Intensity") except Exception as e: self.plot1.clear_plot() print("Failed Plot1", e) try: self.plot4.colorplotMD(self.data1d[:, 0], self.data1d[:, 1], self.data1d[:, 0], title="Total Projection Color", xlabel=self.ylab, cmap="hsv", max=factor, ylabel="Total Intensity", config=self.config) except Exception as e: self.plot4.clear_plot() print("Failed Plot 4", e)