source: sasmodels/load.py @ 8a20be5

core_shell_microgelscostrafo411magnetic_modelrelease_v0.94release_v0.95ticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 8a20be5 was 5378e40, checked in by Helen Park <HMP1@…>, 10 years ago

Initial commit

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