Changeset 3540156 in sasview for sanscalculator


Ignore:
Timestamp:
Jan 11, 2013 6:06:11 PM (12 years ago)
Author:
Jae Cho <jhjcho@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
3657667
Parents:
440006a
Message:

cleaned up

Location:
sanscalculator
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • sanscalculator/src/sans/calculator/sans_gen.py

    rbe0fe41 r3540156  
    587587                input_f = numpy.loadtxt(path, dtype='float', skiprows=1,  
    588588                                        ndmin=1, unpack=True) 
    589                 raise 
    590589                pos_x = numpy.array(input_f[0]) 
    591590                pos_y = numpy.array(input_f[1]) 
  • sanscalculator/test/utest_sans_gen.py

    rd7b6913 r3540156  
    77import unittest 
    88from sans.calculator import sans_gen 
     9from sans.models.SphereModel import SphereModel 
     10 
     11import numpy 
    912  
    1013import os.path 
     
    1316     
    1417    def setUp(self): 
    15         self.model = sans_gen.GenSAS() 
    1618        self.sldloader = sans_gen.SLDReader() 
    1719        self.pdbloader = sans_gen.PDBReader() 
    18         self.omfloader = sans_gen.OMFReader() 
     20        self.omfloader = sans_gen.OMFReader()  
     21        self.comp = SphereModel() 
    1922         
    2023    def test_sldreader(self): 
     
    4144        """ 
    4245        f = self.omfloader.read("A_Raw_Example-1.omf") 
     46        output = sans_gen.OMF2SLD() 
     47        output.set_data(f) 
    4348        self.assertEqual(f.mx[0], 0) 
    4449        self.assertEqual(f.my[0], 0) 
    4550        self.assertEqual(f.mz[0], 0) 
    46          
     51        self.assertEqual(output.pos_x[0], -390.0) 
     52        self.assertEqual(output.pos_y[0], -390.0) 
     53        self.assertEqual(output.pos_z[0], -90.0) 
     54 
     55"""       
     56    def test_slda_and_run(self): # Works when sld reader uses loadtxt 
     57        sld_data = self.sldloader.read("sphere697_r30.sld") 
     58        # Generic computation   
     59        model = sans_gen.GenSAS() 
     60        model.setParam('background', 0.0) 
     61        model.setParam('scale', 1.0) 
     62        model.setParam('Up_frac_in', 0.5) 
     63        model.setParam('Up_frac_out', 0.5) 
     64        model.setParam('Up_theta', 0.0) 
     65        x = numpy.array([0.01]) 
     66        y = numpy.array([0.01]) 
     67        model.set_sld_data(sld_data) 
     68        out_gen = model.runXY([x, y]) 
     69        # Analytic computation 
     70        analy_model = self.comp 
     71        analy_model.setParam('background', 0.0) 
     72        analy_model.setParam('scale', 1.0) 
     73        analy_model.setParam('radius', 30.0) 
     74        analy_model.setParam('sldSolv', 0.0) 
     75        analy_model.setParam('sldSph', 6.97e-06)  
     76        out_analy = analy_model.runXY([0.01, 0.01]) 
     77        # Comparison 
     78        self.assertAlmostEqual(out_gen[0], out_analy, 1) 
     79"""    
    4780if __name__ == '__main__': 
    4881    unittest.main() 
Note: See TracChangeset for help on using the changeset viewer.