[ae3ce4e] | 1 | try: |
---|
| 2 | from sans.models.prototypes.TestSphere2 import TestSphere2 |
---|
| 3 | from sans.models.prototypes.SimCylinderF import SimCylinderF |
---|
| 4 | from sans.models.prototypes.SimCylinder import SimCylinder |
---|
| 5 | except: |
---|
| 6 | print "This test uses the prototypes module." |
---|
| 7 | from sans.models.SphereModel import SphereModel |
---|
| 8 | from sans.models.CylinderModel import CylinderModel |
---|
| 9 | import math, time |
---|
| 10 | |
---|
| 11 | |
---|
| 12 | def test_lores(): |
---|
| 13 | |
---|
| 14 | lores = open('lores.iq', 'r') |
---|
| 15 | f = open('lores_check.txt', 'w') |
---|
| 16 | content = lores.read() |
---|
| 17 | lines = content.split('\n') |
---|
| 18 | inum = 0 |
---|
| 19 | norma = 0. |
---|
| 20 | for line in lines: |
---|
| 21 | toks = line.split() |
---|
| 22 | if len(toks)==2: |
---|
| 23 | inum += 1 |
---|
| 24 | q = float(toks[0]) |
---|
| 25 | ana = sph.run(q) |
---|
| 26 | if inum==1: |
---|
| 27 | continue |
---|
| 28 | elif inum==2: |
---|
| 29 | norma = ana/float(toks[1]) |
---|
| 30 | lor = float(toks[1])*norma |
---|
| 31 | f.write("%g %g %g\n" % (q, ana, lor)) |
---|
| 32 | f.close() |
---|
| 33 | |
---|
| 34 | |
---|
| 35 | #sim = TestSphere2() |
---|
| 36 | #sph = SphereModel() |
---|
| 37 | sim = SimCylinderF() |
---|
| 38 | sph = CylinderModel() |
---|
| 39 | |
---|
| 40 | sim.setParam('radius', 20) |
---|
| 41 | sim.setParam('length', 200) |
---|
| 42 | sim.setParam('phi', 1) |
---|
| 43 | sim.setParam('theta', 1) |
---|
| 44 | sim.setParam('npoints',2500) |
---|
| 45 | #print sph.params |
---|
| 46 | |
---|
| 47 | sph.setParam('radius', 20) |
---|
| 48 | sph.setParam('scale', 1) |
---|
| 49 | sph.setParam('contrast',1) |
---|
| 50 | sph.setParam('length', 200) |
---|
| 51 | sph.setParam('cyl_phi', 1) |
---|
| 52 | sph.setParam('cyl_theta', 1) |
---|
| 53 | |
---|
| 54 | #print "ANA", sph.run(0.1) |
---|
| 55 | #print "SIM", sim.run(0.1) |
---|
| 56 | |
---|
| 57 | f = open('sim_iq.txt', 'w') |
---|
| 58 | f.write("<q> <ana> <sim>\n") |
---|
| 59 | |
---|
| 60 | t_0 = time.time() |
---|
| 61 | |
---|
| 62 | for i in range(60): |
---|
| 63 | q = 0.01 * (i+1) /3.0 |
---|
| 64 | #ana_value = sph.run([q,0]) |
---|
| 65 | #sim_value = sim.run([q,0]) |
---|
| 66 | ana_value = sph.run(q) |
---|
| 67 | sim_value = sim.run(q) |
---|
| 68 | ratio = 0 |
---|
| 69 | if sim_value>0: |
---|
| 70 | ratio = sim_value/ana_value |
---|
| 71 | print q, ana_value, sim_value, ratio |
---|
| 72 | f.write("%10g %10g %10g\n" % (q, ana_value, sim_value)) |
---|
| 73 | |
---|
| 74 | t_f = time.time() |
---|
| 75 | print "Time = ", t_f-t_0 |
---|
| 76 | f.close() |
---|
| 77 | |
---|