Index: fit.py
===================================================================
--- fit.py	(revision 4001d6ef0c7f2735a7194f740e6ce959bca030e5)
+++ fit.py	(revision 87985ca5989a70a24a7e9ac09a971d544fe16dfe)
@@ -2,90 +2,80 @@
 # -*- coding: utf-8 -*-
 
+import sys
 from bumps.names import *
-from sasmodel import SasModel, load_data, set_beam_stop, set_half, set_top
-from Models.code_capcyl import GpuCapCylinder
-from Models.code_coreshellcyl_f import GpuCoreShellCylinder
-from Models.code_cylinder_f import GpuCylinder
-#from Models.code_cylinder import GpuCylinder, OneDGpuCylinder
-from Models.code_ellipse_f import GpuEllipse
-from Models.code_lamellar import GpuLamellar
-from Models.code_triaxialellipse import GpuTriEllipse
+from sasmodels import bumps_model as sas
 
 """ IMPORT THE DATA USED """
-#data = load_data('December/Tangential/Sector0/DEC07133.ABS')
-data = load_data('December/DEC07098.DAT')
+radial_data = sas.load_data('December/DEC07267.DAT')
+sas.set_beam_stop(radial_data, 0.00669, outer=0.025)
+sas.set_top(radial_data, -.0185)
 
-""" SET INNER BEAM STOP, OUTER RING, AND MASK HALF OF THE DATA """
-set_beam_stop(data, 0.004)#, outer=0.025)
-set_top(data, -.018)
-#set_half(data, 'right')
+tan_data = sas.load_data('December/DEC07266.DAT')
+sas.set_beam_stop(tan_data, 0.00669, outer=0.025)
+sas.set_top(tan_data, -.0185)
+#sas.set_half(tan_data, 'right')
 
+name = "ellipsoid" if len(sys.argv) < 2 else sys.argv[1]
+section = "radial" if len(sys.argv) < 3 else sys.argv[2]
+data = radial_data if section is not "tangent" else tan_data
+kernel = sas.load_model(name, dtype="single")
 
-if 0:
-    model = SasModel(data, OneDGpuCylinder,
-    scale=0.0013, radius=105, length=1000,
-    background=21, sldCyl=.291e-6,sldSolv=7.105e-6,
-    radius_pd=0.1,radius_pd_n=10,radius_pd_nsigma=0,
-    length_pd=0.1,length_pd_n=5,length_pd_nsigma=0,
-    bolim=0.0, uplim=90) #bottom limit, upper limit of angle integral
-
-
-if 0:
-    model = SasModel(data, GpuEllipse,
+if name == "ellipsoid":
+    model = sas.BumpsModel(data, kernel,
     scale=0.08,
-    radius_a=15, radius_b=800,
-    sldEll=.291e-6, sldSolv=7.105e-6,
+    rpolar=15, requatorial=800,
+    sld=.291, solvent_sld=7.105,
     background=0,
-    axis_theta=90, axis_phi=0,
-    axis_theta_pd=15, axis_theta_pd_n=40, axis_theta_pd_nsigma=3,
-    radius_a_pd=0.222296, radius_a_pd_n=1, radius_a_pd_nsigma=0,
-    radius_b_pd=.000128, radius_b_pd_n=1, radius_b_pd_nsigma=0,
-    axis_phi_pd=2.63698e-05, axis_phi_pd_n=20, axis_phi_pd_nsigma=3,
-    dtype='float32')
+    theta=90, phi=0,
+    theta_pd=15, theta_pd_n=40, theta_pd_nsigma=3,
+    rpolar_pd=0.222296, rpolar_pd_n=1, rpolar_pd_nsigma=0,
+    requatorial_pd=.000128, requatorial_pd_n=1, requatorial_pd_nsigma=0,
+    phi_pd=0, phi_pd_n=20, phi_pd_nsigma=3,
+    )
 
 
     # SET THE FITTING PARAMETERS
-    #model.radius_a.range(15, 1000)
-    #model.radius_b.range(15, 1000)
-    #model.axis_theta_pd.range(0, 360)
+    #model.rpolar.range(15, 1000)
+    #model.requatorial.range(15, 1000)
+    #model.theta_pd.range(0, 360)
     #model.background.range(0,1000)
     model.scale.range(0, 1)
 
 
