def test_sample_transmission_calculation(self):
        """
        Test a basic transmission calculation using number density.
        """

        # Using water sample
        formula = "H2-O"
        density = 0.100272
        thickness = 0.1

        ws = CalculateSampleTransmission(WavelengthRange='5.0,0.2,7.0',
                                         ChemicalFormula=formula,
                                         Density=density,
                                         Thickness=thickness,
                                         DensityType='Number Density')

        self.assertEqual(ws.getNumberHistograms(), 2)

        expected_trans = [
            0.56335639, 0.56310584, 0.5628554, 0.56260506, 0.56235484,
            0.56210473, 0.56185474, 0.56160485, 0.56135507, 0.56110541
        ]
        expected_scatt = [
            0.43017862, 0.43017862, 0.43017862, 0.43017862, 0.43017862,
            0.43017862, 0.43017862, 0.43017862, 0.43017862, 0.43017862
        ]
        trans = ws.readY(0)
        scatt = ws.readY(1)

        np.testing.assert_array_almost_equal(trans, expected_trans, decimal=4)
        np.testing.assert_array_almost_equal(scatt, expected_scatt, decimal=4)
    def test_sample_transmission_calculation(self):
        """
        Test a basic transmission calculation using number density.
        """

        # Using water sample
        formula = "H2-O"
        density = 0.033424
        thickness = 0.1

        ws = CalculateSampleTransmission(WavelengthRange='5.0,0.2,7.0',
                                         ChemicalFormula=formula,
                                         Density=density,
                                         Thickness=thickness,
                                         DensityType='Number Density')

        self.assertEqual(ws.getNumberHistograms(), 2)

        expected_trans = [
            0.825901, 0.825778, 0.825656, 0.825533, 0.825411, 0.825288,
            0.825166, 0.825044, 0.824921, 0.824799
        ]
        expected_scatt = [
            0.170971, 0.170971, 0.170971, 0.170971, 0.170971, 0.170971,
            0.170971, 0.170971, 0.170971, 0.170971
        ]
        trans = ws.readY(0)
        scatt = ws.readY(1)

        np.testing.assert_array_almost_equal(trans, expected_trans, decimal=4)
        np.testing.assert_array_almost_equal(scatt, expected_scatt, decimal=4)
    def test_mass_density(self):
        """
        Tests a transmission calculation using mass density
        """
        formula = "H2-O"
        density = 1
        thickness = 0.1

        ws = CalculateSampleTransmission(WavelengthRange='5.0,0.2,7.0',
                                         ChemicalFormula=formula,
                                         Density=density,
                                         Thickness=thickness,
                                         DensityType='Mass Density')

        self.assertEqual(ws.getNumberHistograms(), 2)

        expected_trans = [
            0.56339476, 0.56314421, 0.56289378, 0.56264346, 0.56239326,
            0.56214316, 0.56189317, 0.5616433, 0.56139354, 0.56114388
        ]
        expected_scatt = [
            0.43021665, 0.43021665, 0.43021665, 0.43021665, 0.43021665,
            0.43021665, 0.43021665, 0.43021665, 0.43021665, 0.43021665
        ]

        trans = ws.readY(0)
        scatt = ws.readY(1)
        np.testing.assert_array_almost_equal(trans, expected_trans, decimal=4)
        np.testing.assert_array_almost_equal(scatt, expected_scatt, decimal=4)
Ejemplo n.º 4
0
    def test_sample_transmission_calculation(self):
        """
        Test a basic transmission calculation.
        """

        # Using water sample
        formula = "H2-O"
        density = 0.1
        thickness = 0.1

        ws = CalculateSampleTransmission(WavelengthRange='5.0,0.2,7.0',
                                         ChemicalFormula=formula,
                                         NumberDensity=density,
                                         Thickness=thickness)

        self.assertEqual(ws.getNumberHistograms(), 2)

        expected_trans = [
            0.564272, 0.564022, 0.563772, 0.563522, 0.563272, 0.563022,
            0.562772, 0.562523, 0.562273, 0.562024
        ]
        expected_scatt = [
            0.429309, 0.429309, 0.429309, 0.429309, 0.429309, 0.429309,
            0.429309, 0.429309, 0.429309, 0.429309
        ]
        trans = ws.readY(0)
        scatt = ws.readY(1)

        np.testing.assert_array_almost_equal(trans, expected_trans, decimal=4)
        np.testing.assert_array_almost_equal(scatt, expected_scatt, decimal=4)
