Skip to content
Snippets Groups Projects
Commit 4b59a78e authored by Pospelov, Gennady's avatar Pospelov, Gennady
Browse files

Fixes in check_example script, bug fix in detector resolution function example.

parent 5395ea19
No related branches found
No related tags found
No related merge requests found
"""
All formfactors available in BornAgain in DWBA
All formfactors available in BornAgain in Born Approximation
"""
import numpy
import matplotlib
......@@ -65,7 +65,7 @@ def get_simulation():
def run_simulation():
"""
Run simulation and plot results
Run simulation one by one for every formfactor from the list and plot results on single canvas
"""
dpi = 72.
......@@ -77,7 +77,7 @@ def run_simulation():
for ff in formfactors:
name = ff.__class__.__name__
name = name.replace("FormFactor", "")
print "Generating intensity map in BA for ", name
print "Generating intensity map in BA for '{0}'".format(name)
sample = get_sample(ff)
simulation = get_simulation()
......@@ -92,8 +92,6 @@ def run_simulation():
im = pylab.imshow(numpy.rot90(result, 1), norm=matplotlib.colors.LogNorm(),
extent=[phi_min, phi_max, alpha_min, alpha_max], aspect='auto')
# pylab.xlabel(r'$\phi_f$', fontsize=16)
# pylab.ylabel(r'$\alpha_f$', fontsize=16)
pylab.tick_params(axis='both', which='major', labelsize=8)
pylab.tick_params(axis='both', which='minor', labelsize=6)
pylab.xticks(numpy.arange(phi_min, phi_max+0.0001, 1.0))
......
......@@ -43,7 +43,7 @@ def get_simulation():
simulation = Simulation()
simulation.setDetectorParameters(100, phi_min*degree, phi_max*degree, 100, alpha_min*degree, alpha_max*degree)
simulation.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree)
simulation.setDetectorResolutionFunction(ResolutionFunction2DSimple(0.0025, 0.0025))
simulation.setDetectorResolutionFunction(ResolutionFunction2DGaussian(0.0025, 0.0025))
return simulation
......
......@@ -34,14 +34,31 @@ def FilesAreDifferent(file1, file2):
return False
def get_figure(filename):
"""
Returns pylab figure of appropriate size
"""
if "AllFormFactorsAvailable" in filename:
xsize = 1024
ysize = 768
else:
xsize = 640
ysize = 480
dpi = 72.
xinch = xsize / dpi
yinch = ysize / dpi
return pylab.figure(figsize=(xinch, yinch))
def generate_example_plot(dirname, filename):
"""
Tries to run python example and produce a *.png image
"""
print "Analysing {:40s}".format(filename),
fig = get_figure(filename)
try:
fig = pylab.figure()
d = dict(locals(), **globals())
execfile(os.path.join(dirname, filename), d, d)
plot_file_name = os.path.splitext(filename)[0] + ".png"
......@@ -126,6 +143,7 @@ if __name__ == '__main__':
if len(sys.argv) == 2:
examples_dir = sys.argv[1]
examples_dir = os.path.abspath(examples_dir)
print "Analysing examples in '{0}' directory.".format(examples_dir)
tempdir = create_directories()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment