Ejemplo n.º 1
0
    def testBackengineSingleInputFile(self):
        """ Test a backengine run with a single input file. """
        # Ensure clean-up.
        self.__files_to_remove.append('prop_out_0000001.h5')

        # Construct the object.
        xfel_propagator = WavePropagator(parameters=None,
                                         input_path=self.input_h5,
                                         output_path='prop_out_0000001.h5')

        # Call the backengine.
        status = xfel_propagator.backengine()

        # Check backengine returned sanely.
        self.assertEqual(status, 0)
Ejemplo n.º 2
0
    def testBackengineMultipleInputFile(self):
        """ Test a backengine run with multiple input files. """
        # Construct the object.
        xfel_propagator = WavePropagator(
            parameters=None,
            input_path=TestUtilities.generateTestFilePath('FELsource_out'),
            output_path='prop_out')

        # Call the backengine.
        status = xfel_propagator.backengine()

        # Check backengine returned sanely.
        self.assertEqual(status, 0)

        # Ensure clean-up.
        self.__dirs_to_remove.append(xfel_propagator.output_path)
Ejemplo n.º 3
0
    def testReadCalculateWrite(self):
        """ Test a backengine run with a single input file. """
        # Define a beamline.
        beamline = setupSPBDay1Beamline()

        # Construct the object.
        propagator = WavePropagator(parameters=beamline,
                                    input_path=self.input_h5,
                                    output_path='wpg_out.h5')

        # Read the data.
        propagator._readH5()

        # Call the backengine.
        status = propagator.backengine()

        # Check backengine returned sanely.
        self.assertEqual(status, 0)

        # Write propagated wavefront.
        propagator.saveH5()

        # Check output was written.
        self.assertTrue(os.path.isfile(propagator.output_path))

        # Ensure clean-up.
        self.__files_to_remove.append(propagator.output_path)
Ejemplo n.º 4
0
    def testShapedConstruction(self):
        """ Testing the construction of the class with non-default parameters. """

        # Construct the object.
        xfel_propagator = WavePropagator(parameters=None,
                                         input_path=self.input_h5,
                                         output_path='prop_out_0000000.h5')

        self.assertIsInstance(xfel_propagator, WavePropagator)
Ejemplo n.º 5
0
    def testDefaultConstruction(self):
        """ Testing the default construction of the class. """

        # Construct the object.
        xfel_propagator = WavePropagator()

        self.assertIsInstance(xfel_propagator, WavePropagator)

        self.assertEqual(xfel_propagator.input_path, os.path.abspath('source'))
        self.assertEqual(xfel_propagator.output_path, os.path.abspath('prop'))
Ejemplo n.º 6
0
    def testConstructionBeamline(self):
        """ Testing the construction of the class with the beamline given instead of a dictionary. """

        # Define a beamline.
        beamline = setupSPBDay1Beamline()

        # Construct the object.
        propagator = WavePropagator(parameters=beamline,
                                    input_path=self.input_h5,
                                    output_path='wpg_out_0000000.h5')

        self.assertIsInstance(propagator, WavePropagator)
Ejemplo n.º 7
0
    def testConstruction(self):
        """ Testing the default construction of the class. """

        # Define a beamline.
        beamline = setupSPBDay1Beamline()

        # Construct the object.
        propagator = WavePropagator(parameters={'beamline': beamline},
                                    input_path=self.input_h5,
                                    output_path='wpg_out_0000000.h5')

        self.assertIsInstance(propagator, WavePropagator)
Ejemplo n.º 8
0
    def testReadH5ExceptionInput(self):
        """ Test exception raises if input is not a valid h5 file. """
        # Define a beamline.
        beamline = setupSPBDay1Beamline()

        # Construct the object.
        propagator = WavePropagator(parameters=beamline,
                                    input_path='/tmp',
                                    output_path='wpg_out_0000001.h5')

        # Check exception raises when attempting to read.
        self.assertRaises(IOError, propagator._readH5)
Ejemplo n.º 9
0
    def reference2NIP(self):
        """ Testing that diffraction intensities with 9fs 5keV pulses through SPB-SFX KB beamline are of the order of Yoon 2016. """

        source_file = "/data/netapp/grotec/datadump/5keV_9fs_2015_slice12_fromYoon2016.h5"
        #source_file = TestUtilities.generateTestFilePath("FELsource_out.h5")

        # Propagate
        propagator = XFELPhotonPropagator(parameters=None,
                                          input_path=source_file,
                                          output_path="prop_out.h5")
        propagator.backengine()
        propagator.saveH5()

        pmi = XMDYNDemoPhotonMatterInteractor(
            parameters=None,
            input_path=propagator.output_path,
            output_path="pmi",
            sample_path=TestUtilities.generateTestFilePath("sample.h5"))
        pmi.backengine()

        #  Diffraction with parameters.
        diffraction_parameters = SingFELPhotonDiffractorParameters(
            uniform_rotation=True,
            calculate_Compton=False,
            slice_interval=100,
            number_of_slices=100,
            pmi_start_ID=1,
            pmi_stop_ID=1,
            number_of_diffraction_patterns=1,
            beam_parameter_file=TestUtilities.generateTestFilePath('s2e.beam'),
            beam_geometry_file=TestUtilities.generateTestFilePath('s2e.geom'),
            number_of_MPI_processes=8,
        )

        diffractor = SingFELPhotonDiffractor(parameters=diffraction_parameters,
                                             input_path=pmi.output_path,
                                             output_path="diffr_out.h5")
        diffractor.backengine()
Ejemplo n.º 10
0
    def testBackengineDefaultPaths(self):
        """ Test a backengine run with a default io paths."""
        # Cleanup.
        self.__dirs_to_remove.append('source')
        self.__dirs_to_remove.append('prop')

        # Prepare source.
        shutil.copytree(TestUtilities.generateTestFilePath('FELsource_out'),
                        os.path.abspath('source'))

        # Construct the object.
        xfel_propagator = WavePropagator()

        # Call the backengine.
        status = xfel_propagator.backengine()

        # Check backengine returned sanely.
        self.assertEqual(status, 0)

        # Check expected files exist.
        self.assertTrue(os.path.isdir, os.path.abspath('prop'))
        self.assertIn('prop_out_0000000.h5', os.listdir('prop'))
        self.assertIn('prop_out_0000001.h5', os.listdir('prop'))