-if 0:
-    model = SasModel(data, GpuLamellar,
+elif name == "lamellar":
+    model = sas.BumpsModel(data, kernel,
     scale=0.08,
-    bi_thick=19.2946,
-    sld_bi=5.38e-6,sld_sol=7.105e-6,
+    thickness=19.2946,
+    sld=5.38,sld_sol=7.105,
     background=0.003,
-    bi_thick_pd= 0.37765, bi_thick_pd_n=10, bi_thick_pd_nsigma=3,
-    dtype='float32')
+    thickness_pd= 0.37765, thickness_pd_n=10, thickness_pd_nsigma=3,
+    )
 
     # SET THE FITTING PARAMETERS
-    #model.bi_thick.range(0, 1000)
+    #model.thickness.range(0, 1000)
     #model.scale.range(0, 1)
-    #model.bi_thick_pd.range(0, 1000)
+    #model.thickness_pd.range(0, 1000)
     #model.background.range(0, 1000)
-    model.sld_bi.range(0, 1)
+    model.sld.range(0, 1)
 
 
-if 0:
+elif name == "cylinder":
     """
     pars = dict(scale=0.0023, radius=92.5, length=798.3,
-        sldCyl=.29e-6, sldSolv=7.105e-6, background=5,
-        cyl_theta=0, cyl_phi=0,
-        cyl_theta_pd=22.11, cyl_theta_pd_n=5, cyl_theta_pd_nsigma=3,
+        sld=.29, solvent_sld=7.105, background=5,
+        theta=0, phi=0,
+        theta_pd=22.11, theta_pd_n=5, theta_pd_nsigma=3,
         radius_pd=.0084, radius_pd_n=10, radius_pd_nsigma=3,
         length_pd=0.493, length_pd_n=10, length_pd_nsigma=3,
-        cyl_phi_pd=0, cyl_phi_pd_n=5, cyl_phi_pd_nsigma=3,)
+        phi_pd=0, phi_pd_n=5, phi_pd_nsigma=3,)
         """
     pars = dict(
-        scale=.01, radius=64.1, length=66.96, sldCyl=.291e-6, sldSolv=5.77e-6, background=.1,
-        cyl_theta=90, cyl_phi=0,
+        scale=.01, radius=64.1, length=66.96, sld=.291, solvent_sld=5.77, background=.1,
+        theta=90, phi=0,
         radius_pd=0.1, radius_pd_n=10, radius_pd_nsigma=3,
         length_pd=0.1,length_pd_n=5, length_pd_nsigma=3,
-        cyl_theta_pd=0.1, cyl_theta_pd_n=5, cyl_theta_pd_nsigma=3,
-        cyl_phi_pd=0.1, cyl_phi_pd_n=10, cyl_phi_pd_nsigma=3)
-    model = SasModel(data, GpuCylinder, dtype="float32", **pars)
+        theta_pd=0.1, theta_pd_n=5, theta_pd_nsigma=3,
+        phi_pd=0.1, phi_pd_n=10, phi_pd_nsigma=3)
+    model = sas.BumpsModel(data, kernel, **pars)
 
 
@@ -94,26 +84,26 @@
     model.radius.range(1, 500)
     model.length.range(1, 5000)
-    #model.cyl_theta.range(-90,100)
-    #model.cyl_theta_pd.range(0, 90)
-    #model.cyl_theta_pd_n = model.cyl_theta_pd + 5
+    #model.theta.range(-90,100)
+    #model.theta_pd.range(0, 90)
+    #model.theta_pd_n = model.theta_pd + 5
     #model.radius_pd.range(0, 90)
     #model.length_pd.range(0, 90)
     model.scale.range(0, 1)
     #model.background.range(0, 100)
-    #model.sldCyl.range(0, 1)
+    #model.sld.range(0, 1)
 
 
-if 1:
-    model = SasModel(data, GpuCoreShellCylinder,
+elif name == "core_shell_cylinder":
+    model = sas.BumpsModel(data, kernel,
     scale= .031, radius=19.5, thickness=30, length=22,
-    core_sld=7.105e-6, shell_sld=.291e-6, solvent_sld=7.105e-6,
-    background=0, axis_theta=0, axis_phi=0,
+    core_sld=7.105, shell_sld=.291, solvent_sld=7.105,
+    background=0, theta=0, phi=0,
 
     radius_pd=0.26, radius_pd_n=10, radius_pd_nsigma=3,
     length_pd=0.26, length_pd_n=10, length_pd_nsigma=3,
     thickness_pd=1, thickness_pd_n=1, thickness_pd_nsigma=1,
-    axis_theta_pd=1, axis_theta_pd_n=10, axis_theta_pd_nsigma=3,
-    axis_phi_pd=0.1, axis_phi_pd_n=1, axis_phi_pd_nsigma=1,
-    dtype='float32')
+    theta_pd=1, theta_pd_n=10, theta_pd_nsigma=3,
+    phi_pd=0.1, phi_pd_n=1, phi_pd_nsigma=1,
+    )
 
     # SET THE FITTING PARAMETERS
