def __call__(self, npts = 101): """ Perform test and produce output file @param npts: number of points to average over @return: True if the test passed, otherwise False """ passed = True model = EllipticalCylinderModel() theta_label = 'cyl_theta' if not model.params.has_key(theta_label): theta_label = 'axis_theta' phi_label = 'cyl_phi' if not model.params.has_key(phi_label): phi_label = 'axis_phi' output_f = open("average_func.txt",'w') output_f.write("<q_average> <2d_average> <1d_average>\n") for i_q in range(1, 15): q = 0.3/15.0*i_q value = self.average_point_3D(model, q, npts) ana = model.run(q) if q<0.3 and (value-ana)/ana>0.05: passed = False output_f.write("%10g %10g %10g\n" % (q, value, ana)) if self.verbose: print "Q=%g: %10g %10g %10g %10g" % (q, value, ana, value-ana, value/ana) output_f.close() return passed
def setUp(self): from sas.models.EllipticalCylinderModel import EllipticalCylinderModel self.model= EllipticalCylinderModel() self.model.setParam('scale', 1.0) self.model.setParam('r_minor', 20.0) self.model.setParam('r_ratio', 1.5) self.model.setParam('length', 400.0) self.model.setParam('sldCyl', 4.0e-6) self.model.setParam('sldSolv', 1.0e-6) self.model.setParam('background', 0.0) self.model.setParam('cyl_theta', 90) self.model.setParam('cyl_phi', 0.0) self.model.setParam('cyl_psi', 0.0)
def checkCylinder(self, points): """ Compare the average over all orientations of the main cylinder axis for a cylinder and the elliptical cylinder with r_ratio = 1 @param points: number of points to average over @return: True if the test passed, otherwise False """ from sas.models.CylinderModel import CylinderModel passed = True npts =points model = EllipticalCylinderModel() model.setParam('r_ratio', 1.0) model.setParam("r_minor", 20) model.setParam("cyl_theta", 90) model.setParam("cyl_phi", 0.0) model.setParam("length", 400) model.setParam("sldEll", 2.0e-6) model.setParam("sldSolv", 1.0e-6) cyl = CylinderModel() cyl.setParam("cyl_theta", 90) cyl.setParam("cyl_phi", 0.0) cyl.setParam("radius", 20) cyl.setParam("length", 400) cyl.setParam("sldCyl", 2.0e-6) cyl.setParam("sldSolv", 1.0e-6) output_f = open("average_func.txt",'w') output_f.write("<q_average> <2d_average> <1d_average>\n") for i_q in range(1, 15): q = 0.3/15.0*i_q value = self.average_point_2D(model, q, npts) ana = cyl.run(q) if q<0.3 and math.fabs(value-ana)/ana>0.05: passed = False output_f.write("%10g %10g %10g\n" % (q, value, ana)) if self.verbose: print "Q=%g: %10g %10g %10g %10g" % (q, value, ana, value-ana, value/ana) output_f.close() return passed
def checkCylinder2D(self, phi): """ Check that the 2D scattering intensity reduces to a cylinder when r_ratio = 1.0 @param phi: angle of the vector q on the detector @return: True if the test passed, otherwise False """ from sas.models.CylinderModel import CylinderModel cyl = CylinderModel() cyl.setParam("cyl_theta", 90) cyl.setParam("cyl_phi", 0.0) cyl.setParam("radius", 20) cyl.setParam("length", 400) cyl.setParam("sldCyl", 2.0e-6) cyl.setParam("sldSolv", 1.0e-6) ell = EllipticalCylinderModel() ell.setParam("r_ratio", 1.0) ell.setParam("r_minor", 20) ell.setParam("cyl_theta", 90) ell.setParam("cyl_phi", 0.0) ell.setParam("length", 400) ell.setParam("sldCyl", 2.0e-6) ell.setParam("sldSolv", 1.0e-6) passed = True for i_q in range(1, 30): q = 0.025 * i_q ell_val = ell.run([q, phi]) cyl_val = cyl.run([q, phi]) if self.verbose: print "Q=%g Ell=%g Cyl=%g R=%g" % (q, ell_val, cyl_val, ell_val / cyl_val) if math.fabs(ell_val - cyl_val) / cyl_val > 0.05: passed = False return passed
def setUp(self): from sas.models.EllipticalCylinderModel import EllipticalCylinderModel from sas.models.DiamCylFunc import DiamCylFunc self.comp = EllipticalCylinderModel() self.diam = DiamCylFunc()