Example #1
0
    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
Example #2
0
def get_image_array_from_file(fname, dtype=np.float32) :

    arr = get_array_from_file(fname, dtype)
    if arr is None :
        return None

    img_arr = None
        
    if   arr.size == 32*185*388 : # CSPAD
        arr.shape = (32*185,388) 
        img_arr = cspadimg.get_cspad_raw_data_array_image(arr)

    elif arr.size == 185*388*2 : # CSPAD2x2
        arr.shape = (185,388,2) 
        img_arr = cspad2x2img.get_cspad2x2_non_corrected_image_for_raw_data_array(arr)

    elif arr.ndim == 2 : # Use it as any camera 2d image
        img_arr = arr

    else :
        msg = 'Array loaded from file: %s\n has shape: %s, size: %s, ndim: %s' % \
              (fname, str(arr.shape), str(arr.size), str(arr.ndim))
        msg += '\nIs not recognized as image'
        logger.warning(msg, __name__)         
        return None

    return img_arr
Example #3
0
    def onButDet(self):
        #print 'onButDet'
        #item_selected = gu.selectFromListInPopupMenu(cp.list_of_dets)
        #if item_selected is None : return            # selection is cancelled
        #if item_selected == self.instr_name.value() : return # selected the same item  
        #self.setDet(item_selected)
        
        list_of_cbox = []
        #for det in cp.list_of_dets :
        for det_name, det_data_type, det_cbx_state in cp.list_of_det_pars :
            #print 'Detector list:', det_name, det_data_type, det_cbx_state.value()    
            list_of_cbox.append([det_name, det_cbx_state.value()])

        #list_of_cbox_out = gu.changeCheckBoxListInPopupMenu(list_of_cbox, win_title='Select Detectors')
        resp = gu.changeCheckBoxListInPopupMenu(list_of_cbox, win_title='Select detector(s)')

        if resp != 1 : return # at cancel

        str_of_detectors = ''

        for [name,state],state_par in zip(list_of_cbox, cp.det_cbx_states_list) :
            #print  '%s checkbox is in state %s' % (name.ljust(10), state)
            state_par.setValue(state)
            if state : str_of_detectors += name + ' '

        self.det_name.setValue(str_of_detectors.rstrip(' '))

        if self.det_name.value() == '' :
            self.butDet.setStyleSheet(cp.styleButtonBad)
            logger.warning('At least one detector needs to be selected !!!', __name__)
            self.setDet('Select')
            return

        self.setDet()
        self.setStyleButtons()
Example #4
0
    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 cfg_file_body_for_peds_aver(self) :

        txt_cfg_body   = '#Module parameters'
        self.ind = 0

        for det_name in cp.list_of_dets_selected() :
            lst_tepes, lst_srcs = cp.blsp.list_of_types_and_sources_for_detector(det_name)
            list_path_peds_ave    = gu.get_list_of_files_for_list_of_insets(fnm.path_peds_ave(),    lst_srcs)
            list_path_peds_rms    = gu.get_list_of_files_for_list_of_insets(fnm.path_peds_rms(),    lst_srcs)
            list_path_hotpix_mask = gu.get_list_of_files_for_list_of_insets(fnm.path_hotpix_mask(), lst_srcs)

            if self.do_test_print : print 'Detector selected: %10s' % (det_name), '  sources:', lst_srcs

            for (self.source, self.fname_ave, self.fname_rms, self.fname_mask) in zip(lst_srcs, list_path_peds_ave, list_path_peds_rms, list_path_hotpix_mask) :
                self.ind += 1 
                #print self.ind, self.source, self.fname_ave, self.fname_rms

                # list_of_dets   = ['CSPAD', 'CSPAD2x2', 'Princeton', 'pnCCD', 'Tm6740', 'Opal2000', 'Opal4000', 'Acqiris'] 
                #if   det_name == cp.list_of_dets[0] : self.add_cfg_module_peds_aver_cspad('cspad_mod.CsPadPedestals')
                #elif det_name == cp.list_of_dets[1] : self.add_cfg_module_peds_aver_cspad('cspad_mod.CsPad2x2Pedestals')
                if   det_name == cp.list_of_dets[0] : self.add_cfg_module_peds_aver_cspad_with_mask('CSPadPixCoords.CSPadNDArrProducer')
                elif det_name == cp.list_of_dets[1] : self.add_cfg_module_peds_aver_cspad_with_mask('CSPadPixCoords.CSPad2x2NDArrProducer')
                elif det_name == cp.list_of_dets[2] : self.add_cfg_module_peds_aver_princeton()
                elif det_name == cp.list_of_dets[3] : self.add_cfg_module_peds_aver_pnccd()
                elif det_name == cp.list_of_dets[4] : self.add_cfg_module_peds_aver_camera()
                elif det_name == cp.list_of_dets[5] : self.add_cfg_module_peds_aver_camera()
                elif det_name == cp.list_of_dets[6] : self.add_cfg_module_peds_aver_camera()
                elif det_name == cp.list_of_dets[7] : self.add_cfg_module_peds_aver_acqiris()
                elif det_name == cp.list_of_dets[8] : self.print_warning()
                else : logger.warning('UNKNOWN DETECTOR: %s' % det_name, __name__)
Example #6
0
    def list_of_sorted_calib_files(self) :

        list_of_fnames = os.listdir(self.path)
        if list_of_fnames == [] :
            logger.warning('Directory %s IS EMPTY!' % self.path, __name__)
            return []
        return list_of_sorted_calib_files_from_list_of_files(list_of_fnames)
Example #7
0
def batch_job_submit(command, queue='psnehq', log_file='batch-log.txt') :

    if os.path.lexists(log_file) : remove_file(log_file)

    out, err = subproc(['bsub', '-q', queue, '-o', log_file, command])
    line_fields = out.split()
    if line_fields[0] != 'Job' :
        msg = 'EXIT: Unexpected response at batch submission:\nout: %s \nerr: %s'%(out, err)
        print msg
        logger.warning(msg, __name__) 
        #sys.exit(msg)
        job_id_str = 'JOB_ID_IS_UNKNOWN'
    else :
        job_id_str = line_fields[1].strip('<').rstrip('>')

    if err != '' :
        msg = ''
        if 'job being submitted without an AFS token' in err :
            msg = err + '      This warning does not matter for jobs on LCLS NFS, continue' 
        else :
            msg = '\n' + 80*'!' + '\n' + err + 80*'!' + '\n'

        logger.warning(msg, __name__) 

    logger.info(out, __name__) 

    return job_id_str, out, err
