parser.add_argument('--partition',default=None,nargs='+',help='Field name(s) to partition on. Partitioning only occurs if this is provided, otherwise partnum, partmin, and partmax are not used. Partition names appended to outfile as outfile_nm') parser.add_argument('--histclipmax',default=None,type=float,help='Values above are set to 0') parser.add_argument('--histclipmin',default=None,type=float,help='Values below are set to 0') parser.add_argument('--flatten',action='store_true',help='Sum the array to a single value after clipping') parser.add_argument('--savelst',action='store_true',help='Assuming flat data, save output as text file columns') parser.add_argument('--background',default=None,help='Subtract before histogram clipping, should be h5 file with same fields.') parser.add_argument('infile',help='the dat file (or a .npz file output from datview/datexport)') parser.add_argument('outfile',help='the output file, use %%s to show location of partition name. Will be h5 format') args=parser.parse_args() model=DataModel(args.infile,args.group,cfg=ModelConfig(args.cfg)) if args.filter is not None: model.loadFilters(args.filter) assert model.canSaveLst() args.model=model partitions=None if args.partition is not None: partitions=model.partitionMulti(args.partition,args.partmin,args.partmax,args.partnum) if '%s' not in args.outfile and not args.savelst: args.outfile +="_%s" backgrounds=None if args.background is not None:
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Author: Natasha Stander import sys,os import argparse import numpy as np sys.path.append(os.path.dirname(sys.path[0])) from api.datamodel import DataModel from api.modelcfg import ModelConfig parser=argparse.ArgumentParser(description='Show the min (with -1), min(no -1), mean (no -1), max of each column.') parser.add_argument('--cfg',default=None,help='Use the provided configuration file (xml) instead of the default one. Default one is found in api/modelcfg.xml') parser.add_argument('infile',help='the dat file') args=parser.parse_args() model=DataModel(args.infile,None,cfg=ModelConfig(args.cfg)) print("name\tmin (all)\tmin (no -1)\tmean\tmax") for col in model.cols: print (col,np.min(model.data[col]), model.fieldmin(col), np.mean(model.data[col][model.data[col]!= -1]),np.max(model.data[col]),sep="\t")
) parser.add_argument( '--cfg', default=None, help= 'Use the provided configuration file (xml) instead of the default one. Default one is found in api/modelcfg.xml' ) parser.add_argument( 'infiles', nargs='+', help= 'dat files (npz not accepted). Files must have the same columns relative to each other' ) args = parser.parse_args() cfg = ModelConfig(args.cfg) if args.alias is None: args.alias = [] for infile in args.infiles: args.alias.append(os.path.basename(infile)) with open(args.infiles[0]) as dfile: hdrline = dfile.readline().strip() cols = hdrline.split(cfg.sep) if cfg.commentchar is not None: cols[0] = cols[0].replace(cfg.commentchar, "") synccols = [] for c in args.synccols: if c in cols:
def __init__(self, datfile, groupfile, filterfile, cfg, geom, mask): QMainWindow.__init__(self) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.setAttribute(Qt.WA_DeleteOnClose) self.setWindowTitle("Datview: %s" % datfile) config = ModelConfig(cfg) self.model = DataModel(datfile, groupfile, cfg=config) self.histcolumns = config.histperrow if filterfile is not None: self.model.loadFilters(filterfile) self.ui.actionSave_Dat.triggered.connect(self.onSaveDat) self.ui.actionSave_List.setEnabled(self.model.canSaveLst()) self.ui.actionSave_List.triggered.connect(self.onSaveLst) self.ui.actionSave_Stream.setEnabled(self.model.canSaveStream()) self.ui.actionSave_Stream.triggered.connect(self.onSaveStream) self.ui.actionSave_Numpy.setEnabled(self.model.canSaveNumpy()) self.ui.actionSave_Numpy.triggered.connect(self.onSaveNumpy) self.ui.actionScatter.triggered.connect(self.onShowScatter) self.ui.action2D_Histogram.triggered.connect(self.onShowHist2d) self.ui.actionPixel.triggered.connect(self.onShowPixelPlot) self.ui.actionAggregated_Plot.triggered.connect(self.onShowAggPlot) self.ui.actionOpen.setVisible(False) self.ui.actionSave_Plot.setVisible(False) self.ui.actionComparison_Scatter.setVisible( self.model.hasComparisons()) self.ui.actionComparison_Scatter.triggered.connect( self.onShowCmpScatter) self.ui.actionComparison_2D_Histogram.setVisible( self.model.hasComparisons()) self.ui.actionComparison_2D_Histogram.triggered.connect( self.onShowCmpHist2d) self.filtmessage = QLabel(self) self.ui.statusbar.addWidget(self.filtmessage) self.onFilterChange() self.model.filterchange.connect(self.onFilterChange) # Histogram Menu self.checkedhistograms = [] self.cachedHistograms = {} self.ui.menuHistogram_Bar.removeAction(self.ui.actionReset) self.addHistogramMenu( self.model.cfg.defaultHistograms & set(self.model.cols), True) self.ui.menuHistogram_Bar.addSeparator() self.addHistogramMenu( set(self.model.cols) - self.model.cfg.defaultHistograms - self.model.cfg.internalCols, False) self.placeHistograms() # Filter Panel self.controlPanel = MyControlPanel(self.model, parent=self) self.controlPanel.setWindowFlags(Qt.Window) self.ui.actionViewControls.triggered.connect(self.controlPanel.show) self.ui.actionSave_Filters.triggered.connect( self.controlPanel.onSaveFilters) # Item Viewer itemviewer = MyItemViewer(self.model, geom, mask, parent=self) itemviewer.setWindowFlags(Qt.Window) self.ui.actionItem_Viewer.triggered.connect(itemviewer.show) self.controlPanel.flagselected.connect(itemviewer.model.setRow) if qt5: self.ui.plotScrollArea.viewport().installEventFilter(self)