Exemple #1
0
    def dump_theta(self, file_name):
        """Add theta to the hdf5 file by using unique ids stored in the same hdf5 file

        - read unique projection ids from the hdf5 file
        - take angles by ids from the PSO
        - dump angles into hdf5 file
        """

        log.info('dump theta into the hdf5 file %s',file_name)
        hdf_file = util.open_hdf5(file_name,'r+')                
        unique_ids = hdf_file['/defaults/NDArrayUniqueId'][:]
        theta = self.epics_pvs['ThetaArray'].get(count=int(self.epics_pvs['NumAngles'].get()))             
        dset = hdf_file.create_dataset('/exchange/theta', (len(unique_ids),), dtype='float32')
        dset[:] = theta[unique_ids]        
        log.info('theta to save: %s .. %s', theta[unique_ids[0]], theta[unique_ids[-1]])
        log.info('total saved theta: %s', len(unique_ids))        
Exemple #2
0
 def broadcast_flat(self):
     """Broadcast flat fields
     
     - read flat fields from the file
     - take average and bin flat fields according to StreamBinning parameter
     - broadcast flat field with the pv variable    
     """
     
     log.info('broadcast flat fields')        
     dirname = os.path.dirname(self.epics_pvs['FPFullFileName'].get(as_string=True))            
     h5file = util.open_hdf5(dirname+'/flat_fields.h5','r') 
     data = h5file['exchange/data_white'][:]
     data = numpy.mean(data.astype('float32'),0)
     for k in range(self.epics_pvs['StreamBinning'].get() ):
         data = 0.5*(data[:, ::2]+data[:, 1::2])
         data = 0.5*(data[::2, :]+data[1::2, :])
     self.pva_stream_flat['value'] = data.flatten()
     self.pva_stream_flat['sizex'] = data.shape[1] 
     self.pva_stream_flat['sizey'] = data.shape[0]          
Exemple #3
0
    def dump_theta(self):
        """Add theta to the hdf5 file by using unique ids stored in the same hdf5 file

        - read unique projection ids from the hdf5 file
        - take angles by ids from the PSO
        - dump angles into hdf5 file
        """
        file_name = self.epics_pvs['FPFullFileName'].get(as_string=True)
        log.info('dump theta into the hdf5 file %s', file_name)
        with util.open_hdf5(file_name, 'r+') as hdf_file:
            unique_ids = hdf_file['/defaults/NDArrayUniqueId'][:]
            if '/exchange/theta' in hdf_file:
                del hdf_file['/exchange/theta']
            dset = hdf_file.create_dataset('/exchange/theta',
                                           (len(unique_ids), ),
                                           dtype='float32')
            dset[:] = self.theta[unique_ids]
        log.info('saved theta: %s .. %s', self.theta[unique_ids[0]],
                 self.theta[unique_ids[-1]])
        log.info('total saved theta: %s', len(unique_ids))