当前位置: 首页>>代码示例>>Python>>正文


Python SphereModel.runXY方法代码示例

本文整理汇总了Python中sas.models.SphereModel.SphereModel.runXY方法的典型用法代码示例。如果您正苦于以下问题:Python SphereModel.runXY方法的具体用法?Python SphereModel.runXY怎么用?Python SphereModel.runXY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sas.models.SphereModel.SphereModel的用法示例。


在下文中一共展示了SphereModel.runXY方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestSphere

# 需要导入模块: from sas.models.SphereModel import SphereModel [as 别名]
# 或者: from sas.models.SphereModel.SphereModel import runXY [as 别名]
class TestSphere(unittest.TestCase):
    """
        Testing C++ Cylinder model
    """
    def setUp(self):
        from sas.models.SphereModel import SphereModel
        self.model= SphereModel()
        
        self.model.setParam('scale', 1.0)
        self.model.setParam('radius', 60.0)
        self.model.setParam('sldSph', 2.0)
        self.model.setParam('sldSolv', 1.0)
        self.model.setParam('background', 0.0)
        
    def test_simple(self):
        """
            Test simple 1D and 2D values
            Numbers taken from model that passed validation, before
            the update to C++ underlying class.
        """
        self.assertTrue(math.fabs(self.model.run(0.001)-90412744456148.094)<=50.0)
        self.assertAlmostEqual(self.model.runXY([0.001,0.001]), 
                               90347660670656.391, 1)

    def test_dispersion(self):
        """
            Test with dispersion
        """
        from sas.models.DisperseModel import DisperseModel
        disp = DisperseModel(self.model, ['radius'], [10])
        disp.setParam('n_pts', 10)
        disp.setParam('radius.npts', 10)
        disp.setParam('radius.nsigmas', 2.5)
        self.assertTrue(math.fabs(disp.run(0.001)-96795008379475.219<50.0))
        
    def test_new_disp(self):
        from sas.models.dispersion_models import GaussianDispersion
        disp_rm = GaussianDispersion()
        self.model.set_dispersion('radius', disp_rm)
        self.model.dispersion['radius']['width'] = 0.1666666667
        self.model.dispersion['radius']['npts'] = 10
        self.model.dispersion['radius']['nsigmas'] = 2
开发者ID:ricleal,项目名称:SasModeling,代码行数:44,代码来源:utest_dispersity.py

示例2: test_5

# 需要导入模块: from sas.models.SphereModel import SphereModel [as 别名]
# 或者: from sas.models.SphereModel.SphereModel import runXY [as 别名]
def test_5():
    from sas.models.SphereModel import SphereModel
    model = VolumeCanvas.VolumeCanvas()
    
    handle = model.add('sphere')
    
    radius = 10
    density = .1
    
    ana = SphereModel()
    ana.setParam('scale', 1.0)
    ana.setParam('contrast', 1.0)
    ana.setParam('background', 0.0)
    ana.setParam('radius', radius)
    
    model.setParam('lores_density', density)
    model.setParam('%s.radius' % handle, radius)
    model.setParam('scale' , 1.0)
    model.setParam('%s.contrast' % handle, 1.0)
    model.setParam('background' , 0.0)
    
    ana = ana.runXY([0.1, 0.1])
    sim = model.getIq2D(0.1, 0.1)
    print ana, sim, sim/ana, ana/sim
开发者ID:diffpy,项目名称:srfit-sasview,代码行数:26,代码来源:early_test.py

示例3: TestEvalMethods

# 需要导入模块: from sas.models.SphereModel import SphereModel [as 别名]
# 或者: from sas.models.SphereModel.SphereModel import runXY [as 别名]
class TestEvalMethods(unittest.TestCase):
    """ Testing evalDistribution for C models """

    def setUp(self):
        self.model= SphereModel()
        
    def test_scalar_methods(self):
        """
            Simple test comparing the run(), runXY() and
            evalDistribution methods
        """
        q1 = self.model.run(0.001)
        q2 = self.model.runXY(0.001)
        q4 = self.model.run(0.002)
        qlist3 = numpy.asarray([0.001, 0.002])
        q3 = self.model.evalDistribution(qlist3)

        self.assertEqual(q1, q2)
        self.assertEqual(q1, q3[0])
        self.assertEqual(q4, q3[1])
        
    def test_XY_methods(self):
        """
            Compare to the runXY() method for 2D models.
            
                      +--------+--------+--------+
            qy=0.009  |        |        |        | 
                      +--------+--------+--------+
            qy-0.006  |        |        |        |
                      +--------+--------+--------+            
            qy=0.003  |        |        |        | 
                      +--------+--------+--------+
                      qx=0.001   0.002   0.003
            
        """
        # These are the expected values for all bins
        expected = numpy.zeros([3,3])
        for i in range(3):
            for j in range(3):
                q_length = math.sqrt( (0.001*(i+1.0))*(0.001*(i+1.0)) + (0.003*(j+1.0))*(0.003*(j+1.0)) )
                expected[i][j] = self.model.run(q_length)
        
        qx_values = [0.001, 0.002, 0.003]
        qy_values = [0.003, 0.006, 0.009]
        
        qx = numpy.asarray(qx_values)
        qy = numpy.asarray(qy_values)
              
        new_x = numpy.tile(qx, (len(qy),1))
        new_y = numpy.tile(qy, (len(qx),1))
        new_y = new_y.swapaxes(0,1)
    
        #iq is 1d array now (since 03-12-2010)
        qx_prime = new_x.flatten()
        qy_prime = new_y.flatten()
        
        iq = self.model.evalDistribution([qx_prime, qy_prime])
        
        for i in range(3):
            for j in range(3):
                # convert index into 1d array
                k = i+len(qx)*j
                self.assertAlmostEquals(iq[k], expected[i][j])
开发者ID:diffpy,项目名称:srfit-sasview,代码行数:65,代码来源:utest_evaldist.py

示例4: SphereModel

# 需要导入模块: from sas.models.SphereModel import SphereModel [as 别名]
# 或者: from sas.models.SphereModel.SphereModel import runXY [as 别名]
comp = SphereModel()
comp.setParam("radius", 30.0)
comp.setParam("background", 0.01)

# Generate Q and calculate I
q = np.linspace(0.001, 1, num=200)
i = map(comp.run,q)

# Plot I(q)
plt.figure()
plt.plot(q,np.log(i))


qx = np.linspace(-1, 1, num=400)
qy = qx
xv, yv = np.meshgrid(qx, qy)
xv= xv.flatten()
yv= yv.flatten()
qxy = np.column_stack((xv,yv))

ixy = [ comp.runXY(list(i)) for i in qxy]
ixy = np.array(ixy)


ixy = ixy.reshape(400,400)
ixy = np.log(ixy)

plt.figure()
plt.imshow(ixy)
plt.show()
开发者ID:ricleal,项目名称:SasModeling,代码行数:32,代码来源:plot1.py


注:本文中的sas.models.SphereModel.SphereModel.runXY方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。