Example #8
0
def get_array_from_file(fname) :
    if os.path.lexists(fname) :
        logger.info('Get array from file: ' + fname, __name__)         
        return np.loadtxt(fname, dtype=np.float32)
    else :
        logger.warning(fname + ' is not available', __name__)         
        return None
Example #9
0
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
Example #10
0
    def onButView(self):
        logger.info('onButView', __name__)
        if   self.but_Ip           .hasFocus() : self.selectedOption(  0, '<Ip> map, ',   show_tau=True)
        elif self.but_If           .hasFocus() : self.selectedOption(  1, '<If> map, ',   show_tau=True)
        elif self.but_I2           .hasFocus() : self.selectedOption(  2, '<Ip x If>, ',  show_tau=True)
        elif self.but_g2raw        .hasFocus() : self.selectedOption(  3, 'g2 raw map, ', show_tau=True)
        elif self.but_X            .hasFocus() : self.selectedOption(  4, 'X map')
        elif self.but_Y            .hasFocus() : self.selectedOption(  5, 'Y map')
        elif self.but_R            .hasFocus() : self.selectedOption(  6, 'R map')
        elif self.but_P            .hasFocus() : self.selectedOption(  7, 'Phi map')
        elif self.but_Q            .hasFocus() : self.selectedOption(  8, 'Q map' )
        elif self.but_P_st         .hasFocus() : self.selectedOption(  9, 'Phi map for static bins')
        elif self.but_Q_st         .hasFocus() : self.selectedOption( 10, 'Q map for static bins')
        elif self.but_P_dy         .hasFocus() : self.selectedOption( 11, 'Phi map for dynamic bins')
        elif self.but_Q_dy         .hasFocus() : self.selectedOption( 12, 'Q map for dynamic bins')
        elif self.but_QP_st        .hasFocus() : self.selectedOption( 13, 'Q-Phi map for static bins')
        elif self.but_QP_dy        .hasFocus() : self.selectedOption( 14, 'Q-Phi map for dynamic bins')
        elif self.but_1oIp         .hasFocus() : self.selectedOption( 15, '1/<Ip> norm. map for static bins, ', show_tau=True)
        elif self.but_1oIf         .hasFocus() : self.selectedOption( 16, '1/<If> norm. map for static bins, ', show_tau=True)
        elif self.but_g2map        .hasFocus() : self.selectedOption( 17, 'g2 map, ',                           show_tau=True)
        elif self.but_g2dy         .hasFocus() : self.selectedOption( 18, 'g2 map for dynamic bins, ',          show_tau=True)
        elif self.but_g2tau        .hasFocus() : self.selectedOption( 19, 'g2 vs itau')
        #elif self.but_g2tau_gr     .hasFocus() : self.selectedOption( 20, 'g2(tau) for dynamic bins')

        elif self.but_mask_img_lims.hasFocus() : self.selectedOption( 30, 'Mask image limits')
        elif self.but_mask_blemish .hasFocus() : self.selectedOption( 31, 'Mask blemish')
        elif self.but_mask_hotpix  .hasFocus() : self.selectedOption( 32, 'Mask hot pixels')
        elif self.but_mask_regs    .hasFocus() : self.selectedOption( 33, 'Mask for good regions')
        elif self.but_mask_total   .hasFocus() : self.selectedOption( 34, 'Mask total')
        else :
            logger.warning('Request for non-implemented button ...', __name__)

        self.drawPlot()
Example #11
0
    def setValueFromString ( self, str_val ) :
        """Set parameter value fron string based on its declared type: 'str', 'int', 'long', 'float', 'bool' """

        if str_val.lower() == 'none' :
            self._value = self._value_def

        if self._type == 'str' :
            self._value = str( str_val )

        elif self._type == 'int' :
            self._value = int( str_val )

        elif self._type == 'long' :
            self._value = long( str_val )

        elif self._type == 'float' :
            self._value = float( str_val )

        elif self._type == 'bool' :
            self._value = self.dicBool[str_val.lower()]

        else :
            msg = 'Parameter.setValueForType: Requested parameter type ' + type + ' is not supported\n'  
            msg+= 'WARNING! The parameter value is left unchanged...\n'
            logger.warning(msg)
    def list_of_group_copy_cmds(self):

        list_of_fnames = cp.guidirtree.get_list_of_checked_item_names()

        dst_calib_dir = fnm.path_to_calib_dir()
        dst_fname = '%s.data' % self.getRunRange()

        #print 'dst_calib_dir:', dst_calib_dir
        #print 'dst_fname:', dst_fname

        list_of_cmds = []

        for fname in list_of_fnames :
            #print '   split fname', fname
            fields = fname.split('/')
            
            if len(fields) < 5 :
                logger.info('File %s has a un-expected path: ' % fname, __name__)
                continue
            if  fields[-5] != 'calib' :
                logger.info('File %s is not from "calib" directory: ' % fname, __name__)
                continue
            if fields[-1] == 'HISTORY' :
                logger.warning('File %s copy is NOT allowed' % fname, __name__)
                continue
                
            dst_path = os.path.join(dst_calib_dir, fields[-4], fields[-3], fields[-2], dst_fname)
            cmd = 'cp %s %s' % (fname, dst_path)
            list_of_cmds.append(cmd)

        return list_of_cmds
Example #13
0
	def __writefile(self,filename,filecontent):
		if os.path.exists(filename):
			logger.warning(filename + 'already exists')
			return
		f_handler = file(filename,'w+')
		f_handler.write(filecontent)
		f_handler.close()
Example #14
0
 def get_mask_hotpix(sp) :
     #sp.mask_hotpix = gu.get_array_from_file(fnm.path_hotpix())
     #return sp.mask_hotpix
     msg = 'get_mask_hotpix IS NOT IMPLEMENTED YET! get random binomial for now...'
     logger.warning(msg, __name__)
     print 'WOARNING: ' + msg
     #return sp.get_random_img()
     return sp.get_random_binomial_img(p=0.99)
Example #15
0
    def __set_self_db_conn(self):
	try:
	    self.__prod_conn=psycopg2.connect(self.get_conn_string())
	except Exception:
	    logger.warning("Cannot connect to postgres: {0}".format(self.get_conn_string()))
	    return False
	logger.debug('Connection to DB for host "{0}" obtained succsessfully'.format(self.db_fields['hostname']))
	return True
