source: sasmodels/Testers/load.py @ 1726b21

core_shell_microgelscostrafo411magnetic_modelrelease_v0.94release_v0.95ticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 1726b21 was 473183c, checked in by HMP1 <helen.park@…>, 10 years ago

organizing

  • Property mode set to 100644
File size: 1.8 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3
4from sans.dataloader.loader import Loader
5from sans.dataloader.manipulations import Ringcut
6from Kernel import fit
7
8
9def cylinder(data): ##################################################################################
10    from sans.models.CylinderModel import CylinderModel
11    model1 = CylinderModel()
12    model1.setParam("scale", 10.0)
13    model1.setParam("radius",18)
14    model1.setParam("length", 397)
15    model1.setParam("sldCyl",3e-006 )
16    model1.setParam("sldSolv",0.0 )
17    model1.setParam("background", 0.0)
18
19    # Dispersion parameters
20    model1.dispersion['radius']['width'] = 0.25
21    model1.dispersion['radius']['npts'] = 50
22
23    theory = model1.evalDistribution([data.qx_data, data.qy_data])
24    return theory
25
26def load_data(filename):
27    loader = Loader()
28    f = loader.load(filename)
29    return f
30
31def set_beam_stop(data, radius):
32    data.mask = Ringcut(0, radius)(data)
33
34def plot_data(data):
35    from numpy.ma import masked_array
36    import matplotlib.pyplot as plt
37    img = masked_array(data.data, data.mask)
38    xmin, xmax = min(data.qx_data), max(data.qx_data)
39    ymin, ymax = min(data.qy_data), max(data.qy_data)
40    plt.imshow(img.reshape(128,128),
41               interpolation='nearest', aspect=1, origin='upper',
42               extent=[xmin, xmax, ymin, ymax])
43
44def demo():
45
46    data = load_data('NOV07090.DAT')
47    """
48    print data
49    print type(data)
50    set_beam_stop(data, 0.004)
51    plot_data(data)
52    import matplotlib.pyplot as plt; plt.show()
53    """
54    import matplotlib.pyplot as plt
55    import numpy as np
56    sasviewcyl = cylinder(data)
57    gpucyl = fit.Fit(data)
58    diff = gpucyl - sasviewcyl
59    np.linalg.norm(diff, order=None)
60    np.linalg.norm(diff, order=np.inf)
61
62    plot_data(data, diff)
63    plt.show()
64
65
66
67
68if __name__ == "__main__":
69    demo()
70
Note: See TracBrowser for help on using the repository browser.