diff --git a/Examples/python/fitting/ex01_SampleParametersIntro/SampleParametersIntro.py b/Examples/python/fitting/ex01_SampleParametersIntro/SampleParametersIntro.py index 66b9e6d337202f60c3286107e9da136294c8d1d6..5eb044affbfbafd17d19fcba708418cc5b9eaf1e 100644 --- a/Examples/python/fitting/ex01_SampleParametersIntro/SampleParametersIntro.py +++ b/Examples/python/fitting/ex01_SampleParametersIntro/SampleParametersIntro.py @@ -11,8 +11,8 @@ from bornagain import degree, angstrom, nanometer def get_sample(): """ - Build and return the sample representing cylinders and prisms on top of - substrate without interference. Sample is made for fixed set of parameters. + Returns a sample with uncorrelated cylinders and prisms on a substrate. + Parameter set is fixed. """ # defining materials m_air = ba.HomogeneousMaterial("Air", 0.0, 0.0) @@ -45,7 +45,8 @@ def get_simulation(): Create and return GISAXS simulation with beam and detector defined """ simulation = ba.GISASSimulation() - simulation.setDetectorParameters(100, -1.0*degree, 1.0*degree, 100, 0.0*degree, 2.0*degree) + simulation.setDetectorParameters(100, -1.0*degree, 1.0*degree, + 100, 0.0*degree, 2.0*degree) simulation.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) return simulation @@ -73,16 +74,17 @@ def run_simulations(): results.append(simulation.getIntensityData()) # simulation #2 - # one sample parameter (height of the cylinder) is changed using exact parameter name + # one sample parameter (cylinder height) is changed using exact parameter name sample.setParameterValue( - "/MultiLayer/Layer0/ParticleLayout/Particle0/Cylinder/Height", 10.0*nanometer) + "/MultiLayer/Layer0/ParticleLayout/Particle0/Cylinder/Height", + 10.0*nanometer) simulation.setSample(sample) simulation.runSimulation() results.append(simulation.getIntensityData()) # simulation #3 - # all parameters matching criteria will be changed (height of the cylinder in this case) + # all parameters matching criteria will be changed (cylinder height in this case) sample.setParameterValue("*/Cylinder/Height", 100.0*nanometer) simulation.setSample(sample) simulation.runSimulation() @@ -91,7 +93,7 @@ def run_simulations(): # simulation #4 # all parameters which are matching criteria will be changed sample.setParameterValue("*/Cylinder/Height", 10.0*nanometer) - # both ba.FormFactorPrism3/half_side and ba.FormFactorPrism3/height will be set to 10 nanometer + # set ba.FormFactorPrism3/half_side and ba.FormFactorPrism3/height to 10 nm sample.setParameterValue("*/Prism3/*", 10.0*nanometer) simulation.setSample(sample) simulation.runSimulation() @@ -107,8 +109,11 @@ def draw_results(results): plt.figure(1) for nplot, hist in enumerate(results): plt.subplot(2, 2, nplot+1) - plt.imshow(hist.getArray(), norm=matplotlib.colors.LogNorm(1, hist.getMaximum()), - extent=[hist.getXmin()/degree, hist.getXmax()/degree, hist.getYmin()/degree, hist.getYmax()/degree]) + plt.imshow( + hist.getArray(), + norm=matplotlib.colors.LogNorm(1, hist.getMaximum()), + extent=[hist.getXmin()/degree, hist.getXmax()/degree, + hist.getYmin()/degree, hist.getYmax()/degree]) plt.show() @@ -116,5 +121,3 @@ def draw_results(results): if __name__ == '__main__': results = run_simulations() draw_results(results) - - diff --git a/Examples/python/fitting/ex02_FitCylindersAndPrisms/FitCylindersPrisms.py b/Examples/python/fitting/ex02_FitCylindersAndPrisms/FitCylindersPrisms.py index 448e2d3e66a592fdb9164840e61ac8b5ecd9fb40..3017dd65ad37be0ecc1a908e3ee60af91d1a90ce 100644 --- a/Examples/python/fitting/ex02_FitCylindersAndPrisms/FitCylindersPrisms.py +++ b/Examples/python/fitting/ex02_FitCylindersAndPrisms/FitCylindersPrisms.py @@ -7,8 +7,7 @@ from bornagain import degree, angstrom, nanometer def get_sample(): """ - Build the sample representing cylinders and pyramids on top of - substrate without interference. + Returns a sample with uncorrelated cylinders and prisms on a substrate. """ # defining materials m_air = ba.HomogeneousMaterial("Air", 0.0, 0.0) @@ -38,10 +37,11 @@ def get_sample(): def get_simulation(): """ - Create GISAXS simulation with beam and detector defined + Returns a GISAXS simulation with beam and detector defined """ simulation = ba.GISASSimulation() - simulation.setDetectorParameters(100, -1.0*degree, 1.0*degree, 100, 0.0*degree, 2.0*degree) + simulation.setDetectorParameters(100, -1.0*degree, 1.0*degree, + 100, 0.0*degree, 2.0*degree) simulation.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) return simulation @@ -54,17 +54,22 @@ def run_fitting(): simulation = get_simulation() simulation.setSample(sample) - real_data = IntensityDataIOFactory.readIntensityData('refdata_fitcylinderprisms.int.gz') + real_data = IntensityDataIOFactory.readIntensityData( + 'refdata_fitcylinderprisms.int.gz') fit_suite = ba.FitSuite() fit_suite.addSimulationAndRealData(simulation, real_data) fit_suite.initPrint(10) # setting fitting parameters with starting values - fit_suite.addFitParameter("*Cylinder/Height", 4.*nanometer, ba.AttLimits.lowerLimited(0.01)) - fit_suite.addFitParameter("*Cylinder/Radius", 6.*nanometer, ba.AttLimits.lowerLimited(0.01)) - fit_suite.addFitParameter("*Prism3/Height", 4.*nanometer, ba.AttLimits.lowerLimited(0.01)) - fit_suite.addFitParameter("*Prism3/Length", 12.*nanometer, ba.AttLimits.lowerLimited(0.01)) + fit_suite.addFitParameter("*Cylinder/Height", 4.*nanometer, + ba.AttLimits.lowerLimited(0.01)) + fit_suite.addFitParameter("*Cylinder/Radius", 6.*nanometer, + ba.AttLimits.lowerLimited(0.01)) + fit_suite.addFitParameter("*Prism3/Height", 4.*nanometer, + ba.AttLimits.lowerLimited(0.01)) + fit_suite.addFitParameter("*Prism3/Length", 12.*nanometer, + ba.AttLimits.lowerLimited(0.01)) # running fit fit_suite.runFit() diff --git a/Examples/python/fitting/ex02_FitCylindersAndPrisms/FitCylindersPrisms_detailed.py b/Examples/python/fitting/ex02_FitCylindersAndPrisms/FitCylindersPrisms_detailed.py index 890f3d217d79e9cefc0f7dd5a979a33da48a2782..e1255f70cbe0da6bf5c6a03cb6492d005348a3c4 100644 --- a/Examples/python/fitting/ex02_FitCylindersAndPrisms/FitCylindersPrisms_detailed.py +++ b/Examples/python/fitting/ex02_FitCylindersAndPrisms/FitCylindersPrisms_detailed.py @@ -1,7 +1,9 @@ """ Fitting example: 4 parameters fit with simple output -This is more detailed version of ba.FitCylindersPrisms.py. We show how to generate "real" data and how to draw fit progress. -Please take a note, that performance here is determined by poor performance of matplotlib drawing routines. +This is more detailed version of ba.FitCylindersPrisms.py. +We show how to generate "real" data and how to draw fit progress. +Please take a note, that performance here is determined +by poor performance of matplotlib drawing routines. """ import matplotlib @@ -15,8 +17,7 @@ from bornagain import degree, angstrom, nanometer def get_sample(cylinder_height=1.0*nanometer, cylinder_radius=1.0*nanometer, prism_length=2.0*nanometer, prism_height=1.0*nanometer): """ - Build the sample representing cylinders and pyramids on top of - substrate without interference. + Returns a sample with uncorrelated cylinders and prisms on a substrate. """ # defining materials m_air = ba.HomogeneousMaterial("Air", 0.0, 0.0) @@ -47,7 +48,8 @@ def get_sample(cylinder_height=1.0*nanometer, cylinder_radius=1.0*nanometer, def create_real_data(): """ Generating "real" data by adding noise to the simulated data. - This function has been used once to generate refdata_fitcylinderprisms.int located in same directory + This function has been used once to generate refdata_fitcylinderprisms.int + located in same directory. """ # creating sample with set of parameters we will later try to find during the fit sample = get_sample(5.0*nanometer, 5.0*nanometer, 5.0*nanometer, 5.0*nanometer) @@ -68,23 +70,26 @@ def create_real_data(): real_data.setBinContent(i, noisy_amplitude) # ucomment line to save generated data on disk - #IntensityDataIOFactory.writeIntensityData(real_data, 'refdata_fitcylinderprisms.int') + #IntensityDataIOFactory.writeIntensityData( + # real_data, 'refdata_fitcylinderprisms.int') return real_data def get_simulation(): """ - Create GISAXS simulation with beam and detector defined + Returns a GISAXS simulation with beam and detector defined """ simulation = ba.GISASSimulation() - simulation.setDetectorParameters(100, -1.0*degree, 1.0*degree, 100, 0.0*degree, 2.0*degree) + simulation.setDetectorParameters(100, -1.0*degree, 1.0*degree, + 100, 0.0*degree, 2.0*degree) simulation.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) return simulation class DrawObserver(ba.IFitObserver): """ - Draws fit progress every nth iteration. This class has to be attached to ba.FitSuite via attachObserver method. + Draws fit progress every nth iteration. + This class has to be attached to ba.FitSuite via attachObserver method. ba.FitSuite kernel will call DrawObserver's update() method every n'th iteration. It is up to the user what to do here. """ @@ -98,29 +103,37 @@ class DrawObserver(ba.IFitObserver): def plot(self, data, title, nplot, min=1, max=1e6): plt.subplot(2, 2, nplot) plt.subplots_adjust(wspace=0.2, hspace=0.2) - im = plt.imshow(data.getArray(), - norm=matplotlib.colors.LogNorm(min, max), - extent=[data.getXmin()/degree, data.getXmax()/degree, data.getYmin()/degree, data.getYmax()/degree]) + im = plt.imshow( + data.getArray(), + norm=matplotlib.colors.LogNorm(min, max), + extent=[data.getXmin()/degree, data.getXmax()/degree, + data.getYmin()/degree, data.getYmax()/degree]) plt.colorbar(im) plt.title(title) def update(self, fit_suite): self.fig.clf() real_data = fit_suite.getRealData() - self.plot(real_data, "\"Real\" data", nplot=1, min=1.0, max=real_data.getMaximum()) - self.plot(fit_suite.getSimulationData(), "Simulated data", nplot=2, min=1.0, max=real_data.getMaximum()) - self.plot(fit_suite.getChiSquaredMap(), "Chi2 map", nplot=3, min=0.001, max=10.0) + self.plot(real_data, "\"Real\" data", + nplot=1, min=1.0, max=real_data.getMaximum()) + self.plot(fit_suite.getSimulationData(), "Simulated data", + nplot=2, min=1.0, max=real_data.getMaximum()) + self.plot(fit_suite.getChiSquaredMap(), "Chi2 map", + + nplot=3, min=0.001, max=10.0) plt.subplot(2, 2, 4) plt.title('Parameters') plt.axis('off') plt.text(0.01, 0.85, "Iterations " + '{:d} {:s}'. - format(fit_suite.getNumberOfIterations(), fit_suite.getMinimizer().getMinimizerName())) + format(fit_suite.getNumberOfIterations(), + fit_suite.getMinimizer().getMinimizerName())) plt.text(0.01, 0.75, "Chi2 " + '{:8.4f}'.format(fit_suite.getChi2())) fitpars = fit_suite.getFitParameters() for i in range(0, fitpars.size()): - plt.text(0.01, 0.55 - i*0.1, '{:30.30s}: {:6.3f}'.format(fitpars[i].getName(), fitpars[i].getValue())) - + plt.text(0.01, 0.55 - i*0.1, + '{:30.30s}: {:6.3f}'.format(fitpars[i].getName(), + fitpars[i].getValue())) plt.draw() plt.pause(0.01) @@ -152,10 +165,14 @@ def run_fitting(): fit_suite.attachObserver(draw_observer) # setting fitting parameters with starting values - fit_suite.addFitParameter("*Cylinder/Height", 4.*nanometer, ba.AttLimits.lowerLimited(0.01)) - fit_suite.addFitParameter("*Cylinder/Radius", 6.*nanometer, ba.AttLimits.lowerLimited(0.01)) - fit_suite.addFitParameter("*Prism3/Height", 4.*nanometer, ba.AttLimits.lowerLimited(0.01)) - fit_suite.addFitParameter("*Prism3/BaseEdge", 12.*nanometer, ba.AttLimits.lowerLimited(0.01)) + fit_suite.addFitParameter("*Cylinder/Height", 4.*nanometer, + ba.AttLimits.lowerLimited(0.01)) + fit_suite.addFitParameter("*Cylinder/Radius", 6.*nanometer, + ba.AttLimits.lowerLimited(0.01)) + fit_suite.addFitParameter("*Prism3/Height", 4.*nanometer, + ba.AttLimits.lowerLimited(0.01)) + fit_suite.addFitParameter("*Prism3/BaseEdge", 12.*nanometer, + ba.AttLimits.lowerLimited(0.01)) # running fit fit_suite.runFit() diff --git a/Examples/python/fitting/ex03_FitSpheresInHexLattice/FitSpheresInHexLattice.py b/Examples/python/fitting/ex03_FitSpheresInHexLattice/FitSpheresInHexLattice.py index 83d7eab99cf4b190cd8172d877db3da0beafe278..12546d287d55d833ecc7db72a98f067670f2098d 100644 --- a/Examples/python/fitting/ex03_FitSpheresInHexLattice/FitSpheresInHexLattice.py +++ b/Examples/python/fitting/ex03_FitSpheresInHexLattice/FitSpheresInHexLattice.py @@ -11,8 +11,8 @@ from bornagain import degree, angstrom, nanometer def get_sample(radius=5*nanometer, lattice_constant=10*nanometer): """ - Build the sample representing cylinders and pyramids on top of - substrate without interference. + Returns a sample with cylinders and pyramids on a substrate, + forming a hexagonal lattice. """ m_air = ba.HomogeneousMaterial("Air", 0.0, 0.0) m_substrate = ba.HomogeneousMaterial("Substrate", 6e-6, 2e-8) @@ -43,7 +43,8 @@ def get_simulation(): Create and return GISAXS simulation with beam and detector defined """ simulation = ba.GISASSimulation() - simulation.setDetectorParameters(100, -1.0*degree, 1.0*degree, 100, 0.0*degree, 2.0*degree) + simulation.setDetectorParameters(100, -1.0*degree, 1.0*degree, + 100, 0.0*degree, 2.0*degree) simulation.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) return simulation @@ -92,8 +93,10 @@ def run_fitting(): fit_suite.attachObserver(draw_observer) # this fit parameter will change both length_1 and length_2 simultaneously - fit_suite.addFitParameter("*2DLattice/LatticeLength*", 8.*nanometer, ba.AttLimits.limited(4., 12.)) - fit_suite.addFitParameter("*/FullSphere/Radius", 8.*nanometer, ba.AttLimits.limited(4., 12.)) + fit_suite.addFitParameter( + "*2DLattice/LatticeLength*", 8.*nanometer, ba.AttLimits.limited(4., 12.)) + fit_suite.addFitParameter( + "*/FullSphere/Radius", 8.*nanometer, ba.AttLimits.limited(4., 12.)) # running fit fit_suite.runFit() @@ -108,4 +111,3 @@ def run_fitting(): if __name__ == '__main__': run_fitting() plt.show() - diff --git a/Examples/python/fitting/ex03_FitSpheresInHexLattice/FitSpheresInHexLattice_builder.py b/Examples/python/fitting/ex03_FitSpheresInHexLattice/FitSpheresInHexLattice_builder.py index ea0773ad2b57c7f6fb2028bb91baaed01e673f0d..11d8e4a5a88c69cc412459a18ac6574d808669e6 100644 --- a/Examples/python/fitting/ex03_FitSpheresInHexLattice/FitSpheresInHexLattice_builder.py +++ b/Examples/python/fitting/ex03_FitSpheresInHexLattice/FitSpheresInHexLattice_builder.py @@ -13,7 +13,8 @@ from bornagain import degree, angstrom, nanometer class MySampleBuilder(ISampleBuilder): """ Sample builder is used to build complex samples from set of parameters. - Given builder produces the sample representing spheres at hex lattice using two parameters as an input: + Given builder produces the sample representing spheres at hex lattice + using two parameters as an input: radius - radius of spheres lattice_constant - hexagonal lattice constant """ @@ -25,7 +26,8 @@ class MySampleBuilder(ISampleBuilder): self.lattice_constant = ctypes.c_double(10.0*nanometer) # register parameters self.registerParameter("radius", ctypes.addressof(self.radius)) - self.registerParameter("lattice_constant", ctypes.addressof(self.lattice_constant)) + self.registerParameter("lattice_constant", + ctypes.addressof(self.lattice_constant)) # constructs the sample for current values of parameters def buildSample(self): @@ -38,7 +40,8 @@ class MySampleBuilder(ISampleBuilder): particle_layout = ba.ParticleLayout() particle_layout.addParticle(sphere) - interference = ba.InterferenceFunction2DLattice.createHexagonal(self.lattice_constant.value) + interference = ba.InterferenceFunction2DLattice.createHexagonal( + self.lattice_constant.value) pdf = ba.FTDecayFunction2DCauchy(10*nanometer, 10*nanometer) interference.setDecayFunction(pdf) @@ -56,10 +59,11 @@ class MySampleBuilder(ISampleBuilder): def get_simulation(): """ - Create and return GISAXS simulation with beam and detector defined + Returns a GISAXS simulation with beam and detector defined. """ simulation = ba.GISASSimulation() - simulation.setDetectorParameters(100, -1.0*degree, 1.0*degree, 100, 0.0*degree, 2.0*degree) + simulation.setDetectorParameters(100, -1.0*degree, 1.0*degree, + 100, 0.0*degree, 2.0*degree) simulation.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) return simulation @@ -111,7 +115,8 @@ def run_fitting(): # setting fitting parameters with starting values fit_suite.addFitParameter("*radius", 8.*nanometer, ba.AttLimits.limited(4., 12.)) - fit_suite.addFitParameter("*lattice_constant", 8.*nanometer, ba.AttLimits.limited(4., 12.)) + fit_suite.addFitParameter("*lattice_constant", + 8.*nanometer, ba.AttLimits.limited(4., 12.)) # running fit fit_suite.runFit() @@ -126,4 +131,3 @@ def run_fitting(): if __name__ == '__main__': run_fitting() plt.show() - diff --git a/Examples/python/fitting/ex04_FitScaleAndShift/FitScaleAndShift.py b/Examples/python/fitting/ex04_FitScaleAndShift/FitScaleAndShift.py index bdd080ab3f73d52860985409c8600c74c7403e39..c4b0b954c963b883c489e94f804d661b60681487 100644 --- a/Examples/python/fitting/ex04_FitScaleAndShift/FitScaleAndShift.py +++ b/Examples/python/fitting/ex04_FitScaleAndShift/FitScaleAndShift.py @@ -2,7 +2,8 @@ Fitting example: looking for background and scale factors. Real data contains some "unknown" background and scale factors. -In the fit we are trying to find cylinder radius and height, scale and background factors. +In the fit we are trying to find cylinder radius and height, +scale and background factors. """ from __future__ import print_function @@ -43,7 +44,8 @@ def get_simulation(): Create and return GISAXS simulation with beam and detector defined """ simulation = ba.GISASSimulation() - simulation.setDetectorParameters(100, -1.0*degree, 1.0*degree, 100, 0.0*degree, 2.0*degree) + simulation.setDetectorParameters(100, -1.0*degree, 1.0*degree, + 100, 0.0*degree, 2.0*degree) simulation.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) simulation.setBeamIntensity(1e12) return simulation @@ -51,9 +53,11 @@ def get_simulation(): def create_real_data(): """ - Generating "real" data by adding noise, background and scale to the simulated data. + Generating "real" data by adding noise, background and scale + to the simulated data. Cylinder radius is set to 5nm, cylinder height to 10nm. - During the fit we will try to find cylinder height and radius and scale, background factors. + During the fit we will try to find cylinder height and radius and + scale, background factors. """ sample = get_sample(5.0*nanometer, 10.0*nanometer) @@ -67,7 +71,7 @@ def create_real_data(): background = 100 real_data.scale(scale) - # spoiling simulated data with the noise and adding background to produce "real" data + # spoil simulated data with the noise, and add background to produce "real" data noise_factor = 1.0 for i in range(0, real_data.getTotalNumberOfBins()): amplitude = real_data.getBinContent(i) @@ -102,13 +106,18 @@ def run_fitting(): draw_observer = ba.DefaultFitObserver(draw_every_nth=10) fit_suite.attachObserver(draw_observer) - fit_suite.getFitObjects().printParameters() # prints all defined parameters for sample and simulation + # print all defined parameters for sample and simulation + fit_suite.getFitObjects().printParameters() # setting fitting parameters with starting values - fit_suite.addFitParameter("*/Cylinder/Radius", 6.*nanometer, ba.AttLimits.limited(4., 8.)) - fit_suite.addFitParameter("*/Cylinder/Height", 9.*nanometer, ba.AttLimits.limited(8., 12.)) - fit_suite.addFitParameter("*/Normalizer/scale", 1.5, ba.AttLimits.limited(1.0, 3.0)) - fit_suite.addFitParameter("*/Normalizer/shift", 50., ba.AttLimits.limited(1, 500.)) + fit_suite.addFitParameter("*/Cylinder/Radius", 6.*nanometer, + ba.AttLimits.limited(4., 8.)) + fit_suite.addFitParameter("*/Cylinder/Height", 9.*nanometer, + ba.AttLimits.limited(8., 12.)) + fit_suite.addFitParameter("*/Normalizer/scale", 1.5, + ba.AttLimits.limited(1.0, 3.0)) + fit_suite.addFitParameter("*/Normalizer/shift", 50., + ba.AttLimits.limited(1, 500.)) # running fit fit_suite.runFit() @@ -123,4 +132,3 @@ def run_fitting(): if __name__ == '__main__': run_fitting() plt.show() - diff --git a/Examples/python/fitting/ex05_FitWithMasks/FitWithMasks.py b/Examples/python/fitting/ex05_FitWithMasks/FitWithMasks.py index 06447de33dc8e0b86d30f5951c4009e187c7f102..d02982b5d06233ae3eeea2ba464b78b0f029ef45 100644 --- a/Examples/python/fitting/ex05_FitWithMasks/FitWithMasks.py +++ b/Examples/python/fitting/ex05_FitWithMasks/FitWithMasks.py @@ -40,7 +40,8 @@ def get_simulation(): Create and return GISAXS simulation with beam and detector defined """ simulation = ba.GISASSimulation() - simulation.setDetectorParameters(100, -1.0*degree, 1.0*degree, 100, 0.0*degree, 2.0*degree) + simulation.setDetectorParameters(100, -1.0*degree, 1.0*degree, + 100, 0.0*degree, 2.0*degree) simulation.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) return simulation @@ -74,8 +75,9 @@ def add_mask_to_simulation(simulation): Here we demonstrate how to add masks to the simulation. Only unmasked areas will be simulated and then used during the fit. - Masks can have different geometrical shapes (ba.Rectangle, ba.Ellipse, Line) with the mask value either - "True" (detector bin is excluded from the simulation) or False (will be simulated). + Masks can have different geometrical shapes (ba.Rectangle, ba.Ellipse, Line) + with the mask value either "True" (detector bin is excluded from the simulation) + or False (will be simulated). Every subsequent mask override previously defined masks in this area. @@ -86,23 +88,31 @@ def add_mask_to_simulation(simulation): simulation.maskAll() # set mask to simulate pacman's head - simulation.addMask(ba.Ellipse(0.0*degree, 1.0*degree, 0.5*degree, 0.5*degree), False) + simulation.addMask( + ba.Ellipse(0.0*degree, 1.0*degree, 0.5*degree, 0.5*degree), False) # set mask for pacman's eye - simulation.addMask(ba.Ellipse(0.11*degree, 1.25*degree, 0.05*degree, 0.05*degree), True) + simulation.addMask( + ba.Ellipse(0.11*degree, 1.25*degree, 0.05*degree, 0.05*degree), True) # set mask for pacman's mouth - points = [[0.0*degree, 1.0*degree], [0.5*degree, 1.2*degree], [0.5*degree, 0.8*degree], [0.0*degree, 1.0*degree]] + points = [[0.0*degree, 1.0*degree], [0.5*degree, 1.2*degree], + [0.5*degree, 0.8*degree], [0.0*degree, 1.0*degree]] simulation.addMask(ba.Polygon(points), True) # giving pacman something to eat - simulation.addMask(ba.Rectangle(0.45*degree, 0.95*degree, 0.55*degree, 1.05*degree), False) - simulation.addMask(ba.Rectangle(0.61*degree, 0.95*degree, 0.71*degree, 1.05*degree), False) - simulation.addMask(ba.Rectangle(0.75*degree, 0.95*degree, 0.85*degree, 1.05*degree), False) + simulation.addMask( + ba.Rectangle(0.45*degree, 0.95*degree, 0.55*degree, 1.05*degree), False) + simulation.addMask( + ba.Rectangle(0.61*degree, 0.95*degree, 0.71*degree, 1.05*degree), False) + simulation.addMask( + ba.Rectangle(0.75*degree, 0.95*degree, 0.85*degree, 1.05*degree), False) # other mask's shapes are possible too # simulation.removeMasks() - # simulation.addMask(ba.Ellipse(0.11*degree, 1.25*degree, 1.0*degree, 0.5*degree, 45.0*degree), True) # rotated ellipse + # # rotated ellipse: + # simulation.addMask(ba.Ellipse(0.11*degree, 1.25*degree, + # 1.0*degree, 0.5*degree, 45.0*degree), True) # simulation.addMask(Line(-1.0*degree, 0.0*degree, 1.0*degree, 2.0*degree), True) # simulation.addMask(ba.HorizontalLine(1.0*degree), False) # simulation.addMask(ba.VerticalLine(0.0*degree), False) @@ -128,8 +138,10 @@ def run_fitting(): fit_suite.attachObserver(draw_observer) # setting fitting parameters with starting values - fit_suite.addFitParameter("*/Cylinder/Radius", 6.*nanometer, ba.AttLimits.limited(4., 8.)) - fit_suite.addFitParameter("*/Cylinder/Height", 9.*nanometer, ba.AttLimits.limited(8., 12.)) + fit_suite.addFitParameter( + "*/Cylinder/Radius", 6.*nanometer, ba.AttLimits.limited(4., 8.)) + fit_suite.addFitParameter( + "*/Cylinder/Height", 9.*nanometer, ba.AttLimits.limited(8., 12.)) # running fit fit_suite.runFit() @@ -145,4 +157,3 @@ def run_fitting(): if __name__ == '__main__': run_fitting() plt.show() - diff --git a/Examples/python/fitting/ex06_FitStrategies/FitStrategyAdjustMinimizer.py b/Examples/python/fitting/ex06_FitStrategies/FitStrategyAdjustMinimizer.py index 4cb853662f0c68b06068105316b9aa530b225bc7..55a0d9409e48089bc7048a85126b2152d9ac84a8 100644 --- a/Examples/python/fitting/ex06_FitStrategies/FitStrategyAdjustMinimizer.py +++ b/Examples/python/fitting/ex06_FitStrategies/FitStrategyAdjustMinimizer.py @@ -1,10 +1,12 @@ """ Two parameter fit of cylinders. -In this example we are trying to find cylinder's height and radius using chain of minimizers. +In this example we are trying to find cylinder's height and radius +using chain of minimizers. -During the first fit round Genetic minimizer will be used. It will roughly look for possible local minimas. -After it is done, the second Minuit2 minimizer will continue to find the precise location of best minima -found on previous step. +During the first fit round Genetic minimizer will be used. +It will roughly look for possible local minimas. +After it is done, the second Minuit2 minimizer will continue +to find the precise location of best minima found on previous step. """ from __future__ import print_function @@ -18,8 +20,7 @@ from bornagain import degree, angstrom, nanometer def get_sample(radius=5*nanometer, height=5*nanometer): """ - Build the sample representing cylinders and pyramids on top of - substrate without interference. + Returns a sample with uncorrelated cylinders and pyramids on a substrate. """ m_air = ba.HomogeneousMaterial("Air", 0.0, 0.0) m_substrate = ba.HomogeneousMaterial("Substrate", 6e-6, 2e-8) @@ -41,13 +42,13 @@ def get_sample(radius=5*nanometer, height=5*nanometer): return multi_layer - def get_simulation(): """ - Create and return GISAXS simulation with beam and detector defined + Returns a GISAXS simulation with beam and detector defined. """ simulation = ba.GISASSimulation() - simulation.setDetectorParameters(100, 0.0*degree, 2.0*degree, 100, 0.0*degree, 2.0*degree) + simulation.setDetectorParameters(100, 0.0*degree, 2.0*degree, + 100, 0.0*degree, 2.0*degree) simulation.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) return simulation @@ -94,17 +95,23 @@ def run_fitting(): fit_suite.attachObserver(draw_observer) # setting fitting parameters with starting values - # Here we select starting values being quite far from true values to puzzle our minimizer's as much as possible - fit_suite.addFitParameter("*Height", 1.*nanometer, ba.AttLimits.limited(0.01, 30.), 0.04*nanometer) - fit_suite.addFitParameter("*Radius", 20.*nanometer, ba.AttLimits.limited(0.01, 30.), 0.06*nanometer) - - # Now we create first fig strategy which will run first minimization round using Genetic minimizer. - # Genetic minimizer is able to explore large parameter space without being trapped by some local minima. + # Here we select starting values being quite far from true values + # to puzzle our minimizer's as much as possible + fit_suite.addFitParameter( + "*Height", 1.*nanometer, ba.AttLimits.limited(0.01, 30.), 0.04*nanometer) + fit_suite.addFitParameter( + "*Radius", 20.*nanometer, ba.AttLimits.limited(0.01, 30.), 0.06*nanometer) + + # Now we create first fig strategy which will run first minimization round + # using the Genetic minimizer. + # The Genetic minimizer is able to explore large parameter space + # without being trapped by some local minima. strategy1 = ba.FitStrategyAdjustMinimizer("Genetic") strategy1.getMinimizerOptions().setMaxIterations(3) fit_suite.addFitStrategy(strategy1) - # Second fit strategy will use another minimizer. It starts from best parameters found in previous minimization + # Second fit strategy will use another minimizer. + # It starts from best parameters found in previous minimization # and then continues until fit converges. strategy2 = ba.FitStrategyAdjustMinimizer("Minuit2", "Migrad") fit_suite.addFitStrategy(strategy2) @@ -122,4 +129,3 @@ def run_fitting(): if __name__ == '__main__': run_fitting() plt.show() - diff --git a/Examples/python/fitting/ex07_FitAlongSlices/FitAlongSlices.py b/Examples/python/fitting/ex07_FitAlongSlices/FitAlongSlices.py index e3a3dca4e56225bbcb99cfd5593dcbf93d611960..41f9f6ff5cc3812c6716742ca039824dc350509b 100644 --- a/Examples/python/fitting/ex07_FitAlongSlices/FitAlongSlices.py +++ b/Examples/python/fitting/ex07_FitAlongSlices/FitAlongSlices.py @@ -17,7 +17,7 @@ alpha_slice_value = 0.2*degree # position of horizontal slice def get_sample(radius=5*nanometer, height=10*nanometer): """ - Build the sample representing cylinders on top of substrate without interference. + Returns a sample with uncorrelated cylinders on a substrate. """ m_air = ba.HomogeneousMaterial("Air", 0.0, 0.0) m_substrate = ba.HomogeneousMaterial("Substrate", 6e-6, 2e-8) @@ -44,7 +44,8 @@ def get_simulation(): Create and return GISAXS simulation with beam and detector defined """ simulation = ba.GISASSimulation() - simulation.setDetectorParameters(100, -1.0*degree, 1.0*degree, 100, 0.0*degree, 2.0*degree) + simulation.setDetectorParameters(100, -1.0*degree, 1.0*degree, + 100, 0.0*degree, 2.0*degree) simulation.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) return simulation @@ -58,7 +59,7 @@ def create_real_data(): simulation = get_simulation() simulation.setSample(sample) - simulation.runSimulation() + simulation.runSimulation() real_data = simulation.getIntensityData() # spoiling simulated data with the noise to produce "real" data @@ -75,7 +76,8 @@ def create_real_data(): class DrawObserver(ba.IFitObserver): """ - Draws fit progress every nth iteration. Here we plot slices along real and simulated images to see fit progress. + Draws fit progress every nth iteration. Here we plot slices along real + and simulated images to see fit progress. """ def __init__(self, draw_every_nth=10): @@ -87,25 +89,30 @@ class DrawObserver(ba.IFitObserver): def plot_real_data(self, data, nplot): plt.subplot(2, 2, nplot) plt.subplots_adjust(wspace=0.2, hspace=0.2) - im = plt.imshow(data.getArray(), - norm=matplotlib.colors.LogNorm(1.0, data.getMaximum()), - extent=[data.getXmin()/degree, data.getXmax()/degree, data.getYmin()/degree, data.getYmax()/degree]) + im = plt.imshow( + data.getArray(), + norm=matplotlib.colors.LogNorm(1.0, data.getMaximum()), + extent=[data.getXmin()/degree, data.getXmax()/degree, + data.getYmin()/degree, data.getYmax()/degree]) plt.colorbar(im) plt.title("\"Real\" data") plt.xlabel(r'$\phi_f$', fontsize=12) plt.ylabel(r'$\alpha_f$', fontsize=12) # line representing vertical slice - plt.plot([phi_slice_value / deg, phi_slice_value / deg], [data.getYmin() / deg, data.getYmax() / deg], + plt.plot([phi_slice_value / deg, phi_slice_value / deg], + [data.getYmin() / deg, data.getYmax() / deg], color='gray', linestyle='-', linewidth=1) # line representing horizontal slice - plt.plot([data.getXmin() / deg, data.getXmax() / deg], [alpha_slice_value / deg, alpha_slice_value / deg], + plt.plot([data.getXmin() / deg, data.getXmax() / deg], + [alpha_slice_value / deg, alpha_slice_value / deg], color='gray', linestyle='-', linewidth=1) def plot_slices(self, slices, title, nplot): plt.subplot(2, 2, nplot) plt.subplots_adjust(wspace=0.2, hspace=0.3) for label, slice in slices: - plt.semilogy(slice.getBinCenters()/degree, slice.getBinValues(), label=label) + plt.semilogy(slice.getBinCenters()/degree, + slice.getBinValues(), label=label) plt.xlim(slice.getXmin()/degree, slice.getXmax()/degree) plt.ylim(1.0, slice.getMaximum()*10.0) plt.legend(loc='upper right') @@ -116,11 +123,14 @@ class DrawObserver(ba.IFitObserver): plt.title('Parameters') plt.axis('off') plt.text(0.01, 0.85, "Iteration " + '{:d} {:s}'. - format(fit_suite.getNumberOfIterations(), fit_suite.getMinimizer().getMinimizerName())) + format(fit_suite.getNumberOfIterations(), + fit_suite.getMinimizer().getMinimizerName())) plt.text(0.01, 0.75, "Chi2 " + '{:8.4f}'.format(fit_suite.getChi2())) fitpars = fit_suite.getFitParameters() for i in range(0, fitpars.size()): - plt.text(0.01, 0.55 - i*0.1, '{:30.30s}: {:6.3f}'.format(fitpars[i].getName(), fitpars[i].getValue())) + plt.text(0.01, 0.55 - i*0.1, + '{:30.30s}: {:6.3f}'.format(fitpars[i].getName(), + fitpars[i].getValue())) plt.draw() plt.pause(0.01) @@ -143,7 +153,8 @@ class DrawObserver(ba.IFitObserver): ("real", real_data.projectionX(alpha_slice_value)), ("simul", simul_data.projectionX(alpha_slice_value)) ] - title = "Horizontal slice at alpha =" + '{:3.1f}'.format(alpha_slice_value/degree) + title = ( "Horizontal slice at alpha =" + + '{:3.1f}'.format(alpha_slice_value/degree) ) self.plot_slices(slices, title, nplot=2) # vertical slices @@ -172,8 +183,9 @@ def run_fitting(): simulation = get_simulation() simulation.setSample(sample) - # At this point we mask all the detector and then unmask two areas corresponding to the vertical - # and horizontal lines. This will make simulation/fitting to be performed along slices only. + # At this point we mask all the detector and then unmask two areas + # corresponding to the vertical and horizontal lines. This will make + # simulation/fitting to be performed along slices only. simulation.maskAll() simulation.addMask(ba.HorizontalLine(alpha_slice_value), False) simulation.addMask(ba.VerticalLine(phi_slice_value), False) @@ -185,8 +197,10 @@ def run_fitting(): fit_suite.attachObserver(draw_observer) # setting fitting parameters with starting values - fit_suite.addFitParameter("*/Cylinder/Radius", 6.*nanometer, ba.AttLimits.limited(4., 8.)) - fit_suite.addFitParameter("*/Cylinder/Height", 9.*nanometer, ba.AttLimits.limited(8., 12.)) + fit_suite.addFitParameter( + "*/Cylinder/Radius", 6.*nanometer, ba.AttLimits.limited(4., 8.)) + fit_suite.addFitParameter( + "*/Cylinder/Height", 9.*nanometer, ba.AttLimits.limited(8., 12.)) # running fit fit_suite.runFit() diff --git a/Examples/python/fitting/ex08_SimultaneousFitOfTwoDatasets/SimultaneousFitOfTwoDatasets.py b/Examples/python/fitting/ex08_SimultaneousFitOfTwoDatasets/SimultaneousFitOfTwoDatasets.py index ffdf8002fa276dd67acb9651051e0dcce1688905..eeed493e497f71b103c27c889d4d5f69eec3c221 100644 --- a/Examples/python/fitting/ex08_SimultaneousFitOfTwoDatasets/SimultaneousFitOfTwoDatasets.py +++ b/Examples/python/fitting/ex08_SimultaneousFitOfTwoDatasets/SimultaneousFitOfTwoDatasets.py @@ -14,8 +14,7 @@ from bornagain import degree, angstrom, nanometer def get_sample(radius_a=4.0*nanometer, radius_b=4.0*nanometer, height=4.0*nanometer): """ - Build the sample representing cylinders and pyramids on top of - substrate without interference. + Returns a sample with uncorrelated cylinders and pyramids. """ m_air = ba.HomogeneousMaterial("Air", 0.0, 0.0) m_substrate = ba.HomogeneousMaterial("Substrate", 6e-6, 2e-8) @@ -39,10 +38,11 @@ def get_sample(radius_a=4.0*nanometer, radius_b=4.0*nanometer, height=4.0*nanome def get_simulation(incident_alpha=0.2): """ - Create and return GISAXS simulation with beam and detector defined + Returns a GISAXS simulation with beam and detector defined. """ simulation = ba.GISASSimulation() - simulation.setDetectorParameters(50, -1.5*degree, 1.5*degree, 50, 0.0*degree, 2.0*degree) + simulation.setDetectorParameters(50, -1.5*degree, 1.5*degree, + 50, 0.0*degree, 2.0*degree) simulation.setBeamParameters(1.0*angstrom, incident_alpha, 0.0*degree) return simulation @@ -51,7 +51,8 @@ def create_real_data(incident_alpha): """ Generating "real" data by adding noise to the simulated data. """ - sample = get_sample(radius_a=5.0*nanometer, radius_b=6.0*nanometer, height=8.0*nanometer) + sample = get_sample( + radius_a=5.0*nanometer, radius_b=6.0*nanometer, height=8.0*nanometer) simulation = get_simulation(incident_alpha) simulation.setSample(sample) @@ -73,7 +74,8 @@ def create_real_data(incident_alpha): class DrawObserver(ba.IFitObserver): """ - Draws fit progress every nth iteration. Real data, simulated data and chi2 map will be shown for both datasets. + Draws fit progress every nth iteration. Real data, simulated data + and chi2 map will be shown for both datasets. """ def __init__(self, draw_every_nth=10): ba.IFitObserver.__init__(self, draw_every_nth) @@ -82,10 +84,12 @@ class DrawObserver(ba.IFitObserver): plt.ion() def plot_colormap(self, data, title, min=1, max=1e6): - im = plt.imshow(data.getArray(), - norm=matplotlib.colors.LogNorm(min, max), - extent=[data.getXmin()/degree, data.getXmax()/degree, data.getYmin()/degree, data.getYmax()/degree], - aspect='auto') + im = plt.imshow( + data.getArray(), + norm=matplotlib.colors.LogNorm(min, max), + extent=[data.getXmin()/degree, data.getXmax()/degree, + data.getYmin()/degree, data.getYmax()/degree], + aspect='auto') plt.colorbar(im) plt.title(title) @@ -96,28 +100,36 @@ class DrawObserver(ba.IFitObserver): chi2_map = fit_suite.getChiSquaredMap(i_dataset) plt.subplot(canvas[i_dataset*3]) - self.plot_colormap(real_data, "\"Real\" data - #"+str(i_dataset+1), min=1.0, max=real_data.getMaximum()) + self.plot_colormap(real_data, "\"Real\" data - #"+str(i_dataset+1), + min=1.0, max=real_data.getMaximum()) plt.subplot(canvas[1+i_dataset*3]) - self.plot_colormap(simul_data, "Simulated data - #"+str(i_dataset+1), min=1.0, max=real_data.getMaximum()) + self.plot_colormap(simul_data, "Simulated data - #"+str(i_dataset+1), + min=1.0, max=real_data.getMaximum()) plt.subplot(canvas[2+i_dataset*3]) - self.plot_colormap(chi2_map, "Chi2 map - #"+str(i_dataset+1), min=0.001, max=10.0) + self.plot_colormap(chi2_map, "Chi2 map - #"+str(i_dataset+1), + min=0.001, max=10.0) def plot_fit_parameters(self, fit_suite, canvas): # fit parameters plt.subplot(canvas[6:]) plt.axis('off') plt.text(0.01, 0.95, "Iterations " + '{:d} {:s}'. - format(fit_suite.getNumberOfIterations(), fit_suite.getMinimizer().getMinimizerName())) + format(fit_suite.getNumberOfIterations(), + fit_suite.getMinimizer().getMinimizerName())) plt.text(0.01, 0.70, "Chi2 " + '{:8.4f}'.format(fit_suite.getChi2())) fitpars = fit_suite.getFitParameters() for i in range(0, fitpars.size()): - plt.text(0.01, 0.30 - i*0.3, '{:40.40s}: {:6.3f}'.format(fitpars[i].getName(), fitpars[i].getValue())) + plt.text(0.01, 0.30 - i*0.3, + '{:40.40s}: {:6.3f}'.format(fitpars[i].getName(), + fitpars[i].getValue())) def update(self, fit_suite): self.fig.clf() - # we divide figure to have 3x3 subplots, with two first rows occupying most of the space - canvas = matplotlib.gridspec.GridSpec(3, 3, width_ratios=[1, 1, 1], height_ratios=[4, 4, 1]) + # we divide figure to have 3x3 subplots, with two first rows occupying + # most of the space + canvas = matplotlib.gridspec.GridSpec( + 3, 3, width_ratios=[1, 1, 1], height_ratios=[4, 4, 1]) canvas.update(left=0.05, right=0.95, hspace=0.4, wspace=0.2) self.plot_datasets(fit_suite, canvas) @@ -150,9 +162,12 @@ def run_fitting(): fit_suite.attachObserver(draw_observer) # setting fitting parameters with starting values - fit_suite.addFitParameter("*/HemiEllipsoid/RadiusX", 4.*nanometer, ba.AttLimits.limited(2., 10.)) - fit_suite.addFitParameter("*/HemiEllipsoid/RadiusY", 6.*nanometer, ba.AttLimits.fixed()) - fit_suite.addFitParameter("*/HemiEllipsoid/Height", 4.*nanometer, ba.AttLimits.limited(2., 10.)) + fit_suite.addFitParameter( + "*/HemiEllipsoid/RadiusX", 4.*nanometer, ba.AttLimits.limited(2., 10.)) + fit_suite.addFitParameter( + "*/HemiEllipsoid/RadiusY", 6.*nanometer, ba.AttLimits.fixed()) + fit_suite.addFitParameter( + "*/HemiEllipsoid/Height", 4.*nanometer, ba.AttLimits.limited(2., 10.)) # running fit fit_suite.runFit() diff --git a/Examples/python/fitting/ex10_FitGALAXIData/FitGALAXIData.py b/Examples/python/fitting/ex10_FitGALAXIData/FitGALAXIData.py index 5b34fb1f9428c6edc98f66d7f71758f6929c02e4..97d4d56bc3abc1177363a6ad75ce6bb7978d61f7 100644 --- a/Examples/python/fitting/ex10_FitGALAXIData/FitGALAXIData.py +++ b/Examples/python/fitting/ex10_FitGALAXIData/FitGALAXIData.py @@ -19,11 +19,12 @@ beam_xpos, beam_ypos = 597.1, 323.4 # in pixels def create_detector(): """ - Creates and returns GALAXY detector + Returns a model of the GALAXY detector """ u0 = beam_xpos*pilatus_pixel_size # in mm v0 = beam_ypos*pilatus_pixel_size # in mm - detector = ba.RectangularDetector(pilatus_npx, pilatus_npx*pilatus_pixel_size, pilatus_npy, pilatus_npy*pilatus_pixel_size) + detector = ba.RectangularDetector(pilatus_npx, pilatus_npx*pilatus_pixel_size, + pilatus_npy, pilatus_npy*pilatus_pixel_size) detector.setPerpendicularToDirectBeam(detector_distance, u0, v0) return detector @@ -39,7 +40,9 @@ def create_simulation(): # mask on reflected beam simulation.addMask(ba.Rectangle(101.9, 82.1, 103.7, 85.2), True) # detector resolution function - # simulation.setDetectorResolutionFunction(ba.ResolutionFunction2DGaussian(0.5*pilatus_pixel_size, 0.5*pilatus_pixel_size)) + # simulation.setDetectorResolutionFunction( + # ba.ResolutionFunction2DGaussian(0.5*pilatus_pixel_size, + # 0.5*pilatus_pixel_size)) # beam divergence # alpha_distr = ba.DistributionGaussian(alpha_i, 0.02*ba.degree) # simulation.addParameterDistribution("*/Beam/Alpha", alpha_distr, 5) @@ -69,9 +72,14 @@ def run_fitting(): fit_suite.addSimulationAndRealData(simulation, real_data) # setting fitting parameters with starting values - fit_suite.addFitParameter("*radius", 5.0*ba.nanometer, ba.AttLimits.limited(4.0, 6.0), 0.1*ba.nanometer) - fit_suite.addFitParameter("*sigma", 0.55, ba.AttLimits.limited(0.2, 0.8), 0.01*ba.nanometer) - fit_suite.addFitParameter("*distance", 27.*ba.nanometer, ba.AttLimits.limited(20, 70), 0.1*ba.nanometer) + fit_suite.addFitParameter( + "*radius", 5.0*ba.nanometer, ba.AttLimits.limited(4.0, 6.0), + 0.1*ba.nanometer) + fit_suite.addFitParameter( + "*sigma", 0.55, ba.AttLimits.limited(0.2, 0.8), 0.01*ba.nanometer) + fit_suite.addFitParameter( + "*distance", 27.*ba.nanometer, ba.AttLimits.limited(20, 70), + 0.1*ba.nanometer) use_two_minimizers_strategy = False if use_two_minimizers_strategy: @@ -79,7 +87,8 @@ def run_fitting(): strategy1.getMinimizerOptions().setMaxIterations(3) fit_suite.addFitStrategy(strategy1) - # Second fit strategy will use another algorithm. It will use best parameters found from previous minimization round. + # Second fit strategy will use another algorithm. + # It will use best parameters found from previous minimization round. strategy2 = ba.FitStrategyAdjustMinimizer("Minuit2", "Migrad") fit_suite.addFitStrategy(strategy2) diff --git a/Examples/python/fitting/ex10_FitGALAXIData/SampleBuilder.py b/Examples/python/fitting/ex10_FitGALAXIData/SampleBuilder.py index 6a80bcb3a0407c80f925ffe733aa91778d785096..dfa154d7842d8f57853b71b219cec8be3ffa6839 100644 --- a/Examples/python/fitting/ex10_FitGALAXIData/SampleBuilder.py +++ b/Examples/python/fitting/ex10_FitGALAXIData/SampleBuilder.py @@ -1,5 +1,6 @@ """ -3 layers system (substrate, teflon, air). Air layer is populated with spheres with some size distribution. +3 layers system (substrate, teflon, air). +Air layer is populated with spheres with some size distribution. """ import bornagain as ba import ctypes @@ -44,19 +45,24 @@ class MySampleBuilder(ba.ISampleBuilder): nparticles = 20 nfwhm = 2.0 sphere_ff = ba.FormFactorFullSphere(self.radius.value) - # sphere_ff = ba.FormFactorTruncatedSphere(self.radius.value, self.radius.value*1.5) + # sphere_ff = ba.FormFactorTruncatedSphere( + # self.radius.value, self.radius.value*1.5) sphere = ba.Particle(m_Ag, sphere_ff) - position = ba.kvector_t(0*ba.nanometer, 0*ba.nanometer, -1.0*self.hmdso_thickness.value) + position = ba.kvector_t(0*ba.nanometer, 0*ba.nanometer, + -1.0*self.hmdso_thickness.value) sphere.setPosition(position) ln_distr = ba.DistributionLogNormal(self.radius.value, self.sigma.value) - par_distr = ba.ParameterDistribution("/Particle/FullSphere/Radius", ln_distr, nparticles, nfwhm) - # par_distr = ba.ParameterDistribution("/Particle/TruncatedSphere/Radius", ln_distr, nparticles, nfwhm) + par_distr = ba.ParameterDistribution( + "/Particle/FullSphere/Radius", ln_distr, nparticles, nfwhm) + # par_distr = ba.ParameterDistribution( + # "/Particle/TruncatedSphere/Radius", ln_distr, nparticles, nfwhm) # par_distr.linkParameter("/Particle/TruncatedSphere/Height") part_coll = ba.ParticleDistribution(sphere, par_distr) # interference function - interference = ba.InterferenceFunctionRadialParaCrystal(self.distance.value, 1e6*ba.nanometer) + interference = ba.InterferenceFunctionRadialParaCrystal( + self.distance.value, 1e6*ba.nanometer) interference.setKappa(self.kappa.value) interference.setDomainSize(20000.0) pdf = ba.FTDistribution1DGauss(self.disorder.value) diff --git a/Examples/python/simulation/ex01_BasicParticles/CylindersAndPrisms.py b/Examples/python/simulation/ex01_BasicParticles/CylindersAndPrisms.py index f45073f4b3a0784f0612b3f93684b8d3016884aa..76e00b8dcf89a8f9478fecfb793417612190d80e 100644 --- a/Examples/python/simulation/ex01_BasicParticles/CylindersAndPrisms.py +++ b/Examples/python/simulation/ex01_BasicParticles/CylindersAndPrisms.py @@ -13,8 +13,7 @@ alpha_min, alpha_max = 0.0, 2.0 def get_sample(): """ - Build and return the sample representing cylinders and prisms on top of - substrate without interference. + Returns a sample with uncorrelated cylinders and prisms on a substrate. """ # defining materials m_air = ba.HomogeneousMaterial("Air", 0.0, 0.0) @@ -45,10 +44,11 @@ def get_sample(): def get_simulation(): """ - Create and return GISAXS simulation with beam and detector defined + Returns a GISAXS simulation with beam and detector defined. """ simulation = ba.GISASSimulation() - simulation.setDetectorParameters(100, phi_min*degree, phi_max*degree, 100, alpha_min*degree, alpha_max*degree) + 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) return simulation @@ -63,10 +63,12 @@ def run_simulation(): simulation.runSimulation() result = simulation.getIntensityData() - im = plt.imshow(result.getArray(), - norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), - extent=[result.getXmin()/degree, result.getXmax()/degree, result.getYmin()/degree, result.getYmax()/degree], - aspect='auto') + im = plt.imshow( + result.getArray(), + norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), + extent=[result.getXmin()/degree, result.getXmax()/degree, + result.getYmin()/degree, result.getYmax()/degree], + aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) plt.xlabel(r'$\phi_f (^{\circ})$', fontsize=16) @@ -76,6 +78,3 @@ def run_simulation(): if __name__ == '__main__': run_simulation() - - - diff --git a/Examples/python/simulation/ex01_BasicParticles/CylindersInBA.py b/Examples/python/simulation/ex01_BasicParticles/CylindersInBA.py index 6461b0c2893d1f2885189db252ee9fee102eb106..14d54d21e570543077c506077f7acb009bd22414 100644 --- a/Examples/python/simulation/ex01_BasicParticles/CylindersInBA.py +++ b/Examples/python/simulation/ex01_BasicParticles/CylindersInBA.py @@ -13,7 +13,8 @@ alpha_min, alpha_max = 0.0, 2.0 def get_sample(): """ - Build and return the sample to calculate cylinder formfactor in Born approximation. + Returns a sample with cylinders in a homogeneous environment ("air"), + implying a simulation in plain Born approximation. """ # defining materials m_ambience = ba.HomogeneousMaterial("Air", 0.0, 0.0) @@ -35,10 +36,11 @@ def get_sample(): def get_simulation(): """ - Create and return GISAXS simulation with beam and detector defined + Returns a GISAXS simulation with beam and detector defined """ simulation = ba.GISASSimulation() - simulation.setDetectorParameters(200, phi_min*degree, phi_max*degree, 200, alpha_min*degree, alpha_max*degree) + simulation.setDetectorParameters(200, phi_min*degree, phi_max*degree, + 200, alpha_min*degree, alpha_max*degree) simulation.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) return simulation @@ -54,10 +56,12 @@ def run_simulation(): result = simulation.getIntensityData() # showing the result - im = plt.imshow(result.getArray(), - norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), - extent=[result.getXmin()/degree, result.getXmax()/degree, result.getYmin()/degree, result.getYmax()/degree], - aspect='auto') + im = plt.imshow( + result.getArray(), + norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), + extent=[result.getXmin()/degree, result.getXmax()/degree, + result.getYmin()/degree, result.getYmax()/degree], + aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) plt.xlabel(r'$\phi_f (^{\circ})$', fontsize=16) diff --git a/Examples/python/simulation/ex01_BasicParticles/CylindersInDWBA.py b/Examples/python/simulation/ex01_BasicParticles/CylindersInDWBA.py index 92ce715477354136ac0d1973fd05993ede78e42f..531d597481934144c23c21e00c1fdef11baa45ae 100644 --- a/Examples/python/simulation/ex01_BasicParticles/CylindersInDWBA.py +++ b/Examples/python/simulation/ex01_BasicParticles/CylindersInDWBA.py @@ -13,7 +13,7 @@ alpha_min, alpha_max = 0.0, 2.0 def get_sample(): """ - Build and return the sample to calculate cylinder formfactor in Distorted Wave Born Approximation. + Returns a sample with cylinders on a substrate. """ # defining materials m_ambience = ba.HomogeneousMaterial("Air", 0.0, 0.0) @@ -38,10 +38,11 @@ def get_sample(): def get_simulation(): """ - Create and return GISAXS simulation with beam and detector defined + Returns a GISAXS simulation with beam and detector defined """ simulation = ba.GISASSimulation() - simulation.setDetectorParameters(200, phi_min*degree, phi_max*degree, 200, alpha_min*degree, alpha_max*degree) + simulation.setDetectorParameters(200, phi_min*degree, phi_max*degree, + 200, alpha_min*degree, alpha_max*degree) simulation.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) return simulation @@ -57,10 +58,12 @@ def run_simulation(): result = simulation.getIntensityData() # showing the result - im = plt.imshow(result.getArray(), - norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), - extent=[result.getXmin()/degree, result.getXmax()/degree, result.getYmin()/degree, result.getYmax()/degree], - aspect='auto') + im = plt.imshow( + result.getArray(), + norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), + extent=[result.getXmin()/degree, result.getXmax()/degree, + result.getYmin()/degree, result.getYmax()/degree], + aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) plt.xlabel(r'$\phi_f (^{\circ})$', fontsize=16) @@ -70,5 +73,3 @@ def run_simulation(): if __name__ == '__main__': run_simulation() - - diff --git a/Examples/python/simulation/ex01_BasicParticles/CylindersWithSizeDistribution.py b/Examples/python/simulation/ex01_BasicParticles/CylindersWithSizeDistribution.py index 8531fe90f2ccacf83f0720881e5bae855be38c7c..16870c3f36c35f07588f34ac94ada78e6c4f16c6 100644 --- a/Examples/python/simulation/ex01_BasicParticles/CylindersWithSizeDistribution.py +++ b/Examples/python/simulation/ex01_BasicParticles/CylindersWithSizeDistribution.py @@ -13,8 +13,8 @@ alpha_min, alpha_max = 0.0, 2.0 def get_sample(): """ - Build and return the sample to calculate cylinder formfactor in Born approximation. - Cylinders have size distribution. + Return a sample with cylinders on a substrate. + The cylinders have a Gaussian size distribution. """ m_ambience = ba.HomogeneousMaterial("Air", 0.0, 0.0) m_particle = ba.HomogeneousMaterial("Particle", 6e-4, 2e-8) @@ -31,9 +31,11 @@ def get_sample(): sigma = 0.2*radius gauss_distr = ba.DistributionGaussian(radius, sigma) - par_distr = ba.ParameterDistribution("/Particle/Cylinder/Radius", gauss_distr, nparticles, nfwhm) - # by uncommenting the line below the height of cylinders can be scaled proportionally to the radius - #par_distr.linkParameter("/Particle/Cylinder/Height") + par_distr = ba.ParameterDistribution( + "/Particle/Cylinder/Radius", gauss_distr, nparticles, nfwhm) + # by uncommenting the line below, the height of the cylinders + # can be scaled proportionally to the radius: + # par_distr.linkParameter("/Particle/Cylinder/Height") part_coll = ba.ParticleDistribution(cylinder, par_distr) # assembling the sample @@ -52,7 +54,8 @@ def get_simulation(): Create and return GISAXS simulation with beam and detector defined """ simulation = ba.GISASSimulation() - simulation.setDetectorParameters(200, phi_min*degree, phi_max*degree, 200, alpha_min*degree, alpha_max*degree) + simulation.setDetectorParameters(200, phi_min*degree, phi_max*degree, + 200, alpha_min*degree, alpha_max*degree) simulation.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) return simulation @@ -69,10 +72,12 @@ def run_simulation(): result = simulation.getIntensityData() # showing the result - im = plt.imshow(result.getArray(), - norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), - extent=[result.getXmin()/degree, result.getXmax()/degree, result.getYmin()/degree, result.getYmax()/degree], - aspect='auto') + im = plt.imshow( + result.getArray(), + norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), + extent=[result.getXmin()/degree, result.getXmax()/degree, + result.getYmin()/degree, result.getYmax()/degree], + aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) plt.xlabel(r'$\phi_f (^{\circ})$', fontsize=16) @@ -82,5 +87,3 @@ def run_simulation(): if __name__ == '__main__': run_simulation() - - diff --git a/Examples/python/simulation/ex01_BasicParticles/RotatedPyramids.py b/Examples/python/simulation/ex01_BasicParticles/RotatedPyramids.py index 2c46b1501a1cfd76dcb314806305f96784a992eb..502684c40fff9f382178f1e3892d158956a47575 100644 --- a/Examples/python/simulation/ex01_BasicParticles/RotatedPyramids.py +++ b/Examples/python/simulation/ex01_BasicParticles/RotatedPyramids.py @@ -13,7 +13,7 @@ alpha_min, alpha_max = 0.0, 2.0 def get_sample(): """ - Build and return the sample representing rotated pyramids on top of substrate + Returns a sample with rotated pyramids on top of a substrate. """ # defining materials m_ambience = ba.HomogeneousMaterial("Air", 0.0, 0.0) @@ -25,7 +25,8 @@ def get_sample(): pyramid = ba.Particle(m_particle, pyramid_ff) transform = ba.RotationZ(45.*degree) particle_layout = ba.ParticleLayout() - particle_layout.addParticle(pyramid, 1.0, ba.kvector_t(0.0, 0.0, 0.0), transform) + particle_layout.addParticle( + pyramid, 1.0, ba.kvector_t(0.0, 0.0, 0.0), transform) air_layer = ba.Layer(m_ambience) air_layer.addLayout(particle_layout) @@ -39,10 +40,11 @@ def get_sample(): def get_simulation(): """ - Create and return GISAXS simulation with beam and detector defined + Returns a GISAXS simulation with beam and detector defined. """ simulation = ba.GISASSimulation() - simulation.setDetectorParameters(200, phi_min*degree, phi_max*degree, 200, alpha_min*degree, alpha_max*degree) + simulation.setDetectorParameters(200, phi_min*degree, phi_max*degree, + 200, alpha_min*degree, alpha_max*degree) simulation.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) return simulation @@ -58,10 +60,12 @@ def run_simulation(): result = simulation.getIntensityData() # showing the result - im = plt.imshow(result.getArray(), - norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), - extent=[result.getXmin()/degree, result.getXmax()/degree, result.getYmin()/degree, result.getYmax()/degree], - aspect='auto') + im = plt.imshow( + result.getArray(), + norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), + extent=[result.getXmin()/degree, result.getXmax()/degree, + result.getYmin()/degree, result.getYmax()/degree], + aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) plt.xlabel(r'$\phi_f (^{\circ})$', fontsize=16) diff --git a/Examples/python/simulation/ex01_BasicParticles/TwoTypesOfCylindersWithSizeDistribution.py b/Examples/python/simulation/ex01_BasicParticles/TwoTypesOfCylindersWithSizeDistribution.py index 8b15ce892f1f84bc482d3376180ab01e163f58e8..1eb6a2d14f2c6ba6faeb830a172fe66a7013a8d3 100644 --- a/Examples/python/simulation/ex01_BasicParticles/TwoTypesOfCylindersWithSizeDistribution.py +++ b/Examples/python/simulation/ex01_BasicParticles/TwoTypesOfCylindersWithSizeDistribution.py @@ -1,5 +1,5 @@ """ -Mixture cylinder particles with different size distribution +Mixture cylinder particles with different size distribution """ import numpy import matplotlib @@ -13,7 +13,8 @@ alpha_min, alpha_max = 0.0, 2.0 def get_sample(): """ - Build and return the sample representing cylinder particles with different size distribution. + Returns a sample with cylinders in a homogeneous medium ("air"). + The cylinders are a 95:5 mixture of two different size distributions. """ # defining materials m_air = ba.HomogeneousMaterial("Air", 0.0, 0.0) @@ -32,7 +33,8 @@ def get_sample(): gauss_distr1 = ba.DistributionGaussian(radius1, sigma1) - par_distr1 = ba.ParameterDistribution("/Particle/Cylinder/Radius", gauss_distr1, nparticles, nfwhm) + par_distr1 = ba.ParameterDistribution( + "/Particle/Cylinder/Radius", gauss_distr1, nparticles, nfwhm) part_coll1 = ba.ParticleDistribution(cylinder1, par_distr1) # collection of particles #2 @@ -45,7 +47,8 @@ def get_sample(): gauss_distr2 = ba.DistributionGaussian(radius2, sigma2) - par_distr2 = ba.ParameterDistribution("/Particle/Cylinder/Radius", gauss_distr2, nparticles, nfwhm) + par_distr2 = ba.ParameterDistribution( + "/Particle/Cylinder/Radius", gauss_distr2, nparticles, nfwhm) part_coll2 = ba.ParticleDistribution(cylinder2, par_distr2) # assembling the sample @@ -66,7 +69,8 @@ def get_simulation(): Create and return GISAXS simulation with beam and detector defined """ simulation = ba.GISASSimulation() - simulation.setDetectorParameters(200, phi_min*degree, phi_max*degree, 200, alpha_min*degree, alpha_max*degree) + simulation.setDetectorParameters(200, phi_min*degree, phi_max*degree, + 200, alpha_min*degree, alpha_max*degree) simulation.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) return simulation @@ -82,10 +86,12 @@ def run_simulation(): result = simulation.getIntensityData() # showing the result - im = plt.imshow(result.getArray(), - norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), - extent=[result.getXmin()/degree, result.getXmax()/degree, result.getYmin()/degree, result.getYmax()/degree], - aspect='auto') + im = plt.imshow( + result.getArray(), + norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), + extent=[result.getXmin()/degree, result.getXmax()/degree, + result.getYmin()/degree, result.getYmax()/degree], + aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) plt.xlabel(r'$\phi_f (^{\circ})$', fontsize=16) @@ -95,7 +101,3 @@ def run_simulation(): if __name__ == '__main__': run_simulation() - - - - diff --git a/Examples/python/simulation/ex02_LayeredStructures/BuriedParticles.py b/Examples/python/simulation/ex02_LayeredStructures/BuriedParticles.py index 5e589d190eca5e63bc5369c02f0d4c73606a317c..54e50e2187a93a01a0c9283b428d78710888d855 100644 --- a/Examples/python/simulation/ex02_LayeredStructures/BuriedParticles.py +++ b/Examples/python/simulation/ex02_LayeredStructures/BuriedParticles.py @@ -13,7 +13,7 @@ alpha_min, alpha_max = 0.0, 2.0 def get_sample(): """ - Build and return the sample with buried spheres in Distorted Wave Born Approximation. + Returns a sample with spherical particles in an layer between air and substrate. """ # defining materials m_ambience = ba.HomogeneousMaterial("Air", 0.0, 0.0) @@ -43,10 +43,11 @@ def get_sample(): def get_simulation(): """ - Create and return GISAXS simulation with beam and detector defined + Returns a GISAXS simulation with beam and detector defined. """ simulation = ba.GISASSimulation() - simulation.setDetectorParameters(200, phi_min*degree, phi_max*degree, 200, alpha_min*degree, alpha_max*degree) + simulation.setDetectorParameters(200, phi_min*degree, phi_max*degree, + 200, alpha_min*degree, alpha_max*degree) simulation.setBeamParameters(1.5*angstrom, 0.15*degree, 0.0*degree) return simulation @@ -62,10 +63,12 @@ def run_simulation(): result = simulation.getIntensityData() # showing the result - im = plt.imshow(result.getArray(), - norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), - extent=[result.getXmin()/degree, result.getXmax()/degree, result.getYmin()/degree, result.getYmax()/degree], - aspect='auto') + im = plt.imshow( + result.getArray(), + norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), + extent=[result.getXmin()/degree, result.getXmax()/degree, + result.getYmin()/degree, result.getYmax()/degree], + aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) plt.xlabel(r'$\phi_f (^{\circ})$', fontsize=16) @@ -75,4 +78,3 @@ def run_simulation(): if __name__ == '__main__': run_simulation() - diff --git a/Examples/python/simulation/ex02_LayeredStructures/CorrelatedRoughness.py b/Examples/python/simulation/ex02_LayeredStructures/CorrelatedRoughness.py index ac06e20ae247e49b7932ab0441c1d2d7993286ac..da2fc5291119b43a9c20986eb62ea14993f54364 100644 --- a/Examples/python/simulation/ex02_LayeredStructures/CorrelatedRoughness.py +++ b/Examples/python/simulation/ex02_LayeredStructures/CorrelatedRoughness.py @@ -13,7 +13,7 @@ alpha_min, alpha_max = 0.0, 1.0 def get_sample(): """ - Build and return the sample representing the layers with correlated roughness. + Returns a sample with two layers on a substrate, with correlated roughnesses. """ # defining materials m_ambience = ba.HomogeneousMaterial("ambience", 0.0, 0.0) @@ -53,7 +53,8 @@ def get_simulation(): Characterizing the input beam and output detector """ simulation = ba.GISASSimulation() - simulation.setDetectorParameters(200, phi_min*degree, phi_max*degree, 200, alpha_min*degree, alpha_max*degree) + simulation.setDetectorParameters(200, phi_min*degree, phi_max*degree, + 200, alpha_min*degree, alpha_max*degree) simulation.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) return simulation @@ -69,10 +70,13 @@ def run_simulation(): result = simulation.getIntensityData() # showing the result - im = plt.imshow(result.getArray(), - norm=matplotlib.colors.LogNorm(result.getMaximum()/1000., result.getMaximum()), - extent=[result.getXmin()/degree, result.getXmax()/degree, result.getYmin()/degree, result.getYmax()/degree], - aspect='auto') + im = plt.imshow( + result.getArray(), + norm=matplotlib.colors.LogNorm(result.getMaximum()/1000., + result.getMaximum()), + extent=[result.getXmin()/degree, result.getXmax()/degree, + result.getYmin()/degree, result.getYmax()/degree], + aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) plt.xlabel(r'$\phi_f (^{\circ})$', fontsize=16) @@ -82,4 +86,3 @@ def run_simulation(): if __name__ == '__main__': run_simulation() - diff --git a/Examples/python/simulation/ex03_InterferenceFunctions/ApproximationDA.py b/Examples/python/simulation/ex03_InterferenceFunctions/ApproximationDA.py index 140bd0f8c815705f463bb7a1e9f6e817c7013a3e..fb962dde552d2647e8932fc31e83541ca5a465e6 100644 --- a/Examples/python/simulation/ex03_InterferenceFunctions/ApproximationDA.py +++ b/Examples/python/simulation/ex03_InterferenceFunctions/ApproximationDA.py @@ -13,8 +13,8 @@ alpha_min, alpha_max = 0.0, 2.0 def get_sample(): """ - Build and return the sample. - Cylinders come in two different sizes. + Returns a sample with cylinders of two different sizes on a substrate. + The cylinder positions are modelled in Decoupling Approximation. """ m_ambience = ba.HomogeneousMaterial("Air", 0.0, 0.0) m_substrate = ba.HomogeneousMaterial("Substrate", 6e-6, 2e-8) @@ -33,7 +33,8 @@ def get_sample(): cylinder2 = ba.Particle(m_particle, cylinder_ff2) # interference function - interference = ba.InterferenceFunctionRadialParaCrystal(18.0*nanometer, 1e3*nanometer) + interference = ba.InterferenceFunctionRadialParaCrystal( + 18.0*nanometer, 1e3*nanometer) pdf = ba.FTDistribution1DGauss(3 * nanometer) interference.setProbabilityDistribution(pdf) @@ -57,7 +58,8 @@ def get_simulation(): Create and return GISAXS simulation with beam and detector defined """ simulation = ba.GISASSimulation() - simulation.setDetectorParameters(200, phi_min*degree, phi_max*degree, 200, alpha_min*degree, alpha_max*degree) + simulation.setDetectorParameters(200, phi_min*degree, phi_max*degree, + 200, alpha_min*degree, alpha_max*degree) simulation.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) return simulation @@ -73,10 +75,12 @@ def run_simulation(): result = simulation.getIntensityData() # showing the result - im = plt.imshow(result.getArray(), - norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), - extent=[result.getXmin()/degree, result.getXmax()/degree, result.getYmin()/degree, result.getYmax()/degree], - aspect='auto') + im = plt.imshow( + result.getArray(), + norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), + extent=[result.getXmin()/degree, result.getXmax()/degree, + result.getYmin()/degree, result.getYmax()/degree], + aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) plt.xlabel(r'$\phi_f (^{\circ})$', fontsize=16) @@ -86,5 +90,3 @@ def run_simulation(): if __name__ == '__main__': run_simulation() - - diff --git a/Examples/python/simulation/ex03_InterferenceFunctions/ApproximationLMA.py b/Examples/python/simulation/ex03_InterferenceFunctions/ApproximationLMA.py index 8794e1cb17a361733b1df3f64228dd74ec11a516..0645815525fd53e1822e3fba35da2c1d762318f9 100644 --- a/Examples/python/simulation/ex03_InterferenceFunctions/ApproximationLMA.py +++ b/Examples/python/simulation/ex03_InterferenceFunctions/ApproximationLMA.py @@ -13,8 +13,8 @@ alpha_min, alpha_max = 0.0, 2.0 def get_sample(): """ - Build and return the sample. - Cylinders come in two different sizes. + Returns a sample with cylinders of two different sizes on a substrate. + The cylinder positions are modelled in Local Monodisperse Approximation. """ m_ambience = ba.HomogeneousMaterial("Air", 0.0, 0.0) m_substrate = ba.HomogeneousMaterial("Substrate", 6e-6, 2e-8) @@ -33,12 +33,14 @@ def get_sample(): cylinder2 = ba.Particle(m_particle, cylinder_ff2) # interference function1 - interference1 = ba.InterferenceFunctionRadialParaCrystal(16.8*nanometer, 1e3*nanometer) + interference1 = ba.InterferenceFunctionRadialParaCrystal( + 16.8*nanometer, 1e3*nanometer) pdf = ba.FTDistribution1DGauss(3 * nanometer) interference1.setProbabilityDistribution(pdf) # interference function2 - interference2 = ba.InterferenceFunctionRadialParaCrystal(22.8*nanometer, 1e3*nanometer) + interference2 = ba.InterferenceFunctionRadialParaCrystal( + 22.8*nanometer, 1e3*nanometer) interference2.setProbabilityDistribution(pdf) # assembling the sample @@ -65,7 +67,8 @@ def get_simulation(): Create and return GISAXS simulation with beam and detector defined """ simulation = ba.GISASSimulation() - simulation.setDetectorParameters(200, phi_min*degree, phi_max*degree, 200, alpha_min*degree, alpha_max*degree) + simulation.setDetectorParameters(200, phi_min*degree, phi_max*degree, + 200, alpha_min*degree, alpha_max*degree) simulation.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) return simulation @@ -81,10 +84,12 @@ def run_simulation(): result = simulation.getIntensityData() # showing the result - im = plt.imshow(result.getArray(), - norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), - extent=[result.getXmin()/degree, result.getXmax()/degree, result.getYmin()/degree, result.getYmax()/degree], - aspect='auto') + im = plt.imshow( + result.getArray(), + norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), + extent=[result.getXmin()/degree, result.getXmax()/degree, + result.getYmin()/degree, result.getYmax()/degree], + aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) plt.xlabel(r'$\phi_f (^{\circ})$', fontsize=16) @@ -94,5 +99,3 @@ def run_simulation(): if __name__ == '__main__': run_simulation() - - diff --git a/Examples/python/simulation/ex03_InterferenceFunctions/ApproximationSSCA.py b/Examples/python/simulation/ex03_InterferenceFunctions/ApproximationSSCA.py index 7e6a2b78ff4cac87201f8f11693bc678c67e5b06..216179907cc3faa393139cfefd858048e569e49f 100644 --- a/Examples/python/simulation/ex03_InterferenceFunctions/ApproximationSSCA.py +++ b/Examples/python/simulation/ex03_InterferenceFunctions/ApproximationSSCA.py @@ -13,8 +13,8 @@ alpha_min, alpha_max = 0.0, 2.0 def get_sample(): """ - Build and return the sample. - Cylinders come in two different sizes. + Returns a sample with cylinders of two different sizes on a substrate. + The cylinder positions are modelled in Size-Spacing Coupling Approximation. """ m_ambience = ba.HomogeneousMaterial("Air", 0.0, 0.0) m_substrate = ba.HomogeneousMaterial("Substrate", 6e-6, 2e-8) @@ -33,7 +33,8 @@ def get_sample(): cylinder2 = ba.Particle(m_particle, cylinder_ff2) # interference function - interference = ba.InterferenceFunctionRadialParaCrystal(18.0*nanometer, 1e3*nanometer) + interference = ba.InterferenceFunctionRadialParaCrystal( + 18.0*nanometer, 1e3*nanometer) pdf = ba.FTDistribution1DGauss(3 * nanometer) interference.setProbabilityDistribution(pdf) interference.setKappa(1.0) @@ -59,7 +60,8 @@ def get_simulation(): Create and return GISAXS simulation with beam and detector defined """ simulation = ba.GISASSimulation() - simulation.setDetectorParameters(200, phi_min*degree, phi_max*degree, 200, alpha_min*degree, alpha_max*degree) + simulation.setDetectorParameters(200, phi_min*degree, phi_max*degree, + 200, alpha_min*degree, alpha_max*degree) simulation.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) return simulation @@ -75,10 +77,12 @@ def run_simulation(): result = simulation.getIntensityData() # showing the result - im = plt.imshow(result.getArray(), - norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), - extent=[result.getXmin()/degree, result.getXmax()/degree, result.getYmin()/degree, result.getYmax()/degree], - aspect='auto') + im = plt.imshow( + result.getArray(), + norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), + extent=[result.getXmin()/degree, result.getXmax()/degree, + result.getYmin()/degree, result.getYmax()/degree], + aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) plt.xlabel(r'$\phi_f (^{\circ})$', fontsize=16) diff --git a/Examples/python/simulation/ex03_InterferenceFunctions/CosineRipplesAtRectLattice.py b/Examples/python/simulation/ex03_InterferenceFunctions/CosineRipplesAtRectLattice.py index b1432eb37fa5489fb6ae3a54f7ef5ba7a9bebd84..6b23b8a098243cc0b0afab1b26b4483f10cf552c 100644 --- a/Examples/python/simulation/ex03_InterferenceFunctions/CosineRipplesAtRectLattice.py +++ b/Examples/python/simulation/ex03_InterferenceFunctions/CosineRipplesAtRectLattice.py @@ -13,7 +13,8 @@ alpha_min, alpha_max = 0.0, 2.5 def get_sample(): """ - Build and return the sample representing the cosine ripple in the framework of the 2D Lattice. + Returns a sample with cosine ripples on a substrate. + The structure is modelled as a 2D Lattice. """ # defining materials m_ambience = ba.HomogeneousMaterial("Air", 0.0, 0.0) @@ -27,8 +28,10 @@ def get_sample(): particle_layout = ba.ParticleLayout() particle_layout.addParticle(ripple, 1.0) - interference = ba.InterferenceFunction2DLattice(200.0*nanometer, 50.0*nanometer, 90.0*degree, 0.0*degree) - pdf = ba.FTDecayFunction2DCauchy(1000.*nanometer/2./numpy.pi, 100.*nanometer/2./numpy.pi) + interference = ba.InterferenceFunction2DLattice( + 200.0*nanometer, 50.0*nanometer, 90.0*degree, 0.0*degree) + pdf = ba.FTDecayFunction2DCauchy( + 1000.*nanometer/2./numpy.pi, 100.*nanometer/2./numpy.pi) interference.setDecayFunction(pdf) particle_layout.addInterferenceFunction(interference) @@ -48,7 +51,8 @@ def get_simulation(): characterizing the input beam and output detector """ simulation = ba.GISASSimulation() - simulation.setDetectorParameters(100, phi_min*degree, phi_max*degree, 100, alpha_min*degree, alpha_max*degree) + simulation.setDetectorParameters(100, phi_min*degree, phi_max*degree, + 100, alpha_min*degree, alpha_max*degree) simulation.setBeamParameters(1.6*angstrom, 0.3*degree, 0.0*degree) return simulation @@ -64,10 +68,12 @@ def run_simulation(): result = simulation.getIntensityData() # showing the result - im = plt.imshow(result.getArray(), - norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), - extent=[result.getXmin()/degree, result.getXmax()/degree, result.getYmin()/degree, result.getYmax()/degree], - aspect='auto') + im = plt.imshow( + result.getArray(), + norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), + extent=[result.getXmin()/degree, result.getXmax()/degree, + result.getYmin()/degree, result.getYmax()/degree], + aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) plt.xlabel(r'$\phi_f (^{\circ})$', fontsize=16) @@ -77,4 +83,3 @@ def run_simulation(): if __name__ == '__main__': run_simulation() - diff --git a/Examples/python/simulation/ex03_InterferenceFunctions/Interference1DLattice.py b/Examples/python/simulation/ex03_InterferenceFunctions/Interference1DLattice.py index bfc85cf72c248e457a32f525b1099ed0f90e6dea..bf285dc8f2da647e4834389fbc3ed4d1c6f28d4a 100644 --- a/Examples/python/simulation/ex03_InterferenceFunctions/Interference1DLattice.py +++ b/Examples/python/simulation/ex03_InterferenceFunctions/Interference1DLattice.py @@ -13,7 +13,8 @@ alpha_min, alpha_max = 0.0, 2.0 def get_sample(): """ - Build and return the sample representing infinitely long boxes on a 1D lattice + Returns a sample with a grating on a substrate. + The structure is modelled by infinitely long boxes forming a 1D lattice. """ # defining materials m_ambience = ba.HomogeneousMaterial("Air", 0.0, 0.0) @@ -23,7 +24,8 @@ def get_sample(): # collection of particles lattice_length = 30.0*nanometer lattice_rotation_angle = 0.0*degree - interference = ba.InterferenceFunction1DLattice(lattice_length, lattice_rotation_angle) + interference = ba.InterferenceFunction1DLattice( + lattice_length, lattice_rotation_angle) pdf = ba.FTDecayFunction1DCauchy(20./2./numpy.pi*nanometer) interference.setDecayFunction(pdf) @@ -50,7 +52,8 @@ def get_simulation(): Create and return GISAXS simulation with beam and detector defined """ simulation = ba.GISASSimulation() - simulation.setDetectorParameters(200, phi_min*degree, phi_max*degree, 200, alpha_min*degree, alpha_max*degree) + simulation.setDetectorParameters(200, phi_min*degree, phi_max*degree, + 200, alpha_min*degree, alpha_max*degree) simulation.setBeamParameters(24.0*angstrom, 0.2*degree, 0.0*degree) return simulation @@ -66,10 +69,12 @@ def run_simulation(): result = simulation.getIntensityData() # showing the result - im = plt.imshow(result.getArray(), - norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), - extent=[result.getXmin()/degree, result.getXmax()/degree, result.getYmin()/degree, result.getYmax()/degree], - aspect='auto') + im = plt.imshow( + result.getArray(), + norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), + extent=[result.getXmin()/degree, result.getXmax()/degree, + result.getYmin()/degree, result.getYmax()/degree], + aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) plt.xlabel(r'$\phi_f (^{\circ})$', fontsize=16) diff --git a/Examples/python/simulation/ex03_InterferenceFunctions/Interference1DRadialParaCrystal.py b/Examples/python/simulation/ex03_InterferenceFunctions/Interference1DRadialParaCrystal.py index 9908e115849d7270188db5953d8b7d745ecc6b3a..40115b90b024eb40c02f57cb3d0ac89c24e79a41 100644 --- a/Examples/python/simulation/ex03_InterferenceFunctions/Interference1DRadialParaCrystal.py +++ b/Examples/python/simulation/ex03_InterferenceFunctions/Interference1DRadialParaCrystal.py @@ -13,7 +13,7 @@ alpha_min, alpha_max = 0.0, 2.0 def get_sample(): """ - Build and return the sample representing radial paracrystal + Returns a sample with cylinders on a substrate that form a radial paracrystal. """ # defining materials m_ambience = ba.HomogeneousMaterial("Air", 0.0, 0.0) @@ -24,7 +24,8 @@ def get_sample(): cylinder_ff = ba.FormFactorCylinder(5*nanometer, 5*nanometer) cylinder = ba.Particle(m_particle, cylinder_ff) - interference = ba.InterferenceFunctionRadialParaCrystal(20.0*nanometer, 1e3*nanometer) + interference = ba.InterferenceFunctionRadialParaCrystal( + 20.0*nanometer, 1e3*nanometer) pdf = ba.FTDistribution1DGauss(7 * nanometer) interference.setProbabilityDistribution(pdf) @@ -48,7 +49,8 @@ def get_simulation(): Create and return GISAXS simulation with beam and detector defined """ simulation = ba.GISASSimulation() - simulation.setDetectorParameters(200, phi_min*degree, phi_max*degree, 200, alpha_min*degree, alpha_max*degree) + simulation.setDetectorParameters(200, phi_min*degree, phi_max*degree, + 200, alpha_min*degree, alpha_max*degree) simulation.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) return simulation @@ -64,10 +66,12 @@ def run_simulation(): result = simulation.getIntensityData() # showing the result - im = plt.imshow(result.getArray(), - norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), - extent=[result.getXmin()/degree, result.getXmax()/degree, result.getYmin()/degree, result.getYmax()/degree], - aspect='auto') + im = plt.imshow( + result.getArray(), + norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), + extent=[result.getXmin()/degree, result.getXmax()/degree, + result.getYmin()/degree, result.getYmax()/degree], + aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) plt.xlabel(r'$\phi_f (^{\circ})$', fontsize=16) @@ -77,6 +81,3 @@ def run_simulation(): if __name__ == '__main__': run_simulation() - - - diff --git a/Examples/python/simulation/ex03_InterferenceFunctions/Interference2DCenteredSquareLattice.py b/Examples/python/simulation/ex03_InterferenceFunctions/Interference2DCenteredSquareLattice.py index a7e23d929f4ab8797b0951ce7a1af80399df0aa0..c06c126d4bcd785f8d92e9245ceda6324d701a38 100644 --- a/Examples/python/simulation/ex03_InterferenceFunctions/Interference2DCenteredSquareLattice.py +++ b/Examples/python/simulation/ex03_InterferenceFunctions/Interference2DCenteredSquareLattice.py @@ -13,7 +13,8 @@ alpha_min, alpha_max = 0.0, 2.0 def get_sample(): """ - Build and return the sample representing 2D centered square lattice + Returns a sample with cylinders on a substrate, + forming a 2D centered square lattice """ # defining materials m_ambience = ba.HomogeneousMaterial("Air", 0.0, 0.0) @@ -22,7 +23,8 @@ def get_sample(): # collection of particles interference = ba.InterferenceFunction2DLattice.createSquare(25.0*nanometer) - pdf = ba.FTDecayFunction2DCauchy(300.0*nanometer/2.0/numpy.pi, 100.0*nanometer/2.0/numpy.pi) + pdf = ba.FTDecayFunction2DCauchy(300.0*nanometer/2.0/numpy.pi, + 100.0*nanometer/2.0/numpy.pi) interference.setDecayFunction(pdf) particle_layout = ba.ParticleLayout() @@ -51,7 +53,8 @@ def get_simulation(): Create and return GISAS simulation with beam and detector defined """ simulation = ba.GISASSimulation() - simulation.setDetectorParameters(200, phi_min*degree, phi_max*degree, 200, alpha_min*degree, alpha_max*degree) + simulation.setDetectorParameters(200, phi_min*degree, phi_max*degree, + 200, alpha_min*degree, alpha_max*degree) simulation.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) return simulation @@ -68,10 +71,12 @@ def run_simulation(): result = simulation.getIntensityData() # showing the result - im = plt.imshow(result.getArray(), - norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), - extent=[result.getXmin()/degree, result.getXmax()/degree, result.getYmin()/degree, result.getYmax()/degree], - aspect='auto') + im = plt.imshow( + result.getArray(), + norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), + extent=[result.getXmin()/degree, result.getXmax()/degree, + result.getYmin()/degree, result.getYmax()/degree], + aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) plt.xlabel(r'$\phi_f (^{\circ})$', fontsize=16) diff --git a/Examples/python/simulation/ex03_InterferenceFunctions/Interference2DLatticeSumOfRotated.py b/Examples/python/simulation/ex03_InterferenceFunctions/Interference2DLatticeSumOfRotated.py index 87e1e690de29a6bc284f4abed46b75e185b4fd10..8f169a94022cbf2434aed690f8e488ea57d5b9ff 100644 --- a/Examples/python/simulation/ex03_InterferenceFunctions/Interference2DLatticeSumOfRotated.py +++ b/Examples/python/simulation/ex03_InterferenceFunctions/Interference2DLatticeSumOfRotated.py @@ -11,8 +11,8 @@ alpha_min, alpha_max = 0.0, 2.0 def get_sample(xi_value): """ - Build and return the sample representing 2D lattice with different disorder - rotated lattice + Returns a sample with cylinders on a substrate, + forming a 2D lattice with different disorder rotated lattice """ m_ambience = ba.HomogeneousMaterial("Air", 0.0, 0.0) m_substrate = ba.HomogeneousMaterial("Substrate", 6e-6, 2e-8) @@ -21,8 +21,10 @@ def get_sample(xi_value): air_layer = ba.Layer(m_ambience) substrate_layer = ba.Layer(m_substrate) - p_interference_function = ba.InterferenceFunction2DLattice.createSquare(25.0*nanometer, xi_value) - pdf = ba.FTDecayFunction2DCauchy(300.0*nanometer/2.0/numpy.pi, 100.0*nanometer/2.0/numpy.pi) + p_interference_function = ba.InterferenceFunction2DLattice.createSquare( + 25.0*nanometer, xi_value) + pdf = ba.FTDecayFunction2DCauchy(300.0*nanometer/2.0/numpy.pi, + 100.0*nanometer/2.0/numpy.pi) p_interference_function.setDecayFunction(pdf) particle_layout = ba.ParticleLayout() @@ -43,17 +45,20 @@ def get_sample(xi_value): def get_simulation(): """ - Create and return GISAXS simulation with beam and detector defined + Returns a GISAXS simulation with beam and detector defined """ simulation = ba.GISASSimulation() - simulation.setDetectorParameters(100, phi_min*degree, phi_max*degree, 100, alpha_min*degree, alpha_max*degree) + 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) return simulation def run_simulation(): """ - Run several simulations, sum up intensities from different rotated lattices and plot results + Runs several simulations, + sums intensities from different rotated lattices, + and plots results """ simulation = get_simulation() @@ -81,10 +86,12 @@ def run_simulation(): result = OutputData_total # showing the result - im = plt.imshow(result.getArray(), - norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), - extent=[result.getXmin()/degree, result.getXmax()/degree, result.getYmin()/degree, result.getYmax()/degree], - aspect='auto') + im = plt.imshow( + result.getArray(), + norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), + extent=[result.getXmin()/degree, result.getXmax()/degree, + result.getYmin()/degree, result.getYmax()/degree], + aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) plt.xlabel(r'$\phi_f (^{\circ})$', fontsize=16) @@ -94,4 +101,3 @@ def run_simulation(): if __name__ == '__main__': run_simulation() - diff --git a/Examples/python/simulation/ex03_InterferenceFunctions/Interference2DParaCrystal.py b/Examples/python/simulation/ex03_InterferenceFunctions/Interference2DParaCrystal.py index 2ec2b846ba047e287578d44d852fbd6b928c3bf5..6b3960dcc16e9d2859c6576fc35e0eb38a42319d 100644 --- a/Examples/python/simulation/ex03_InterferenceFunctions/Interference2DParaCrystal.py +++ b/Examples/python/simulation/ex03_InterferenceFunctions/Interference2DParaCrystal.py @@ -14,7 +14,7 @@ alpha_min, alpha_max = 0.0, 2.0 def get_sample(): """ - Build and return the sample representing 2D paracrystal + Returns a sample with cylinders on a substrate, forming a 2D paracrystal """ m_ambience = ba.HomogeneousMaterial("Air", 0.0, 0.0) m_substrate = ba.HomogeneousMaterial("Substrate", 6e-6, 2e-8) @@ -24,9 +24,8 @@ def get_sample(): cylinder_ff = ba.FormFactorCylinder(5*nanometer, 5*nanometer) cylinder = ba.Particle(m_particle, cylinder_ff) - #interference = ba.InterferenceFunction2DParaCrystal.createHexagonal(20.0*nanometer, - interference = ba.InterferenceFunction2DParaCrystal.createSquare(20.0*nanometer, - 0.0, 20.0*micrometer, 20.0*micrometer) + interference = ba.InterferenceFunction2DParaCrystal.createSquare( + 20.0*nanometer, 0.0, 20.0*micrometer, 20.0*micrometer) pdf = ba.FTDistribution2DCauchy(1.0*nanometer, 1.0*nanometer) interference.setProbabilityDistributions(pdf, pdf) @@ -48,10 +47,11 @@ def get_sample(): def get_simulation(): """ - Create and return GISAXS simulation with beam and detector defined + Returns a GISAXS simulation with beam and detector defined. """ simulation = ba.GISASSimulation() - simulation.setDetectorParameters(200, phi_min*degree, phi_max*degree, 200, alpha_min*degree, alpha_max*degree) + simulation.setDetectorParameters(200, phi_min*degree, phi_max*degree, + 200, alpha_min*degree, alpha_max*degree) simulation.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) return simulation @@ -67,10 +67,12 @@ def run_simulation(): result = simulation.getIntensityData() # showing the result - im = plt.imshow(result.getArray(), - norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), - extent=[result.getXmin()/degree, result.getXmax()/degree, result.getYmin()/degree, result.getYmax()/degree], - aspect='auto') + im = plt.imshow( + result.getArray(), + norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), + extent=[result.getXmin()/degree, result.getXmax()/degree, + result.getYmin()/degree, result.getYmax()/degree], + aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) plt.xlabel(r'$\phi_f (^{\circ})$', fontsize=16) diff --git a/Examples/python/simulation/ex03_InterferenceFunctions/Interference2DRotatedSquareLattice.py b/Examples/python/simulation/ex03_InterferenceFunctions/Interference2DRotatedSquareLattice.py index 2b1504f56273a3f1954846e1626ea86a9e8a5cac..ffd483bda7f73981b66484c9fb355bb0f914f710 100644 --- a/Examples/python/simulation/ex03_InterferenceFunctions/Interference2DRotatedSquareLattice.py +++ b/Examples/python/simulation/ex03_InterferenceFunctions/Interference2DRotatedSquareLattice.py @@ -13,7 +13,7 @@ alpha_min, alpha_max = 0.0, 2.0 def get_sample(): """ - Build and return the sample representing a rotated 2D lattice of cylinders + Returns a sample with cylinders on a substrate, forming a rotated 2D lattice """ # defining materials m_ambience = ba.HomogeneousMaterial("Air", 0.0, 0.0) @@ -21,8 +21,10 @@ def get_sample(): m_particle = ba.HomogeneousMaterial("Particle", 6e-4, 2e-8) # collection of particles - interference = ba.InterferenceFunction2DLattice.createSquare(25.0*nanometer, 30.0*degree) - pdf = ba.FTDecayFunction2DCauchy(300.0*nanometer/2.0/numpy.pi, 100.0*nanometer/2.0/numpy.pi) + interference = ba.InterferenceFunction2DLattice.createSquare( + 25.0*nanometer, 30.0*degree) + pdf = ba.FTDecayFunction2DCauchy( + 300.0*nanometer/2.0/numpy.pi, 100.0*nanometer/2.0/numpy.pi) pdf.setGamma(30.0*degree) interference.setDecayFunction(pdf) @@ -48,7 +50,8 @@ def get_simulation(): Create and return GISAXS simulation with beam and detector defined """ simulation = ba.GISASSimulation() - simulation.setDetectorParameters(200, phi_min*degree, phi_max*degree, 200, alpha_min*degree, alpha_max*degree) + simulation.setDetectorParameters(200, phi_min*degree, phi_max*degree, + 200, alpha_min*degree, alpha_max*degree) simulation.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) return simulation @@ -65,10 +68,12 @@ def run_simulation(): result = simulation.getIntensityData() # showing the result - im = plt.imshow(result.getArray(), - norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), - extent=[result.getXmin()/degree, result.getXmax()/degree, result.getYmin()/degree, result.getYmax()/degree], - aspect='auto') + im = plt.imshow( + result.getArray(), + norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), + extent=[result.getXmin()/degree, result.getXmax()/degree, + result.getYmin()/degree, result.getYmax()/degree], + aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) plt.xlabel(r'$\phi_f (^{\circ})$', fontsize=16) diff --git a/Examples/python/simulation/ex03_InterferenceFunctions/Interference2DSquareLattice.py b/Examples/python/simulation/ex03_InterferenceFunctions/Interference2DSquareLattice.py index 2f8eea1346a5b7bbab5c56fc2a86024a45a87601..0b20735548c2a059d30682475e7eb0a1142c6776 100644 --- a/Examples/python/simulation/ex03_InterferenceFunctions/Interference2DSquareLattice.py +++ b/Examples/python/simulation/ex03_InterferenceFunctions/Interference2DSquareLattice.py @@ -13,7 +13,7 @@ alpha_min, alpha_max = 0.0, 2.0 def get_sample(): """ - Build and return the sample representing a 2D square lattice of cylinders + Returns a sample with cylinders on a substrate, forming a 2D square lattice. """ # defining materials m_ambience = ba.HomogeneousMaterial("Air", 0.0, 0.0) @@ -22,7 +22,8 @@ def get_sample(): # collection of particles interference = ba.InterferenceFunction2DLattice.createSquare(25.0*nanometer) - pdf = ba.FTDecayFunction2DCauchy(300.0*nanometer/2.0/numpy.pi, 100.0*nanometer/2.0/numpy.pi) + pdf = ba.FTDecayFunction2DCauchy(300.0*nanometer/2.0/numpy.pi, + 100.0*nanometer/2.0/numpy.pi) interference.setDecayFunction(pdf) cylinder_ff = ba.FormFactorCylinder(3.*nanometer, 3.*nanometer) @@ -47,7 +48,8 @@ def get_simulation(): Create and return GISAXS simulation with beam and detector defined """ simulation = ba.GISASSimulation() - simulation.setDetectorParameters(200, phi_min*degree, phi_max*degree, 200, alpha_min*degree, alpha_max*degree) + simulation.setDetectorParameters(200, phi_min*degree, phi_max*degree, + 200, alpha_min*degree, alpha_max*degree) simulation.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) return simulation @@ -63,10 +65,12 @@ def run_simulation(): result = simulation.getIntensityData() # showing the result - im = plt.imshow(result.getArray(), - norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), - extent=[result.getXmin()/degree, result.getXmax()/degree, result.getYmin()/degree, result.getYmax()/degree], - aspect='auto') + im = plt.imshow( + result.getArray(), + norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), + extent=[result.getXmin()/degree, result.getXmax()/degree, + result.getYmin()/degree, result.getYmax()/degree], + aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) plt.xlabel(r'$\phi_f (^{\circ})$', fontsize=16) diff --git a/Examples/python/simulation/ex03_InterferenceFunctions/RectangularGrating.py b/Examples/python/simulation/ex03_InterferenceFunctions/RectangularGrating.py index 4a7501efb163f3f1021a9abb3e7d5d85cde5acc8..a835d76782af2694db6b5b2bc48b45c0dea97641 100644 --- a/Examples/python/simulation/ex03_InterferenceFunctions/RectangularGrating.py +++ b/Examples/python/simulation/ex03_InterferenceFunctions/RectangularGrating.py @@ -1,6 +1,7 @@ """ -Simulation of grating using very long boxes and 1D lattice. Monte-carlo integration is used to get rid -from large particle form factor oscillations. +Simulation of grating using very long boxes and 1D lattice. +Monte-carlo integration is used to get rid of +large-particle form factor oscillations. """ import numpy import matplotlib @@ -14,7 +15,8 @@ alpha_min, alpha_max = 0.0, 2.0 def get_sample(lattice_rotation_angle=45.0*degree): """ - Build and return the sample representing 1D grating made out from a very long boxes + Returns a sample with a grating on a substrate, + modelled by very long boxes forming a 1D lattice with Cauchy correlations. """ # defining materials m_ambience = ba.HomogeneousMaterial("Air", 0.0, 0.0) @@ -25,7 +27,8 @@ def get_sample(lattice_rotation_angle=45.0*degree): lattice_length = 30.0*nanometer # collection of particles - interference = ba.InterferenceFunction1DLattice(lattice_length, lattice_rotation_angle) + interference = ba.InterferenceFunction1DLattice( + lattice_length, lattice_rotation_angle) pdf = ba.FTDecayFunction1DCauchy(1000.0) interference.setDecayFunction(pdf) @@ -33,7 +36,8 @@ def get_sample(lattice_rotation_angle=45.0*degree): box = ba.Particle(m_particle, box_ff) particle_layout = ba.ParticleLayout() - particle_layout.addParticle(box, 1.0, ba.kvector_t(0.0, 0.0, 0.0), ba.RotationZ(lattice_rotation_angle)) + particle_layout.addParticle( + box, 1.0, ba.kvector_t(0.0, 0.0, 0.0), ba.RotationZ(lattice_rotation_angle)) particle_layout.addInterferenceFunction(interference) # assembling the sample @@ -52,7 +56,8 @@ def get_simulation(monte_carlo_integration=True): Create and return GISAXS simulation with beam and detector defined """ simulation = ba.GISASSimulation() - simulation.setDetectorParameters(200, phi_min*degree, phi_max*degree, 200, alpha_min*degree, alpha_max*degree) + simulation.setDetectorParameters(200, phi_min*degree, phi_max*degree, + 200, alpha_min*degree, alpha_max*degree) simulation.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) if monte_carlo_integration: sim_pars = SimulationParameters() @@ -74,10 +79,12 @@ def run_simulation(): result = simulation.getIntensityData() # showing the result - im = plt.imshow(result.getArray(), - norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), - extent=[result.getXmin()/degree, result.getXmax()/degree, result.getYmin()/degree, result.getYmax()/degree], - aspect='auto') + im = plt.imshow( + result.getArray(), + norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), + extent=[result.getXmin()/degree, result.getXmax()/degree, + result.getYmin()/degree, result.getYmax()/degree], + aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) plt.xlabel(r'$\phi_f (^{\circ})$', fontsize=16) diff --git a/Examples/python/simulation/ex03_InterferenceFunctions/SpheresAtHexLattice.py b/Examples/python/simulation/ex03_InterferenceFunctions/SpheresAtHexLattice.py index 20d16219cb1bee9894381d15ea9fdec527dcb56a..7cf0c9b406df2306b83b396cca1c1ec3127fb145 100644 --- a/Examples/python/simulation/ex03_InterferenceFunctions/SpheresAtHexLattice.py +++ b/Examples/python/simulation/ex03_InterferenceFunctions/SpheresAtHexLattice.py @@ -13,7 +13,8 @@ alpha_min, alpha_max = 0.0, 1.0 def get_sample(): """ - Build and return the sample representing spheres on a hexagonal 2D lattice + Returns a sample with spherical particles on a substrate, + forming a hexagonal 2D lattice. """ m_air = ba.HomogeneousMaterial("Air", 0.0, 0.0) m_substrate = ba.HomogeneousMaterial("Substrate", 6e-6, 2e-8) @@ -44,7 +45,8 @@ def get_simulation(): Create and return GISAXS simulation with beam and detector defined """ simulation = ba.GISASSimulation() - simulation.setDetectorParameters(200, phi_min*degree, phi_max*degree, 200, alpha_min*degree, alpha_max*degree) + simulation.setDetectorParameters(200, phi_min*degree, phi_max*degree, + 200, alpha_min*degree, alpha_max*degree) simulation.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) return simulation @@ -60,10 +62,12 @@ def run_simulation(): result = simulation.getIntensityData() # showing the result - im = plt.imshow(result.getArray(), - norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), - extent=[result.getXmin()/degree, result.getXmax()/degree, result.getYmin()/degree, result.getYmax()/degree], - aspect='auto') + im = plt.imshow( + result.getArray(), + norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), + extent=[result.getXmin()/degree, result.getXmax()/degree, + result.getYmin()/degree, result.getYmax()/degree], + aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) plt.xlabel(r'$\phi_f (^{\circ})$', fontsize=16) @@ -73,5 +77,3 @@ def run_simulation(): if __name__ == '__main__': run_simulation() - - diff --git a/Examples/python/simulation/ex03_InterferenceFunctions/TriangularRipple.py b/Examples/python/simulation/ex03_InterferenceFunctions/TriangularRipple.py index ee7f5a158d45f91d6842493a29cd087e45f343ac..1fb1f1937211e36f490d328b9e98bcda480658ee 100644 --- a/Examples/python/simulation/ex03_InterferenceFunctions/TriangularRipple.py +++ b/Examples/python/simulation/ex03_InterferenceFunctions/TriangularRipple.py @@ -13,7 +13,8 @@ alpha_min, alpha_max = 0.0, 2.5 def get_sample(): """ - Build and return the sample representing the triangular ripple in the framework of the 1D Paracrystal. + Returns a sample with a grating on a substrate, modelled by triangular ripples + forming a 1D Paracrystal. """ # defining materials m_ambience = ba.HomogeneousMaterial("Air", 0.0, 0.0) @@ -21,14 +22,17 @@ def get_sample(): m_particle = ba.HomogeneousMaterial("Particle", 6e-4, 2e-8) # collection of particles - ripple2_ff = ba.FormFactorRipple2(100*nanometer, 20*nanometer, 4*nanometer, -3.0*nanometer) + ripple2_ff = ba.FormFactorRipple2( + 100*nanometer, 20*nanometer, 4*nanometer, -3.0*nanometer) ripple = ba.Particle(m_particle, ripple2_ff) particle_layout = ba.ParticleLayout() particle_layout.addParticle(ripple, 1.0) - interference = ba.InterferenceFunction2DLattice(200.0*nanometer, 50.0*nanometer, 90.0*degree, 0.0*degree) - pdf = ba.FTDecayFunction2DGauss(1000.*nanometer/2./numpy.pi, 100.*nanometer/2./numpy.pi) + interference = ba.InterferenceFunction2DLattice( + 200.0*nanometer, 50.0*nanometer, 90.0*degree, 0.0*degree) + pdf = ba.FTDecayFunction2DGauss( + 1000.*nanometer/2./numpy.pi, 100.*nanometer/2./numpy.pi) interference.setDecayFunction(pdf) particle_layout.addInterferenceFunction(interference) @@ -48,7 +52,8 @@ def get_simulation(): characterizing the input beam and output detector """ simulation = ba.GISASSimulation() - simulation.setDetectorParameters(400, phi_min*degree, phi_max*degree, 400, alpha_min*degree, alpha_max*degree) + simulation.setDetectorParameters(400, phi_min*degree, phi_max*degree, + 400, alpha_min*degree, alpha_max*degree) simulation.setBeamParameters(1.6*angstrom, 0.3*degree, 0.0*degree) return simulation @@ -64,10 +69,12 @@ def run_simulation(): result = simulation.getIntensityData() # showing the result - im = plt.imshow(result.getArray(), - norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), - extent=[result.getXmin()/degree, result.getXmax()/degree, result.getYmin()/degree, result.getYmax()/degree], - aspect='auto') + im = plt.imshow( + result.getArray(), + norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), + extent=[result.getXmin()/degree, result.getXmax()/degree, + result.getYmin()/degree, result.getYmax()/degree], + aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) plt.xlabel(r'$\phi_f (^{\circ})$', fontsize=16) @@ -77,4 +84,3 @@ def run_simulation(): if __name__ == '__main__': run_simulation() - diff --git a/Examples/python/simulation/ex04_ComplexShapes/CoreShellNanoparticles.py b/Examples/python/simulation/ex04_ComplexShapes/CoreShellNanoparticles.py index 7c063aa383a7ea65b3aa7dd764795516704e825b..ea045ca4b02599057a30b00a2cc7a8e0d391888a 100644 --- a/Examples/python/simulation/ex04_ComplexShapes/CoreShellNanoparticles.py +++ b/Examples/python/simulation/ex04_ComplexShapes/CoreShellNanoparticles.py @@ -13,7 +13,7 @@ alpha_min, alpha_max = 0.0, 2.0 def get_sample(): """ - Build and return the sample representing core shell nano particles + Returns a sample with box-shaped core-shell particles on a substrate. """ # defining materials m_air = ba.HomogeneousMaterial("Air", 0.0, 0.0 ) @@ -44,10 +44,11 @@ def get_sample(): def get_simulation(): """ - Create and return GISAXS simulation with beam and detector defined + Returns a GISAXS simulation with beam and detector defined. """ simulation = ba.GISASSimulation() - simulation.setDetectorParameters(200, phi_min*degree, phi_max*degree, 200, alpha_min*degree, alpha_max*degree) + simulation.setDetectorParameters(200, phi_min*degree, phi_max*degree, + 200, alpha_min*degree, alpha_max*degree) simulation.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) return simulation @@ -63,10 +64,12 @@ def run_simulation(): result = simulation.getIntensityData() # showing the result - im = plt.imshow(result.getArray(), - norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), - extent=[result.getXmin()/degree, result.getXmax()/degree, result.getYmin()/degree, result.getYmax()/degree], - aspect='auto') + im = plt.imshow( + result.getArray(), + norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), + extent=[result.getXmin()/degree, result.getXmax()/degree, + result.getYmin()/degree, result.getYmax()/degree], + aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) plt.xlabel(r'$\phi_f (^{\circ})$', fontsize=16) @@ -76,4 +79,3 @@ def run_simulation(): if __name__ == '__main__': run_simulation() - diff --git a/Examples/python/simulation/ex04_ComplexShapes/CustomFormFactor.py b/Examples/python/simulation/ex04_ComplexShapes/CustomFormFactor.py index 5b18e97a502934bd8b976a13a865d94a4de13cee..b05003e384412978f2daba5745d7e93d1f703264 100644 --- a/Examples/python/simulation/ex04_ComplexShapes/CustomFormFactor.py +++ b/Examples/python/simulation/ex04_ComplexShapes/CustomFormFactor.py @@ -46,13 +46,14 @@ class CustomFormFactor(ba.IFormFactorBorn): qxhL = 0.5*q.x()*self.L qyhL = 0.5*q.y()*self.L return 0.5*self.H*self.L**2*cmath.exp(complex(0.,1.)*qzhH)*sinc(qzhH)* - (sinc(0.5*qyhL)*(sinc(qxhL)-0.5*sinc(0.5*qxhL))+sinc(0.5*qxhL)*sinc(qyhL)) + (sinc(0.5*qyhL)*(sinc(qxhL)-0.5*sinc(0.5*qxhL))+ + sinc(0.5*qxhL)*sinc(qyhL)) def get_sample(): """ - Build and return the sample to calculate custom form factor in Distorted Wave Born Approximation. + Returns a sample with particles, having a custom form factor, on a substrate. """ # defining materials m_ambience = ba.HomogeneousMaterial("Air", 0.0, 0.0) @@ -77,13 +78,14 @@ def get_sample(): def get_simulation(): """ - Create and return GISAXS simulation with beam and detector defined + Returns a GISAXS simulation with beam and detector defined. IMPORTANT NOTE: Multithreading should be deactivated by putting ThreadInfo.n_threads to -1 """ simulation = ba.GISASSimulation() simulation.getOptions().setNumberOfThreads(-1) - simulation.setDetectorParameters(100, phi_min*degree, phi_max*degree, 100, alpha_min*degree, alpha_max*degree) + 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) return simulation @@ -99,10 +101,12 @@ def run_simulation(): result = simulation.getIntensityData() # showing the result - im = plt.imshow(result.getArray(), - norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), - extent=[result.getXmin()/degree, result.getXmax()/degree, result.getYmin()/degree, result.getYmax()/degree], - aspect='auto') + im = plt.imshow( + result.getArray(), + norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), + extent=[result.getXmin()/degree, result.getXmax()/degree, + result.getYmin()/degree, result.getYmax()/degree], + aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) plt.xlabel(r'$\phi_f (^{\circ})$', fontsize=16) diff --git a/Examples/python/simulation/ex04_ComplexShapes/HexagonalLatticesWithBasis.py b/Examples/python/simulation/ex04_ComplexShapes/HexagonalLatticesWithBasis.py index 14754d48c680fc5a73a750cac4f7e8c37e586297..89f5033bafdf0b40c7051ae0a42a08a132d4b642 100644 --- a/Examples/python/simulation/ex04_ComplexShapes/HexagonalLatticesWithBasis.py +++ b/Examples/python/simulation/ex04_ComplexShapes/HexagonalLatticesWithBasis.py @@ -13,7 +13,8 @@ alpha_min, alpha_max = 0.0, 1.0 def get_sample(): """ - Build and return the sample representing spheres on two hexagonal close packed layers + Returns a sample with spheres on a substrate, + forming two hexagonal close packed layers. """ m_air = ba.HomogeneousMaterial("Air", 0.0, 0.0) m_substrate = ba.HomogeneousMaterial("Substrate", 6e-6, 2e-8) @@ -47,10 +48,11 @@ def get_sample(): def get_simulation(): """ - Create and return GISAXS simulation with beam and detector defined + Returns a GISAXS simulation with beam and detector defined. """ simulation = ba.GISASSimulation() - simulation.setDetectorParameters(200, phi_min*degree, phi_max*degree, 200, alpha_min*degree, alpha_max*degree) + simulation.setDetectorParameters(200, phi_min*degree, phi_max*degree, + 200, alpha_min*degree, alpha_max*degree) simulation.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) return simulation @@ -66,10 +68,12 @@ def run_simulation(): result = simulation.getIntensityData() # showing the result - im = plt.imshow(result.getArray(), - norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), - extent=[result.getXmin()/degree, result.getXmax()/degree, result.getYmin()/degree, result.getYmax()/degree], - aspect='auto') + im = plt.imshow( + result.getArray(), + norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), + extent=[result.getXmin()/degree, result.getXmax()/degree, + result.getYmin()/degree, result.getYmax()/degree], + aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) plt.xlabel(r'$\phi_f (^{\circ})$', fontsize=16) @@ -79,5 +83,3 @@ def run_simulation(): if __name__ == '__main__': run_simulation() - - diff --git a/Examples/python/simulation/ex04_ComplexShapes/LargeParticlesFormFactor.py b/Examples/python/simulation/ex04_ComplexShapes/LargeParticlesFormFactor.py index 96444ebffefe76db80ab0b2d4f4991e00cdc20a4..cdbd3ef7246e39d015848c79e18aee62de59e79d 100644 --- a/Examples/python/simulation/ex04_ComplexShapes/LargeParticlesFormFactor.py +++ b/Examples/python/simulation/ex04_ComplexShapes/LargeParticlesFormFactor.py @@ -1,8 +1,9 @@ """ Large cylinders in DWBA. -Examples demonstrates, that for large particles (~1000nm) the formfactor oscillates rapidly within -one detector bin and analytical calculations (performed for the bin center) give completely wrong intensity pattern. +This example demonstrates that for large particles (~1000nm) the formfactor +oscillates rapidly within one detector bin and analytical calculations +(performed for the bin center) give completely wrong intensity pattern. In this case Monte-Carlo integration over detector bin should be used. """ import numpy @@ -19,8 +20,7 @@ default_cylinder_height = 20*nanometer def get_sample(cylinder_radius, cylinder_height): """ - Build and return the sample to calculate cylinder formfactor in Distorted Wave Born Approximation - for given cylinder_radius and cylinder_height + Returns a sample with cylindrical particles on a substrate. """ # defining materials m_ambience = ba.HomogeneousMaterial("Air", 0.0, 0.0) @@ -45,11 +45,12 @@ def get_sample(cylinder_radius, cylinder_height): def get_simulation(integration_flag): """ - Create and return GISAXS simulation with beam and detector defined. - If integration_flag=True, the simulation will perform an integration over detector bin size + Returns a GISAXS simulation with defined beam and detector. + If integration_flag=True, the simulation will integrate over detector bins. """ simulation = ba.GISASSimulation() - simulation.setDetectorParameters(200, phi_min*degree, phi_max*degree, 200, alpha_min*degree, alpha_max*degree) + simulation.setDetectorParameters( + 200, phi_min*degree, phi_max*degree, 200, alpha_min*degree, alpha_max*degree) simulation.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) simulation.getOptions().setMonteCarloIntegration(integration_flag, 50) @@ -58,17 +59,22 @@ def get_simulation(integration_flag): def run_simulation(): """ - Run simulation and plot results 4 times: for small and large cylinders, with and without integration + Runs simulation and plots 4 results: +for small and large cylinders, with and without integration """ fig = plt.figure(figsize=(12.80, 10.24)) # conditions to define cylinders scale factor and Monte-Carlo integration flag conditions = [ - {'title': "Small cylinders, analytical calculations", 'scale': 1, 'integration': False, 'max': 1e+08}, - {'title': "Small cylinders, Monte-Carlo integration", 'scale': 1, 'integration': True, 'max': 1e+08}, - {'title': "Large cylinders, analytical calculations", 'scale': 100, 'integration': False, 'max': 1e+12}, - {'title': "Large cylinders, Monte-Carlo integration", 'scale': 100, 'integration': True, 'max': 1e+12} + {'title': "Small cylinders, analytical calculations", 'scale': 1, + 'integration': False, 'max': 1e+08}, + {'title': "Small cylinders, Monte-Carlo integration", 'scale': 1, + 'integration': True, 'max': 1e+08}, + {'title': "Large cylinders, analytical calculations", 'scale': 100, + 'integration': False, 'max': 1e+12}, + {'title': "Large cylinders, Monte-Carlo integration", 'scale': 100, + 'integration': True, 'max': 1e+12} ] # run simulation 4 times and plot results @@ -76,7 +82,8 @@ def run_simulation(): scale = conditions[i_plot]['scale'] integration_flag = conditions[i_plot]['integration'] - sample = get_sample(default_cylinder_radius*scale, default_cylinder_height*scale) + sample = get_sample(default_cylinder_radius*scale, + default_cylinder_height*scale) simulation = get_simulation(integration_flag) simulation.setSample(sample) simulation.runSimulation() @@ -85,15 +92,21 @@ def run_simulation(): # plotting results plt.subplot(2, 2, i_plot+1) plt.subplots_adjust(wspace=0.3, hspace=0.3) - im = plt.imshow(result.getArray(), - norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), - extent=[result.getXmin()/degree, result.getXmax()/degree, result.getYmin()/degree, result.getYmax()/degree], - aspect='auto') + im = plt.imshow( + result.getArray(), + norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), + extent=[result.getXmin()/degree, result.getXmax()/degree, + result.getYmin()/degree, result.getYmax()/degree], + aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) plt.xlabel(r'$\phi_f (^{\circ})$', fontsize=16) plt.ylabel(r'$\alpha_f (^{\circ})$', fontsize=16) - plt.text(0.0, 2.1, conditions[i_plot]['title'], horizontalalignment='center', verticalalignment='center', fontsize=13) + plt.text(0.0, 2.1, + conditions[i_plot]['title'], + horizontalalignment='center', + verticalalignment='center', + fontsize=13) plt.show() diff --git a/Examples/python/simulation/ex05_BeamAndDetector/BeamDivergence.py b/Examples/python/simulation/ex05_BeamAndDetector/BeamDivergence.py index 45edb96bab4d0f1b39d29df4ac916cb17dfb055b..998d78b4ab6f4f61903e9e3ce53af9a8ac72ff15 100644 --- a/Examples/python/simulation/ex05_BeamAndDetector/BeamDivergence.py +++ b/Examples/python/simulation/ex05_BeamAndDetector/BeamDivergence.py @@ -13,7 +13,7 @@ alpha_min, alpha_max = 0.0, 2.0 def get_sample(): """ - Build and return the sample to calculate cylinder formfactor in Distorted Wave Born Approximation. + Returns a sample with uncorrelated cylinders on a substrate. """ # defining materials m_ambience = ba.HomogeneousMaterial("Air", 0.0, 0.0) @@ -39,10 +39,11 @@ def get_sample(): def get_simulation(): """ - Create and return GISAXS simulation with beam (+ divergence) and detector defined + Returns a GISAXS simulation with beam (+ divergence) and detector defined. """ simulation = ba.GISASSimulation() - simulation.setDetectorParameters(100, phi_min*degree, phi_max*degree, 100, alpha_min*degree, alpha_max*degree) + 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) wavelength_distr = ba.DistributionLogNormal(1.0*angstrom, 0.1) alpha_distr = ba.DistributionGaussian(0.2*degree, 0.1*degree) @@ -66,10 +67,12 @@ def run_simulation(): result = simulation.getIntensityData() # showing the result - im = plt.imshow(result.getArray(), - norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), - extent=[result.getXmin()/degree, result.getXmax()/degree, result.getYmin()/degree, result.getYmax()/degree], - aspect='auto') + im = plt.imshow( + result.getArray(), + norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), + extent=[result.getXmin()/degree, result.getXmax()/degree, + result.getYmin()/degree, result.getYmax()/degree], + aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) plt.xlabel(r'$\phi_f (^{\circ})$', fontsize=16) @@ -79,5 +82,3 @@ def run_simulation(): if __name__ == '__main__': run_simulation() - - diff --git a/Examples/python/simulation/ex05_BeamAndDetector/DetectorResolutionFunction.py b/Examples/python/simulation/ex05_BeamAndDetector/DetectorResolutionFunction.py index f1a8f089865253ce8bbc02bdd32975942b8ee791..2af85478f5fc86a622d3910c0666ad9444cfee2e 100644 --- a/Examples/python/simulation/ex05_BeamAndDetector/DetectorResolutionFunction.py +++ b/Examples/python/simulation/ex05_BeamAndDetector/DetectorResolutionFunction.py @@ -13,7 +13,7 @@ alpha_min, alpha_max = 0.0, 2.0 def get_sample(): """ - Build and return the sample to calculate cylinder formfactor in Distorted Wave Born Approximation. + Returns a sample with uncorrelated cylinders on a substrate. """ # defining materials m_ambience = ba.HomogeneousMaterial("Air", 0.0, 0.0) @@ -39,12 +39,14 @@ def get_sample(): def get_simulation(): """ - Create and return GISAXS simulation with detector resolution function defined + Returns a GISAXS simulation with detector resolution function defined. """ simulation = ba.GISASSimulation() - simulation.setDetectorParameters(100, phi_min*degree, phi_max*degree, 100, alpha_min*degree, alpha_max*degree) + 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(ba.ResolutionFunction2DGaussian(0.0025, 0.0025)) + simulation.setDetectorResolutionFunction( + ba.ResolutionFunction2DGaussian(0.0025, 0.0025)) return simulation @@ -60,10 +62,12 @@ def run_simulation(): result = simulation.getIntensityData() # showing the result - im = plt.imshow(result.getArray(), - norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), - extent=[result.getXmin()/degree, result.getXmax()/degree, result.getYmin()/degree, result.getYmax()/degree], - aspect='auto') + im = plt.imshow( + result.getArray(), + norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), + extent=[result.getXmin()/degree, result.getXmax()/degree, + result.getYmin()/degree, result.getYmax()/degree], + aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) plt.xlabel(r'$\phi_f (^{\circ})$', fontsize=16) @@ -73,5 +77,3 @@ def run_simulation(): if __name__ == '__main__': run_simulation() - - diff --git a/Examples/python/simulation/ex05_BeamAndDetector/OffSpecularSimulation.py b/Examples/python/simulation/ex05_BeamAndDetector/OffSpecularSimulation.py index 3d6238c732fa4404367b3c8a3b2d80083d0e34cc..33008f0770e4a9bbea16aab61052c923a6f47398 100644 --- a/Examples/python/simulation/ex05_BeamAndDetector/OffSpecularSimulation.py +++ b/Examples/python/simulation/ex05_BeamAndDetector/OffSpecularSimulation.py @@ -15,7 +15,8 @@ alpha_i_min, alpha_i_max = 0.0, 10.0 # incoming beam def get_sample(): """ - Build and return the sample infinitely long boxes at 1D lattice + Returns a sample with a grating on a substrate, + modelled by infinitely long boxes forming a 1D lattice. """ # defining materials m_ambience = ba.HomogeneousMaterial("Air", 0.0, 0.0) @@ -25,7 +26,8 @@ def get_sample(): # collection of particles lattice_length = 100.0*nanometer lattice_rotation_angle = 0.0*degree - interference = ba.InterferenceFunction1DLattice(lattice_length, lattice_rotation_angle) + interference = ba.InterferenceFunction1DLattice( + lattice_length, lattice_rotation_angle) pdf = ba.FTDecayFunction1DCauchy(1e+6) interference.setDecayFunction(pdf) @@ -49,12 +51,14 @@ def get_sample(): def get_simulation(): """ - Create and return off-specular simulation with beam and detector defined + Returns an off-specular simulation with beam and detector defined. """ simulation = ba.OffSpecSimulation() - simulation.setDetectorParameters(20, phi_f_min*degree, phi_f_max*degree, 200, alpha_f_min*degree, alpha_f_max*degree) - # defining the beam with incidence alpha_i varied between alpha_i_min and alpha_i_max - alpha_i_axis = ba.FixedBinAxis("alpha_i", 200, alpha_i_min*degree, alpha_i_max*degree) + simulation.setDetectorParameters(20, phi_f_min*degree, phi_f_max*degree, + 200, alpha_f_min*degree, alpha_f_max*degree) + # define the beam with alpha_i varied between alpha_i_min and alpha_i_max + alpha_i_axis = ba.FixedBinAxis( + "alpha_i", 200, alpha_i_min*degree, alpha_i_max*degree) simulation.setBeamParameters(1.0*angstrom, alpha_i_axis, 0.0*degree) simulation.setBeamIntensity(1e9) return simulation @@ -71,10 +75,12 @@ def run_simulation(): result = simulation.getIntensityData() # showing the result - im = plt.imshow(result.getArray(), - norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), - extent=[result.getXmin()/degree, result.getXmax()/degree, result.getYmin()/degree, result.getYmax()/degree], - aspect='auto') + im = plt.imshow( + result.getArray(), + norm=matplotlib.colors.LogNorm(1.0, result.getMaximum()), + extent=[result.getXmin()/degree, result.getXmax()/degree, + result.getYmin()/degree, result.getYmax()/degree], + aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) plt.xlabel(r'$\phi_f (^{\circ})$', fontsize=16) diff --git a/Examples/python/simulation/ex05_BeamAndDetector/RectangularDetector.py b/Examples/python/simulation/ex05_BeamAndDetector/RectangularDetector.py index 7a8c236992c39412452c69f460b75117e4600cb8..b91a2166323a4e39edf76bbca59eb769aa15ef98 100644 --- a/Examples/python/simulation/ex05_BeamAndDetector/RectangularDetector.py +++ b/Examples/python/simulation/ex05_BeamAndDetector/RectangularDetector.py @@ -1,6 +1,6 @@ """ Simulation with rectangular detector. Pilatus3-1M detector is used as an example. -Results will be compared against simulation with spherical detector. +Results will be compared against simulation with spherical detector. """ import numpy import matplotlib @@ -16,7 +16,7 @@ pilatus_npx, pilatus_npy = 981, 1043 # number of pixels def get_sample(): """ - Build and return the sample to calculate cylinder formfactor in Distorted Wave Born Approximation. + Returns a sample with cylinderical particles on a substrate. """ # defining materials m_ambience = ba.HomogeneousMaterial("Air", 0.0, 0.0) @@ -41,7 +41,7 @@ def get_sample(): def get_spherical_detector(): """ - Returns spherical detector roughly representing our PILATUS detector + Returns a spherical detector roughly approximating our PILATUS detector """ n_phi = pilatus_npx n_alpha = pilatus_npy @@ -51,12 +51,13 @@ def get_spherical_detector(): phi_max = numpy.arctan(width/2./detector_distance) alpha_min = 0.0 alpha_max = numpy.arctan(height/detector_distance) - return ba.SphericalDetector(n_phi, phi_min, phi_max, n_alpha, alpha_min, alpha_max) + return ba.SphericalDetector( + n_phi, phi_min, phi_max, n_alpha, alpha_min, alpha_max) def get_rectangular_detector(): """ - Returns rectangular detector representing our PILATUS detector + Returns a rectangular detector representing our PILATUS detector """ width = pilatus_npx*pilatus_pixel_size height = pilatus_npy*pilatus_pixel_size @@ -67,7 +68,7 @@ def get_rectangular_detector(): def get_simulation(): """ - Create and return GISAXS simulation with beam defined + Return a GISAXS simulation with defined beam """ simulation = ba.GISASSimulation() simulation.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) @@ -82,10 +83,12 @@ def plot_results(result_sph, result_rect): # showing result of spherical detector simulation plt.subplot(1, 3, 1) - im = plt.imshow(result_sph.getArray(), - norm=matplotlib.colors.LogNorm(1.0, result_sph.getMaximum()), - extent=[result_sph.getXmin()/degree, result_sph.getXmax()/degree, result_sph.getYmin()/degree, result_sph.getYmax()/degree], - aspect='auto') + im = plt.imshow( + result_sph.getArray(), + norm=matplotlib.colors.LogNorm(1.0, result_sph.getMaximum()), + extent=[result_sph.getXmin()/degree, result_sph.getXmax()/degree, + result_sph.getYmin()/degree, result_sph.getYmax()/degree], + aspect='auto') cb = plt.colorbar(im, pad=0.025) plt.xlabel(r'$\phi_f ^{\circ}$', fontsize=16) plt.ylabel(r'$\alpha_f ^{\circ}$', fontsize=16) @@ -93,22 +96,26 @@ def plot_results(result_sph, result_rect): # showing result of rectangular detector simulation plt.subplot(1, 3, 2) - im = plt.imshow(result_rect.getArray(), - norm=matplotlib.colors.LogNorm(1.0, result_rect.getMaximum()), - extent=[result_rect.getXmin(), result_rect.getXmax(), result_rect.getYmin(), result_rect.getYmax()], - aspect='auto') + im = plt.imshow( + result_rect.getArray(), + norm=matplotlib.colors.LogNorm(1.0, result_rect.getMaximum()), + extent=[result_rect.getXmin(), result_rect.getXmax(), + result_rect.getYmin(), result_rect.getYmax()], + aspect='auto') cb = plt.colorbar(im, pad = 0.025) plt.xlabel('X, mm', fontsize=12) plt.ylabel('Y, mm', fontsize=12) plt.title("Rectangular detector") - # showing relative difference between two plots (sph[i]-rect[i])/rect[i] for every detector pixel + # show relative difference between two plots (sph[i]-rect[i])/rect[i] + # for every detector pixel diff = result_sph.relativeDifferenceHistogram(result_rect) plt.subplot(1, 3, 3) - im = plt.imshow(diff.getArray(), - norm=matplotlib.colors.LogNorm(1e-06, 1.0), - extent=[diff.getXmin(), diff.getXmax(), diff.getYmin(), diff.getYmax()], - aspect='auto') + im = plt.imshow( + diff.getArray(), + norm=matplotlib.colors.LogNorm(1e-06, 1.0), + extent=[diff.getXmin(), diff.getXmax(), diff.getYmin(), diff.getYmax()], + aspect='auto') cb = plt.colorbar(im, pad=0.025) plt.xlabel('X, mm', fontsize=12) plt.ylabel('Y, mm', fontsize=12) @@ -140,5 +147,3 @@ def run_simulation(): if __name__ == '__main__': run_simulation() - - diff --git a/Examples/python/simulation/ex05_BeamAndDetector/SpecularSimulation.py b/Examples/python/simulation/ex05_BeamAndDetector/SpecularSimulation.py index 21b8c9a719fb7c90fa7b9dcc589c02a3af9a6fe4..f82a5547883346b637021afa92ee3e633369332d 100644 --- a/Examples/python/simulation/ex05_BeamAndDetector/SpecularSimulation.py +++ b/Examples/python/simulation/ex05_BeamAndDetector/SpecularSimulation.py @@ -12,7 +12,7 @@ alpha_i_min, alpha_i_max = 0.0, 2.0 # incoming beam def get_sample(): """ - Build and return the sample representing the layers with correlated roughness. + Returns a sample with two layers on a substrate, with correlated roughnesses. """ m_ambience = ba.HomogeneousMaterial("ambience", 0.0, 0.0) m_part_a = ba.HomogeneousMaterial("PartA", 5e-6, 0.0) @@ -47,10 +47,11 @@ def get_sample(): def get_simulation(): """ - Create and return specular simulation with beam and detector defined + Returns a specular simulation with beam and detector defined. """ simulation = ba.SpecularSimulation() - simulation.setBeamParameters(1.54*angstrom, 1000, alpha_i_min*degree, alpha_i_max*degree) + simulation.setBeamParameters( + 1.54*angstrom, 1000, alpha_i_min*degree, alpha_i_max*degree) return simulation @@ -71,11 +72,9 @@ def run_simulation(): nplot = 1 for layer_index in selected_layers: - R = [] for coeff in simulation.getScalarR(layer_index): R.append(numpy.abs(coeff)) - T = [] for coeff in simulation.getScalarT(layer_index): T.append(numpy.abs(coeff)) @@ -85,10 +84,11 @@ def run_simulation(): plt.xlabel(r'$\alpha_f$ (rad)', fontsize=16) plt.semilogy(alpha_angles, R) plt.semilogy(alpha_angles, T) - plt.legend(['|R| layer #'+str(layer_index), '|T| layer #'+str(layer_index)], loc='upper right') + plt.legend(['|R| layer #'+str(layer_index), + '|T| layer #'+str(layer_index)], + loc='upper right') nplot = nplot + 1 - plt.show() diff --git a/Examples/python/simulation/ex06_Miscellaneous/AccessingSimulationResults.py b/Examples/python/simulation/ex06_Miscellaneous/AccessingSimulationResults.py index 9c58ea2794a1f38372dc918a5a419c2b5f78cdf9..cb550100085c5c0104ff8bba51adafd0eaf02cfb 100644 --- a/Examples/python/simulation/ex06_Miscellaneous/AccessingSimulationResults.py +++ b/Examples/python/simulation/ex06_Miscellaneous/AccessingSimulationResults.py @@ -16,7 +16,7 @@ alpha_min, alpha_max = 0.0, 2.0 def get_sample(): """ - Build and return the sample to calculate cylinder formfactor in Distorted Wave Born Approximation. + Returns tha sample with uncorrelated cylinders on a substrate. """ # defining materials m_ambience = ba.HomogeneousMaterial("Air", 0.0, 0.0) @@ -41,10 +41,11 @@ def get_sample(): def get_simulation(): """ - Create and return GISAXS simulation with beam and detector defined + Returns a GISAXS simulation with beam and detector defined. """ simulation = ba.GISASSimulation() - simulation.setDetectorParameters(200, phi_min*degree, phi_max*degree, 200, alpha_min*degree, alpha_max*degree) + simulation.setDetectorParameters(200, phi_min*degree, phi_max*degree, + 200, alpha_min*degree, alpha_max*degree) simulation.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) return simulation @@ -59,10 +60,12 @@ def plot_as_colormap(hist, zmin=None, zmax=None): if not zmax: zmax = hist.getMaximum() - im = plt.imshow(hist.getArray(), - norm=matplotlib.colors.LogNorm(zmin, zmax), - extent=[hist.getXmin()/degree, hist.getXmax()/degree, hist.getYmin()/degree, hist.getYmax()/degree], - aspect='auto') + im = plt.imshow( + hist.getArray(), + norm=matplotlib.colors.LogNorm(zmin, zmax), + extent=[hist.getXmin()/degree, hist.getXmax()/degree, + hist.getYmin()/degree, hist.getYmax()/degree], + aspect='auto') cb = plt.colorbar(im, pad=0.025) plt.xlabel(r'$\phi_f ^{\circ}$', fontsize=16) plt.ylabel(r'$\alpha_f ^{\circ}$', fontsize=16) @@ -108,15 +111,21 @@ def plot_slices(hist): # projection along Y, slice at fixed x-value proj1 = noisy.projectionY(0.0*degree) - plt.semilogy(proj1.getBinCenters()/degree, proj1.getBinValues(), label=r'$\phi=0.0^{\circ}$') + plt.semilogy(proj1.getBinCenters()/degree, + proj1.getBinValues(), + label=r'$\phi=0.0^{\circ}$') # projection along Y, slice at fixed x-value proj2 = noisy.projectionY(0.5*degree) # slice at fixed value - plt.semilogy(proj2.getBinCenters()/degree, proj2.getBinValues(), label=r'$\phi=0.5^{\circ}$') + plt.semilogy(proj2.getBinCenters()/degree, + proj2.getBinValues(), + label=r'$\phi=0.5^{\circ}$') # projection along Y for all X values between [xlow, xup], averaged proj3 = noisy.projectionY(0.4*degree, 0.6*degree) - plt.semilogy(proj3.getBinCenters()/degree, proj3.getArray(ba.IHistogram.AVERAGE), label=r'$<\phi>=0.5^{\circ}$') + plt.semilogy(proj3.getBinCenters()/degree, + proj3.getArray(ba.IHistogram.AVERAGE), + label=r'$<\phi>=0.5^{\circ}$') plt.xlim(proj1.getXmin()/degree, proj1.getXmax()/degree) plt.ylim(1.0, proj1.getMaximum()*10.0) @@ -141,7 +150,8 @@ def save_to_file(result): def plot_results(result): """ - Runs different plotting functions one by one to demonstrate trivial data presentation tasks + Runs different plotting functions one by one + to demonstrate trivial data presentation tasks. """ fig = plt.figure(figsize=(12.80, 10.24)) @@ -183,5 +193,3 @@ def run_simulation(): if __name__ == '__main__': run_simulation() - - diff --git a/Examples/python/simulation/ex06_Miscellaneous/AxesInDifferentUnits.py b/Examples/python/simulation/ex06_Miscellaneous/AxesInDifferentUnits.py index eb3f8928a58990fbf7097c150fde76380e77e668..dbd53c9ca8bbb2bd812d93fe99a2766494eab9f9 100644 --- a/Examples/python/simulation/ex06_Miscellaneous/AxesInDifferentUnits.py +++ b/Examples/python/simulation/ex06_Miscellaneous/AxesInDifferentUnits.py @@ -15,7 +15,7 @@ pilatus_npx, pilatus_npy = 981, 1043 # number of pixels def get_sample(): """ - Build and return the sample to calculate cylinder formfactor in Distorted Wave Born Approximation. + Returns a sample with uncorrelated cylinders on a substrate. """ # defining materials m_ambience = ba.HomogeneousMaterial("Air", 0.0, 0.0) @@ -51,7 +51,7 @@ def get_rectangular_detector(): def get_simulation(): """ - Create and return GISAXS simulation with beam defined + Returns a GISAXS simulation with beam defined """ simulation = ba.GISASSimulation() simulation.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) @@ -64,10 +64,12 @@ def plot_as_colormap(hist, Title, xLabel, yLabel): Simple plot of intensity data as color map """ - im = plt.imshow(hist.getArray(), - norm=matplotlib.colors.LogNorm(1.0, hist.getMaximum()), - extent=[hist.getXmin(), hist.getXmax(), hist.getYmin(), hist.getYmax()], - aspect='auto') + im = plt.imshow( + hist.getArray(), + norm=matplotlib.colors.LogNorm(1.0, hist.getMaximum()), + extent=[hist.getXmin(), hist.getXmax(), + hist.getYmin(), hist.getYmax()], + aspect='auto') cb = plt.colorbar(im, pad=0.025) plt.xlabel(xLabel, fontsize=16) plt.ylabel(yLabel, fontsize=16) @@ -88,19 +90,23 @@ def run_simulation(): plt.subplot(2, 2, 1) # default units for rectangular detector are millimeters result = simulation.getIntensityData() - plot_as_colormap(result, "In default units", r'$X_{mm}$', r'$Y_{mm}$') + plot_as_colormap(result, "In default units", + r'$X_{mm}$', r'$Y_{mm}$') plt.subplot(2, 2, 2) result = simulation.getIntensityData(ba.IDetector2D.NBINS) - plot_as_colormap(result, "In number of bins", r'$X_{nbins}$', r'$Y_{nbins}$') + plot_as_colormap(result, "In number of bins", + r'$X_{nbins}$', r'$Y_{nbins}$') plt.subplot(2, 2, 3) result = simulation.getIntensityData(ba.IDetector2D.DEGREES) - plot_as_colormap(result, "In degrees", r'$\phi_f ^{\circ}$', r'$\alpha_f ^{\circ}$') + plot_as_colormap(result, "In degrees", + r'$\phi_f ^{\circ}$', r'$\alpha_f ^{\circ}$') plt.subplot(2, 2, 4) result = simulation.getIntensityData(ba.IDetector2D.QYQZ) - plot_as_colormap(result, "Q-space", r'$Q_{y} [1/nm]$', r'$Q_{z} [1/nm]$') + plot_as_colormap(result, "Q-space", + r'$Q_{y} [1/nm]$', r'$Q_{z} [1/nm]$') plt.subplots_adjust(left=0.07, right=0.97, top=0.9, bottom=0.1, hspace=0.25) plt.show() @@ -108,5 +114,3 @@ def run_simulation(): if __name__ == '__main__': run_simulation() - -