Example #16
0
 def isReadyToStartRun(self):
     fstatus, fstatus_str = bjcora.status_for_cora_proc_files()
     if fstatus : 
         logger.info(fstatus_str, __name__)
         return True
     else :
         msg = 'JOB IS NOT SUBMITTED !!!' + fstatus_str
         logger.warning(msg, __name__)
         return False
Example #17
0
	def normalize(self,scoredict):
		maxnum = max(scoredict.values())
		newscore = {}
		if maxnum > 0:
			newscore = dict([(url,scoredict[url]/maxnum) for url in scoredict])
		else:
			logger.warning('how can scoredict has number 0 in it???')
			return scoredict
		return newscore
Example #18
0
    def setParameterValueByName ( self, name, str_val ) :

        if not ( name in self.dict_pars.keys() ) :
            msg  = 'The parameter name ' + name + ' is unknown in the dictionary.\n'
            msg += 'WARNING! Parameter needs to be declared first. Skip this parameter initialization.\n' 
            logger.warning(msg)
            return

        self.dict_pars[name].setValueFromString(str_val)
Example #19
0
	def __sort(self,reslist):
		if len(reslist) == 0:
			logger.warning('result list is empty')
			return None
		#对结果进行分析后,排序
		rankobj = ranker(reslist)
		#返回以URL为key的链接列表,以weight降序排序
		resultlist = rankobj.rank()
		return resultlist
Example #20
0
    def get_self_db_conn(self):
	if not self.prod_conn:
	    try:
		self.prod_conn=psycopg2.connect(self.conn_string)
	    except Exception, e:
		logger.warning("Cannot connect to postgres: {0}".format(self.get_conn_string()))
		logger.warning("Details: {0}".format(e))
		return False
#	    logger.debug('Connection to DB "{0}" obtained succsessfully'.format(self.db_fields['db_name']))
	    return True
Example #21
0
def bsub_is_available() :
    out, err = subproc(['which', 'bsub'])
    if err != '' :
        msg = 'Check if bsub is available on this node:\n' + err + \
              '\nbsub IS NOT available in current configuration of your node... (try command: which bsub)\n'
        print msg
        logger.warning(msg, __name__)         
        return False
    else :
        return True
Example #22
0
    def statusButtonsIsGood(self):
        if self.str_run_to == 'end' : return True

        if int(self.str_run_from) > int(self.str_run_to) :
            msg  = 'Begin run number %s exceeds the end run number %s' % (self.str_run_from, self.str_run_to)
            msg += '\nRUN RANGE SEQUENCE SHOULD BE FIXED !!!!!!!!'
            logger.warning(msg, __name__ )            
            return False

        return True
Example #23
0
    def on_but_aver(self):
        logger.debug('on_but_aver', __name__)

        if(cp.bat_data_end.value() == cp.bat_data_end.value_def()) :
            self.edi_bat_end.setStyleSheet(cp.styleEditBad)
            logger.warning('JOB IS NOT SUBMITTED !!!\nFirst, set the number of events for data avaraging.', __name__)
            return
        else :
            self.edi_bat_end.setStyleSheet(cp.styleEdit)
        bjdata.submit_batch_for_data_aver()
Example #24
0
    def get_image_array_from_file(self, fname) :
        """DEPRICATED: Recognizes detector by file name and returns image array or None
        """

        arr     = None
        img_arr = None

        arr = gu.get_array_from_file( fname )
        if arr is None :
            logger.warning('Array is not retreaved from file...', __name__)
            return None

        #print 'arr:\n', arr
        msg = 'arr.shape: %s' % str(arr.shape)
        logger.info(msg, __name__)
 
        fname_lower = fname.lower()

        #print 'fname_lower =', fname_lower
        #print 'list_of_dets_lower =', cp.list_of_dets_lower

        #self.list_of_dets   = ['CSPAD', 'CSPAD2x2', 'Princeton', 'pnCCD', 'Tm6740', 'Opal2000', 'Opal4000', 'Acqiris']

        if cp.list_of_dets_lower[0]+'.' in fname_lower : # CSAPD, shape = (5920,388) 
            arr.shape = (32*185,388) 
            img_arr = cspadimg.get_cspad_raw_data_array_image(arr)

        elif cp.list_of_dets_lower[1] in fname_lower : # CSAPD2x2
            arr.shape = (185,388,2) 
            img_arr = cspad2x2img.get_cspad2x2_non_corrected_image_for_raw_data_array(arr)

        elif cp.list_of_dets_lower[2] in fname_lower : # Princeton
            img_arr = arr

        elif cp.list_of_dets_lower[3] in fname_lower : # pnCCD
            img_arr = arr

        elif cp.list_of_dets_lower[4] in fname_lower : # Camera
            img_arr = arr

        elif cp.list_of_dets_lower[5] in fname_lower : # Camera
            img_arr = arr

        elif cp.list_of_dets_lower[6] in fname_lower : # Camera
            img_arr = arr

        elif cp.list_of_dets_lower[7] in fname_lower : # Acqiris
            img_arr = arr

        else :
            msg = 'Detector is not recognized in the file name: %s' %  fname
            logger.warning(msg, __name__)
            return None

        return img_arr
Example #25
0
    def on_but_aver(self):
        logger.debug('on_but_aver', __name__)

        if(cp.bat_dark_end.value() == cp.bat_dark_end.value_def()) :
            self.edi_bat_end.setStyleSheet(cp.styleEditBad)
            logger.warning('JOB IS NOT SUBMITTED !!!\nFirst, set the number of events for pedestal avaraging.', __name__)
            return
        else :
            self.edi_bat_end.setStyleSheet(cp.styleEdit)
        bjpeds.submit_batch_for_peds_aver()
        self.connectToThread1()
Example #26
0
    def job_was_recently_submitted(self, t_sub, comment='') :

        if t_sub == None : return False

        if gu.get_time_sec() - t_sub > self.time_interval_sec :
            return False
        else :
            msg = 'Sorry, but '+ comment +' job has already been submitted less then ' + \
            str(self.time_interval_sec) + ' sec ago and has not been completed yet... Be patient, relax and wait...'
            logger.warning(msg, __name__)         
            return True
 def onButCopy(self):
     #logger.info('onButCopy', __name__)
     if os.path.basename(self.str_path()) == 'HISTORY' :
         logger.warning('File %s copy is NOT allowed' % self.str_path(), __name__)
         return
     
     cmd = 'cp %s %s' % (self.str_path(), self.get_out_path())
     if self.approveCommand(self.but_copy, cmd) :
         #os.system(cmd)
         fd.procDeployCommand(cmd, 'single-file-manager')
         if cp.guistatus is not None : cp.guistatus.updateStatusInfo()