@@ -122,8 +112,8 @@
     #model.thickness.range(18, 38)
     #model.thickness_pd.range(0, 1)
-    #model.axis_phi.range(0, 90)
+    #model.phi.range(0, 90)
     #model.radius_pd.range(0, 1)
     #model.length_pd.range(0, 1)
-    #model.axis_theta_pd.range(0, 360)
+    #model.theta_pd.range(0, 360)
     #model.background.range(0,5)
     model.scale.range(0, 1)
@@ -131,35 +121,35 @@
 
 
-if 0:
-    model = SasModel(data, GpuCapCylinder,
-    scale=.08, rad_cyl=20, rad_cap=40, len_cyl=400,
-    sld_capcyl=1e-6, sld_solv=6.3e-6,
+elif name == "capped_cylinder":
+    model = sas.BumpsModel(data, kernel,
+    scale=.08, radius=20, cap_radius=40, length=400,
+    sld_capcyl=1, sld_solv=6.3,
     background=0, theta=0, phi=0,
-    rad_cyl_pd=.1, rad_cyl_pd_n=5, rad_cyl_pd_nsigma=3,
-    rad_cap_pd=.1, rad_cap_pd_n=5, rad_cap_pd_nsigma=3,
-    len_cyl_pd=.1, len_cyl_pd_n=1, len_cyl_pd_nsigma=0,
+    radius_pd=.1, radius_pd_n=5, radius_pd_nsigma=3,
+    cap_radius_pd=.1, cap_radius_pd_n=5, cap_radius_pd_nsigma=3,
+    length_pd=.1, length_pd_n=1, length_pd_nsigma=0,
     theta_pd=.1, theta_pd_n=1, theta_pd_nsigma=0,
     phi_pd=.1, phi_pd_n=1, phi_pd_nsigma=0,
-    dtype='float32')
+    dtype=dtype)
 
     model.scale.range(0, 1)
 
 
-if 0:
-    model = SasModel(data, GpuTriEllipse,
-    scale=0.08, axisA=15, axisB=20, axisC=500,
-    sldEll=7.105e-6, sldSolv=.291e-6,
+elif name == "triaxial_ellipsoid":
+    model = sas.BumpsModel(data, kernel,
+    scale=0.08, req_minor=15, req_major=20, rpolar=500,
+    sldEll=7.105, solvent_sld=.291,
     background=5, theta=0, phi=0, psi=0,
     theta_pd=20, theta_pd_n=40, theta_pd_nsigma=3,
     phi_pd=.1, phi_pd_n=1, phi_pd_nsigma=0,
     psi_pd=30, psi_pd_n=1, psi_pd_nsigma=0,
-    axisA_pd=.1, axisA_pd_n=1, axisA_pd_nsigma=0,
-    axisB_pd=.1, axisB_pd_n=1, axisB_pd_nsigma=0,
-    axisC_pd=.1, axisC_pd_n=1, axisC_pd_nsigma=0, dtype='float32')
+    req_minor_pd=.1, req_minor_pd_n=1, req_minor_pd_nsigma=0,
+    req_major_pd=.1, req_major_pd_n=1, req_major_pd_nsigma=0,
+    rpolar_pd=.1, rpolar_pd_n=1, rpolar_pd_nsigma=0, dtype=dtype)
 
     # SET THE FITTING PARAMETERS
-    model.axisA.range(15, 1000)
-    model.axisB.range(15, 1000)
-    #model.axisC.range(15, 1000)
+    model.req_minor.range(15, 1000)
+    model.req_major.range(15, 1000)
+    #model.rpolar.range(15, 1000)
     #model.background.range(0,1000)
     #model.theta_pd.range(0, 360)
@@ -167,7 +157,13 @@
     #model.psi_pd.range(0, 360)
 
+else:
+    print "No parameters for %s"%name
+    sys.exit(1)
 
+if section is "both":
+   tan_model = sas.BumpsModel(tan_data, model.model, model.parameters())
+   tan_model.phi = model.phi - 90
+   problem = FitProblem([model, tan_model])
+else:
+   problem = FitProblem(model)
 
-
-problem = FitProblem(model)
-
