예제 #1
0
 def _preparePreScanSnapshot(self, env):
     '''Extract pre-scan snapshot, filters elements of shape different 
     than scalar and split labels and values into chunks of 8 items.
     
     :param: env (dict) scan environment
     
     :return: labels, values (tuple<list,list>)
              labels - list of chunks with 8 elements containing labels 
              values - list of chunks with 8 elements containing values    
     '''
     # preScanSnapShot is a list o ColumnDesc objects
     pre_scan_snapshot = env.get('preScanSnapShot',[])
     labels = []; values = []
     for column_desc in pre_scan_snapshot:
         shape = column_desc.shape # shape is a tuple of dimensions
         label = column_desc.label
         dtype = column_desc.dtype
         pre_scan_value = column_desc.pre_scan_value
         # skip items with shape different than scalar
         if  len(shape) > 0:
             self.info('Pre-scan snapshot of "%s" will not be stored.' + \
                       ' Reason: value is non-scalar', label)
             continue
         if dtype not in self.supported_dtypes:
             self.info('Pre-scan snapshot of "%s" will not be stored.' + \
                       ' Reason: type %s not supported', label, dtype)
             continue
         labels.append(label)
         values.append(pre_scan_value)
     # split labels in chunks o 8 items
     labels_chunks = list(chunks(labels, 8))
     values_chunks = list(chunks(values, 8))
     return labels_chunks, values_chunks
예제 #2
0
파일: storage.py 프로젝트: cmft/sardana
 def _preparePreScanSnapshot(self, env):
     '''Extract pre-scan snapshot, filters elements of shape different 
     than scalar and split labels and values into chunks of 8 items.
     
     :param: env (dict) scan environment
     
     :return: labels, values (tuple<list,list>)
              labels - list of chunks with 8 elements containing labels 
              values - list of chunks with 8 elements containing values    
     '''
     # preScanSnapShot is a list o ColumnDesc objects
     pre_scan_snapshot = env.get('preScanSnapShot',[])
     labels = []; values = []
     for column_desc in pre_scan_snapshot:
         shape = column_desc.shape # shape is a tuple of dimensions
         label = column_desc.label
         dtype = column_desc.dtype
         pre_scan_value = column_desc.pre_scan_value
         # skip items with shape different than scalar
         if  len(shape) > 0:
             self.info('Pre-scan snapshot of "%s" will not be stored.' + \
                       ' Reason: value is non-scalar', label)
             continue
         if dtype not in self.supported_dtypes:
             self.info('Pre-scan snapshot of "%s" will not be stored.' + \
                       ' Reason: type %s not supported', label, dtype)
             continue
         labels.append(label)
         values.append(pre_scan_value)
     # split labels in chunks o 8 items
     labels_chunks = list(chunks(labels, 8))
     values_chunks = list(chunks(values, 8))
     return labels_chunks, values_chunks