def end_scan(self): """Performs the operations needed at the very end of a scan. This does the following: - Calls ``save_configuration()``. - Put the camera back in "FreeRun" mode and acquiring so the user sees live images. - Sets the speed of the rotation stage back to the maximum value. - Calls ``move_sample_in()``. - Calls the base class method. - Closes shutter. - Add theta to the raw data file. - Copy raw data to data analysis computer. """ if self.return_rotation == 'Yes': # Reset rotation position by mod 360 , the actual return # to start position is handled by super().end_scan() log.info('wait until the stage is stopped') time.sleep(self.epics_pvs['RotationAccelTime'].get() * 1.2) ang = self.epics_pvs['RotationRBV'].get() current_angle = np.sign(ang) * (np.abs(ang) % 360) self.epics_pvs['RotationSet'].put('Set', wait=True) self.epics_pvs['Rotation'].put(current_angle, wait=True) self.epics_pvs['RotationSet'].put('Use', wait=True) # Call the base class method super().end_scan() # Close shutter self.close_shutter() # Stop the file plugin self.epics_pvs['FPCapture'].put('Done') self.wait_pv(self.epics_pvs['FPCaptureRBV'], 0) # Add theta in the hdf file self.add_theta() # Copy raw data to data analysis computer if self.epics_pvs['CopyToAnalysisDir'].get(): log.info( 'Automatic data trasfer to data analysis computer is enabled.') full_file_name = self.epics_pvs['FPFullFileName'].get( as_string=True) remote_analysis_dir = self.epics_pvs['RemoteAnalysisDir'].get( as_string=True) dm.scp(full_file_name, remote_analysis_dir) else: log.warning( 'Automatic data trasfer to data analysis computer is disabled.' )
def auto_copy_data(self): '''Copies data from detector computer to analysis computer. ''' # Copy raw data to data analysis computer if self.epics_pvs['CopyToAnalysisDir'].get(): log.info('Automatic data trasfer to data analysis computer is enabled.') full_file_name = self.epics_pvs['FPFullFileName'].get(as_string=True) remote_analysis_dir = self.epics_pvs['RemoteAnalysisDir'].get(as_string=True) dm.scp(full_file_name, remote_analysis_dir) else: log.warning('Automatic data trasfer to data analysis computer is disabled.')
def end_scan(self): """Performs the operations needed at the very end of a scan. This does the following: - Reset rotation position by mod 360. - Calls the base class method. - Stop the file plugin. - Closes shutter. - Add theta to the raw data file. - Copy raw data to data analysis computer. """ if self.return_rotation == 'Yes': # Reset rotation position by mod 360 , the actual return # to start position is handled by super().end_scan() current_angle = self.epics_pvs['Rotation'].get() % 360 self.epics_pvs['RotationSet'].put('Set', wait=True) self.epics_pvs['Rotation'].put(current_angle, wait=True) self.epics_pvs['RotationSet'].put('Use', wait=True) # Call the base class method super().end_scan() # Close shutter self.close_shutter() # Stop the file plugin self.epics_pvs['FPCapture'].put('Done') self.wait_pv(self.epics_pvs['FPCaptureRBV'], 0) # Add theta in the hdf file self.add_theta() # Copy raw data to data analysis computer if self.epics_pvs['CopyToAnalysisDir'].get(): log.info( 'Automatic data trasfer to data analysis computer is enabled.') full_file_name = self.epics_pvs['FPFullFileName'].get( as_string=True) remote_analysis_dir = self.epics_pvs['RemoteAnalysisDir'].get( as_string=True) dm.scp(full_file_name, remote_analysis_dir) else: log.warning( 'Automatic data trasfer to data analysis computer is disabled.' )
def copy_flat_dark_to_hdf(self): """Copies the flat and dark field data to the HDF5 file with the projection data. This allows the file to be a fully valid DXchange file. Once the file is created it will be copied to the remote data analysis computer (if CopyToAnalysisDir is set to yes) """ log.info('save dark and flat to projection hdf file') fname = self.epics_pvs['FPFullFileName'].get(as_string=True) basename = os.path.basename(fname) dirname = os.path.dirname(fname) darkfield_name = os.path.join(dirname, 'dark_fields_' + basename) flatfield_name = os.path.join(dirname, 'flat_fields_' + basename) log.info('save dark fields') cmd = 'cp ' + os.path.join(dirname, 'dark_fields.h5') + ' ' + darkfield_name os.system(cmd) log.info('save flat fields') cmd = 'cp ' + os.path.join(dirname, 'flat_fields.h5') + ' ' + flatfield_name os.system(cmd) with h5py.File(fname, 'r+') as proj_hdf: if 'data_white' in proj_hdf['/exchange'].keys(): del (proj_hdf['/exchange/data_white']) with h5py.File(flatfield_name, 'r') as flat_hdf: proj_hdf['/exchange'].create_dataset( 'data_white', data=flat_hdf['/exchange/data_white'][...]) if 'data_dark' in proj_hdf['/exchange'].keys(): del (proj_hdf['/exchange/data_dark']) with h5py.File(darkfield_name, 'r') as dark_hdf: proj_hdf['/exchange'].create_dataset( 'data_dark', data=dark_hdf['/exchange/data_dark'][...]) log.info('done saving dark and flat to projection hdf file') # Copy raw data to data analysis computer if self.epics_pvs['CopyToAnalysisDir'].get(): log.info( 'Automatic data trasfer to data analysis computer is enabled.') full_file_name = self.epics_pvs['FPFullFileName'].get( as_string=True) remote_analysis_dir = self.epics_pvs['RemoteAnalysisDir'].get( as_string=True) dm.scp(full_file_name, remote_analysis_dir) else: log.warning( 'Automatic data trasfer to data analysis computer is disabled.' )
def end_scan(self): """Performs the operations needed at the very end of a scan. This does the following: - Calls ``save_configuration()``. - Put the camera back in "FreeRun" mode and acquiring so the user sees live images. - Sets the speed of the rotation stage back to the maximum value. - Calls ``move_sample_in()``. - Calls the base class method. - Closes shutter. - Add theta to the raw data file. - Copy raw data to data analysis computer. """ if self.return_rotation == 'Yes': # Reset rotation position by mod 360 , the actual return # to start position is handled by super().end_scan() # allow stage to stop log.info('wait until the stage is stopped') time.sleep(self.epics_pvs['RotationAccelTime'].get() * 1.2) ang = self.epics_pvs['RotationRBV'].get() current_angle = np.sign(ang) * (np.abs(ang) % 360) self.epics_pvs['RotationSet'].put('Set', wait=True) self.epics_pvs['Rotation'].put(current_angle, wait=True) self.epics_pvs['RotationSet'].put('Use', wait=True) # Close shutter self.close_shutter() # Stop the file plugin self.epics_pvs['FPCapture'].put('Done') self.wait_pv(self.epics_pvs['FPCaptureRBV'], 0) # Add theta in the hdf file self.add_theta() log.info('Adding a frame from the IP camera') ret, frame = cv2.VideoCapture( 'http://*****:*****@164.54.113.162/cgi-bin/mjpeg?stream=1' ).read() # we should hide the password #station A # NetBooter = NetBooter_Control(mode='telnet',id=self.access_dic['pdu_username'],password=self.access_dic['pdu_password'],ip=self.access_dic['pdu_ip_address']) # NetBooter.power_on(1) # log.info('wait 10 sec while the web camera has focused') # time.sleep(10) # ret, frame = cv2.VideoCapture('http://*****:*****@164.54.113.137/cgi-bin/mjpeg?stream=1').read()# we should hide the password #ret, frame = cv2.VideoCapture('http://' + self.access_dic['webcam_username'] +':' + self.access_dic['webcam_password'] + '@' + self.access_dic['webcam_ip_address'] + '/cgi-bin/mjpeg?stream=1').read() # NetBooter.power_off(1) if ret == True: full_file_name = self.epics_pvs['FPFullFileName'].get( as_string=True) with h5py.File(full_file_name, 'r+') as fid: fid.create_dataset('exchange/web_camera_frame', data=frame) log.info('The frame was added') else: log.warning('The frame was not added') # Copy raw data to data analysis computer if self.epics_pvs['CopyToAnalysisDir'].get(): log.info( 'Automatic data trasfer to data analysis computer is enabled.') full_file_name = self.epics_pvs['FPFullFileName'].get( as_string=True) remote_analysis_dir = self.epics_pvs['RemoteAnalysisDir'].get( as_string=True) dm.scp(full_file_name, remote_analysis_dir) else: log.warning( 'Automatic data trasfer to data analysis computer is disabled.' ) # Call the base class method super().end_scan()