def MatrixView(self, args): """ Load a matrix from file, then display it in 2d """ hist = SpecReader().GetMatrix(args.filename, args.format) title = hist.GetTitle() viewer = ROOT.HDTV.Display.MTViewer(400, 400, hist, title) self.matviews.append(viewer)
def WriteSpectrum(self, fname, fmt): """ Write the spectrum to file """ fname = os.path.expanduser(fname) try: SpecReader().WriteSpectrum(self._hist, fname, fmt) except SpecReaderError as msg: hdtv.ui.error("Failed to write spectrum: %s (file: %s)" % (msg, fname)) return False return True
def __init__(self, fname, sym): # check if file exists try: os.stat(fname) except OSError as error: hdtv.ui.error(str(error)) raise self.GenerateFiles(fname, sym) basename = self.GetBasename(fname) # call to SpecReader to get the hist try: self.vmatrix = SpecReader().GetVMatrix(fname) except SpecReaderError as msg: hdtv.ui.error(str(msg)) raise self._xproj = FileHistogram(basename + ".prx") self._xproj.typeStr = "Projection" if sym: self._yproj = None self.tvmatrix = None else: self._yproj = FileHistogram(basename + ".pry") self._yproj.typeStr = "Projection" try: self.tvmatrix = SpecReader().GetVMatrix(basename + ".tmtx") except SpecReaderError as msg: hdtv.ui.error(str(msg)) raise self.filename = fname
def Refresh(self): """ Reload the spectrum from disk """ try: os.path.exists(self.filename) except OSError: hdtv.ui.warning("File %s not found, keeping previous data" % self.filename) return # call to SpecReader to get the hist try: hist = SpecReader().GetSpectrum(self.filename, self.fmt) except SpecReaderError as msg: hdtv.ui.warning( "Failed to load spectrum: %s (file: %s), keeping previous data" % (msg, self.filename)) return self.hist = hist
def __init__(self, fname, fmt=None, color=hdtv.color.default, cal=None): """ Read a spectrum from file """ # check if file exists try: os.path.exists(fname) except OSError: hdtv.ui.error("File %s not found" % fname) raise # call to SpecReader to get the hist try: hist = SpecReader().GetSpectrum(fname, fmt) except SpecReaderError as msg: hdtv.ui.error(str(msg)) raise self.fmt = fmt self.filename = fname Histogram.__init__(self, hist, color, cal) self.typeStr = "spectrum, read from file"