def getConfigFileFromInput() : """DO NOT PARSE INPUT PARAMETERS IN THIS APPLICATION This is interfere with other applications which really need to use input pars, for example maskeditor... """ return None msg = 'Input pars sys.argv: ' for par in sys.argv : msg += par logger.debug(msg, self.name) #print msg if len(sys.argv) > 2 : usage() msg = 'Too many arguments ...\n' msg += 'EXIT application ...\n' sys.exit (msg) elif len(sys.argv) == 1 : return None else : path = sys.argv[1] if os.path.exists(path) : return path else : usage() msg = 'Requested configuration file "' + path + '" does not exist.\n' msg += 'EXIT application ...\n' sys.exit (msg)
def printStyleInfo(widg): qstyle = widg.style() qpalette = qstyle.standardPalette() qcolor_bkg = qpalette.color(1) #r,g,b,alp = qcolor_bkg.getRgb() msg = 'Background color: r,g,b,alpha = %d,%d,%d,%d' % ( qcolor_bkg.getRgb() ) logger.debug(msg)
def parse_xtc_path(path='.') : logger.debug( 'parse_xtc_path(...): ' + path, __name__) instrument = 'INS' experiment = 'expt' run_str = 'r0000' run_num = 0 bname = os.path.basename(path) # i.e. e167-r0015-s00-c00.xtc try: run_str = bname.split('-')[1] # i.e. r0015 run_num = int(run_str[1:]) # i.e. 15 except : print 'Unexpected xtc file name:', bname print 'Use default instrument, experiment, run_str, run_num: ', instrument, experiment, run_str, run_num return instrument, experiment, run_str, run_num pass dirname = os.path.dirname(path) # i.e /reg/data/ana12/xcs/xcsi0112/xtc fields = dirname.split('/') n_fields = len(fields) if n_fields < 4 : msg1 = 'Unexpected xtc dirname: %s: Number of fields in dirname = %d' % (dirname, n_fields) msg2 = 'Use default instrument, experiment, run_str, run_num: %s %s %s %d' % (instrument, experiment, run_str, run_num) logger.warning( msg1+msg2, __name__) return instrument, experiment, run_str, run_num xtc_subdir = fields[-1] # i.e. xtc experiment = fields[-2] # i.e. xcsi0112 instrument = fields[-3].upper() # i.e. XCS msg = 'Set instrument, experiment, run_str, run_num: %s %s %s %d' % (instrument, experiment, run_str, run_num) logger.debug( msg, __name__) return instrument, experiment, run_str, run_num
def print_substitution_dict (self) : msg = '\nSubstitution dictionary for %s' % self.path_in for k,v in self.d_subs.iteritems() : msg += '\n%s : %s' % (k.ljust(16), v.ljust(32)) logger.debug(msg) logger.debug(msg,__name__) if self.do_test_print : print msg
def on_but_plot(self): self.exportLocalPars() logger.debug('on_but_plot', __name__) try : cp.plotimgspe.close() try : del cp.plotimgspe except : pass except : self.arr = None self.img_arr = None msg = 'Plot image for %s' % self.det_name.value() logger.info(msg, __name__) list_of_fnames = cp.blsp.get_list_of_files_for_all_sources(fnm.path_peds_ave()) \ + cp.blsp.get_list_of_files_for_all_sources(fnm.path_peds_rms()) #print 'list_of_fnames = ', list_of_fnames if list_of_fnames != [] : fname = list_of_fnames[0] if len(list_of_fnames) > 1 : fname = gu.selectFromListInPopupMenu(list_of_fnames) msg = 'Selected file to plot: %s' % fname logger.info(msg, __name__) self.arr = gu.get_array_from_file( fname ) #print self.arr.shape,'\n', self.arr.shape if self.det_name.value() == cp.list_of_dets[0] : # CSAPD, shape = (5920,388) self.arr.shape = (32*185,388) self.img_arr = cspadimg.get_cspad_raw_data_array_image(self.arr) elif self.det_name.value() == cp.list_of_dets[1] : # CSAPD2x2 self.arr.shape = (185,388,2) self.img_arr = cspad2x2img.get_cspad2x2_non_corrected_image_for_raw_data_array(self.arr) elif self.det_name.value() == cp.list_of_dets[2] : # Camera pass elif self.det_name.value() == cp.list_of_dets[3] : # Princeton self.img_arr = self.arr elif self.det_name.value() == cp.list_of_dets[4] : # pnCCD pass if self.img_arr == None : msg = 'self.img_arr == None' return #print arr.shape,'\n', arr.shape cp.plotimgspe = PlotImgSpe(None, self.img_arr, ofname=fnm.path_peds_aver_plot()) #cp.plotimgspe = PlotImgSpe(None, self.img_arr, ifname=fnm.path_peds_ave(), ofname=fnm.path_peds_aver_plot()) #cp.plotimgspe.setParent(self) cp.plotimgspe.move(cp.guimain.pos().__add__(QtCore.QPoint(720,120))) cp.plotimgspe.show()
def onButDeploy(self): logger.debug('onButDeploy', __name__) if self.script == 'Select' : msg = 'Script for processing metrology file is not selected.... Select it first and evaluate constants (Item 4)' logger.warning(msg, __name__) return if self.source_name == 'Select' : msg = 'Detector is not selected. Select it first...' logger.warning(msg, __name__) return list_of_cmds = self.list_of_copy_cmds() txt = '\nList of commands for tentetive file deployment:' for cmd in list_of_cmds : txt += '\n' + cmd logger.info(txt, __name__) msg = 'Approve commands \njust printed in the logger' if self.approveCommand(self.butDeploy, msg) : for cmd in list_of_cmds : fd.procDeployCommand(cmd, 'metrology-alignment') #print 'Command for deployer: ', cmd if cp.guistatus is not None : cp.guistatus.updateStatusInfo()
def closeEvent(self, event): logger.debug('closeEvent', __name__) try: # try to delete self object in the cp del cp.guilistoftau # GUIListOfTau except AttributeError: pass # silently ignore
def on_but_load(self): logger.debug('on_but_load', __name__ ) if self.fexmod : if self.afe_rd.is_new_arr_available() : logger.info('WAIT for image loading', __name__ ) arr = self.afe_rd.get_arr_latest() self.widgimage.set_image_array_new(arr, rot_ang_n90 = self.widgimage.rot_ang_n90, y_is_flip = self.widgimage.y_is_flip) #title='Image from %s...' % self.ifname, logger.info('Image is loaded', __name__ ) return else : logger.info('New image is N/A !', __name__ ) return file_filter = 'Files (*.txt *.data *.npy)\nAll files (*)' path = gu.get_open_fname_through_dialog_box(self, self.ifname, 'Select file with image', filter=file_filter) if path == None or path == '' : logger.info('Loading is cancelled...', __name__ ) return self.ifname = path arr = gu.get_image_array_from_file(path) # dtype=np.float32) if arr is None : return #arr = gu.get_array_from_file(path) # dtype=np.float32) #print 'arr:\n', arr self.widgimage.set_image_array_new(arr, rot_ang_n90 = self.widgimage.rot_ang_n90, y_is_flip = self.widgimage.y_is_flip)
def getHeight(self): logger.debug('getHeight', __name__) h=0 #if self.gui_table is not None : # h += self.gui_table.height() h += 40 # for self.gui_more return h
def closeEvent(self, event): logger.debug('closeEvent', __name__) self.disconnectFromThread1() try : del cp.guirunsplit # GUIRunSplit except : pass
def onStatusMerge(self): logger.debug('onStatusMerge', __name__) bstatus, bstatus_str = bjcora.status_batch_job_for_cora_merge() fstatus, fstatus_str = bjcora.status_for_cora_merge_files(comment='') status_str = '3. MERGE: ' + bstatus_str + ' ' + fstatus_str self.setStatusMessage(fstatus, self.lab_status_merge, status_str) self.setStatusButton(fstatus)
def on_but(self): but = self.get_pushed_but() msg = 'on_but ' + str(but.text()) logger.debug(msg, __name__ ) #if self.verb : print msg but_text = str(but.text()) #Set MODE if but_text in self.list_of_modes : self.fig.my_mode = but_text # Sets mode for Drag objects if self.fig.my_mode == 'Zoom' : self.widgimage.connectZoomMode() self.disconnect_all() self.current_form = None else : self.widgimage.disconnectZoomMode() #Set FORM if but_text in self.list_of_forms : self.disconnect_all() self.current_form = but_text self.connect_form(self.current_form) # Connect objects for NEW form self.setButtonStyle() self.setStatus()
def onClickExpand(self): logger.debug('onClickExpand', __name__) #self.gui_add = QtGui.QLabel('Additional information') self.gui_add = GUIDarkListItemAdd(self, self.str_run_num) self.hboxW.addWidget(self.gui_add) self.setFixedHeight( self.height() + self.gui_add.height() )
def closeEvent(self, event): logger.debug('closeEvent', __name__) try : del cp.guisystemsettingsleft # GUISystemSettingsLeft except : pass try : cp.guiccdsettings.close() except : pass
def makeTabBar(self,mode=None) : #if mode != None : self.tab_bar.close() self.tab_bar = QtGui.QTabBar() #Uses self.list_of_tabnames self.ind_tab_0 = self.tab_bar.addTab( self.list_of_tabnames[0] ) self.ind_tab_1 = self.tab_bar.addTab( self.list_of_tabnames[1] ) self.tab_bar.setTabTextColor(self.ind_tab_0, QtGui.QColor('magenta')) self.tab_bar.setTabTextColor(self.ind_tab_1, QtGui.QColor('magenta')) self.tab_bar.setShape(QtGui.QTabBar.RoundedNorth) #self.tab_bar.setTabEnabled(1, False) #self.tab_bar.setTabEnabled(2, False) #self.tab_bar.setTabEnabled(3, False) #self.tab_bar.setTabEnabled(4, False) try : tab_index = self.list_of_tabnames.index(cp.current_fmanager_tab.value()) except : tab_index = 3 cp.current_fmanager_tab.setValue(self.list_of_tabnames[tab_index]) self.tab_bar.setCurrentIndex(tab_index) logger.debug(' make_tab_bar - set mode: ' + cp.current_fmanager_tab.value(), __name__) self.connect(self.tab_bar, QtCore.SIGNAL('currentChanged(int)'), self.onTabBar)
def getArray(self,imon): logger.debug('getArray for imon: '+str(imon), __name__) arr_all = gu.get_array_from_file(fnm.path_data_scan_monitors_data()) if arr_all == None : return None logger.debug('Array shape: ' + str(arr_all.shape), __name__) ibase = 1+imon*4 arr_imon = arr_all[:,ibase:ibase+4] #print 'arr_imon:\n', arr_imon #print 'arr_imon.shape:', arr_imon.shape #mask = self.maskForIMonChannels(imon) #npmask = np.array(mask,dtype=float) npmask = self.npIntMaskForIMonChannels(imon) size = arr_imon.shape[0] npcol1 = np.ones(size) X,Y = np.meshgrid(npmask,npcol1) arr_prod = (arr_imon * X) arr_sum = arr_prod.sum(1) #print 'npmask=', npmask #print 'size=', size #print X #print X.shape #print arr_imon #print arr_imon.shape #print arr_prod #print arr_prod.shape return arr_sum
def onButEvaluate(self): logger.debug('onButEvaluate', __name__) det = self.get_detector_selected() if det is None : return list_of_metrology_scripts = cp.dict_of_metrology_scripts[det] if self.script == 'Select' : msg = 'Script for processing metrology file is not selected. Select it first...' logger.warning(msg, __name__) return #print 'list_of_metrology_scripts', list_of_metrology_scripts #for CSPAD script CSPADV1 if det == cp.list_of_dets[0] and self.script == list_of_metrology_scripts[0] : msg = 'Evaluate parameters for %s using script %s' % (det, self.script) logger.info(msg, __name__) self.procCspadV1() # for other detectors and scripts for now... else : msg = 'Script %s is not yet implemented for detector %s...' % (self.script, det) logger.warning(msg, __name__) return
def closeEvent(self, event): logger.debug('closeEvent', self.name) if cp.res_save_log : logger.saveLogInFile ( fnm.log_file() ) logger.saveLogTotalInFile( fnm.log_file_total() ) #try : cp.guifiles.close() #except : pass #try : cp.guisetupinfo.close() #except : pass #try : cp.guianasettings.close() #except : pass #try : cp.guisystemsettings.close() #except : pass #try : cp.guiviewresults.close() #except : pass #try : cp.guirun.close() #except : pass try : cp.guilogger.close() except : pass try : cp.guifilebrowser.close() except : pass
def closeEvent(self, event): logger.debug('closeEvent', self.name) try : cp.guifilebrowser.close() except : pass try : cp.plotimgspe.close() except : pass
def closeEvent(self, event): logger.debug('closeEvent', __name__) try : cp.guiviewcontrol.close() except : pass try : del cp.guiviewresults # GUIViewResults except : pass
def on_but_browser (self): logger.debug('on_but_browser', __name__) try : cp.guifilebrowser.close() except : cp.guifilebrowser = GUIFileBrowser(None, [fnm.path_blem()]) cp.guifilebrowser.move(cp.guimain.pos().__add__(QtCore.QPoint(720,120))) cp.guifilebrowser.show()
def onRun (self): logger.debug('onRun', self.name) try : cp.guirun.close() except : cp.guirun = GUIRun() cp.guirun.move(self.pos().__add__(QtCore.QPoint(160,195))) # open window with offset w.r.t. parent cp.guirun.show()
def onViewResults(self): logger.debug('onViewResults', self.name) try : cp.guiviewresults.close() except : cp.guiviewresults = GUIViewResults() cp.guiviewresults.move(self.pos().__add__(QtCore.QPoint(160,230))) # open window with offset w.r.t. parent cp.guiviewresults.show()
def onSystem(self): logger.debug('onSystem', self.name) try : cp.guisystemsettings.close() except : cp.guisystemsettings = GUISystemSettings() cp.guisystemsettings.move(self.pos().__add__(QtCore.QPoint(160,160))) # open window with offset w.r.t. parent cp.guisystemsettings.show()
def onIntMon(self): logger.debug('onIntMon', self.name) try : cp.guiintensitymonitors.close() except : cp.guiintensitymonitors = GUIIntensityMonitors() cp.guiintensitymonitors.move(self.pos().__add__(QtCore.QPoint(160,160))) # open window with offset w.r.t. parent cp.guiintensitymonitors.show()
def getHeight(self): logger.debug('getHeight', __name__) h=0 #h += 30 # self.lab_dir.height() if self.gui_table is not None : h += self.gui_table.height() h += 50 # for self.gui_more return h
def onAnaSettings(self): logger.debug('onAnaSettings', self.name) try : cp.guianasettings.close() except : cp.guianasettings = GUIAnaSettings() cp.guianasettings.move(self.pos().__add__(QtCore.QPoint(160,130))) # open window with offset w.r.t. parent cp.guianasettings.show()
def on_but_status(self): logger.debug('on_but_status', __name__) logger.info('='*110, __name__) bjpeds.check_work_files_for_pedestals() bjpeds.check_batch_job_for_peds_scan() bjpeds.check_batch_job_for_peds_aver() self.check_status()
def onFBrowser (self): logger.debug('onFBrowser', self.name) try : cp.guifilebrowser.close() except : cp.guifilebrowser = GUIFileBrowser(None, fnm.get_list_of_files_total()) cp.guifilebrowser.move(self.pos().__add__(QtCore.QPoint(240,40))) # open window with offset w.r.t. parent cp.guifilebrowser.show()
def redrawArray(self,imon): logger.debug('plotIMon', __name__) arr = self.getArray(imon) if arr == None : return try : cp.plotarray.set_array(arr, title=self.titleForIMon(imon)) except : pass
def startFileBrowser(self, msg): logger.debug('Start the GUIHelp.', __name__) self.box_txt.setText(msg) self.setStatus(0, 'Status: show help info...')
def onItemDoubleClick(self, item): logger.debug('onItemDoubleClick', __name__)
def onEdiFrom(self): logger.debug('onEdiFrom', __name__) self.str_run_from = str(self.edi_from.displayText()) msg = 'Set the run validity range from %s' % self.str_run_from logger.info(msg, __name__)
def onEdiTo(self): logger.debug('onEdiTo', __name__) self.str_run_to = str(self.edi_to.displayText()) msg = 'Set the run validity range up to %s' % self.str_run_to logger.info(msg, __name__)
def closeEvent(self, event): logger.debug('closeEvent', __name__) try : del cp.guiviewcontrol # GUIViewControl except : pass # silently ignore
def closeEvent(self, event): logger.debug('closeEvent', __name__)
def onItemShrink(self, widg): run, item = self.getRunAndItemForWidget(widg) logger.debug('Shrink widget for run %s' % run, __name__) item.setSizeHint(widg.size())
def onEdit(self): logger.debug('onEdit', __name__) edi = self.edi par = cp.res_fname par.setValue( str(edi.displayText()) ) logger.info('Set parameter = ' + str( par.value()), __name__ )
def onExit(self): logger.debug('onExit', self.name) self.close()
def print_substitution_dict(self): logger.debug('Substitution dictionary:', __name__) for k, v in self.d_subs.iteritems(): msg = '%s : %s' % (k.ljust(16), v.ljust(32)) logger.debug(msg)
def setFieldsEnabled(self, is_enabled=True): logger.debug('Set fields enabled: %s' % is_enabled, __name__) #self.lab_rnum .setEnabled(is_enabled) self.but_expand_shrink.setEnabled(is_enabled) self.gui_run.setFieldsEnabled(is_enabled)
def onClose(self): logger.debug('onClose', __name__) self.close()
def setStatusMessage(self, msg='msg is empty...'): logger.debug('Set status message', __name__) self.box_txt.setText(msg)
def getHeight(self): logger.debug('getHeight', __name__) h = self.gui_run.height() if self.gui_add is not None: h += self.gui_add.getHeight() return h + 10