Changeset 3540156 in sasview for sanscalculator
- Timestamp:
- Jan 11, 2013 6:06:11 PM (12 years ago)
- 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
- Location:
- sanscalculator
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sanscalculator/src/sans/calculator/sans_gen.py
rbe0fe41 r3540156 587 587 input_f = numpy.loadtxt(path, dtype='float', skiprows=1, 588 588 ndmin=1, unpack=True) 589 raise590 589 pos_x = numpy.array(input_f[0]) 591 590 pos_y = numpy.array(input_f[1]) -
sanscalculator/test/utest_sans_gen.py
rd7b6913 r3540156 7 7 import unittest 8 8 from sans.calculator import sans_gen 9 from sans.models.SphereModel import SphereModel 10 11 import numpy 9 12 10 13 import os.path … … 13 16 14 17 def setUp(self): 15 self.model = sans_gen.GenSAS()16 18 self.sldloader = sans_gen.SLDReader() 17 19 self.pdbloader = sans_gen.PDBReader() 18 self.omfloader = sans_gen.OMFReader() 20 self.omfloader = sans_gen.OMFReader() 21 self.comp = SphereModel() 19 22 20 23 def test_sldreader(self): … … 41 44 """ 42 45 f = self.omfloader.read("A_Raw_Example-1.omf") 46 output = sans_gen.OMF2SLD() 47 output.set_data(f) 43 48 self.assertEqual(f.mx[0], 0) 44 49 self.assertEqual(f.my[0], 0) 45 50 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 """ 47 80 if __name__ == '__main__': 48 81 unittest.main()
Note: See TracChangeset
for help on using the changeset viewer.