diff --git a/rawEx/bayesian/likelihood_sampling.py b/rawEx/bayesian/likelihood_sampling.py index be2f4332cfe7ecf3f6dd552706f20c3a571be465..cb82203951ee6279ba9f3c68690b181abd5516d0 100755 --- a/rawEx/bayesian/likelihood_sampling.py +++ b/rawEx/bayesian/likelihood_sampling.py @@ -101,7 +101,10 @@ if __name__ == '__main__': flat_samples = sampler.get_chain(flat=True) corner.corner(flat_samples, labels=['Ni-thickness/nm', 'Ti-thickness/nm']) - <%= sm ? "# " : "" %>plt.show() + <%- if sm -%> + <%- else -%> + plt.show() + <%- end -%> # Plot and show MLE and data of reflectivity plt.errorbar(q, y, dy, marker='.', ls='') @@ -112,4 +115,8 @@ if __name__ == '__main__': plt.xlabel('$\\alpha$/rad') plt.ylabel('$R$') plt.yscale('log') - <%= sm ? "plt.close() # " : "" %>plt.show() + <%- if sm -%> + plt.close() + <%- else -%> + plt.show() + <%- end -%> diff --git a/rawEx/ff/BarLorentz.py b/rawEx/ff/BarLorentz.py index d42b25a57101bab23371839cd83c2a41d592b06d..9e9d32df1d44ac00d552f7cc9317b8497d1b1caa 100755 --- a/rawEx/ff/BarLorentz.py +++ b/rawEx/ff/BarLorentz.py @@ -27,6 +27,11 @@ if __name__ == '__main__': result.setTitle(title) results.append(result) + <%- if sm -%> plotargs = bp.parse_commandline() bp.make_plot_row(results, **plotargs) - bp.show_or_export(**plotargs) \ No newline at end of file + bp.export(**plotargs) + <%- else -%> + bp.make_plot_row(results) + plt.show() + <%- end -%> diff --git a/rawEx/ff/Bipyramid4.py b/rawEx/ff/Bipyramid4.py index e9c4233a16b90e52b0426f6a492c252351437257..9f6330f88c7a0c2ebc1f4ca4c3f04d554c7131e2 100755 --- a/rawEx/ff/Bipyramid4.py +++ b/rawEx/ff/Bipyramid4.py @@ -27,6 +27,11 @@ if __name__ == '__main__': result.setTitle(title) results.append(result) + <%- if sm -%> plotargs = bp.parse_commandline() bp.make_plot_row(results, **plotargs) - bp.show_or_export(**plotargs) \ No newline at end of file + bp.export(**plotargs) + <%- else -%> + bp.make_plot_row(results) + plt.show() + <%- end -%> diff --git a/rawEx/ff/Box.py b/rawEx/ff/Box.py index 58bf914942e40e2b527ed6830fc11bc8fe160378..0f6c80fc5b56ab25978d17934152085bc0355e4c 100755 --- a/rawEx/ff/Box.py +++ b/rawEx/ff/Box.py @@ -27,6 +27,11 @@ if __name__ == '__main__': result.setTitle(title) results.append(result) + <%- if sm -%> plotargs = bp.parse_commandline() bp.make_plot_row(results, **plotargs) - bp.show_or_export(**plotargs) \ No newline at end of file + bp.export(**plotargs) + <%- else -%> + bp.make_plot_row(results) + plt.show() + <%- end -%> diff --git a/rawEx/ff/CantellatedCube.py b/rawEx/ff/CantellatedCube.py index eacf06da7dd0d00debdeed14987f897cd1eeeff0..b3220a6417481198246c89bdbeeb48266bf2373e 100755 --- a/rawEx/ff/CantellatedCube.py +++ b/rawEx/ff/CantellatedCube.py @@ -27,6 +27,11 @@ if __name__ == '__main__': result.setTitle(title) results.append(result) + <%- if sm -%> plotargs = bp.parse_commandline() bp.make_plot_row(results, **plotargs) - bp.show_or_export(**plotargs) \ No newline at end of file + bp.export(**plotargs) + <%- else -%> + bp.make_plot_row(results) + plt.show() + <%- end -%> diff --git a/rawEx/ff/Cone.py b/rawEx/ff/Cone.py index 9260bc65674855c12bc2bd910ed2636e421e94f7..0ded925d523035a6c9b6eb3c694ce86979f76729 100755 --- a/rawEx/ff/Cone.py +++ b/rawEx/ff/Cone.py @@ -27,6 +27,11 @@ if __name__ == '__main__': result.setTitle(title) results.append(result) + <%- if sm -%> plotargs = bp.parse_commandline() bp.make_plot_row(results, **plotargs) - bp.show_or_export(**plotargs) \ No newline at end of file + bp.export(**plotargs) + <%- else -%> + bp.make_plot_row(results) + plt.show() + <%- end -%> diff --git a/rawEx/ff/CosineRippleBox.py b/rawEx/ff/CosineRippleBox.py index 2b0bc82595b32cd986770c62fc7b219e0a0c1a76..e960bce94109706b225136bf7132a29082e457e0 100755 --- a/rawEx/ff/CosineRippleBox.py +++ b/rawEx/ff/CosineRippleBox.py @@ -27,6 +27,11 @@ if __name__ == '__main__': result.setTitle(title) results.append(result) + <%- if sm -%> plotargs = bp.parse_commandline() bp.make_plot_row(results, **plotargs) - bp.show_or_export(**plotargs) \ No newline at end of file + bp.export(**plotargs) + <%- else -%> + bp.make_plot_row(results) + plt.show() + <%- end -%> diff --git a/rawEx/ff/Cylinder.py b/rawEx/ff/Cylinder.py index 409b2f6a4f39fcf0d100c5461a1f1aed7784d151..5da91794d7914c1f67edbe46b8215d6c0881627d 100755 --- a/rawEx/ff/Cylinder.py +++ b/rawEx/ff/Cylinder.py @@ -27,6 +27,11 @@ if __name__ == '__main__': result.setTitle(title) results.append(result) + <%- if sm -%> plotargs = bp.parse_commandline() bp.make_plot_row(results, **plotargs) - bp.show_or_export(**plotargs) \ No newline at end of file + bp.export(**plotargs) + <%- else -%> + bp.make_plot_row(results) + plt.show() + <%- end -%> diff --git a/rawEx/ff/Dodecahedron.py b/rawEx/ff/Dodecahedron.py index 293ff941fd71935d6b7625f14fba2277f942090c..e7d8838e886f3f7c78aedd7fc0be6a29eb403dec 100755 --- a/rawEx/ff/Dodecahedron.py +++ b/rawEx/ff/Dodecahedron.py @@ -28,6 +28,11 @@ if __name__ == '__main__': result.setTitle(titles[i]) results.append(result) + <%- if sm -%> plotargs = bp.parse_commandline() bp.make_plot_row(results, **plotargs) - bp.show_or_export(**plotargs) \ No newline at end of file + bp.export(**plotargs) + <%- else -%> + bp.make_plot_row(results) + plt.show() + <%- end -%> diff --git a/rawEx/ff/EllipsoidalCylinder.py b/rawEx/ff/EllipsoidalCylinder.py index 90ffcd489a21466021bd551d497213105b9a66ee..0ab10ff623617641e4838ed4c8e9b13fdccffabe 100755 --- a/rawEx/ff/EllipsoidalCylinder.py +++ b/rawEx/ff/EllipsoidalCylinder.py @@ -27,6 +27,11 @@ if __name__ == '__main__': result.setTitle(title) results.append(result) + <%- if sm -%> plotargs = bp.parse_commandline() bp.make_plot_row(results, **plotargs) - bp.show_or_export(**plotargs) \ No newline at end of file + bp.export(**plotargs) + <%- else -%> + bp.make_plot_row(results) + plt.show() + <%- end -%> diff --git a/rawEx/ff/HemiEllipsoid.py b/rawEx/ff/HemiEllipsoid.py index b79316b4e223148a14ebe6a4ea44329a5f413a6b..ec1d414c0ea56c36b0abaf62684880bc892edf3f 100755 --- a/rawEx/ff/HemiEllipsoid.py +++ b/rawEx/ff/HemiEllipsoid.py @@ -27,6 +27,11 @@ if __name__ == '__main__': result.setTitle(title) results.append(result) + <%- if sm -%> plotargs = bp.parse_commandline() bp.make_plot_row(results, **plotargs) - bp.show_or_export(**plotargs) \ No newline at end of file + bp.export(**plotargs) + <%- else -%> + bp.make_plot_row(results) + plt.show() + <%- end -%> diff --git a/rawEx/ff/HorizontalCylinder.py b/rawEx/ff/HorizontalCylinder.py index 7fedfadea9055801584c2bbff04f9f14c93f6678..382fb33ffefac8f7e40b1b1041ee3efc0c35a900 100755 --- a/rawEx/ff/HorizontalCylinder.py +++ b/rawEx/ff/HorizontalCylinder.py @@ -27,6 +27,11 @@ if __name__ == '__main__': result.setTitle(title) results.append(result) + <%- if sm -%> plotargs = bp.parse_commandline() bp.make_plot_row(results, **plotargs) - bp.show_or_export(**plotargs) \ No newline at end of file + bp.export(**plotargs) + <%- else -%> + bp.make_plot_row(results) + plt.show() + <%- end -%> diff --git a/rawEx/ff/Icosahedron.py b/rawEx/ff/Icosahedron.py index 01f75bbf0238f587289cd78d925d13288e987ebb..d5a9a022c476a6684c263c50ad5a8201cc183ee6 100755 --- a/rawEx/ff/Icosahedron.py +++ b/rawEx/ff/Icosahedron.py @@ -28,6 +28,11 @@ if __name__ == '__main__': result.setTitle(titles[i]) results.append(result) + <%- if sm -%> plotargs = bp.parse_commandline() bp.make_plot_row(results, **plotargs) - bp.show_or_export(**plotargs) \ No newline at end of file + bp.export(**plotargs) + <%- else -%> + bp.make_plot_row(results) + plt.show() + <%- end -%> diff --git a/rawEx/ff/PlatonicOctahedron.py b/rawEx/ff/PlatonicOctahedron.py index 166fc1613569e7165d86883ff1080e36c555d5a7..d8546a7291a8d24863b53fdb6277ca0151eb8e27 100755 --- a/rawEx/ff/PlatonicOctahedron.py +++ b/rawEx/ff/PlatonicOctahedron.py @@ -28,6 +28,11 @@ if __name__ == '__main__': result.setTitle(titles[i]) results.append(result) + <%- if sm -%> plotargs = bp.parse_commandline() bp.make_plot_row(results, **plotargs) - bp.show_or_export(**plotargs) \ No newline at end of file + bp.export(**plotargs) + <%- else -%> + bp.make_plot_row(results) + plt.show() + <%- end -%> diff --git a/rawEx/ff/PlatonicTetrahedron.py b/rawEx/ff/PlatonicTetrahedron.py index da8150c0afb4ed2837bf6fe03085be0046e7c831..9e3dc4391ff8a8a0adb2eeff69541f00bc984613 100755 --- a/rawEx/ff/PlatonicTetrahedron.py +++ b/rawEx/ff/PlatonicTetrahedron.py @@ -28,6 +28,11 @@ if __name__ == '__main__': result.setTitle(titles[i]) results.append(result) + <%- if sm -%> plotargs = bp.parse_commandline() bp.make_plot_row(results, **plotargs) - bp.show_or_export(**plotargs) \ No newline at end of file + bp.export(**plotargs) + <%- else -%> + bp.make_plot_row(results) + plt.show() + <%- end -%> diff --git a/rawEx/ff/Prism3.py b/rawEx/ff/Prism3.py index 98eff7c6be20f8cf13338fa6ef39031f3da5113e..3b28882aba6cfcee88f4bad017bd6dd6e218b003 100755 --- a/rawEx/ff/Prism3.py +++ b/rawEx/ff/Prism3.py @@ -27,6 +27,11 @@ if __name__ == '__main__': result.setTitle(title) results.append(result) + <%- if sm -%> plotargs = bp.parse_commandline() bp.make_plot_row(results, **plotargs) - bp.show_or_export(**plotargs) \ No newline at end of file + bp.export(**plotargs) + <%- else -%> + bp.make_plot_row(results) + plt.show() + <%- end -%> diff --git a/rawEx/ff/Prism6.py b/rawEx/ff/Prism6.py index f7aaca94552d7348006de0f9cbe6b62f5bf3f5eb..bef543b8b95a86d9e696df9ada6fd931dbed14f0 100755 --- a/rawEx/ff/Prism6.py +++ b/rawEx/ff/Prism6.py @@ -27,6 +27,11 @@ if __name__ == '__main__': result.setTitle(title) results.append(result) + <%- if sm -%> plotargs = bp.parse_commandline() bp.make_plot_row(results, **plotargs) - bp.show_or_export(**plotargs) \ No newline at end of file + bp.export(**plotargs) + <%- else -%> + bp.make_plot_row(results) + plt.show() + <%- end -%> diff --git a/rawEx/ff/Pyramid2.py b/rawEx/ff/Pyramid2.py index 1f60aa5602bfcb8409ac85da4b5a1ed573d82f6c..c1858a1f50789194c23c8ca7ed2a35c6d9d2bf02 100755 --- a/rawEx/ff/Pyramid2.py +++ b/rawEx/ff/Pyramid2.py @@ -27,6 +27,11 @@ if __name__ == '__main__': result.setTitle(title) results.append(result) + <%- if sm -%> plotargs = bp.parse_commandline() bp.make_plot_row(results, **plotargs) - bp.show_or_export(**plotargs) \ No newline at end of file + bp.export(**plotargs) + <%- else -%> + bp.make_plot_row(results) + plt.show() + <%- end -%> diff --git a/rawEx/ff/Pyramid3.py b/rawEx/ff/Pyramid3.py index a93a6b654d3e6d7d7819f1b336e157f152ba745c..eeb375adc768d861c51d228b761485f941c653e8 100755 --- a/rawEx/ff/Pyramid3.py +++ b/rawEx/ff/Pyramid3.py @@ -27,6 +27,11 @@ if __name__ == '__main__': result.setTitle(title) results.append(result) + <%- if sm -%> plotargs = bp.parse_commandline() bp.make_plot_row(results, **plotargs) - bp.show_or_export(**plotargs) \ No newline at end of file + bp.export(**plotargs) + <%- else -%> + bp.make_plot_row(results) + plt.show() + <%- end -%> diff --git a/rawEx/ff/Pyramid4.py b/rawEx/ff/Pyramid4.py index e1a30e50eacb35b83e499d0329baf86eaed88f11..efb3281622e07923916c3326addc09dc8926c28c 100755 --- a/rawEx/ff/Pyramid4.py +++ b/rawEx/ff/Pyramid4.py @@ -27,6 +27,11 @@ if __name__ == '__main__': result.setTitle(title) results.append(result) + <%- if sm -%> plotargs = bp.parse_commandline() bp.make_plot_row(results, **plotargs) - bp.show_or_export(**plotargs) \ No newline at end of file + bp.export(**plotargs) + <%- else -%> + bp.make_plot_row(results) + plt.show() + <%- end -%> diff --git a/rawEx/ff/Pyramid6.py b/rawEx/ff/Pyramid6.py index e06e9283f8154beb6733a0ec7a8963541c8fd556..aec17a11e0ea3fa2910f745a369bac50f3289cf9 100755 --- a/rawEx/ff/Pyramid6.py +++ b/rawEx/ff/Pyramid6.py @@ -27,6 +27,11 @@ if __name__ == '__main__': result.setTitle(title) results.append(result) + <%- if sm -%> plotargs = bp.parse_commandline() bp.make_plot_row(results, **plotargs) - bp.show_or_export(**plotargs) \ No newline at end of file + bp.export(**plotargs) + <%- else -%> + bp.make_plot_row(results) + plt.show() + <%- end -%> diff --git a/rawEx/ff/SawtoothRippleBox.py b/rawEx/ff/SawtoothRippleBox.py index 4345eb8ab6dd17d8c673a2112f12de2019982ec5..1270772770d0a754bb7697140f9c812f54bb0c86 100755 --- a/rawEx/ff/SawtoothRippleBox.py +++ b/rawEx/ff/SawtoothRippleBox.py @@ -27,6 +27,11 @@ if __name__ == '__main__': result.setTitle(title) results.append(result) + <%- if sm -%> plotargs = bp.parse_commandline() bp.make_plot_row(results, **plotargs) - bp.show_or_export(**plotargs) \ No newline at end of file + bp.export(**plotargs) + <%- else -%> + bp.make_plot_row(results) + plt.show() + <%- end -%> diff --git a/rawEx/ff/Sphere.py b/rawEx/ff/Sphere.py index 75edea0940a45ea5cd67ac14e82427f4382d92ee..8f3fad7173d42916e8b915dc1cf9d3df23a28344 100755 --- a/rawEx/ff/Sphere.py +++ b/rawEx/ff/Sphere.py @@ -20,6 +20,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() - + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/ff/Spheroid.py b/rawEx/ff/Spheroid.py index 4d4c6b3fd8211743cb4e22b97fc5ae191242f848..11c0862bf09e5a3911cf6d5276f3908828ffa955 100755 --- a/rawEx/ff/Spheroid.py +++ b/rawEx/ff/Spheroid.py @@ -27,6 +27,11 @@ if __name__ == '__main__': result.setTitle(title) results.append(result) + <%- if sm -%> plotargs = bp.parse_commandline() bp.make_plot_row(results, **plotargs) - bp.show_or_export(**plotargs) \ No newline at end of file + bp.export(**plotargs) + <%- else -%> + bp.make_plot_row(results) + plt.show() + <%- end -%> diff --git a/rawEx/ff/TruncatedCube.py b/rawEx/ff/TruncatedCube.py index ae82b05f0478926d4991e6fcdd8ae7a104a5aa72..004710c55617736394470b6c5528a0a92be41c1a 100755 --- a/rawEx/ff/TruncatedCube.py +++ b/rawEx/ff/TruncatedCube.py @@ -27,6 +27,11 @@ if __name__ == '__main__': result.setTitle(title) results.append(result) + <%- if sm -%> plotargs = bp.parse_commandline() bp.make_plot_row(results, **plotargs) - bp.show_or_export(**plotargs) \ No newline at end of file + bp.export(**plotargs) + <%- else -%> + bp.make_plot_row(results) + plt.show() + <%- end -%> diff --git a/rawEx/ff/TruncatedSphere.py b/rawEx/ff/TruncatedSphere.py index eb22b52ec555cc1d9696f96331b0216a4e23e117..215e2b8acbc84403cfd95c0def96500f341ae708 100755 --- a/rawEx/ff/TruncatedSphere.py +++ b/rawEx/ff/TruncatedSphere.py @@ -27,6 +27,11 @@ if __name__ == '__main__': result.setTitle(title) results.append(result) + <%- if sm -%> plotargs = bp.parse_commandline() bp.make_plot_row(results, **plotargs) - bp.show_or_export(**plotargs) \ No newline at end of file + bp.export(**plotargs) + <%- else -%> + bp.make_plot_row(results) + plt.show() + <%- end -%> diff --git a/rawEx/ff/TruncatedSpheroid.py b/rawEx/ff/TruncatedSpheroid.py index 8821319b9ab8855da75460ac9d518bdb2ee4cacf..8cf1059ddfb558a67798ef19a35edb7185a594f8 100755 --- a/rawEx/ff/TruncatedSpheroid.py +++ b/rawEx/ff/TruncatedSpheroid.py @@ -27,6 +27,12 @@ if __name__ == '__main__': result.setTitle(title) results.append(result) + + <%- if sm -%> plotargs = bp.parse_commandline() bp.make_plot_row(results, **plotargs) - bp.show_or_export(**plotargs) \ No newline at end of file + bp.export(**plotargs) + <%- else -%> + bp.make_plot_row(results) + plt.show() + <%- end -%> diff --git a/rawEx/fit/scatter2d/consecutive_fitting.py b/rawEx/fit/scatter2d/consecutive_fitting.py index 34ab34254959d025838d8ac91147f5ae9455032f..3cc653fdeb7c2441588f6ed5a834b7e96c1eb020 100755 --- a/rawEx/fit/scatter2d/consecutive_fitting.py +++ b/rawEx/fit/scatter2d/consecutive_fitting.py @@ -71,7 +71,12 @@ def run_fitting(): fit_objective.addFitPair(get_simulation, data, 1) fit_objective.initPrint(30) observer = ba_fitmonitor.PlotterGISAS() - <%= sm ? "plt.close() # (hide plot) " :"" %>fit_objective.initPlot(30, observer) + + <%- if sm -%> + plt.close() # hide plot + <%- else -%> + fit_objective.initPlot(30, observer) + <%- end -%> """ Setting fitting parameters with starting values. Here we select starting values being quite far from true values diff --git a/rawEx/fit/scatter2d/expfit_galaxi.py b/rawEx/fit/scatter2d/expfit_galaxi.py index 7db4f8e7d3325ca181857b9d535a1d2648e77a2d..2e21889d27227eb5a6f223700e657a409c2da7e5 100755 --- a/rawEx/fit/scatter2d/expfit_galaxi.py +++ b/rawEx/fit/scatter2d/expfit_galaxi.py @@ -130,7 +130,11 @@ def run_fitting(): fit_objective.addFitPair(create_simulation, data, 1) fit_objective.initPrint(10) observer = ba_fitmonitor.PlotterGISAS() - <%= sm ? "plt.close() # (hide plot) " :"" %>fit_objective.initPlot(10, observer) + <%- if sm -%> + plt.close() # hide plot + <%- end -%> + + fit_objective.initPlot(10, observer) P = ba.Parameters() P.add("radius", 5.*nm, min=4, max=6, step=0.1*nm) @@ -138,7 +142,9 @@ def run_fitting(): P.add("distance", 27.*nm, min=20, max=70) minimizer = ba.Minimizer() - <%= sm ? "minimizer.setMinimizer(\"Minuit2\", \"Migrad\", \"MaxFunctionCalls=2\")" : "" %> + <%- if sm -%> + minimizer.setMinimizer("Minuit2", "Migrad", "MaxFunctionCalls=2") + <%- end -%> result = minimizer.minimize(fit_objective.evaluate, P) fit_objective.finalize(result) diff --git a/rawEx/fit/scatter2d/find_background.py b/rawEx/fit/scatter2d/find_background.py index 8720eb52d8d6f95aa9efa421f2fdd582a82129fb..8a35c0268acd67e4faebdd712dfea67ae3ecd926 100755 --- a/rawEx/fit/scatter2d/find_background.py +++ b/rawEx/fit/scatter2d/find_background.py @@ -53,8 +53,11 @@ if __name__ == '__main__': fit_objective.initPrint(10) observer = ba_fitmonitor.PlotterGISAS() - <%= sm ? "plt.close() # (hide plot) " :"" %>fit_objective.initPlot(10, observer) - + <%- if sm -%> + plt.close() # hide plot + <%- else -%> + fit_objective.initPlot(10, observer) + <%- end -%> P = ba.Parameters() P.add("radius", 5.*nm, vary=False) P.add("height", 9.*nm, min=8.*nm, max=12.*nm) diff --git a/rawEx/fit/scatter2d/fit_along_slices.py b/rawEx/fit/scatter2d/fit_along_slices.py index 49077bc5206c87cde8e90b090f4e36dd100c961b..a2cbcf369fb27ec8decc1653d99a70469464037e 100755 --- a/rawEx/fit/scatter2d/fit_along_slices.py +++ b/rawEx/fit/scatter2d/fit_along_slices.py @@ -162,7 +162,11 @@ def run_fitting(): # creating custom observer which will draw fit progress plotter = PlotObserver() - <%= sm ? "plt.close() # (hide plot) " :"" %>fit_objective.initPlot(10, plotter) + <%- if sm -%> + plt.close() # hide plot + <%- else -%> + fit_objective.initPlot(10, plotter) + <%- end -%> P = ba.Parameters() P.add("radius", 6.*nm, min=4, max=8) diff --git a/rawEx/fit/scatter2d/fit_gisas.py b/rawEx/fit/scatter2d/fit_gisas.py index 358e8b557b99079e70fe40a2bc50a350f12bdb5c..e92967d3a6a8cdf9d770d26115b2ed6247c9114c 100755 --- a/rawEx/fit/scatter2d/fit_gisas.py +++ b/rawEx/fit/scatter2d/fit_gisas.py @@ -23,7 +23,11 @@ if __name__ == '__main__': fit_objective.initPrint(10) # Print on every 10th iteration. observer = ba_fitmonitor.PlotterGISAS() - <%= sm ? "plt.close() # (hide plot) " :"" %>fit_objective.initPlot(10, observer) # Plot every 10th, slow! + <%- if sm -%> + plt.close() # hide plot + <%- else -%> + fit_objective.initPlot(10, observer) # Plot every 10th, slow! + <%- end -%> minimizer = ba.Minimizer() minimizer.setMinimizer("Minuit2", "Migrad", "MaxFunctionCalls=<%= sm ? 10 : 0 %>") diff --git a/rawEx/fit/scatter2d/fit_with_masks.py b/rawEx/fit/scatter2d/fit_with_masks.py index 299521f4c5f5d36522b1360bc8952c3a651dc7a8..5d9f5f08a24b889752112bc80d2131fc5816b8a9 100755 --- a/rawEx/fit/scatter2d/fit_with_masks.py +++ b/rawEx/fit/scatter2d/fit_with_masks.py @@ -62,7 +62,11 @@ if __name__ == '__main__': fit_objective.addFitPair(get_masked_simulation, data, 1) fit_objective.initPrint(10) observer = ba_fitmonitor.PlotterGISAS() - <%= sm ? "plt.close() # (hide plot) " :"" %>fit_objective.initPlot(10, observer) + <%- if sm -%> + plt.close() # hide plot + <%- else -%> + fit_objective.initPlot(10, observer) + <%- end -%> P = ba.Parameters() P.add("radius", 6.*nm, min=4, max=8) diff --git a/rawEx/fit/scatter2d/lmfit_with_plotting.py b/rawEx/fit/scatter2d/lmfit_with_plotting.py index 7e68bd8c35b0412ae8c948a426cc0d5e5b7cb0ab..9400cc98c11897e42ad00ecd5569dffeef690dea 100755 --- a/rawEx/fit/scatter2d/lmfit_with_plotting.py +++ b/rawEx/fit/scatter2d/lmfit_with_plotting.py @@ -34,10 +34,12 @@ if __name__ == '__main__': P = lmfit.Parameters() P.add('radius', value=7*nm, min=5*nm, max=8*nm) P.add('length', value=10*nm, min=8*nm, max=14*nm) - - <%= sm ? "" :"plotter = LMFITPlotter(fit_objective)" %> - result = lmfit.minimize(fit_objective.evaluate_residuals, - P<%= sm ? "" :", iter_cb=plotter" %>) + <%- if sm -%> + result = lmfit.minimize(fit_objective.evaluate_residuals, P) + <%- else -%> + plotter = LMFITPlotter(fit_objective) + result = lmfit.minimize(fit_objective.evaluate_residuals, P, iter_cb=plotter) + <%- end -%> fit_objective.finalize(result) result.params.pretty_print() diff --git a/rawEx/fit/scatter2d/minimizer_settings.py b/rawEx/fit/scatter2d/minimizer_settings.py index db86d83164219e70fe525b41cb28ff0e9050ce9f..8c67b6e3c77b34bdf4cd4ec20aeb3b4dfda1d87a 100755 --- a/rawEx/fit/scatter2d/minimizer_settings.py +++ b/rawEx/fit/scatter2d/minimizer_settings.py @@ -93,7 +93,11 @@ def run_fitting(): P.add("prism_base_edge", 12.*nm, min=0.01) minimizer = ba.Minimizer() - <%= sm ? "minimizer.setMinimizer(\"Minuit2\", \"Migrad\", \"MaxFunctionCalls=5\") # (fast test)" :"" %> + + <%- if sm -%> + minimizer.setMinimizer("Minuit2", "Migrad", "MaxFunctionCalls=5") # fast test + <%- end -%> + # Uncomment one of the line below to adjust minimizer settings """ Setting Minuit2 minimizer with Migrad algorithm, limiting number of iterations. diff --git a/rawEx/fit/scatter2d/multiple_datasets.py b/rawEx/fit/scatter2d/multiple_datasets.py index 6ba16b11cfa354f1abd94a39360c221bed824542..5c6d92e53338882c4c09ea1601e8b089d502e434 100755 --- a/rawEx/fit/scatter2d/multiple_datasets.py +++ b/rawEx/fit/scatter2d/multiple_datasets.py @@ -192,7 +192,11 @@ def run_fitting(): # creating custom observer which will draw fit progress plotter = PlotObserver() - <%= sm ? "plt.close() # (hide plot) " :"" %>fit_objective.initPlot(10, plotter.update) + <%- if sm -%> + plt.close() # hide plot + <%- else -%> + fit_objective.initPlot(10, plotter.update) + <%- end -%> P = ba.Parameters() P.add("radius_a", 4.*nm, min=2, max=10) diff --git a/rawEx/fit/specular/Honeycomb_fit.py b/rawEx/fit/specular/Honeycomb_fit.py index 9fb9abb67589ce5721ab9308971214d97922734a..42128d9489e63e20bb4bf602e825bd96445df17d 100755 --- a/rawEx/fit/specular/Honeycomb_fit.py +++ b/rawEx/fit/specular/Honeycomb_fit.py @@ -127,9 +127,10 @@ def plot(q, rs, data, shifts, labels): plt.xlabel(r"$q\; $(nm$^{-1}$)") plt.ylabel("$R$") - - <%= sm ? "#" : "" %>plt.tight_layout() - #<%= sm ? "#" : "" %>plt.close() + <%- if sm -%> + <%- else -%> + plt.tight_layout() + <%- end -%> def plot_sld_profile(P): @@ -149,8 +150,10 @@ def plot_sld_profile(P): plt.ylabel(r"$\delta(z) \cdot 10^6$") plt.legend() - <%= sm ? "#" : "" %>plt.tight_layout() - #<%= sm ? "#" : "" %>plt.close() + <%- if sm -%> + <%- else -%> + plt.tight_layout() + <%- end -%> #################################################################### # Main @@ -248,13 +251,22 @@ if __name__ == '__main__': result = scipy.optimize.differential_evolution( objective_function, bounds, - maxiter=<%= sm ? 2 : 5 %>, # for a serious DE fit, choose 500 - popsize=<%= sm ? 2 : 3 %>, # for a serious DE fit, choose 10 + <%- if sm -%> + maxiter=2, + popsize=2, + <%- else -%> + maxiter=5, # for a serious DE fit, choose 500 + popsize=3, # for a serious DE fit, choose 10 + <%- end -%> tol=1e-2, mutation=(0.5, 1.5), seed=0, disp=True, - polish=<%= sm ? "False" : "True" %> + <%- if sm -%> + polish=False + <%- else -%> + polish=True + <%- end -%> ) print(f"Final chi2: {result.fun}") @@ -271,4 +283,7 @@ if __name__ == '__main__': ["300K $+$", "300K $-$", "150K $+$", "150K $-$"]) plot_sld_profile(P) - <%= sm ? "#" : "" %>plt.show() + <%- if sm -%> + <%- else -%> + plt.show() + <%- end -%> diff --git a/rawEx/fit/specular/PolarizedSpinAsymmetry.py b/rawEx/fit/specular/PolarizedSpinAsymmetry.py index bd75c69a0d5d4cc562d39cda71ff9ec714ac8e10..8ef1895aafc8fcf0d25dc2ff49f489c6a7efd2b2 100755 --- a/rawEx/fit/specular/PolarizedSpinAsymmetry.py +++ b/rawEx/fit/specular/PolarizedSpinAsymmetry.py @@ -140,7 +140,9 @@ def plotData(qs, rs, exps, labels, colors): plt.ylabel("$R$") plt.tight_layout() - <%= sm ? "plt.close()" : "" %> + <%- if sm -%> + plt.close() + <%- end -%> def plotSpinAsymmetry(data_pp, data_mm, q, r_pp, r_mm): """ @@ -173,7 +175,9 @@ def plotSpinAsymmetry(data_pp, data_mm, q, r_pp, r_mm): plt.ylabel("Spin asymmetry") plt.tight_layout() - <%= sm ? "plt.close()" : "" %> + <%- if sm -%> + plt.close() # hide plot + <%- end -%> #################################################################### # Data Handling # @@ -225,5 +229,9 @@ if __name__ == '__main__': ["$++$", "$--$"], [['orange','red'], ['green','blue']]) plotSpinAsymmetry(expdata_pp, expdata_mm, qzs, r_pp, r_mm) - - bp.show_or_export() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.export(**plotargs) + <%- else -%> + plt.show() + <%- end -%> diff --git a/rawEx/fit/specular/PolarizedSpinAsymmetryFit.py b/rawEx/fit/specular/PolarizedSpinAsymmetryFit.py index e6b2a26920c3ef795644f9418c897a0863cb8533..941911455dbced02c49dd7a9e93d95b3bcf07967 100755 --- a/rawEx/fit/specular/PolarizedSpinAsymmetryFit.py +++ b/rawEx/fit/specular/PolarizedSpinAsymmetryFit.py @@ -119,8 +119,14 @@ if __name__ == '__main__': psa.plotData([q_pp, q_mm], [r_pp, r_mm], [data_pp, data_mm], [legend_pp, legend_mm], [color_pp, color_mm]) - <%= sm ? "#" : "" %>plt.draw() + <%- if sm -%> + <%- else -%> + plt.draw() + <%- end -%> psa.plotSpinAsymmetry(data_pp, data_mm, qzs, r_pp, r_mm) - <%= sm ? "#" : "" %>plt.draw() - <%= sm ? "#" : "" %>plt.show() + <%- if sm -%> + <%- else -%> + plt.draw() + plt.show() + <%- end -%> diff --git a/rawEx/fit/specular/Pt_layer_fit.py b/rawEx/fit/specular/Pt_layer_fit.py index 456075ec6c5dd52d5303d766896bc83b22fe4a88..c82dcacaeed7b3dd0b527fa849bfa503e0151836 100755 --- a/rawEx/fit/specular/Pt_layer_fit.py +++ b/rawEx/fit/specular/Pt_layer_fit.py @@ -94,7 +94,9 @@ def plot(q, r, data, P): y += 0.05 plt.tight_layout() - <%= sm ? "plt.close()" : "" %> + <%- if sm -%> + plt.close() # hide plot + <%- end -%> #################################################################### # Main diff --git a/rawEx/fit/specular/TREFF_Ni_film.py b/rawEx/fit/specular/TREFF_Ni_film.py index d453b1d76f6c0f9d48703e3b87fb015cbaa8afcd..bb027daa880445ba03e7351b491d9cc626542ca2 100755 --- a/rawEx/fit/specular/TREFF_Ni_film.py +++ b/rawEx/fit/specular/TREFF_Ni_film.py @@ -31,7 +31,7 @@ def get_sample(P): Ni_autocorr = ba.K_CorrelationModel(P["sigma_Ni"]) roughness_Ni = ba.LayerRoughness(Ni_autocorr, interlayer) - substrate = ba.Layer(material_SiO2) + substrate = ba.Layer(material_SiO2) sub_autocorr = ba.K_CorrelationModel(P["sigma_Substrate"]) roughness_Substrate = ba.LayerRoughness(sub_autocorr, interlayer) @@ -46,19 +46,19 @@ def get_sample(P): def get_simulation(P): scan = ba.QzScan(data.xAxis()) - + # Finite resolution due to beam divergence n_samples = 5 rel_sampling_width = 2.0 res_distr = ba.DistributionGaussian(0, 1, n_samples, rel_sampling_width) - + wavelength = 0.473*nm res_alpha = 0.006*deg res_q = 4*math.pi*res_alpha/wavelength scan.setAbsoluteQResolution(res_distr, res_q) - + sample = get_sample(P) - simulation = ba.SpecularSimulation(scan, sample) + simulation = ba.SpecularSimulation(scan, sample) simulation.setBackground(ba.ConstantBackground(1e-4)) return simulation @@ -77,23 +77,34 @@ if __name__ == '__main__': fit_objective.setObjectiveMetric("log", "l2") fit_objective.initPrint(50) - <%= sm ? "#" : "" %>plot_observer = ba_fitmonitor.PlotterSpecular(pause=0.001) - <%= sm ? "#" : "" %>fit_objective.initPlot(50, plot_observer) + + <%- if sm -%> + <%- else -%> + plot_observer = ba_fitmonitor.PlotterSpecular(pause=0.001) + fit_objective.initPlot(50, plot_observer) + <%- end -%> minimizer = ba.Minimizer() - + # Main minimization minimizer.setMinimizer("Genetic", "", - "<%= sm ? "MaxIterations=1;PopSize=10" : - "MaxIterations=5;PopSize=300" %>") + <%- if sm -%> + "MaxIterations=1;PopSize=10" + <%- else -%> + "MaxIterations=5;PopSize=300" + <%- end -%> + ) result = minimizer.minimize(fit_objective.evaluate, P) fit_objective.finalize(result) - - # Polish results with another minimizer + + # Polish results with another minimizer best_P_so_far = result.parameters() minimizer.setMinimizer("Minuit2", "Migrad", "MaxFunctionCalls=<%= sm ? 10 : 0 %>") result = minimizer.minimize(fit_objective.evaluate, best_P_so_far) fit_objective.finalize(result) - <%= sm ? "#" : "" %>plot_observer.show() + <%- if sm -%> + <%- else -%> + plot_observer.show() + <%- end -%> diff --git a/rawEx/fq/Sphere.py b/rawEx/fq/Sphere.py index 24243f680c852c14028f7fbe2fe73862b0ccb798..3f61d3b5bf6606cd7701fbcf4566faa403ffedb9 100755 --- a/rawEx/fq/Sphere.py +++ b/rawEx/fq/Sphere.py @@ -29,5 +29,9 @@ if __name__ == '__main__': plt.ylabel("$|F(q)|$", fontsize=label_fontsize) plt.tight_layout() - - bp.show_or_export() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.export(**plotargs) + <%- else -%> + plt.show() + <%- end -%> diff --git a/rawEx/offspec/Offspec1.py b/rawEx/offspec/Offspec1.py index 7e5222fde01fea548f9c1cbc0ab286546765a233..3e43ae7b1fb152b1dbbb519c77b93c7d3caa3a99 100755 --- a/rawEx/offspec/Offspec1.py +++ b/rawEx/offspec/Offspec1.py @@ -58,5 +58,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/offspec/OffspecLambda.py b/rawEx/offspec/OffspecLambda.py index ddc59f98cb56eb3dafda8af82e89cd6b2cdba050..5ff9bacd8c190cdf8d02b06d4fe89bbdaa71e5c4 100755 --- a/rawEx/offspec/OffspecLambda.py +++ b/rawEx/offspec/OffspecLambda.py @@ -55,9 +55,16 @@ def get_simulation(sample): if __name__ == '__main__': - bp.parse_args(intensity_min=1, aspect='auto') sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + plotargs['intensity_min'] = 1 + plotargs['aspect'] = 'auto' + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/offspec/OffspecResolved.py b/rawEx/offspec/OffspecResolved.py index b4f8512e6f37bc6ccd52b31878d27f15fa3308f4..ace0506de8f33fd0dfe3e396e60010b2a8afc828 100755 --- a/rawEx/offspec/OffspecResolved.py +++ b/rawEx/offspec/OffspecResolved.py @@ -54,5 +54,11 @@ if __name__ == '__main__': result = simulate(sample) sum = result.npArray().sum() print(f'sum = {sum/1e9}') + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/ApproximationDA.py b/rawEx/scatter2d/ApproximationDA.py index f9c951e97931a0bf62af0f5bbd38f673c92690da..63b997348f0aa9e0a4a6f2aefc4db7fb3b70b1af 100755 --- a/rawEx/scatter2d/ApproximationDA.py +++ b/rawEx/scatter2d/ApproximationDA.py @@ -62,5 +62,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/ApproximationLMA.py b/rawEx/scatter2d/ApproximationLMA.py index 149ede91f175deec6d79d9fa5e38aa5091ac2cd5..357d17f242a53b9f6e0c124198d2aeb0b4a1b95d 100755 --- a/rawEx/scatter2d/ApproximationLMA.py +++ b/rawEx/scatter2d/ApproximationLMA.py @@ -69,5 +69,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/ApproximationSSCA.py b/rawEx/scatter2d/ApproximationSSCA.py index e373b47a73d97dd7983b31c6b494efd410693f90..883bb8768d7696a23bec31d1fd4ceb4697498403 100755 --- a/rawEx/scatter2d/ApproximationSSCA.py +++ b/rawEx/scatter2d/ApproximationSSCA.py @@ -63,5 +63,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/AxesInDifferentUnits.py b/rawEx/scatter2d/AxesInDifferentUnits.py index e36976dac1ac2b7743f7d1b66b83e1d47a667e0a..c825e45b011e5b5e51389301ba599fec777636f0 100755 --- a/rawEx/scatter2d/AxesInDifferentUnits.py +++ b/rawEx/scatter2d/AxesInDifferentUnits.py @@ -83,4 +83,9 @@ if __name__ == '__main__': hspace=0.35, wspace=0., ) - bp.show_or_export() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.export(**plotargs) + <%- else -%> + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/BeamDivergence.py b/rawEx/scatter2d/BeamDivergence.py index 3389e85df8833e75967ac3284361fb948dd83554..69794f0cd67e8b040e947ac1b584bed775bb413b 100755 --- a/rawEx/scatter2d/BeamDivergence.py +++ b/rawEx/scatter2d/BeamDivergence.py @@ -32,5 +32,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/BiMaterialCylinders.py b/rawEx/scatter2d/BiMaterialCylinders.py index e4134cca348e6ad91f87821ed32425bd90de3335..43e49d215372de486d695e39e94e6f644e4ce593 100755 --- a/rawEx/scatter2d/BiMaterialCylinders.py +++ b/rawEx/scatter2d/BiMaterialCylinders.py @@ -66,5 +66,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/BoxesWithSpecularPeak.py b/rawEx/scatter2d/BoxesWithSpecularPeak.py index 5fd3163c09c8ee935f1865788006075f037b29ad..14fc68463244fbb4e25c9e97e7cdccc8c414be85 100755 --- a/rawEx/scatter2d/BoxesWithSpecularPeak.py +++ b/rawEx/scatter2d/BoxesWithSpecularPeak.py @@ -59,5 +59,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/BroadSpecular.py b/rawEx/scatter2d/BroadSpecular.py index d30a9eda2831ef82e4607eacd770a338c432b65b..8c052ef68f9e698b6484cf7c58e2e99e9797e4d0 100755 --- a/rawEx/scatter2d/BroadSpecular.py +++ b/rawEx/scatter2d/BroadSpecular.py @@ -35,5 +35,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/ConstantBackground.py b/rawEx/scatter2d/ConstantBackground.py index e6e6e8da7ca534a7e755bf9e1ca10c2a70cac8b7..a3b0ffbce216cfb09ab2aa59b7f5eb302ccef7af 100755 --- a/rawEx/scatter2d/ConstantBackground.py +++ b/rawEx/scatter2d/ConstantBackground.py @@ -25,5 +25,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/CoreShellNanoparticles.py b/rawEx/scatter2d/CoreShellNanoparticles.py index fbae1d35aa816d07820838960ee03bc8028b4a44..61b2e95e1c5754cf2b0b8f47f396621beb994f16 100755 --- a/rawEx/scatter2d/CoreShellNanoparticles.py +++ b/rawEx/scatter2d/CoreShellNanoparticles.py @@ -39,5 +39,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/CoreShellNanoparticles2.py b/rawEx/scatter2d/CoreShellNanoparticles2.py index f87f3d4c7e5ff07376c72fa7de99b25bb01429cd..7cd17f23831c3eb66291f0819a6a77bd879bee33 100755 --- a/rawEx/scatter2d/CoreShellNanoparticles2.py +++ b/rawEx/scatter2d/CoreShellNanoparticles2.py @@ -42,5 +42,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/CorrelatedRoughness.py b/rawEx/scatter2d/CorrelatedRoughness.py index d55a91bbf884e6e8f35c74dae03baff1a90160a3..484442d09962c76c631b8722250f20a06e04634d 100755 --- a/rawEx/scatter2d/CorrelatedRoughness.py +++ b/rawEx/scatter2d/CorrelatedRoughness.py @@ -55,5 +55,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/CosineRipplesAtRectLattice.py b/rawEx/scatter2d/CosineRipplesAtRectLattice.py index d0451169811d656f1d0ada7d0c2b30f936b30b09..799942dc0127f4504decf05fc6d7711d2d51fa43 100755 --- a/rawEx/scatter2d/CosineRipplesAtRectLattice.py +++ b/rawEx/scatter2d/CosineRipplesAtRectLattice.py @@ -62,5 +62,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/CustomFormFactor.py b/rawEx/scatter2d/CustomFormFactor.py index 0bb0165b36649aba6b484c763504215223aee6bd..222722a6254a1b079e28009137173f62f24f0b2b 100755 --- a/rawEx/scatter2d/CustomFormFactor.py +++ b/rawEx/scatter2d/CustomFormFactor.py @@ -87,5 +87,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/Cylinders.py b/rawEx/scatter2d/Cylinders.py index 094e60c1d9c812a691e7b3e1177fc764bc2dfaa9..ddb59a33e28379601c47fd629bc41e8f6400ce4f 100755 --- a/rawEx/scatter2d/Cylinders.py +++ b/rawEx/scatter2d/Cylinders.py @@ -31,5 +31,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/CylindersAndPrisms.py b/rawEx/scatter2d/CylindersAndPrisms.py index 20b947993f82794dd91a2e2168051c965d01e378..6d285cca24e542afe16f783e5ecfc40392ce2781 100755 --- a/rawEx/scatter2d/CylindersAndPrisms.py +++ b/rawEx/scatter2d/CylindersAndPrisms.py @@ -53,5 +53,12 @@ def get_simulation(sample): if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) - bp.plot_simulation_result(simulation.simulate()) - bp.show_or_export() + result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> + bp.plot_simulation_result(result) + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/CylindersInAverageLayer.py b/rawEx/scatter2d/CylindersInAverageLayer.py index 0d328231d79c3c816a4833e850de87415bd3ec93..1379daa0e5cd42d26551c9f0924ced7380119056 100755 --- a/rawEx/scatter2d/CylindersInAverageLayer.py +++ b/rawEx/scatter2d/CylindersInAverageLayer.py @@ -54,5 +54,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/CylindersInBA.py b/rawEx/scatter2d/CylindersInBA.py index bcea51ac2b8e2a9b3da1f0d18db214b42736e3ea..4e0b7504a5ad40308f41bcae77701e262679b55d 100755 --- a/rawEx/scatter2d/CylindersInBA.py +++ b/rawEx/scatter2d/CylindersInBA.py @@ -50,5 +50,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/DodecahedraSAS.py b/rawEx/scatter2d/DodecahedraSAS.py index 3aecfd64bdd823c1064582823cff6b618a438aec..ed90417e31fb3e6afad36ee2d975e910541cdb1c 100755 --- a/rawEx/scatter2d/DodecahedraSAS.py +++ b/rawEx/scatter2d/DodecahedraSAS.py @@ -42,5 +42,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/FindPeaks.py b/rawEx/scatter2d/FindPeaks.py index 2ceca69ddc619f78ca15240762f6ffc23a1820e2..ba465af715d4843113f1361b7ac31e257a14d291 100755 --- a/rawEx/scatter2d/FindPeaks.py +++ b/rawEx/scatter2d/FindPeaks.py @@ -79,7 +79,11 @@ if __name__ == '__main__': color='white', markersize=10) + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() - - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/HalfSpheresInAverageTopLayer.py b/rawEx/scatter2d/HalfSpheresInAverageTopLayer.py index 38d54bbea15c3e35a2ae8848df8adfafae214add..e067c325504457b57b1d8f003e8728c7090af610 100755 --- a/rawEx/scatter2d/HalfSpheresInAverageTopLayer.py +++ b/rawEx/scatter2d/HalfSpheresInAverageTopLayer.py @@ -64,5 +64,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/HexagonalLatticesWithBasis.py b/rawEx/scatter2d/HexagonalLatticesWithBasis.py index 4e3248d6988c259d5974f61a275a6eb4d6d36fd3..e35531c579300c86c89436e43d8f461ffbe77398 100755 --- a/rawEx/scatter2d/HexagonalLatticesWithBasis.py +++ b/rawEx/scatter2d/HexagonalLatticesWithBasis.py @@ -71,5 +71,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/Interference1DLattice.py b/rawEx/scatter2d/Interference1DLattice.py index 00a7fcf83c6f37e5dbc5190809074edfb709065f..d7fe1f55daa959b121e54b27f92ee954d0e9fbf4 100755 --- a/rawEx/scatter2d/Interference1DLattice.py +++ b/rawEx/scatter2d/Interference1DLattice.py @@ -67,5 +67,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/Interference1DRadialParacrystal.py b/rawEx/scatter2d/Interference1DRadialParacrystal.py index 8132eb7393268dd7d2794a4b5c402b93a91dca78..bffc097f4923aba02bb7a6ff92240361c54f9acf 100755 --- a/rawEx/scatter2d/Interference1DRadialParacrystal.py +++ b/rawEx/scatter2d/Interference1DRadialParacrystal.py @@ -57,5 +57,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/Interference2DCenteredSquareLattice.py b/rawEx/scatter2d/Interference2DCenteredSquareLattice.py index 4dfc8c327bdcc040f410a1b487703acd43376e46..68d470463163e6a3770fc9f4df4848281fdab222 100755 --- a/rawEx/scatter2d/Interference2DCenteredSquareLattice.py +++ b/rawEx/scatter2d/Interference2DCenteredSquareLattice.py @@ -70,5 +70,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/Interference2DParacrystal.py b/rawEx/scatter2d/Interference2DParacrystal.py index a6a9c47a0757008870bc5ef8c0edb3fbc0d3c0c0..8021f66ed1fc5e23f2250567fe9a211c5214bbb9 100755 --- a/rawEx/scatter2d/Interference2DParacrystal.py +++ b/rawEx/scatter2d/Interference2DParacrystal.py @@ -63,5 +63,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/Interference2DRotatedSquareLattice.py b/rawEx/scatter2d/Interference2DRotatedSquareLattice.py index 68e9b5e17ce05050f01f78e6601282ce6bc62c5c..22f0aae3a4814f6e7e76f1157c81c34b4ef159c2 100755 --- a/rawEx/scatter2d/Interference2DRotatedSquareLattice.py +++ b/rawEx/scatter2d/Interference2DRotatedSquareLattice.py @@ -62,5 +62,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/Interference2DSquareFiniteLattice.py b/rawEx/scatter2d/Interference2DSquareFiniteLattice.py index 13e1a59a02dc737bc6d3b3cd5d6dfcf8f58eacf0..13658d1ccd8b3539f54c6e8edc0b5024338dd3dc 100755 --- a/rawEx/scatter2d/Interference2DSquareFiniteLattice.py +++ b/rawEx/scatter2d/Interference2DSquareFiniteLattice.py @@ -60,5 +60,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/LargeParticlesFormFactor.py b/rawEx/scatter2d/LargeParticlesFormFactor.py index 538ddb9b096eff5e78772d084b4515f527c8cb93..b7bbb68ae025959f81b019e220a5243beb6eb409 100755 --- a/rawEx/scatter2d/LargeParticlesFormFactor.py +++ b/rawEx/scatter2d/LargeParticlesFormFactor.py @@ -100,7 +100,13 @@ def simulate(): if __name__ == '__main__': - bp.parse_args(fontsize=12) results = simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + plotargs['fontsize'] = 12 + bp.make_plot(results, 2, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.make_plot(results, 2) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/LatticeOrientationDistribution.py b/rawEx/scatter2d/LatticeOrientationDistribution.py index 289321fd64735a2c1614906cc4021d6de9cb35b5..5d20da129a8e14f52c1345585cc9992b5de831ad 100755 --- a/rawEx/scatter2d/LatticeOrientationDistribution.py +++ b/rawEx/scatter2d/LatticeOrientationDistribution.py @@ -46,5 +46,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/MagneticCylinders1.py b/rawEx/scatter2d/MagneticCylinders1.py index 2df7f71f7e8070e258345b73f4c58ceef782cb91..f5cd1c4ee939180de2d0ee0db604eec969164a7c 100755 --- a/rawEx/scatter2d/MagneticCylinders1.py +++ b/rawEx/scatter2d/MagneticCylinders1.py @@ -48,5 +48,12 @@ def simulate(): if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) - bp.plot_simulation_result(simulation.simulate()) - bp.show_or_export() + result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> + bp.plot_simulation_result(result) + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/MagneticCylinders2.py b/rawEx/scatter2d/MagneticCylinders2.py index ec3584fdcc38269d9baf6daba78a88484f92915d..0663a6cea2b471f1f3fb98ca8eb7929c47f1eb9b 100755 --- a/rawEx/scatter2d/MagneticCylinders2.py +++ b/rawEx/scatter2d/MagneticCylinders2.py @@ -52,7 +52,6 @@ def simulate(title, pol_dir): if __name__ == '__main__': - bp.parse_args(fontsize=12) z_up = R3(0, 0, 1) z_dn = R3(0, 0, -1) results = [] @@ -60,5 +59,11 @@ if __name__ == '__main__': results.append(simulate('+-', z_dn)) results.append(simulate('-+', z_up)) results.append(simulate('--', z_dn)) - bp.make_plot(results, 2) - bp.show_or_export() + <%- if sm -%> + plotargs = bp.parse_commandline() + plotargs['fontsize'] = 12 + bp.make_plot(results, 2, **plotargs) + bp.export(**plotargs) + <%- else -%> + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/MagneticSpheres.py b/rawEx/scatter2d/MagneticSpheres.py index f7326407fed3f222a3be66a7a7057cfcbdfe7987..11cc9970406420654106e1266f96bd4f256079a3 100755 --- a/rawEx/scatter2d/MagneticSpheres.py +++ b/rawEx/scatter2d/MagneticSpheres.py @@ -53,5 +53,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/Mesocrystal.py b/rawEx/scatter2d/Mesocrystal.py index 2f01ac1ad5afc83b236f27d0f60881bc70a5cb93..adeff4d4467b7017f68630178b496c295abd0661 100755 --- a/rawEx/scatter2d/Mesocrystal.py +++ b/rawEx/scatter2d/Mesocrystal.py @@ -61,5 +61,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/Mesocrystal2.py b/rawEx/scatter2d/Mesocrystal2.py index 75d3e6d93fdc5d6fd524b17c542f25feaba54642..6479bd9fce0f25943234b992e0cba758d4dfb137 100755 --- a/rawEx/scatter2d/Mesocrystal2.py +++ b/rawEx/scatter2d/Mesocrystal2.py @@ -63,5 +63,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/Mesocrystal3.py b/rawEx/scatter2d/Mesocrystal3.py index eac77633deba76d2e71b3af9f27732c5b3a47b2a..7fd326730feeec17817466e66aea80189c441137 100755 --- a/rawEx/scatter2d/Mesocrystal3.py +++ b/rawEx/scatter2d/Mesocrystal3.py @@ -78,5 +78,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/Mesocrystal4.py b/rawEx/scatter2d/Mesocrystal4.py index 78d657b9815b2c7c213af4ce5d293fc0ee3ffeb1..e22b5ce6f8d2cea7b4a97d68221f1ac7d39649db 100755 --- a/rawEx/scatter2d/Mesocrystal4.py +++ b/rawEx/scatter2d/Mesocrystal4.py @@ -79,5 +79,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/ObsoleteSimN.py b/rawEx/scatter2d/ObsoleteSimN.py index d804db8727b075a2af335268deb3747b05def288..d6bc5c6679a8a9971809deb802dc1aceebd19f2b 100755 --- a/rawEx/scatter2d/ObsoleteSimN.py +++ b/rawEx/scatter2d/ObsoleteSimN.py @@ -21,16 +21,21 @@ def get_simulation(sample): beam = ba.Beam(1e9, wavelength, alpha_i) # Detector - n = bp.simargs['n'] + n = 11 # bp.simargs['n'] detector = ba.SphericalDetector(n, -2*deg, 2*deg, n, 0., 3*deg) return ba.ScatteringSimulation(beam, sample, detector) if __name__ == '__main__': - bp.parse_args(sim_n=11) sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/ParticleAcrossInterface.py b/rawEx/scatter2d/ParticleAcrossInterface.py index ac6299fa1a8ba3f5813197da40b34ed7cf79e973..29d9155f00c4669125b909a35bbea2b0b1fd8542 100755 --- a/rawEx/scatter2d/ParticleAcrossInterface.py +++ b/rawEx/scatter2d/ParticleAcrossInterface.py @@ -46,5 +46,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/PolarizedSANS.py b/rawEx/scatter2d/PolarizedSANS.py index 943e973a96450ae2f5278c7e3e4ffea007738078..b5ed5c16af53e65255d8a50cb4971b7a263c016e 100755 --- a/rawEx/scatter2d/PolarizedSANS.py +++ b/rawEx/scatter2d/PolarizedSANS.py @@ -69,5 +69,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/PolydisperseCylinders.py b/rawEx/scatter2d/PolydisperseCylinders.py index 72d6b3c3203d1e3a2e63d139086511e032b48f72..06b9580f3f4c932ce19d80282e56f0c8b84cb4cf 100755 --- a/rawEx/scatter2d/PolydisperseCylinders.py +++ b/rawEx/scatter2d/PolydisperseCylinders.py @@ -39,5 +39,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/PositionVariance.py b/rawEx/scatter2d/PositionVariance.py index ec884d7fae922ab4637ad856a23adc2915167772..140fcb6f4fcadba3012baa61283f55cdeef10087 100755 --- a/rawEx/scatter2d/PositionVariance.py +++ b/rawEx/scatter2d/PositionVariance.py @@ -78,5 +78,9 @@ if __name__ == '__main__': plt.subplots_adjust(bottom=0.05, left=0.1) plt.colorbar(im, cax=plt.axes([0.93, 0.36, 0.03, 0.21])) - - bp.show_or_export() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.export(**plotargs) + <%- else -%> + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/RectangularGrating.py b/rawEx/scatter2d/RectangularGrating.py index 8f28310abd8d96d5daccf23d4664ca30c9465708..27b9ee472c3424a8307cd658befc439b5f185b3f 100755 --- a/rawEx/scatter2d/RectangularGrating.py +++ b/rawEx/scatter2d/RectangularGrating.py @@ -64,5 +64,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/Resolution.py b/rawEx/scatter2d/Resolution.py index e74d23a71c771cc40dc1cdfe901f2a27d4fe0aed..1dc5ac03bf854a1e6a4867cde59b0d87d370533b 100755 --- a/rawEx/scatter2d/Resolution.py +++ b/rawEx/scatter2d/Resolution.py @@ -52,7 +52,11 @@ if __name__ == '__main__': result = simulation.simulate() result.setTitle("resolution 0.2deg, 0.2deg") results.append(result) - + <%- if sm -%> plotargs = bp.parse_commandline() bp.make_plot_row(results, **plotargs) - bp.show_or_export(**plotargs) + bp.export() + <%- else -%> + bp.make_plot_row(results) + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/RotatedPyramids.py b/rawEx/scatter2d/RotatedPyramids.py index fd9c63ecceff2ae3897d55c8bfd1e105136c3c3a..e9cd59861cee4e536ef05f2fa3e51d9fce2b3f19 100755 --- a/rawEx/scatter2d/RotatedPyramids.py +++ b/rawEx/scatter2d/RotatedPyramids.py @@ -53,5 +53,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/RoughAndSpecular.py b/rawEx/scatter2d/RoughAndSpecular.py index a8d88961577c468f430221faca4239e6cceb4d8c..68d85a2696d8d2d513a1fc6c509952d078a03205 100755 --- a/rawEx/scatter2d/RoughAndSpecular.py +++ b/rawEx/scatter2d/RoughAndSpecular.py @@ -50,5 +50,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/SlicedLayer.py b/rawEx/scatter2d/SlicedLayer.py index 18de0f466da1fdd7c9c13680afbd562e52be162d..62084964d52b64624d27afaa8b8dcb76fb03a3f4 100755 --- a/rawEx/scatter2d/SlicedLayer.py +++ b/rawEx/scatter2d/SlicedLayer.py @@ -50,5 +50,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/SpheresAtHexLattice.py b/rawEx/scatter2d/SpheresAtHexLattice.py index c71f0931272d6b3698bede0c9fb631551cbff746..6032decc27dc60ad2cd831b7b1a44c81445d3ce3 100755 --- a/rawEx/scatter2d/SpheresAtHexLattice.py +++ b/rawEx/scatter2d/SpheresAtHexLattice.py @@ -62,5 +62,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/scatter2d/TriangularRipple.py b/rawEx/scatter2d/TriangularRipple.py index 7f52971ebf8ca4403725232e5b05ee6e9eb0b16d..86212f690bc6b8a84e9acd0480ae247c9f1c5a5b 100755 --- a/rawEx/scatter2d/TriangularRipple.py +++ b/rawEx/scatter2d/TriangularRipple.py @@ -62,5 +62,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/specular/AlternatingLayers1.py b/rawEx/specular/AlternatingLayers1.py index 83688a23ec0482dba81c774a043187a455f8d52b..79ba12817450974b3e64f5af455f924944a81fc3 100755 --- a/rawEx/specular/AlternatingLayers1.py +++ b/rawEx/specular/AlternatingLayers1.py @@ -42,5 +42,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/specular/AlternatingLayers2.py b/rawEx/specular/AlternatingLayers2.py index 1d26f682fae12c818240e9bfbe5ba1701bea384d..25fe94ab49a4eb76e0faac3a30ecdaef540e3734 100755 --- a/rawEx/specular/AlternatingLayers2.py +++ b/rawEx/specular/AlternatingLayers2.py @@ -22,5 +22,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/specular/Basic.py b/rawEx/specular/Basic.py index bba2d6a4345104904cb041747865dd96e3b7baed..76715296d8b93ec0df6096175be6da9cb5596e67 100755 --- a/rawEx/specular/Basic.py +++ b/rawEx/specular/Basic.py @@ -35,4 +35,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) + plt.show() + <%- end -%> diff --git a/rawEx/specular/BeamFullDivergence.py b/rawEx/specular/BeamFullDivergence.py index 1ea872b4ae6fc992b80890cd6c0b2d54ff710784..11dd732f978c77c52afd80ff1d3f7da6cfd871c8 100755 --- a/rawEx/specular/BeamFullDivergence.py +++ b/rawEx/specular/BeamFullDivergence.py @@ -42,5 +42,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/specular/Distributions.py b/rawEx/specular/Distributions.py index 0226fc4d7acf4b3eef414eb1e2a2fe2bedc48806..80aa9e75a82f2e3d61c0416b8edd1042874a4054 100755 --- a/rawEx/specular/Distributions.py +++ b/rawEx/specular/Distributions.py @@ -14,9 +14,9 @@ def get_sample(): def simulate(sample, distr, title): n = 300 scan = ba.AlphaScan(n, 0.5*deg, 1*deg) - scan.setWavelength(lambda0) + scan.setWavelength(lambda0) if distr: - scan.setWavelengthDistribution(distr) + scan.setWavelengthDistribution(distr) result = ba.SpecularSimulation(scan, sample).simulate() result.setTitle(title) @@ -35,5 +35,11 @@ if __name__ == '__main__': lambda0, 0.011), "LogNormal"), ] + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_multicurve(results, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_multicurve(results) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/specular/FootprintCorrection.py b/rawEx/specular/FootprintCorrection.py index 142d4a806db0a30d436e88bbb1d2ae331ecbe7f6..645d37774ae9ecfda82ee052d81533aa6e4868c6 100755 --- a/rawEx/specular/FootprintCorrection.py +++ b/rawEx/specular/FootprintCorrection.py @@ -32,5 +32,11 @@ if __name__ == '__main__': simulate(None, "Without footprint"), ] + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_multicurve(results, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_multicurve(results) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/specular/GaussianBeams.py b/rawEx/specular/GaussianBeams.py index 4062eeec9cbda7b05ebaad66dfc8b0bbe4e0092c..b7e27ec602eae715b405a8e0536bb9da820872b0 100755 --- a/rawEx/specular/GaussianBeams.py +++ b/rawEx/specular/GaussianBeams.py @@ -33,6 +33,11 @@ if __name__ == '__main__': simulate(sample, 0.01 * deg, "0.01 deg"), simulate(sample, 0.03 * deg, "0.03 deg"), ] - + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_multicurve(results, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_multicurve(results) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/specular/MagneticLayer.py b/rawEx/specular/MagneticLayer.py index 5000ad586bb15ad5edbacc6aadfb09cbf4325dd5..0bec3b2a3189712976a375d1c3b3eeac179b156d 100755 --- a/rawEx/specular/MagneticLayer.py +++ b/rawEx/specular/MagneticLayer.py @@ -54,6 +54,11 @@ if __name__ == '__main__': simulate(sample, R3(0, +1, 0), R3(0, -1, 0), "$+-$"), simulate(sample, R3(0, -1, 0), R3(0, -1, 0), "$--$"), ] - + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_multicurve(results, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_multicurve(results) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/specular/MagneticLayerImperfect.py b/rawEx/specular/MagneticLayerImperfect.py index 24b412f64349c202b3e32aa636b1296301989da1..919169f1958be46ba091a3878edf4e1f729452d8 100755 --- a/rawEx/specular/MagneticLayerImperfect.py +++ b/rawEx/specular/MagneticLayerImperfect.py @@ -72,5 +72,11 @@ if __name__ == '__main__': results_mm = simulate(R3(0, -1, 0), R3(0, -1, 0), p_eff, a_eff, "$--$") results = [results_pp, results_pm, results_mp, results_mm] + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_multicurve(results, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_multicurve(results) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/specular/PolarizedSpinAsymmetry.py b/rawEx/specular/PolarizedSpinAsymmetry.py index c209821b1f7b45a49f7582fe2fef9d4e45dc5c15..d69bb03128c65974632ffce4bdf376d5dc98f6b9 100755 --- a/rawEx/specular/PolarizedSpinAsymmetry.py +++ b/rawEx/specular/PolarizedSpinAsymmetry.py @@ -140,7 +140,9 @@ def plotData(qs, rs, exps, labels, colors): plt.ylabel("$R$") plt.tight_layout() - <%= sm ? "plt.close()" : "" %> + <%- if sm -%> + plt.close() + <%- end -%> def plotSpinAsymmetry(data_pp, data_mm, q, r_pp, r_mm): """ @@ -173,7 +175,9 @@ def plotSpinAsymmetry(data_pp, data_mm, q, r_pp, r_mm): plt.ylabel("Spin asymmetry") plt.tight_layout() - <%= sm ? "plt.close()" : "" %> + <%- if sm -%> + plt.close() # hide plot + <%- end -%> #################################################################### # Data Handling # @@ -225,5 +229,9 @@ if __name__ == '__main__': ["$++$", "$--$"], [['orange','red'], ['green','blue']]) plotSpinAsymmetry(expdata_pp, expdata_mm, qzs, r_pp, r_mm) - - bp.show_or_export() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.export(**plotargs) + <%- else -%> + plt.show() + <%- end -%> diff --git a/rawEx/specular/RoughnessModel.py b/rawEx/specular/RoughnessModel.py index 513dbe71258ebd9aa3b87768f76cb0b3e2f5265a..bbb869a11e5a5913aa5efe7888e22f5cd7a487be 100755 --- a/rawEx/specular/RoughnessModel.py +++ b/rawEx/specular/RoughnessModel.py @@ -61,6 +61,11 @@ if __name__ == '__main__': simulate(ba.ErfInterlayer(), "Névot-Croce"), simulate(ba.TanhInterlayer(), "Tanh"), ] - + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_multicurve(results, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_multicurve(results) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/specular/SpecularSimulationWithRoughness.py b/rawEx/specular/SpecularSimulationWithRoughness.py index 0bfd1934037e6400478ef43141fd0d10c235985a..e876f424391e89a24be513b800d487f4fdd38cca 100755 --- a/rawEx/specular/SpecularSimulationWithRoughness.py +++ b/rawEx/specular/SpecularSimulationWithRoughness.py @@ -47,5 +47,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/specular/TOFRWithResolution.py b/rawEx/specular/TOFRWithResolution.py index cb89363184392ac6b33a6453ac13be7ef8a3a2da..51bfcf7e692e46852412d419ab1ae421a74be735 100755 --- a/rawEx/specular/TOFRWithResolution.py +++ b/rawEx/specular/TOFRWithResolution.py @@ -37,5 +37,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/specular/TimeOfFlightReflectometry.py b/rawEx/specular/TimeOfFlightReflectometry.py index 2622363510f792b2c77b006b0494d3cca7552438..396fe96188e74785d7b37d473f3472cd739b0ac0 100755 --- a/rawEx/specular/TimeOfFlightReflectometry.py +++ b/rawEx/specular/TimeOfFlightReflectometry.py @@ -29,5 +29,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/specular/VsGenx.py b/rawEx/specular/VsGenx.py index a2a60a5f2be842763ca577d77c8321422a850499..537566a2cf6a0c836ed2fc1c44814b2f6afe1ed8 100755 --- a/rawEx/specular/VsGenx.py +++ b/rawEx/specular/VsGenx.py @@ -59,6 +59,13 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + plt.legend(['GenX', 'BornAgain'], loc='upper right') + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) plt.legend(['GenX', 'BornAgain'], loc='upper right') - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/varia/Depthprobe1.py b/rawEx/varia/Depthprobe1.py index 804765625ac698f8c1b5a1e29736463f7f34fbd2..0cced05a9080a91a93cab89eb5d48ae91e52eada 100755 --- a/rawEx/varia/Depthprobe1.py +++ b/rawEx/varia/Depthprobe1.py @@ -39,8 +39,14 @@ def run_example(flags=0): sample = get_sample() simulation = get_simulation(sample, flags) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> if __name__ == '__main__': diff --git a/rawEx/varia/MaterialProfile.py b/rawEx/varia/MaterialProfile.py index 4cb069973f9e25d224fcf0c08d7c4ecad0eaf629..8ac4386c5dad3fb254cb42b8cb9eacfb3c4d8f2e 100755 --- a/rawEx/varia/MaterialProfile.py +++ b/rawEx/varia/MaterialProfile.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 """ -Plot SLD and magnetization profiles for a +Plot SLD and magnetization profiles for a multilayer sample with rough interfaces. """ @@ -17,7 +17,7 @@ def get_sample(): B_ni = R3(-5e7, 0, 0) material_ni = ba.MaterialBySLD("Ni", 9.4245e-06, 0, B_ni) B_substrate = R3(1e8, 0, 0) - material_substrate = ba.MaterialBySLD("SiSubstrate", 2.0704e-06, 0, + material_substrate = ba.MaterialBySLD("SiSubstrate", 2.0704e-06, 0, B_substrate) # layers @@ -43,14 +43,14 @@ def get_sample(): if __name__ == '__main__': - sample = get_sample() + sample = get_sample() n_points = 400 - z_min, z_max = ba.defaultMaterialProfileLimits(sample) + z_min, z_max = ba.defaultMaterialProfileLimits(sample) z_points = ba.generateZValues(n_points, z_min, z_max) sld = ba.materialProfileSLD(sample, n_points, z_min, z_max) - mag_X = ba.magnetizationProfile(sample, "X", n_points, z_min, z_max) - + mag_X = ba.magnetizationProfile(sample, "X", n_points, z_min, z_max) + plt.subplot(2, 1, 1) plt.plot(z_points, np.real(sld)) plt.title("Re(SLD)") @@ -60,5 +60,9 @@ if __name__ == '__main__': plt.title("X magnetization") plt.tight_layout() - - bp.show_or_export() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.export(**plotargs) + <%- else -%> + plt.show() + <%- end -%> diff --git a/rawEx/varia/MaterialProfileWithParticles.py b/rawEx/varia/MaterialProfileWithParticles.py index 7bd0a45fb3ea46425184198962f8514c97be473f..1eaadfe0c1e10e5fcd8e4d2fd75dcbb8b2a4adaf 100755 --- a/rawEx/varia/MaterialProfileWithParticles.py +++ b/rawEx/varia/MaterialProfileWithParticles.py @@ -43,5 +43,9 @@ if __name__ == '__main__': plt.figure() plt.plot(zpoints, np.real(slds)) - - bp.show_or_export() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.export(**plotargs) + <%- else -%> + plt.show() + <%- end -%> diff --git a/rawEx/varia/OpaqueProfile1.py b/rawEx/varia/OpaqueProfile1.py index 9600d2cbe606b1f97df1fb7f0787758672141350..285ec5212c2cb6b51fb9b11a1221058d9425666e 100755 --- a/rawEx/varia/OpaqueProfile1.py +++ b/rawEx/varia/OpaqueProfile1.py @@ -38,7 +38,7 @@ def get_simulation(sample): """ Returns a depth-probe simulation. """ - nz = bp.simargs['n'] + nz = 500 # bp.simargs['n'] na = 10*nz scan = ba.AlphaScan(na, ai_min, ai_max) @@ -53,8 +53,14 @@ def get_simulation(sample): if __name__ == '__main__': - bp.parse_args(sim_n=500, aspect='auto', intensity_max=1, intensity_min=1e-200) sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_args(aspect='auto', intensity_max=1, intensity_min=1e-200) + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) + plt.show() + <%- end -%> diff --git a/rawEx/varia/Resonator.py b/rawEx/varia/Resonator.py index 3005bc3fae91c2d2e385e0b6746473d0c7f9ca37..68dd785ba115cc28cc9be22247f7dd732b84278d 100755 --- a/rawEx/varia/Resonator.py +++ b/rawEx/varia/Resonator.py @@ -86,5 +86,11 @@ if __name__ == '__main__': sample = get_sample() simulation = get_simulation(sample) result = simulation.simulate() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_simulation_result(result, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_simulation_result(result) - bp.show_or_export() + plt.show() + <%- end -%> diff --git a/rawEx/varia/RoughSurface.py b/rawEx/varia/RoughSurface.py index ea832c30dddb5d6fcd5260f91aa9bd21331ae7e0..36d7e16894b1d9144b06e86b3c13c9f86804868c 100755 --- a/rawEx/varia/RoughSurface.py +++ b/rawEx/varia/RoughSurface.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 """ -Generates random rough surface of the sample with the given +Generates random rough surface of the sample with the given heights statistics and lateral roughness spectrum. """ @@ -9,36 +9,36 @@ import bornagain as ba from bornagain import nm from matplotlib import pyplot as plt, gridspec -def plot(h): +def plot(h): fig = plt.figure(figsize=(10, 6)) gs = gridspec.GridSpec(3, 2) gs.update(left=0.1, right=0.48, wspace=0.15, hspace=0.5) # map fig.add_subplot(gs[:-1, :]) - plt.imshow(h, extent = [0, Lx, 0, Ly], cmap='inferno', aspect='auto') + plt.imshow(h, extent = [0, Lx, 0, Ly], cmap='inferno', aspect='auto') plt.colorbar() - + # psd - fig.add_subplot(gs[-1, 0]) + fig.add_subplot(gs[-1, 0]) factor = X_points*Y_points/np.sqrt(Lx*Ly) N = np.floor(X_points/2 + 1).astype(int) psd = abs(np.fft.rfft2(h)/factor)**2 psd_points_x = np.array([psd[0][i] for i in range(1, N)]) f_points_x = np.array([i/Lx for i in range(1, N)]) plt.plot(f_points_x, psd_points_x) - plt.yscale('log') + plt.yscale('log') plt.xscale('log') plt.title('PSD') plt.xlabel('$\\nu, nm^{-1}$') - + # hist fig.add_subplot(gs[-1, 1]) - plt.hist(h.flatten(), range=[-4*sigma, 4*sigma], + plt.hist(h.flatten(), range=[-4*sigma, 4*sigma], bins=300, color='black') plt.title('Height histogram') plt.xlabel('h, nm') - plt.tick_params(left = False, labelleft = False) + plt.tick_params(left = False, labelleft = False) plt.show() @@ -61,9 +61,14 @@ roughness = ba.LayerRoughness(autocorr, height_distribution) # generate roughness map roughness_map = ba.RoughnessMap(X_points, Y_points, Lx, Ly, roughness<%= sm ? ", 0" : "" %>) surface = roughness_map.generate() - + print("rms = {:.3}".format(np.std(surface)),"nm") -<%= sm ? "from bornagain import ba_plot as bp" : "plot(surface)" %> -<%= sm ? "plotargs = bp.parse_commandline()" : "" %> -<%= sm ? "bp.show_or_export(**plotargs)" : "" %> +<%- if sm -%> +from bornagain import ba_plot as bp +plotargs = bp.parse_commandline() +bp.export(**plotargs) +<%- else -%> +plot(surface) +plt.show() +<%- end -%> diff --git a/rawEx/varia/Transmission.py b/rawEx/varia/Transmission.py index 55f3af0cc2773f7ee4493688a0e0fd11d3ad50d1..c71c1e275c74fa8f257f0ad9d4cec0f95d7b1b31 100755 --- a/rawEx/varia/Transmission.py +++ b/rawEx/varia/Transmission.py @@ -34,4 +34,8 @@ def simulate(): return result.valAt(0) if __name__ == '__main__': - <%= sm ? "ba.check_scalar(simulate(), 0.2697579887696741, 200)" : "print(simulate())" %> + <%- if sm -%> + ba.check_scalar(simulate(), 0.2697579887696741, 200) + <%- else -%> + print(simulate()) + <%- end -%> diff --git a/rawEx/varia/TransmissionVsAlpha.py b/rawEx/varia/TransmissionVsAlpha.py index 63d0235cbe28f399d6fdb6d4c3cb446663d88c53..f15ce7bf1752ac391fd7beeecd6937282f0a5b48 100755 --- a/rawEx/varia/TransmissionVsAlpha.py +++ b/rawEx/varia/TransmissionVsAlpha.py @@ -38,4 +38,11 @@ if __name__ == '__main__': depths = [20, 40, 60] results = [simulate(d) for d in depths] bp.plot_multicurve(results) - bp.show_or_export() + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_multicurve(results, **plotargs) + bp.export(**plotargs) + <%- else -%> + bp.plot_multicurve(results) + plt.show() + <%- end -%> diff --git a/rawEx/varia/TransmissionVsDepth.py b/rawEx/varia/TransmissionVsDepth.py index c9ea99ce2ed79f6ecaf9b1c32105884a99e5d7e5..0cfd119f20407194f2bd525a34cf3733b072cd97 100755 --- a/rawEx/varia/TransmissionVsDepth.py +++ b/rawEx/varia/TransmissionVsDepth.py @@ -36,5 +36,11 @@ if __name__ == '__main__': sample = get_sample() angles = [0.4, 0.5, 0.6, 0.65, 0.7] results = [simulate(sample, ai) for ai in angles] + <%- if sm -%> + plotargs = bp.parse_commandline() + bp.plot_multicurve(results, **plotargs) + bp.export(**plotargs) + <%- else -%> bp.plot_multicurve(results) - bp.show_or_export() + plt.show() + <%- end -%>