From 4b59a78e47a3cb869a93236b6e8ebda1bd05291c Mon Sep 17 00:00:00 2001 From: Gennady Pospelov <g.pospelov@fz-juelich.de> Date: Wed, 10 Dec 2014 17:22:43 +0100 Subject: [PATCH] Fixes in check_example script, bug fix in detector resolution function example. --- .../AllFormFactorsAvailable.py | 8 +++----- .../DetectorResolutionFunction.py | 2 +- dev-tools/check-examples/check_examples.py | 20 ++++++++++++++++++- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/Examples/python/simulation/ex01_BasicParticles/AllFormFactorsAvailable.py b/Examples/python/simulation/ex01_BasicParticles/AllFormFactorsAvailable.py index a3f22fd7c47..7b76c62fd63 100644 --- a/Examples/python/simulation/ex01_BasicParticles/AllFormFactorsAvailable.py +++ b/Examples/python/simulation/ex01_BasicParticles/AllFormFactorsAvailable.py @@ -1,5 +1,5 @@ """ -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)) diff --git a/Examples/python/simulation/ex05_BeamAndDetector/DetectorResolutionFunction.py b/Examples/python/simulation/ex05_BeamAndDetector/DetectorResolutionFunction.py index 945d76b3502..555b88e9a9a 100644 --- a/Examples/python/simulation/ex05_BeamAndDetector/DetectorResolutionFunction.py +++ b/Examples/python/simulation/ex05_BeamAndDetector/DetectorResolutionFunction.py @@ -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 diff --git a/dev-tools/check-examples/check_examples.py b/dev-tools/check-examples/check_examples.py index b6da730a27c..1d380a2286f 100644 --- a/dev-tools/check-examples/check_examples.py +++ b/dev-tools/check-examples/check_examples.py @@ -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() -- GitLab