Exemple #1
0
 def test_stog_add_dataset_default_reciprocal_space_function(self):
     # Checks the default reciprocal space function is S(Q) and the index is
     # set
     stog = StoG()
     index = 300
     info = {'data': pd.DataFrame({'x': self.q, 'y': self.sq})}
     stog.add_dataset(info, index=index)
     self.assertEqual(list(stog.df_individuals.columns.values),
                      ['S(Q)_%d' % index])
Exemple #2
0
 def test_stog_add_dataset_wrong_reciprocal_space_function_exception(self):
     # Check qmin and qmax apply cropping
     stog = StoG()
     index = 0
     info = {
         'data': pd.DataFrame({
             'x': self.q,
             'y': self.sq
         }),
         'ReciprocalFunction': 'ABCDEFG(Q)'
     }
     with self.assertRaises(ValueError):
         stog.add_dataset(info, index=index)
Exemple #3
0
 def test_stog_add_dataset_qmin_qmax_crop(self):
     # Check qmin and qmax apply cropping
     stog = StoG()
     index = 0
     info = {
         'data': pd.DataFrame({
             'x': self.q,
             'y': self.sq
         }),
         'ReciprocalFunction': 'S(Q)'
     }
     stog.qmin = 1.5
     stog.qmax = 12.0
     stog.add_dataset(info, index=index)
     self.assertEqual(stog.df_individuals.iloc[0].name, stog.qmin)
     self.assertEqual(stog.df_individuals.iloc[-1].name, stog.qmax)
Exemple #4
0
 def test_stog_add_dataset_xoffset(self):
     # Offset Q from 1.96 -> 2.14
     stog = StoG()
     index = 0
     info = {
         'data': pd.DataFrame({
             'x': self.q,
             'y': self.sq
         }),
         'ReciprocalFunction': 'S(Q)',
         'X': {
             'Offset': 0.2
         }
     }
     stog.add_dataset(info, index=index)
     self.assertEqual(stog.df_individuals.iloc[self.first].name, 2.14)
Exemple #5
0
 def test_stog_add_dataset_yoffset(self):
     # Offset S(Q) and make sure it does not equal original target values
     stog = StoG()
     index = 0
     info = {
         'data': pd.DataFrame({
             'x': self.q,
             'y': self.sq
         }),
         'ReciprocalFunction': 'S(Q)',
         'Y': {
             'Offset': 2.0
         }
     }
     stog.add_dataset(info, index=index)
     self.assertNotEqual(
         stog.df_individuals.iloc[self.first]['S(Q)_%d' % index],
         self.sq_target[0])
     self.assertNotEqual(
         stog.df_sq_individuals.iloc[self.first]['S(Q)_%d' % index],
         self.sq_target[0])
Exemple #6
0
    def test_stog_add_dataset(self):
        # Number of decimal places for precision
        places = 5

        # Initialize with material info for Argon
        stog = StoG(
            **{
                '<b_coh>^2': self.kwargs['<b_coh>^2'],
                '<b_tot^2>': self.kwargs['<b_tot^2>']
            })

        # Add the S(Q) data set and check values against targets
        index = 0
        info = {
            'data': pd.DataFrame({
                'x': self.q,
                'y': self.sq
            }),
            'ReciprocalFunction': 'S(Q)'
        }
        stog.add_dataset(info, index=index)
        self.assertEqual(stog.df_individuals.iloc[self.first].name,
                         self.reciprocal_xtarget)
        self.assertAlmostEqual(stog.df_individuals.iloc[self.first]['S(Q)_%d' %
                                                                    index],
                               self.sq_target[0],
                               places=places)
        self.assertAlmostEqual(
            stog.df_sq_individuals.iloc[self.first]['S(Q)_%d' % index],
            self.sq_target[0],
            places=places)

        # Add the Q[S(Q)-1] data set and check values for it and S(Q) against
        # targets
        index = 1
        info = {
            'data': pd.DataFrame({
                'x': self.q,
                'y': self.fq
            }),
            'ReciprocalFunction': 'Q[S(Q)-1]'
        }
        stog.add_dataset(info, index=index)
        self.assertAlmostEqual(
            stog.df_individuals.iloc[self.first]['Q[S(Q)-1]_%d' % index],
            self.fq_target[0],
            places=places)
        self.assertAlmostEqual(
            stog.df_sq_individuals.iloc[self.first]['S(Q)_%d' % index],
            self.sq_target[0],
            places=places)

        # Add the FK(Q) data set and check values for it and S(Q) against
        # targets
        index = 2
        info = {
            'data': pd.DataFrame({
                'x': self.q,
                'y': self.fq_keen
            }),
            'ReciprocalFunction': 'FK(Q)'
        }
        stog.add_dataset(info, index=index)
        self.assertAlmostEqual(
            stog.df_individuals.iloc[self.first]['FK(Q)_%d' % index],
            self.fq_keen_target[0],
            places=places)
        self.assertAlmostEqual(
            stog.df_sq_individuals.iloc[self.first]['S(Q)_%d' % index],
            self.sq_target[0],
            places=places)

        # Add the DCS(Q) data set and check values for it and S(Q) against
        # targets
        index = 3
        info = {
            'data': pd.DataFrame({
                'x': self.q,
                'y': self.dcs
            }),
            'ReciprocalFunction': 'DCS(Q)'
        }
        stog.add_dataset(info, index=index)
        self.assertAlmostEqual(
            stog.df_individuals.iloc[self.first]['DCS(Q)_%d' % index],
            self.dcs_target[0],
            places=places)
        self.assertAlmostEqual(
            stog.df_sq_individuals.iloc[self.first]['S(Q)_%d' % index],
            self.sq_target[0],
            places=places)