Esempio n. 1
0
    def test_sample_form(self):
        sample_form = 'Polycrystalline'

        s_data = SData(sample_form=sample_form,
                       data=self.sample_data,
                       frequencies=self.frequencies)
        self.assertEqual(sample_form, s_data.get_sample_form())

        with self.assertRaises(ValueError):
            s_data.check_known_sample_form()

        # Check should pass for 'Powder'
        powder_data = SData(sample_form='Powder',
                            data=self.sample_data,
                            frequencies=self.frequencies)
        powder_data.check_known_sample_form()
Esempio n. 2
0
    def _broaden_sdata(self, sdata: SData,
                       broadening_scheme: str = 'auto') -> SData:
        """
        Apply instrumental broadening to scattering data
        """
        sdata_dict = sdata.extract()
        frequencies = sdata_dict['frequencies']
        del sdata_dict['frequencies']

        for atom_key in sdata_dict:
            for order_key in sdata_dict[atom_key]['s']:
                _, sdata_dict[atom_key]['s'][order_key] = (
                    self._instrument.convolve_with_resolution_function(
                        frequencies=frequencies, bins=self._bins,
                        s_dft=sdata_dict[atom_key]['s'][order_key],
                        scheme=broadening_scheme))
        return SData(data=sdata_dict, frequencies=self._bin_centres,
                     temperature = sdata.get_temperature(),
                     sample_form = sdata.get_sample_form())
Esempio n. 3
0
    def _broaden_sdata(self,
                       sdata: SData,
                       broadening_scheme: str = 'auto') -> SData:
        """
        Apply instrumental broadening to scattering data

        If the data is 2D, process line-by-line.
        (There is room for improvement, by reworking all the broadening
        implementations to accept 2-D input.)
        """
        sdata_dict = sdata.extract()
        frequencies = sdata_dict['frequencies']
        del sdata_dict['frequencies']
        if 'q_bins' in sdata_dict:
            del sdata_dict['q_bins']

        for atom_key in sdata_dict:
            for order_key, s_dft in sdata_dict[atom_key]['s'].items():
                if len(s_dft.shape) == 1:
                    _, sdata_dict[atom_key]['s'][order_key] = (
                        self._instrument.convolve_with_resolution_function(
                            frequencies=frequencies,
                            bins=self._bins,
                            s_dft=s_dft,
                            scheme=broadening_scheme))
                else:  # 2-D data, broaden one line at a time
                    for q_i, s_dft_row in enumerate(
                            sdata_dict[atom_key]['s'][order_key]):
                        _, sdata_dict[atom_key]['s'][order_key][q_i] = (
                            self._instrument.convolve_with_resolution_function(
                                frequencies=frequencies,
                                bins=self._bins,
                                s_dft=s_dft_row,
                                scheme=broadening_scheme))

        return SData(data=sdata_dict,
                     frequencies=self._bin_centres,
                     temperature=sdata.get_temperature(),
                     sample_form=sdata.get_sample_form(),
                     q_bins=sdata.get_q_bins())