Ejemplo n.º 5
0
    def test_mass_density(self):
        """
        Tests a transmission calculation using mass density
        """
        formula = "H2-O"
        density = 1
        thickness = 0.1

        ws = CalculateSampleTransmission(WavelengthRange='5.0,0.2,7.0',
                                         ChemicalFormula=formula,
                                         Density=density,
                                         Thickness=thickness,
                                         DensityType='Mass Density')

        self.assertEqual(ws.getNumberHistograms(), 2)

        expected_trans = [
            0.56619985, 0.56605978, 0.56591975, 0.56577975, 0.56563978,
            0.56549985, 0.56535996, 0.56522009, 0.56508027, 0.56494047
        ]
        expected_scatt = [
            0.43021665, 0.43021665, 0.43021665, 0.43021665, 0.43021665,
            0.43021665, 0.43021665, 0.43021665, 0.43021665, 0.43021665
        ]

        trans = ws.readY(0)
        scatt = ws.readY(1)
        np.testing.assert_array_almost_equal(trans, expected_trans, decimal=4)
        np.testing.assert_array_almost_equal(scatt, expected_scatt, decimal=4)
Ejemplo n.º 6
0
    def test_sample_transmission_calculation(self):
        """
        Test a basic transmission calculation using number density.
        """

        # Using water sample
        formula = "H2-O"
        density = 0.100272
        thickness = 0.1

        ws = CalculateSampleTransmission(WavelengthRange='5.0,0.2,7.0',
                                         ChemicalFormula=formula,
                                         Density=density,
                                         Thickness=thickness,
                                         DensityType='Number Density')

        self.assertEqual(ws.getNumberHistograms(), 2)

        expected_trans = [
            0.56619985, 0.56605978, 0.56591975, 0.56577975, 0.56563978,
            0.56549985, 0.56535996, 0.56522009, 0.56508027, 0.56494047
        ]
        expected_scatt = [
            0.43017862, 0.43017862, 0.43017862, 0.43017862, 0.43017862,
            0.43017862, 0.43017862, 0.43017862, 0.43017862, 0.43017862
        ]
        trans = ws.readY(0)
        scatt = ws.readY(1)

        np.testing.assert_array_almost_equal(trans, expected_trans, decimal=4)
        np.testing.assert_array_almost_equal(scatt, expected_scatt, decimal=4)
    def test_mass_density(self):
        """
        Tests a transmission calculation using mass density
        """
        formula = "H2-O"
        density = 1
        thickness = 0.1

        ws = CalculateSampleTransmission(WavelengthRange='5.0,0.2,7.0', ChemicalFormula=formula,
                                         Density=density, Thickness=thickness, DensityType='Mass Density')

        self.assertEqual(ws.getNumberHistograms(), 2)

        expected_trans = [0.56619985, 0.56605978, 0.56591975, 0.56577975, 0.56563978, 0.56549985, 0.56535996, 0.56522009, 0.56508027, 0.56494047]
        expected_scatt = [0.43021665, 0.43021665, 0.43021665, 0.43021665, 0.43021665, 0.43021665, 0.43021665, 0.43021665, 0.43021665, 0.43021665]

        trans = ws.readY(0)
        scatt = ws.readY(1)
        np.testing.assert_array_almost_equal(trans, expected_trans, decimal=4)
        np.testing.assert_array_almost_equal(scatt, expected_scatt, decimal=4)
    def test_mass_density(self):
        """
        Tests a transmission calculation using mass density
        """
        formula = "H2-O"
        density = 1
        thickness = 0.1

        ws = CalculateSampleTransmission(WavelengthRange='5.0,0.2,7.0', ChemicalFormula=formula,
                                         Density=density, Thickness=thickness, DensityType='Mass Density')

        self.assertEqual(ws.getNumberHistograms(), 2)

        expected_trans = [0.825901, 0.825778, 0.825656, 0.825533, 0.825411, 0.825288, 0.825166, 0.825044, 0.824921, 0.824799]
        expected_scatt = [0.170971, 0.170971, 0.170971, 0.170971, 0.170971, 0.170971, 0.170971, 0.170971, 0.170971, 0.170971]

        trans = ws.readY(0)
        scatt = ws.readY(1)
        np.testing.assert_array_almost_equal(trans, expected_trans, decimal=4)
        np.testing.assert_array_almost_equal(scatt, expected_scatt, decimal=4)
