コード例 #1
0
ファイル: C_spectrum.py プロジェクト: FNNDSC/gridautomaton
    def arr_set(self, arr):
        """
	   DESC
		Given array input <arr>, overwrite internal 
		data with elements as defined in <arr>
		
	   ARGS
	   	arr		in		array to process; can
	   					be 'ndarray' or 'list'
	   	
	   PRECONDITIONS
	   	o self.ml_keys must be valid.
	   	
	   POSTCONDITIONS
	   	o If unable to set array, return False. Make no change
	   	  to internal data.
	   """
        b_setOK = False
        if type(arr).__name__ == 'ndarray':
            self.mdict_spectrum = misc.dict_init(self.ml_keys, arr.tolist())
            b_setOK = True
        if type(arr) is types.ListType:
            self.mdict_spectrum = misc.dict_init(self.ml_keys, arr)
            b_setOK = True
        if b_setOK: self.keys_index()
        return b_setOK
コード例 #2
0
ファイル: C_spectrum.py プロジェクト: FNNDSC/gridautomaton
	def arr_set(self, arr):
	   """
	   DESC
		Given array input <arr>, overwrite internal 
		data with elements as defined in <arr>
		
	   ARGS
	   	arr		in		array to process; can
	   					be 'ndarray' or 'list'
	   	
	   PRECONDITIONS
	   	o self.ml_keys must be valid.
	   	
	   POSTCONDITIONS
	   	o If unable to set array, return False. Make no change
	   	  to internal data.
	   """
	   b_setOK = False
	   if type(arr).__name__ == 'ndarray':
	        self.mdict_spectrum = misc.dict_init(self.ml_keys, 
							arr.tolist())
	        b_setOK = True
	   if type(arr) is types.ListType:
	        self.mdict_spectrum = misc.dict_init(self.ml_keys, arr)
	        b_setOK = True
	   if b_setOK:	self.keys_index()
	   return b_setOK
コード例 #3
0
    def initialize(self):            
        """
        (Re)builds internal dictionary structures. Typically called
        once the number of rotations has been set and/or a new cloud
        has been read.
        """
        if self._numRotations < 1:
            self.fatal('Rotations')
        
        self._M_Crows, self._M_Ccols = self._M_C.shape
        self._M_Cdimensionality = self._M_Ccols
        # The numRotations defines the number of rotations between 
        # 0 and 90 degrees (i.e. the first quadrant). This is used
        # to create a dictionary of rotationKeys and rotationVals
        self._rotationKeys      = range(0, self._numRotations)
        v_keys                  = np.array(self._rotationKeys)
        v_vals                  = v_keys * 90.0/self._numRotations

        for rotation in self._rotationKeys:
            self._d_rotatedCloudStats[rotation] = self._dict_stats.copy()
        self._dict_rotationVal  = misc.dict_init(self._rotationKeys, 
                                                 list(v_vals))
        self._dict_projection   = misc.dict_init(self._rotationKeys, 
                                        np.zeros( (self._M_Ccols, self._M_Ccols),
                                                  dtype = 'object'))
        # 2D Planar quadrant projections
        for quadrant in range(1,5):
            self._dict_Q[quadrant] = misc.dict_init(self._rotationKeys,
                                        np.zeros( (1,2) ))
コード例 #4
0
ファイル: C_spectrum.py プロジェクト: FNNDSC/gridautomaton
	def __init__(self, *args):
	    self.__name__ 	= 'C_spectrum'
	    self.mstr_obj	= 'C_spectrum';	# name of object class
            self.mstr_name	= 'unnamed';	# name of object variable
	    self.mstr_def	= 'void';	# name of function being processed
            self.m_id		= -1; 		# int id
            self.m_iter		= 0;		# current iteration in an
                                		#+ arbitrary processing 
						#+ scheme
            self.m_verbosity	= 0;		# debug related value for 
						#+ object
            self.m_warnings	= 0;            # show warnings 
						#+ (and warnings level)
	    self.mdict_keyIndex	= {};		# lookup of keys to indices
	    self.mdict_spectrum	= {};		# the actual spectrum
	    self.mNumKeys       = 0;
	    self.mb_printHist 	= False;	# If true, print an actual
						#+ histogram representation
	    self.mb_printAsRow  = False;	# If true, print spectrum as a
						# row, else print as column
	    self.mb_printConcise = False;	# If true, print concise 
						#+ version of spectrum
	    self.m_cellWidth 	 = 12		# For row printing, the width
						#+ of a column
	    self.mf_totalPower	 = 0.0;
						
	    c = args[0]
	    if type(c) is types.ListType:
	    	self.ml_keys = c
	    if type(c).__name__ == 'ndarray':
	        ilist = range(1, np.size(c)+1)
	        self.ml_keys = misc.list_i2str(ilist)
	        if len(args) >= 2:
	            if type(args[1] is types.ListType):
	            	if len(args[1]) == np.size(c):
	            	    self.ml_keys = args[1]

	    self.core_construct()
	    self.mdict_keyIndex = misc.dict_init(self.ml_keys, 0)
	    self.mdict_spectrum	= misc.dict_init(self.ml_keys, 0)
	    if type(c).__name__ == 'ndarray':
	        self.mdict_spectrum = misc.dict_init(self.ml_keys, 
							c.tolist())
	    self.keys_index()
	    if isinstance(c, int):
	    	self.component_add(c)
	    if type(c) is types.TupleType:
	    	for component in c:
	    	    self.component_add(component)
	    self.mNumKeys = len(self.ml_keys)
コード例 #5
0
ファイル: C_spectrum.py プロジェクト: FNNDSC/gridautomaton
    def __init__(self, *args):
        self.__name__ = 'C_spectrum'
        self.mstr_obj = 'C_spectrum'
        # name of object class
        self.mstr_name = 'unnamed'
        # name of object variable
        self.mstr_def = 'void'
        # name of function being processed
        self.m_id = -1
        # int id
        self.m_iter = 0
        # current iteration in an
        #+ arbitrary processing
        #+ scheme
        self.m_verbosity = 0
        # debug related value for
        #+ object
        self.m_warnings = 0
        # show warnings
        #+ (and warnings level)
        self.mdict_keyIndex = {}
        # lookup of keys to indices
        self.mdict_spectrum = {}
        # the actual spectrum
        self.mNumKeys = 0
        self.mb_printHist = False
        # If true, print an actual
        #+ histogram representation
        self.mb_printAsRow = False
        # If true, print spectrum as a
        # row, else print as column
        self.mb_printConcise = False
        # If true, print concise
        #+ version of spectrum
        self.m_cellWidth = 12  # For row printing, the width
        #+ of a column
        self.mf_totalPower = 0.0

        c = args[0]
        if type(c) is types.ListType:
            self.ml_keys = c
        if type(c).__name__ == 'ndarray':
            ilist = range(1, np.size(c) + 1)
            self.ml_keys = misc.list_i2str(ilist)
            if len(args) >= 2:
                if type(args[1] is types.ListType):
                    if len(args[1]) == np.size(c):
                        self.ml_keys = args[1]

        self.core_construct()
        self.mdict_keyIndex = misc.dict_init(self.ml_keys, 0)
        self.mdict_spectrum = misc.dict_init(self.ml_keys, 0)
        if type(c).__name__ == 'ndarray':
            self.mdict_spectrum = misc.dict_init(self.ml_keys, c.tolist())
        self.keys_index()
        if isinstance(c, int):
            self.component_add(c)
        if type(c) is types.TupleType:
            for component in c:
                self.component_add(component)
        self.mNumKeys = len(self.ml_keys)