def testPlotAvgSequenceInt(self): """ Check we can plot the avg over a subset of patterns given as list of ints.""" analyzer = DiffractionAnalysis(input_path=self.__test_data, pattern_indices=[1, 3, 6]) analyzer.plotPattern(operation=numpy.mean) if RENDER_PLOT: plt.show()
def testPlotAndStatistics(self): """ Check that we can get two plots (resetting the iterator works.)""" analyzer = DiffractionAnalysis(input_path=self.__test_data, pattern_indices="all", poissonize=True) analyzer.logscale = True analyzer.plotPattern(logscale=True) analyzer.statistics()
def main(args=None): # Setup the object. analyzer = DiffractionAnalysis( input_path=args.input_path, pattern_indices=eval(args.pattern_indices), poissonize=eval(args.poissonize), ) # Plot if requested. if args.plot: analyzer.plotPattern( logscale=args.logscale, operation=eval(args.operation), ) # Plot if requested. if args.radial: analyzer.plotRadialProjection( logscale=args.logscale, operation=eval(args.operation), ) if args.statistics: analyzer.statistics() plt.show() # Animate if requested. if args.animation_filename: analyzer.animatePatterns(output_path=args.animation_filename) print "Animated gif saved to %s." % ( analyzer._DiffractionAnalysis__animation_output_path)
def testPlotAvgPatternLegacy(self): """ Check we can plot the average diffraction pattern as a color map. """ analyzer = DiffractionAnalysis( input_path=TestUtilities.generateTestFilePath('diffr_0.1')) analyzer.plotPattern(operation=numpy.mean) if RENDER_PLOT: plt.show()
def testPlotSumPatternLogscale(self): """ Check we can plot one diffraction pattern as a color map. """ analyzer = DiffractionAnalysis(input_path=self.__test_data, poissonize=False) analyzer.plotPattern(operation=numpy.sum, logscale=True) if RENDER_PLOT: plt.show()
def testPlotOnePattern(self): """ Check we can plot one diffraction pattern as a color map. """ analyzer = DiffractionAnalysis(input_path=self.__test_data, pattern_indices=4) analyzer.plotPattern() if RENDER_PLOT: plt.show()
def testPlotOnePatternLegacy(self): """ Check we can plot one diffraction pattern from a v0.1 dir as a color map. """ analyzer = DiffractionAnalysis( input_path=TestUtilities.generateTestFilePath('diffr_0.1'), pattern_indices=4) analyzer.plotPattern(operation=None) if RENDER_PLOT: plt.show()
def plot_diffr_vs_detector(self): """ Compare patterns before and after detector sim. """ # Cleanup. #self.__files_to_remove.append('5mzd.pdb') #self.__files_to_remove.append('diffr.h5') #self.__dirs_to_remove.append('diffr') # Avoid crash due to multiple instances of G4RunManager del self._detector # Setup detector geometry. detector_panel = DetectorPanel( ranges={ 'fast_scan_min': 0, 'fast_scan_max': 511, 'slow_scan_min': 0, 'slow_scan_max': 511 }, pixel_size=2.2e-4 * Units.meter, photon_response=1.0, distance_from_interaction_plane=0.13 * Units.meter, corners={ 'x': -256, 'y': -256 }, ) detector_geometry = DetectorGeometry(panels=[detector_panel]) # Setup photon beam. beam = PhotonBeamParameters( photon_energy=4.96e3 * Units.electronvolt, beam_diameter_fwhm=1.0e-6 * Units.meter, pulse_energy=1.0e-3 * Units.joule, photon_energy_relative_bandwidth=0.001, divergence=1e-3 * Units.radian, photon_energy_spectrum_type="SASE", ) # Setup and run the diffraction sim. diffraction_parameters = SingFELPhotonDiffractorParameters( uniform_rotation=None, calculate_Compton=False, number_of_diffraction_patterns=1, detector_geometry=detector_geometry, beam_parameters=beam, sample="5mzd.pdb", forced_mpi_command='mpirun -np 1', ) photon_diffractor = SingFELPhotonDiffractor( parameters=diffraction_parameters, output_path='diffr', ) photon_diffractor.backengine() photon_diffractor.saveH5() analysis1 = DiffractionAnalysis(photon_diffractor.output_path, pattern_indices=[1], poissonize=True) analysis1.plotPattern( operation=None, logscale=False, ) parameters = XCSITPhotonDetectorParameters( detector_type="AGIPDSPB", patterns=[0], ) detector = XCSITPhotonDetector( parameters=parameters, input_path="diffr.h5", output_path="detector_out.h5", ) detector._readH5() detector.backengine() detector.saveH5() # Weak test Check we have photons in the signal. pattern = h5py.File("detector_out.h5", 'r')['data/0000001/data'].value analysis2 = DiffractionAnalysis(detector.output_path, pattern_indices=[1], poissonize=True) analysis2.plotPattern( operation=None, logscale=False, ) mpl.pyplot.show()
def testPlotRMSPattern(self): """ Check we can plot the rms diffraction pattern as a color map. """ analyzer = DiffractionAnalysis(input_path=self.__test_data) analyzer.plotPattern(operation=numpy.std) plt.show()
def testPlotPatternDefault(self): """ Check we the sum image of all patterns is plotted by default. """ analyzer = DiffractionAnalysis(input_path=self.__test_data) analyzer.plotPattern() plt.show()
def testPlotOnePatternPoissonized(self): """ Check we can plot one diffraction pattern as a color map. """ analyzer = DiffractionAnalysis(input_path=self.__test_data, pattern_indices=1) analyzer.plotPattern() plt.show()
def testPlotAvgPattern(self): """ Check we can plot the average diffraction pattern as a color map. """ analyzer = DiffractionAnalysis(input_path=self.__test_data) analyzer.plotPattern(operation=numpy.mean) if RENDER_PLOT: plt.show()