Example #28
0
def batch_job_status(job_id_str, queue='psnehq') :
    p = subprocess.Popen(['bjobs', '-q', queue, job_id_str], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    p.wait() # short time waiting untill submission is done, 
    err = p.stderr.read() # reads entire file
    if err != '' : logger.warning('batch_job_status:\n' + err, __name__) 
    status = None
    lines  = p.stdout.readlines() # returns the list of lines in file
    if len(lines)<2 : return None
    line   = lines[1].strip('\n')
    status = line.split()[2]
    return status # it might None, 'RUN', 'PEND', 'EXIT', 'DONE', etc 
    def get_detector_selected(self):
        lst = cp.list_of_dets_selected()
        len_lst = len(lst)
        msg = '%d detector(s) selected: %s' % (len_lst, str(lst))
        #logger.info(msg, __name__ )

        if len_lst !=1 :
            msg += ' Select THE ONE!'
            logger.warning(msg, __name__ )
            return None

        return lst[0]
Example #30
0
    def log(self, msg, level=1) :
        #logger.levels = ['debug','info','warning','error','crytical']
        self.count_msg += 1
        #print 'Received msg: %d' % self.count_msg
        if self.print_bits & 1 or level==4 : print msg

        if   level==1 : logger.info    (msg, __name__)
        elif level==0 : logger.debug   (msg, __name__)
        elif level==2 : logger.warning (msg, __name__)
        elif level==3 : logger.error   (msg, __name__)
        elif level==4 : logger.crytical(msg, __name__)
        else          : logger.info    (msg, __name__)
 def save_to_path(self, df, name='unknown', type='csv'):
     """
     保存信息表
     :param df: 信息表
     :param name: 文件名
     :param type: 文件的保存类型, csv或json
     """
     if not os.path.exists(self.path):
         os.mkdir(self.path)
     if type == 'csv':
         complete_path = self.path + '\\'+name+'.csv'
         df.to_csv(complete_path,
                   index=False,
                   encoding="utf-8-sig")
         logger.info('已保存至 ' + complete_path)
     elif type == 'json':
         complete_path = self.path + '\\'+name+'.json'
         df.to_json(complete_path,
                    orient='records', force_ascii=False)
         logger.info('已保存至 ' + complete_path)
     else:
         logger.warning('文件{}的保存格式不正确!', name)
    def onButDet(self):
        #print 'onButDet'
        self.but_current = self.butDet
        #item_selected = gu.selectFromListInPopupMenu(cp.list_of_dets)
        #if item_selected is None : return            # selection is cancelled
        #if item_selected == self.instr_name.value() : return # selected the same item
        #self.setDet(item_selected)

        list_of_cbox = []
        #for det in cp.list_of_dets :
        for det_name, det_data_type, det_cbx_state in cp.list_of_det_pars:
            #print 'Detector list:', det_name, det_data_type, det_cbx_state.value()
            list_of_cbox.append([det_name, det_cbx_state.value()])

        #list_of_cbox_out = gu.changeCheckBoxListInPopupMenu(list_of_cbox, win_title='Select Detectors')
        resp = gu.changeCheckBoxListInPopupMenu(list_of_cbox,
                                                win_title='Select detector(s)')

        if resp != 1: return  # at cancel

        str_of_detectors = ''

        for [name, state], state_par in zip(list_of_cbox,
                                            cp.det_cbx_states_list):
            #print  '%s checkbox is in state %s' % (name.ljust(10), state)
            state_par.setValue(state)
            if state: str_of_detectors += name + ' '

        self.det_name.setValue(str_of_detectors.rstrip(' '))

        if self.det_name.value() == '':
            self.butDet.setStyleSheet(cp.styleButtonBad)
            logger.warning('At least one detector needs to be selected !!!',
                           __name__)
            self.setDet('Select')
            return

        self.setDet()
        self.setStyleButtons()
Example #33
0
    def onBut(self):
        logger.debug('onBut - xelect file', __name__)
        but = self.but
        edi = self.edi
        par = cp.res_fname
        #dir = cp.dir_results.value() # is not used

        path0 = par.value()
        path = str(
            QtGui.QFileDialog.getOpenFileName(self, 'Select file', path0))
        dname, fname = os.path.split(path)

        if dname == '' or fname == '':
            logger.warning(
                'Input directiry name or file name is empty... keep file name unchanged...',
                __name__)
            return

        edi.setText(os.path.basename(path))
        par.setValue(path)
        logger.info('selected the file name: ' + str(par.value()), __name__)
        self.initCorArray()
    def make_psana_cfg_file_for_peds_aver(self):

        if cp.blsp.list_of_sources == []: return

        self.det_name = cp.det_name.value()

        # list_of_dets   = ['CSPAD', 'CSPAD2x2', 'Camera', 'Princeton', 'pnCCD']

        if self.det_name == cp.list_of_dets[0]:
            self.make_psana_cfg_file_for_peds_aver_cspad(
                module='cspad_mod.CsPadPedestals')
        elif self.det_name == cp.list_of_dets[1]:
            self.make_psana_cfg_file_for_peds_aver_cspad(
                module='cspad_mod.CsPad2x2Pedestals')
        elif self.det_name == cp.list_of_dets[2]:
            self.print_worning()
        elif self.det_name == cp.list_of_dets[3]:
            self.make_psana_cfg_file_for_peds_aver_princeton()
        elif self.det_name == cp.list_of_dets[4]:
            print_worning()
        else:
            logger.warning('UNKNOWN DETECTOR: %s' % self.det_name, __name__)
Example #35
0
    def on_but_diff(self):
        logger.info('on_but_diff', __name__)

        list_of_opts = [
            'Load from WORK directory', 'Load from CALIB directory',
            'Load initial image', 'Cancel'
        ]

        selected = gu.selectFromListInPopupMenu(list_of_opts)
        logger.debug('selected option: %s' % selected, __name__)

        path0 = self.ifname
        if selected is None: return
        elif selected == list_of_opts[0]: path0 = fnm.path_dir_work()
        elif selected == list_of_opts[1]: path0 = fnm.path_to_calib_dir()
        elif selected == list_of_opts[2]: path0 = self.ifname
        elif selected == list_of_opts[3]: return
        else: return

        file_filter = 'Files (*.txt *.data *.npy)\nAll files (*)'
        path = gu.get_open_fname_through_dialog_box(self,
                                                    path0,
                                                    'Select file to subtract',
                                                    filter=file_filter)
        if path == None or path == '':
            logger.info('Loading is cancelled...', __name__)
            return

        arr_sub = gu.get_image_array_from_file(path)  # dtype=np.float32)
        if arr_sub is None: return

        if arr_sub.size != self.widgimage.arr.size:
            msg = 'Subtracted array size: %d is different from current image size: %d. Diff plotting is cancelled.' % \
                  (arr_sub.size, self.widgimage.arr.size)
            logger.warning(msg, __name__)
            #print msg
            return

        self.widgimage.subtract_from_image_array(arr_sub)
Example #36
0
def batch_job_submit(command, queue='psnehq', log_file='batch-log.txt') :

    if os.path.lexists(log_file) : remove_file(log_file)

    out, err = subproc(['bsub', '-q', queue, '-o', log_file, command])
    line_fields = out.split()
    if line_fields[0] != 'Job' :
        msg = 'EXIT: Unexpected response at batch submission:\nout: %s \nerr: %s'%(out, err)
        print msg
        logger.warning(msg, __name__) 
        #sys.exit(msg)
        job_id_str = 'JOB_ID_IS_UNKNOWN'
    else :
        job_id_str = line_fields[1].strip('<').rstrip('>')

    if err != '' :
        msg =  '\n' + 80*'!' + '\n' + err + 80*'!' + '\n'
        logger.warning( msg, __name__) 

    logger.info(out, __name__) 

    return job_id_str, out, err
Example #37
0
    def onButScript(self):
        logger.debug('onButScript', __name__)

        det = self.get_detector_selected()
        if det is None: return

        if det != cp.list_of_dets[0]:
            logger.warning('Scripts are implemented for CSPAD ONLY !!!: ',
                           __name__)

        lst = cp.dict_of_metrology_scripts[det]

        selected = gu.selectFromListInPopupMenu(lst)

        if selected is None: return  # selection is cancelled
        if selected is self.script: return  # the same

        txt = str(selected)

        self.setScript(txt)
        self.setSrc()
        self.setStyleButtons()
Example #38
0
    def onButExp(self):
        #print 'onButExp'
        dir = self.instr_dir.value() + '/' + self.instr_name.value()
        #print 'dir =', dir
        if self.list_of_exp is None: self.list_of_exp = os.listdir(dir)
        item_selected = gu.selectFromListInPopupMenu(self.list_of_exp)
        if item_selected is None: return  # selection is cancelled
        #if item_selected == self.exp_name.value() : return # selected the same item

        self.setExp(item_selected)
        self.setDir(fnm.path_to_calib_dir_default())
        self.setDet('Select')
        self.setStyleButtons()

        #if cp.guidarklist is not None : cp.guidarklist.updateList()

        path_to_xtc_dir = fnm.path_to_xtc_dir()
        if os.path.lexists(path_to_xtc_dir): return

        msg = 'XTC data are not seen on this computer for path: %s' % path_to_xtc_dir
        logger.warning(msg, __name__)
        print msg
Example #39
0
    def __init__(self, querywords):
        if len(querywords.strip()) == 0 or not isinstance(querywords, str):
            logger.warning('querywords invalid!')
            return
        self.querywords = querywords.strip().split(' ')
        self.query = query(querywords)
        self.resultlist = []
        confmap = confparser.confdictory('backinfo')
        buildmap = confparser.confdictory('build')
        if confmap == None or buildmap == None:
            log.warning('config error for backinfo section')
            return None
        if not confmap.has_key('backpath'):
            self.backpath = 'backup'
        else:
            self.backpath = confmap['backpath']

        if not confmap.has_key('rawtext'):
            self.rawtext = '.file'
        else:
            self.rawtext = confmap['rawtext']
        if not confmap.has_key('rawhtml'):
            self.rawhtml = '.html'
        else:
            self.rawhtml = confmap['backtext']

        if not confmap.has_key('backtext'):
            self.backtext = '.file.zip'
        else:
            self.backtext = confmap['backtext']
        if not confmap.has_key('backhtml'):
            self.backhtml = '.htm.zip'
        else:
            self.backhtml = confmap['backhtml']
        if not buildmap.has_key('block'):
            self.block = 128
        else:
            self.block = int(buildmap['block'])
Example #40
0
def parse_xtc_path(path='.'):

    logger.debug('parse_xtc_path(...): ' + str(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
Example #41
0
 def __init__(self):
     confdict = confparser.confdictory('rank')
     if len(confdict) == 0:
         logger.warning('config file load error')
     self.weightdict = {}
     #根据文件配置生成排名函数
     if confdict.has_key('frequence'):
         self.weightdict['frequence'] = {}
         self.weightdict['frequence']['caller'] = self.frequence
         self.weightdict['frequence']['weight'] = int(confdict['frequence'])
     if confdict.has_key('position'):
         self.weightdict['position'] = {}
         self.weightdict['position']['caller'] = self.position
         self.weightdict['position']['weight'] = int(confdict['position'])
     if confdict.has_key('distance'):
         self.weightdict['distance'] = {}
         self.weightdict['distance']['caller'] = self.querydistance
         self.weightdict['distance']['weight'] = int(confdict['distance'])
     if confdict.has_key('titleweight'):
         self.weightdict['titleweight'] = {}
         self.weightdict['titleweight']['caller'] = self.titleweight
         self.weightdict['titleweight']['weight'] = int(
             confdict['distance'])
    def cfg_file_body_for_peds_aver(self) :

        txt_cfg_body   = '#Module parameters'
        self.ind = 0

        for det_name in cp.list_of_dets_selected() :
            lst_types, lst_srcs = cp.blsp.list_of_types_and_sources_for_detector(det_name)
            list_path_peds_ave    = gu.get_list_of_files_for_list_of_insets(fnm.path_peds_ave(),    lst_srcs)
            list_path_peds_rms    = gu.get_list_of_files_for_list_of_insets(fnm.path_peds_rms(),    lst_srcs)
            list_path_hotpix_mask = gu.get_list_of_files_for_list_of_insets(fnm.path_hotpix_mask(), lst_srcs)

            if self.do_test_print : print 'Detector selected: %10s' % (det_name), '  sources:', lst_srcs

            for (self.source, self.fname_ave, self.fname_rms, self.fname_mask) in zip(lst_srcs, list_path_peds_ave, list_path_peds_rms, list_path_hotpix_mask) :
                self.ind += 1 
                #print self.ind, self.source, self.fname_ave, self.fname_rms

                # list_of_dets   = ['CSPAD', 'CSPAD2x2', 'Princeton', 'pnCCD', 'Tm6740', 'Opal2000', 'Opal4000', 'Acqiris'] 
                #if   det_name == cp.list_of_dets[0] : self.add_cfg_module_peds_aver_cspad('cspad_mod.CsPadPedestals')
                #elif det_name == cp.list_of_dets[1] : self.add_cfg_module_peds_aver_cspad('cspad_mod.CsPad2x2Pedestals')
                if   det_name == cp.list_of_dets[0] : self.add_cfg_module_peds_aver_cspad_with_mask('CSPadPixCoords.CSPadNDArrProducer')
                elif det_name == cp.list_of_dets[1] : self.add_cfg_module_peds_aver_cspad_with_mask('CSPadPixCoords.CSPad2x2NDArrProducer')
                elif det_name == cp.list_of_dets[2] : self.add_cfg_module_peds_aver_princeton()
                elif det_name == cp.list_of_dets[3] : self.add_cfg_module_peds_aver_pnccd_ndarr()
               #elif det_name == cp.list_of_dets[3] : self.add_cfg_module_peds_aver_pnccd_img()
                elif det_name == cp.list_of_dets[4] : self.add_cfg_module_peds_aver_camera()
                elif det_name == cp.list_of_dets[5] : self.add_cfg_module_peds_aver_camera()
                elif det_name == cp.list_of_dets[6] : self.add_cfg_module_peds_aver_camera()
                elif det_name == cp.list_of_dets[7] : self.add_cfg_module_peds_aver_acqiris()
                elif det_name == cp.list_of_dets[8] : self.print_warning()
                else : logger.warning('UNKNOWN DETECTOR: %s' % det_name, __name__)

        if self.ind > 0 : return True

        msg = 'Selected detectors NOT FOUND in the list of keys in xtc scan log file !!!'
        logger.warning(msg, __name__)
        return False
Example #43
0
    def setImgArray(self):
        t0 = gu.get_time_sec()
        if   self.g_ind == 0  : self.arr2d = self.vr.get_Ip_for_itau(self.tau_ind)
        elif self.g_ind == 1  : self.arr2d = self.vr.get_If_for_itau(self.tau_ind)
        elif self.g_ind == 2  : self.arr2d = self.vr.get_I2_for_itau(self.tau_ind)
        elif self.g_ind == 3  : self.arr2d = self.vr.get_g2_raw_for_itau(self.tau_ind)
        elif self.g_ind == 4  : self.arr2d = self.vr.get_x_map()
        elif self.g_ind == 5  : self.arr2d = self.vr.get_y_map()
        elif self.g_ind == 6  : self.arr2d = self.vr.get_r_map()
        elif self.g_ind == 7  : self.arr2d = self.vr.get_phi_map()
        elif self.g_ind == 8  : self.arr2d = self.vr.get_q_map()
        elif self.g_ind == 9  : self.arr2d = self.vr.get_phi_map_for_stat_bins()
        elif self.g_ind == 10 : self.arr2d = self.vr.get_q_map_for_stat_bins()
        elif self.g_ind == 11 : self.arr2d = self.vr.get_phi_map_for_dyna_bins()
        elif self.g_ind == 12 : self.arr2d = self.vr.get_q_map_for_dyna_bins()
        elif self.g_ind == 13 : self.arr2d = self.vr.get_q_phi_map_for_stat_bins()
        elif self.g_ind == 14 : self.arr2d = self.vr.get_q_phi_map_for_dyna_bins()
        elif self.g_ind == 15 : self.arr2d = self.vr.get_1oIp_map_for_stat_bins_itau(self.tau_ind)
        elif self.g_ind == 16 : self.arr2d = self.vr.get_1oIf_map_for_stat_bins_itau(self.tau_ind)
        elif self.g_ind == 17 : self.arr2d = self.vr.get_g2_map_for_itau(self.tau_ind)
        elif self.g_ind == 18 : self.arr2d = self.vr.get_g2_map_for_dyna_bins_itau(self.tau_ind)
        elif self.g_ind == 19 : self.arr2d = self.vr.get_g2_vs_itau_arr()
        elif self.g_ind == 20 : pass
        elif self.g_ind == 30 : self.arr2d = self.vr.get_mask_image_limits()
        elif self.g_ind == 31 : self.arr2d = self.vr.get_mask_blemish()
        elif self.g_ind == 32 : self.arr2d = self.vr.get_mask_hotpix()
        elif self.g_ind == 33 : self.arr2d = self.vr.get_mask_satpix()
        elif self.g_ind == 34 : self.arr2d = self.vr.get_mask_roi()
        elif self.g_ind == 35 : self.arr2d = self.vr.get_mask_total()


        else :
            logger.warning('Request for non-implemented plot ...', __name__)

        msg = 'Consumed time to get map: %11.6f sec' % (gu.get_time_sec()-t0)
        logger.info(msg, __name__)
        logger.info('arr2d.shape: ' + str(self.arr2d.shape) , __name__)
Example #44
0
    def onButEvaluate(self):
        logger.debug('onButEvaluate', __name__)
        det = self.get_detector_selected()
        if det is None: return

        if not os.path.exists(fnm.path_metrology_text()):
            msg = 'Input file %s DOES NOT exist!' % fnm.path_metrology_text()
            logger.warning(msg, __name__)
            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

        fname_metrology = fnm.path_metrology_text()

        #print 'list_of_metrology_scripts', list_of_metrology_scripts
        #for CSPAD script CSPADV1 CXI-like
        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__)
            optal = OpticAlignmentCspadV1(fname_metrology, print_bits=0, plot_bits=0, \
                                      exp=self.instr_name.value(), det=det)
            self.procCspad(optal)

        #for CSPAD script CSPADV2 XPP-like
        elif det == cp.list_of_dets[
                0] and self.script == list_of_metrology_scripts[1]:
            msg = 'Evaluate parameters for %s using script %s' % (det,
                                                                  self.script)
            logger.info(msg, __name__)
            optal = OpticAlignmentCspadV2(fname_metrology, print_bits=0, plot_bits=0, \
                                      exp=self.instr_name.value(), det=det)
            self.procCspad(optal)

        #for CSPAD2x2 script CSPAD2X2V1
        elif det == cp.list_of_dets[
                1] and self.script == list_of_metrology_scripts[0]:
            msg = 'Evaluate parameters for %s using script %s' % (det,
                                                                  self.script)
            logger.info(msg, __name__)
            optal = OpticAlignmentCspad2x2V1(fname_metrology, print_bits=0, plot_bits=0, \
                                      exp=self.instr_name.value(), det=det)
            self.procCspad(optal)

        # 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
Example #45
0
    def on_but_plot(self):
        self.exportLocalPars()

        logger.debug('on_but_plot', __name__)
        try :
            cp.plotimgspe.close()
            try    : del cp.plotimgspe
            except : pass

        except :
            list_of_fnames = self.get_list_of_files_peds_for_plot()
            #print 'list_of_fnames = ', list_of_fnames

            if list_of_fnames == [] :
                logger.warning('List of files is empty... There is nothing to plot...', __name__)
                return

            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.img_arr = self.get_image_array_from_file(fname)
            #if self.img_arr == None :
            #    return

            #print arr.shape,'\n', arr.shape
            tit = 'Plot for %s' % os.path.basename(fname)
            cp.plotimgspe = PlotImgSpe(None, ifname=fname, ofname=fnm.path_peds_aver_plot(), title=tit, load_is_visible=True)
            #cp.plotimgspe = PlotImgSpe(None, self.img_arr, ofname=fnm.path_peds_aver_plot(), title=tit)
            #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 get_stu_info(self, save_type='') -> pd.DataFrame:
        """
        获取个人信息
        :param save_type: 保存格式, 若空则不保存
        :return: 个人信息
        """
        response = self.session.get(self.course_table_url, headers=self.headers)
        selector = etree.HTML(response.text)
        # 获取学生信息
        stu_info_list = [field.strip().strip(':') for field in selector.xpath('//td[@style="color: Blue;"]/text()') if field.strip().strip(':')]
        stu_credit_raw = selector.xpath('//table[@class="tblnoborder"]//tr/td[@colspan="20"]/text()')[0]  # 获取学分
        stu_info_list.append(re.search('Total credit:(\d+\.\d+)', stu_credit_raw).group(1))

        # switch to DataFrame
        stu_info_columns = ['学号', '姓名', '性别', '年级', '学院', '校区', '学分']
        try:
            stu_info_df = pd.DataFrame([stu_info_list], columns=stu_info_columns)
            if save_type:
                logger.info('保存个人信息')
                self.save_to_path(stu_info_df, name=self.term_season + '季学期 个人信息', type=save_type)
            return stu_info_df
        except:
            logger.warning('个人信息保存失败')
            return pd.DataFrame()
Example #47
0
    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
Example #48
0
    def checkEdiLimits(self, row):
        sec_dict = self.list_of_dicts[row]
        mis, par_mis = sec_dict[8]
        mas, par_mas = sec_dict[9]
        Imin, Imax = par_mis.value(), par_mas.value()
        if Imin >= Imax :
            logger.warning('Check limits: Imin:' + str(Imin) + ' >= Imax:' + str(Imax), __name__)
            mis.setStyleSheet (cp.styleEditBad)
            mas.setStyleSheet (cp.styleEditBad)

        if par_mis.value() == par_mis.value_def() :
            logger.warning('Imin is equal to the default value: ' + str(par_mis.value()), __name__)
            mis.setStyleSheet (cp.styleEditBad)

        if par_mas.value() == par_mas.value_def() :
            logger.warning('Imax is equal to the default value: ' + str(par_mas.value()), __name__)
            mas.setStyleSheet (cp.styleEditBad)
Example #49
0
 def build(self):
     if self.query == None:
         logger.warning('query instance invalid')
         return None
     self.query.run()
     self.resultlist = self.query.getreslist()
     if self.resultlist == None:
         logger.warning('query module return null!')
         return json.dumps({'status': '1', 'desc': 'no matche result'})
     results_list = []
     for result in self.resultlist:
         if result == None or not result.has_key('urlid'):
             logger.warning({
                 'msg': 'lack of parameter urlid in this query',
                 'query': result
             })
             continue
         backfile = self.backpath + '/' + str(
             result['urlid']) + self.backtext
         zipf = zipfile.ZipFile(backfile)
         olddir = os.getcwd()
         os.chdir(self.backpath)
         zipf.extractall()
         zipf.close()
         rawtext_handler = open(str(result['urlid']) + self.rawtext, 'r')
         string = rawtext_handler.read()
         renderstr = self.rendertext(string, self.querywords)
         rawtext_handler.close()
         os.remove(str(result['urlid']) + self.rawtext)
         os.chdir(olddir)
         urlinfo = result['url']
         titleinfo = result['title']
         titlestr = titleinfo
         if titleinfo != 'undefined':
             titlestr = self.rendertitle(titleinfo, self.querywords)
         results_list.append({
             'url': urlinfo,
             'title': titlestr,
             'content': renderstr
         })
     return json.dumps({
         'status': '0',
         'msg': 'response ok',
         'response': results_list
     })
Example #50
0
 def __init__(self, query_words):
     if isinstance(query_words, str):
         self.wordlist = query_words.split(' ')
         #reslist 存放wordlist的对应结果
         self.reslist = []
         confdictory = confparser.confdictory('database')
         if not confdictory.has_key(
                 'user'):  # or !confdictory.has_key['dbpass']:
             logger.warning('config parser can not be loaded')
             return None
         self.engine = dbcontrol(confdictory['user'],
                                 confdictory['password'])
         if self.engine == None:
             logger.warning({
                 'msg': 'database connect error',
                 'dbname': confdictory['dbuser'],
                 'dbpass': confdictory['dbpass']
             })
             return None
     else:
         logger.warning('query words format error')
Example #51
0
    def isReadyToStartRun(self, ind):

        if cp.autoRunStatus != 0 :            
            msg = 'JOB IS NOT SUBMITTED !!! because Auto-processing procedure is active in stage '+str(cp.autoRunStatus)
            logger.warning(msg, __name__)
            return False 

        fname = fnm.get_list_of_files_cora_split_work()[ind]
        if not os.path.exists(fname) :
            msg1 = 'JOB IS NOT SUBMITTED !!!\nThe file ' + str(fname) + ' does not exist'
            logger.warning(msg1, __name__)
            return False

        fsize = os.path.getsize(fname)
        if fsize < 1 :
            msg2 = 'JOB IS NOT SUBMITTED !!!\nThe file ' + str(fname) + ' has wrong size(Byte): ' + str(fsize) 
            logger.warning(msg2, __name__)
            return False

        msg3 = 'The file ' + str(fname) + ' exists and its size(Byte): ' + str(fsize) 
        logger.info(msg3, __name__)
        return True
Example #52
0
    def isReadyToStartRun(self):

        if cp.autoRunStatus != 0 :            
            msg = 'JOB IS NOT SUBMITTED !!! because Auto-processing procedure is active in stage '+str(cp.autoRunStatus)
            logger.warning(msg, __name__)
            return False 

        msg1 = 'JOB IS NOT SUBMITTED !!!\nFirst, set the number of events for data.'

        if(cp.bat_data_end.value() == cp.bat_data_end.value_def()) :
            #self.edi_bat_end.setStyleSheet(cp.styleEditBad)
            logger.warning(msg1, __name__)
            return False

        elif(cp.bat_data_start.value() >= cp.bat_data_end.value()) :
            #self.edi_bat_end.setStyleSheet(cp.styleEditBad)
            #self.edi_bat_start.setStyleSheet(cp.styleEditBad)
            logger.warning(msg1, __name__)
            return False

        else :
            #self.edi_bat_end.setStyleSheet  (cp.styleEditInfo)
            #self.edi_bat_start.setStyleSheet(cp.styleEditInfo)
            return True
Example #53
0
 def connectToThread1(self):
     try : self.connect   ( cp.thread1, QtCore.SIGNAL('update(QString)'), self.check_status )
     except : logger.warning('connectToThread1 is failed', __name__)
 def print_warning (self) :
     msg = 'cfg_file_body_for_peds_aver_%s - IS NOT IMPLEMENTED YET!!!' % self.det_name
     logger.warning(msg, __name__)
Example #55
0
 def disconnectFromThread1(self):
     try:
         self.disconnect(cp.thread1, QtCore.SIGNAL('update(QString)'),
                         self.updateStatus)
     except:
         logger.warning('connectToThread1 IS FAILED !!!', __name__)
 def list_of_objs_for_mask_is_empty(self):       
     if len(self.get_list_of_objs_for_mask()) == 0 :
         logger.warning('List of objects for mask IS EMPTY!', __name__ )            
         return True
     else :
         return False
    def onButView(self):
        logger.info('onButView', __name__)
        if self.but_Ip.hasFocus():
            self.selectedOption(0, '<Ip> map, ', show_tau=True)
        elif self.but_If.hasFocus():
            self.selectedOption(1, '<If> map, ', show_tau=True)
        elif self.but_I2.hasFocus():
            self.selectedOption(2, '<Ip x If>, ', show_tau=True)
        elif self.but_g2raw.hasFocus():
            self.selectedOption(3, 'g2 raw map, ', show_tau=True)
        elif self.but_X.hasFocus():
            self.selectedOption(4, 'X map')
        elif self.but_Y.hasFocus():
            self.selectedOption(5, 'Y map')
        elif self.but_R.hasFocus():
            self.selectedOption(6, 'R map')
        elif self.but_P.hasFocus():
            self.selectedOption(7, 'Phi map')
        elif self.but_Q.hasFocus():
            self.selectedOption(8, 'Q map')
        elif self.but_P_st.hasFocus():
            self.selectedOption(9, 'Phi map for static bins')
        elif self.but_Q_st.hasFocus():
            self.selectedOption(10, 'Q map for static bins')
        elif self.but_P_dy.hasFocus():
            self.selectedOption(11, 'Phi map for dynamic bins')
        elif self.but_Q_dy.hasFocus():
            self.selectedOption(12, 'Q map for dynamic bins')
        elif self.but_QP_st.hasFocus():
            self.selectedOption(13, 'Q-Phi map for static bins')
        elif self.but_QP_dy.hasFocus():
            self.selectedOption(14, 'Q-Phi map for dynamic bins')
        elif self.but_1oIp.hasFocus():
            self.selectedOption(15,
                                '1/<Ip> norm. map for static bins, ',
                                show_tau=True)
        elif self.but_1oIf.hasFocus():
            self.selectedOption(16,
                                '1/<If> norm. map for static bins, ',
                                show_tau=True)
        elif self.but_g2map.hasFocus():
            self.selectedOption(17, 'g2 map, ', show_tau=True)
        elif self.but_g2dy.hasFocus():
            self.selectedOption(18, 'g2 map for dynamic bins, ', show_tau=True)
        elif self.but_g2tau.hasFocus():
            self.selectedOption(19, 'g2 vs itau')
            #elif self.but_g2tau_gr     .hasFocus() : self.selectedOption( 20, 'g2(tau) for dynamic bins')

        elif self.but_mask_img_lims.hasFocus():
            self.selectedOption(30, 'Mask image limits')
        elif self.but_mask_blemish.hasFocus():
            self.selectedOption(31, 'Mask blemish')
        elif self.but_mask_hotpix.hasFocus():
            self.selectedOption(32, 'Mask hot pixels')
        elif self.but_mask_satpix.hasFocus():
            self.selectedOption(33, 'Mask satturated pixels')
        elif self.but_mask_roi.hasFocus():
            self.selectedOption(34, 'Mask for good regions')
        elif self.but_mask_total.hasFocus():
            self.selectedOption(35, 'Mask total')
        else:
            logger.warning('Request for non-implemented button ...', __name__)

        self.drawPlot()
def usage():
    msg = 'Use command: ' + sys.argv[0] + ' [<configuration-file-name>]\n'
    msg += 'with a single or without arguments.'
    msg = '\n' + 51 * '-' + '\n' + msg + '\n' + 51 * '-'
    logger.warning(msg, self.name)
Example #59
0
 def on_auto_processing_status(self):
     logger.warning(
         'DEFAULT METHOD on_auto_processing_status() SHOULD BE OVERLOADED !!!',
         __name__)
Example #60
0
 def switch_stop_go_button(self):
     logger.warning(
         'DEFAULT METHOD on_auto_processing_status() SHOULD BE OVERLOADED !!!',
         __name__)