def selectDirFromPopupMenu(self, dir_current='.'):

        list_of_opts = [
            'Use WORK directory', 'Use CALIB directory',
            'Use CURRENT FILE directory', 'Use OTHER EXPERIMENT directory',
            'Use ALIGNMENT ARCHIVE', 'Use ./', 'Reset', 'Cancel'
        ]

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

        if selected == list_of_opts[0]: return fnm.path_dir_work()
        elif selected == list_of_opts[1]: return fnm.path_to_calib_dir()
        elif selected == list_of_opts[2]: return dir_current
        elif selected == list_of_opts[3]:
            return os.path.join(fnm.path_to_calib_dir(), '../../')
        elif selected == list_of_opts[4]:
            return '/reg/g/psdm/detector/alignment/'
        elif selected == list_of_opts[5]:
            return './'
        elif selected == list_of_opts[6]:
            return ''
        elif selected == list_of_opts[7]:
            return None
        else:
            return None
    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

            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
Esempio n. 3
0
    def setStyleButtons(self):
        """Set buttons enabled or disabled depending on status of other fields
        """

        file_is_enable = True
        if self.str_path() == '' :
            file_is_enable = False
            self.but_browse.setStyleSheet(cp.styleButtonGood)
        else :
            self.but_browse.setStyleSheet(cp.styleButton)

        self.but_view.setEnabled(file_is_enable)
        self.but_plot.setEnabled(file_is_enable)

        #print '\nself.str_path()', self.str_path()
        #print 'fnm.path_dir_work()', fnm.path_dir_work().lstrip('.')

        is_enable_delete = file_is_enable \
                           and (self.str_path().find(fnm.path_to_calib_dir()) != -1
                                or self.str_path().find(fnm.path_dir_work().lstrip('.')) != -1
                                )
        self.but_delete.setEnabled(is_enable_delete)

        is_enable_copy = file_is_enable \
                         and self.source_name != 'Select' \
                         and self.calib_type != 'Select' 
        self.but_copy  .setEnabled(is_enable_copy)
        
        if self.source_name == 'Select' : self.but_src .setStyleSheet(cp.stylePink)
        else                            : self.but_src .setStyleSheet(cp.styleButton)
        if self.calib_type  == 'Select' : self.but_type.setStyleSheet(cp.stylePink)
        else                            : self.but_type.setStyleSheet(cp.styleButton)
    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-%s.data' % (self.str_run_from, self.str_run_to)

        #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
                
            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
 def get_out_path(self):
     det = self.get_detector_selected()
     if det is None : return
     calib_dir = fnm.path_to_calib_dir()
     calib_type = cp.dict_of_det_calib_types[det]
     fname = '%s.data' % self.getRunRange()
     path = os.path.join(calib_dir, calib_type, self.source_name, self.calib_type, fname)
     return path
Esempio n. 6
0
 def get_out_path(self):
     det = self.get_detector_selected()
     if det is None : return
     calib_dir = fnm.path_to_calib_dir()
     calib_type = cp.dict_of_det_calib_types[det]
     fname = '%s-%s.data' % (self.str_run_from, self.str_run_to)
     path = os.path.join(calib_dir, calib_type, self.source_name, self.calib_type, fname)
     return path
    def selectDirFromPopupMenu(self, dir_current='.'):

        list_of_opts = [  'Use WORK directory'
                         ,'Use CALIB directory'
                         ,'Use CURRENT FILE directory'
                         ,'Use OTHER EXPERIMENT directory'
                         ,'Use ./'
                         ,'Reset'
                         ,'Cancel'
                        ]

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

        if   selected == list_of_opts[0] : return fnm.path_dir_work()
        elif selected == list_of_opts[1] : return fnm.path_to_calib_dir()
        elif selected == list_of_opts[2] : return dir_current
        elif selected == list_of_opts[3] : return os.path.join(fnm.path_to_calib_dir(),'../../')
        elif selected == list_of_opts[4] : return './'
        elif selected == list_of_opts[5] : return ''
        elif selected == list_of_opts[6] : return None
        else                             : return None
Esempio n. 8
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)
Esempio n. 9
0
    def list_of_copy_cmds(self):

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

        dst_calib_dir  = fnm.path_to_calib_dir()
        dst_calib_type = cp.dict_of_det_calib_types[det]
        dst_source     = self.source_name
        dst_fname      = '%s.data' % cp.guirange.getRange()

        #print 'dst_calib_dir  ', dst_calib_dir
        #print 'dst_calib_type ', dst_calib_type
        #print 'dst_source     ', dst_source
        #print 'dst_fname      ', dst_fname

        list_of_cmds = []
        for type, fname in self.dict_metrology_alignment_const_fname_for_type().iteritems() :
            dst_path = os.path.join(dst_calib_dir, dst_calib_type, dst_source, type, dst_fname)
            cmd = 'cp %s %s' % (fname, dst_path)
            list_of_cmds.append(cmd)

        return list_of_cmds
Esempio n. 10
0
    def list_of_copy_cmds(self):

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

        dst_calib_dir  = fnm.path_to_calib_dir()
        dst_calib_type = cp.dict_of_det_calib_types[det]
        dst_source     = self.source_name
        dst_fname      = '%s.data' % self.guirange.getRange()

        #print 'dst_calib_dir  ', dst_calib_dir
        #print 'dst_calib_type ', dst_calib_type
        #print 'dst_source     ', dst_source
        #print 'dst_fname      ', dst_fname

        list_of_cmds = []
        for type, fname in self.dict_metrology_alignment_const_fname_for_type().iteritems() :
            dst_path = os.path.join(dst_calib_dir, dst_calib_type, dst_source, type, dst_fname)
            cmd = 'cp %s %s' % (fname, dst_path)
            list_of_cmds.append(cmd)

        return list_of_cmds
Esempio n. 11
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)
Esempio n. 12
0
 def onSelectedItem(self, path_from_calib, list_expected) :
     cp.guitabs.setTabByName('Status')
     dir = os.path.join(fnm.path_to_calib_dir(), path_from_calib)        
     cp.guistatus.statusOfDir(dir, list_expected)
Esempio n. 13
0
 def onSelectedItem(self, path_from_calib, list_expected):
     cp.guitabs.setTabByName('Status')
     dir = os.path.join(fnm.path_to_calib_dir(), path_from_calib)
     cp.guistatus.statusOfDir(dir, list_expected)