def test_getAddedChannel(self): TOF = pySPM.ITA(data) img1 = TOF.getAddedImageByMass(107) img2, CH = TOF.getAddedImageByName('Ag', strict=True) assert len(CH) == 1 assert CH[0]['assign'] == 'Ag+' assert np.all(img1.pixels == img2.pixels)
def open(self, t_filename=None): settings = QSettings(QSettings.IniFormat, QSettings.UserScope, "pySPM", "pySPM") if t_filename is None: home = QDir.cleanPath(os.getenv("HOMEPATH")) path = settings.value("lastPath", home) self.filename = QFileDialog.getOpenFileName( None, "Choose measurement file", path, "*.ita") else: self.filename = t_filename check_file = QFileInfo(self.filename) self.setWindowTitle(check_file.fileName()) if not check_file.exists() or not check_file.isFile(): return settings.setValue("lastPath", check_file.path()) self.ita = pySPM.ITA(self.filename) self.t, self.S = self.ita.getSpectrum(time=True) self.sf, self.k0 = self.ita.get_mass_cal() self.mass = pySPM.utils.time2mass(self.t, self.sf, self.k0) self.spec = self.ax.plot(self.mass, self.S)[0] SatLevel = self.ita.size['pixels']['x'] * self.ita.size['pixels'][ 'y'] * self.ita.Nscan self.sat_level = self.ax.axhline(SatLevel, color='r') if 'pySPM' in self.ita.root.goto("MassScale"): self.MassCal = [] N = self.ita.root.goto("MassScale/pySPM/N").get_ulong() for i in range(N): elt = self.ita.root.goto("MassScale/pySPM/" + str(i) + "/elt").value.decode('utf8') mass = self.ita.root.goto("MassScale/pySPM/" + str(i) + "/mass").get_double() time = self.ita.root.goto("MassScale/pySPM/" + str(i) + "/time").get_double() self.MassCal.append(dict(elt=elt, mass=mass, time=time)) else: self.MassCal = [] for x in self.ita.root.goto("MassScale/calib"): if x.name == 'assign': self.MassCal.append({'elt': x.get_string()}) if x.name == 'mcp': mcp = struct.unpack("<10d", x.value) self.MassCal[-1]['time'] = mcp[0] self.MassCal[-1]['mass'] = mcp[1] self.DoMassCal()
def __init__(self, filename=None): super(QWidget, self).__init__() self.ui = Ui_slicer() self.ui.setupUi(self) self.canvas = self.ui.mpl.canvas self.fig = self.ui.mpl.canvas.fig self.initPlotLayout() self.level = None if filename is None: if len(sys.argv) < 2: self.path, _ = QFileDialog.getOpenFileName( self, "ITA Image", "", "(*.ITA)") else: # If an argument is sent to the script, the first argument will be used as a Path. Very usefull for debugging the script without having to selectr the folder each time with window dialog self.path = sys.argv[1] else: self.path = filename if not os.path.exists(self.path): raise Exception("File \"{}\" is not found".format(self.path)) if os.path.exists(self.path + ".level.npy"): self.level = np.load(self.path + ".level.npy") self.curs = [0, 0, 0] self.volume = None self.ITA = pySPM.ITA(self.path) for i, x in enumerate(self.ITA.get_masses()): self.ui.peakList.setRowCount(i + 1) self.ui.peakList.setItem(i, 0, QTableWidgetItem(x['assign'])) self.ui.peakList.setItem( i, 1, QTableWidgetItem("{:.2f}u".format((x['cmass'])))) self.ui.peakList.setItem( i, 2, QTableWidgetItem("{:.2f}u".format(x['umass'] - x['lmass']))) self.ui.peakList.show() self.ui.cmap.currentIndexChanged.connect(self.plot) self.ui.prof1daxis.currentIndexChanged.connect(self.plot) self.ui.peakList.cellClicked.connect(self.load_channel) self.canvas.mpl_connect('button_press_event', self.on_pick) self.flatAction = QAction("Flatten substrate from this channel") self.flatAction.triggered.connect(self.flatten) self.ui.correction.stateChanged.connect(self.plot) self.ui.peakList.addAction(self.flatAction) self.ui.status.setText("IDLE")
def test_SI_image(self): TOF = pySPM.ITA(data) assert TOF.img.pixels.shape[0] == TOF.size['pixels']['y'] assert TOF.img.pixels.shape[1] == TOF.size['pixels']['x']
def test_ITA_loading(self): TOF = pySPM.ITA(data)