Changeset 8a5f021 in sasmodels for example/model_ellipsoid_hayter_msa.py


Ignore:
Timestamp:
May 31, 2017 12:02:34 PM (7 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
8bc1a4b
Parents:
1f7792e
Message:

batch fit example: PEP8 cleanup; add .csv output; all pars on one plot; more flexible option handling

File:
1 edited

Legend:

Unmodified
Added
Removed
  • example/model_ellipsoid_hayter_msa.py

    r1f7792e r8a5f021  
    1 #!/usr/bin/env python 
    2 # -*- coding: utf-8 -*- 
    3  
    4 # To Sasview/documents/scripts 
    5  
    61import sys 
    72#sys.path.append('path_to_sasmodels') 
     3 
     4import numpy as np 
    85 
    96from bumps.names import * 
     
    118from sasmodels.bumps_model import Model, Experiment 
    129from sasmodels.data import load_data, plot_data 
    13 import numpy as np 
    14 import matplotlib.pyplot as plt 
    1510 
    16  
    17 """ IMPORT THE DATA USED """ 
    18 data = load_data('data.txt') 
     11# IMPORT THE DATA USED 
     12data = load_data(sys.argv[1]) 
    1913 
    2014#setattr(data, 'qmin', 0.0) 
    2115#setattr(data, 'qmax', 10.0) 
    2216 
    23 """ DEFINE THE MODEL """ 
    24 kernel = load_model('ellipsoid*hayter_msa', dtype="double") 
     17# DEFINE THE MODEL 
     18kernel = load_model('ellipsoid*hayter_msa') 
    2519 
    26 pars = dict(scale=6.4, background=0.06, sld=0.33, sld_solvent=2.15, radius_polar=14.0,  
    27             radius_equatorial=24.0, volfraction=0.075, charge=66.373, temperature=298.0,  
     20pars = dict(scale=6.4, background=0.06, sld=0.33, sld_solvent=2.15, radius_polar=14.0, 
     21            radius_equatorial=24.0, volfraction=0.075, charge=66.373, temperature=298.0, 
    2822            concentration_salt=0.001, dielectconst=71.0) 
    29              
     23 
    3024model = Model(kernel, **pars) 
    3125 
    32 """ PARAMETER RANGES (ONLY THOSE PARAMETERS ARE FITTED) """ 
     26# PARAMETER RANGES (ONLY THOSE PARAMETERS ARE FITTED) 
    3327model.scale.range(0, inf) 
    3428model.background.range(-inf, inf) 
     
    4337#model.dielectconst.range(0,inf) 
    4438 
    45  
    4639M = Experiment(data=data, model=model) 
    4740 
    4841problem = FitProblem(M) 
    49  
Note: See TracChangeset for help on using the changeset viewer.