Пример #1
0
 def draw2DArray(self, arr=None):
     if arr == None : arr = imp.impars.arr
     gm.openFigure(1,12,12,'CSpad standalone')
     print 'dimX, dimY =', arr.shape
     gm.drawImage(arr, 'CSpad image')
     plt.draw()
     self.showPlot ( mode=1 )
Пример #2
0
    def _setQuadNumsInEvent( self, h5file, dsname, event=0 ):
        """Sets the self.quadNumsInEvent from h5file using dsname and optional event number."""

        el_dsname  = gm.get_item_path_to_last_name(dsname) + '/element'
        #self.ds_element = h5file.get_dataset_from_hdf5_file(el_dsname)[:]['quad']
        self.ds_element = h5file.get_dataset_from_hdf5_file(el_dsname)
        #print 'self.ds_element = ', self.ds_element
        self.quadNumsInEvent = self.getQuadNumsInEvent( event )
Пример #3
0
def get_cspad_calib_dir( path, cspad_name='CxiDs1.0:Cspad.0' ) :
    """Constructs the calibration directory name from the path to *.h5 file and the detector name.
       The lates version of calibration is picked up automatically.
    """
    root_calib_dir = get_root_calib_dir_from_hdf5_path( path )

    dirList=gm.getListOfFilesInDir(root_calib_dir)
    calib_version = '' 
    for name in dirList: # loop
        if name[0:5] == 'CsPad' :
            calib_version = name # something like CsPad::CalibV1

    return root_calib_dir + calib_version + '/' + cspad_name     
Пример #4
0
Файл: TSP.py Проект: Grhan/Ciol
    def solve(self):
    #gets the proper function for given cooling schedule(geometric,linear,logaritmic)
        cf = getattr(self, "_SMA__"+self.clng)
    #random solution
        self.route= random.sample(range(self.dimension),self.dimension)
    #calculates objective function value of random solution
        self.obj = GlobalMethods.iterativeobj(self.distances,self.route)
    #temperature value on the i.th iterate
        currenttemp = self.it
        count = 0
        while currenttemp > self.ft:

            for i in range(self.iterlim):
                rnds = np.random.choice(range(self.dimension), 2, replace=False)
                np.sort(rnds)
                s = GlobalMethods.swap(self.route,rnds[0],rnds[1])

                tempobj = GlobalMethods.iterativeobj(self.distances,s)
                delta = tempobj - self.obj
                r = random.uniform(0 ,1)
                g.append(r)
                if delta <= 0:
                    self.bestobj = tempobj
                    self.obj= tempobj
                    self.route= s
                    self.bestroute = self.route
                elif self.__prob(delta,currenttemp) > r:
                    self.obj = tempobj
                    self.route =s


            count += 1

            currenttemp = cf(count,currenttemp)

        return self.bestroute,self.bestobj
Пример #5
0
def get_cspad_name_and_data_type_from_dataset_name( dsname ) :
    """Returns the detector name and data type as a parts of the dataset name
    """
    cspad_name      = ''
    cspad_data_type = ''
    if gm.CSpadIsInTheName(dsname) :
        name1, name2, name3 = gm.get_item_last_three_names(dsname)
        cspad_name      = name2 # something like CxiDs1.0:Cspad.0
        cspad_data_type = name3 # something like CsPad::ElementV2
        #print 'CSPad is found in dataset', dsname
        #print 'CSPad name and data type =', cs.confcspad.cspad_name, cs.confcspad.cspad_data_type
        #return name2
    else :
        print 'ERROR in get_cspad_name_and_data_type_from_dataset_name( dsname ) for\ndsname =', dsname,\
              '\nReturn empty the CSPad name and data_type !!!'
    return cspad_name, cspad_data_type
Пример #6
0
    def get_cspad_config_dsname( self, data_dsname ) :
        """Find the CSPAD configuration dataset name in hdf5 file."""

        grpname = '/Configure:0000'
        pattern = 'CsPad::ConfigV'
        suffix  = gm.get_item_second_to_last_name(data_dsname) + '/config' 

        #print 'get_cspad_config_dsname(): loop over group content:'
        grp = self.get_dataset_from_hdf5_file(grpname)
        for key,val in dict(grp).iteritems() :
            #print '  ', key, val
            if key.find(pattern)==0 :
                #print '    ', val.name
                dsname = val.name  + '/' + suffix
                #print 'get_cspad_config_dsname(): found configuration dsname in hdf5 file:', dsname
                return dsname

        return None
Пример #7
0
 def loadImageArrayFromFile ( self, fname='cspad-ave100-cxi80410-r0628-v02.txt' ) :
     self.arr = gm.getNumpyArrayFromFile(fname)
Пример #8
0
 def loadImageArrayFromFile(self,
                            fname='cspad-ave100-cxi80410-r0628-v02.txt'):
     self.arr = gm.getNumpyArrayFromFile(fname)