Ejemplo n.º 9
0
    def calculate(input_dict):
        output_key = {}
        if input_dict['binning_type'] == 0:
            # single binning
            binning = str(input_dict['single_low']) + ',' + str(input_dict['single_width']) + ',' + \
                      str(input_dict['single_high'])
        if input_dict['binning_type'] == 1:
            # multiple binning
            binning = input_dict['multiple_bin']

        transmission_ws = CalculateSampleTransmission(
            WavelengthRange=binning,
            ChemicalFormula=input_dict['chemical_formula'],
            DensityType=input_dict['density_type'],
            density=input_dict['density'],
            thickness=input_dict['thickness'])
        output_key['x'] = transmission_ws.dataX(0)
        output_key['y'] = transmission_ws.dataY(0)
        output_key['scattering'] = transmission_ws.dataY(1)[0]
        return output_key
    def test_sample_transmission_calculation(self):
        """
        Test a basic transmission calculation using number density.
        """

        # Using water sample
        formula = "H2-O"
        density = 0.100272
        thickness = 0.1

        ws = CalculateSampleTransmission(WavelengthRange='5.0,0.2,7.0', ChemicalFormula=formula,
                                         Density=density, Thickness=thickness, DensityType='Number Density')

        self.assertEqual(ws.getNumberHistograms(), 2)

        expected_trans = [0.56619985, 0.56605978, 0.56591975, 0.56577975, 0.56563978, 0.56549985, 0.56535996, 0.56522009, 0.56508027, 0.56494047]
        expected_scatt = [0.43017862, 0.43017862, 0.43017862, 0.43017862, 0.43017862, 0.43017862, 0.43017862, 0.43017862, 0.43017862, 0.43017862]
        trans = ws.readY(0)
        scatt = ws.readY(1)

        np.testing.assert_array_almost_equal(trans, expected_trans, decimal=4)
        np.testing.assert_array_almost_equal(scatt, expected_scatt, decimal=4)
    def test_sample_transmission_calculation(self):
        """
        Test a basic transmission calculation.
        """

        # Using water sample
        formula = "H2-O"
        density = 0.1
        thickness = 0.1

        ws = CalculateSampleTransmission(WavelengthRange='5.0,0.2,7.0', ChemicalFormula=formula,
                                         NumberDensity=density, Thickness=thickness)

        self.assertEqual(ws.getNumberHistograms(), 2)

        expected_trans = [0.564272, 0.564022, 0.563772, 0.563522, 0.563272, 0.563022, 0.562772, 0.562523, 0.562273, 0.562024]
        expected_scatt = [0.429309, 0.429309, 0.429309, 0.429309, 0.429309, 0.429309, 0.429309, 0.429309, 0.429309, 0.429309]
        trans = ws.readY(0)
        scatt = ws.readY(1)

        np.testing.assert_array_almost_equal(trans, expected_trans, decimal=4)
        np.testing.assert_array_almost_equal(scatt, expected_scatt, decimal=4)