diff --git a/Examples/python/fitting/ex01_SampleParametersIntro/SampleParametersIntro.py b/Examples/python/fitting/ex01_SampleParametersIntro/SampleParametersIntro.py index 5eb044affbfbafd17d19fcba708418cc5b9eaf1e..154401f294b027a77de8c56dd5ba71f33c0bd50b 100644 --- a/Examples/python/fitting/ex01_SampleParametersIntro/SampleParametersIntro.py +++ b/Examples/python/fitting/ex01_SampleParametersIntro/SampleParametersIntro.py @@ -6,7 +6,7 @@ from __future__ import print_function import matplotlib from matplotlib import pyplot as plt import bornagain as ba -from bornagain import degree, angstrom, nanometer +from bornagain import deg, angstrom, nm def get_sample(): @@ -20,9 +20,9 @@ def get_sample(): m_particle = ba.HomogeneousMaterial("Particle", 6e-4, 2e-8) # collection of particles - cylinder_ff = ba.FormFactorCylinder(5*nanometer, 5*nanometer) + cylinder_ff = ba.FormFactorCylinder(5*nm, 5*nm) cylinder = ba.Particle(m_particle, cylinder_ff) - prism_ff = ba.FormFactorPrism3(5*nanometer, 5*nanometer) + prism_ff = ba.FormFactorPrism3(5*nm, 5*nm) prism = ba.Particle(m_particle, prism_ff) particle_layout = ba.ParticleLayout() particle_layout.addParticle(cylinder, 0.5) @@ -45,9 +45,9 @@ 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.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) + simulation.setDetectorParameters(100, -1.0*deg, 1.0*deg, + 100, 0.0*deg, 2.0*deg) + simulation.setBeamParameters(1.0*angstrom, 0.2*deg, 0.0*deg) return simulation @@ -77,7 +77,7 @@ def run_simulations(): # one sample parameter (cylinder height) is changed using exact parameter name sample.setParameterValue( "/MultiLayer/Layer0/ParticleLayout/Particle0/Cylinder/Height", - 10.0*nanometer) + 10.0*nm) simulation.setSample(sample) simulation.runSimulation() @@ -85,16 +85,16 @@ def run_simulations(): # simulation #3 # all parameters matching criteria will be changed (cylinder height in this case) - sample.setParameterValue("*/Cylinder/Height", 100.0*nanometer) + sample.setParameterValue("*/Cylinder/Height", 100.0*nm) simulation.setSample(sample) simulation.runSimulation() results.append(simulation.getIntensityData()) # simulation #4 # all parameters which are matching criteria will be changed - sample.setParameterValue("*/Cylinder/Height", 10.0*nanometer) + sample.setParameterValue("*/Cylinder/Height", 10.0*nm) # set ba.FormFactorPrism3/half_side and ba.FormFactorPrism3/height to 10 nm - sample.setParameterValue("*/Prism3/*", 10.0*nanometer) + sample.setParameterValue("*/Prism3/*", 10.0*nm) simulation.setSample(sample) simulation.runSimulation() results.append(simulation.getIntensityData()) @@ -112,8 +112,8 @@ def draw_results(results): plt.imshow( hist.getArray(), norm=matplotlib.colors.LogNorm(1, hist.getMaximum()), - extent=[hist.getXmin()/degree, hist.getXmax()/degree, - hist.getYmin()/degree, hist.getYmax()/degree]) + extent=[hist.getXmin()/deg, hist.getXmax()/deg, + hist.getYmin()/deg, hist.getYmax()/deg]) plt.show() diff --git a/Examples/python/fitting/ex02_FitCylindersAndPrisms/FitCylindersPrisms.py b/Examples/python/fitting/ex02_FitCylindersAndPrisms/FitCylindersPrisms.py index 3017dd65ad37be0ecc1a908e3ee60af91d1a90ce..8a22cde140958404b0141008f6516662839d92ab 100644 --- a/Examples/python/fitting/ex02_FitCylindersAndPrisms/FitCylindersPrisms.py +++ b/Examples/python/fitting/ex02_FitCylindersAndPrisms/FitCylindersPrisms.py @@ -2,7 +2,7 @@ Fitting example: 4 parameters fit with simple output """ import bornagain as ba -from bornagain import degree, angstrom, nanometer +from bornagain import deg, angstrom, nm def get_sample(): @@ -15,9 +15,9 @@ def get_sample(): m_particle = ba.HomogeneousMaterial("Particle", 6e-4, 2e-8) # collection of particles - cylinder_ff = ba.FormFactorCylinder(1.0*nanometer, 1.0*nanometer) + cylinder_ff = ba.FormFactorCylinder(1.0*nm, 1.0*nm) cylinder = ba.Particle(m_particle, cylinder_ff) - prism_ff = ba.FormFactorPrism3(1.0*nanometer, 1.0*nanometer) + prism_ff = ba.FormFactorPrism3(1.0*nm, 1.0*nm) prism = ba.Particle(m_particle, prism_ff) particle_layout = ba.ParticleLayout() particle_layout.addParticle(cylinder, 0.5) @@ -40,9 +40,9 @@ def get_simulation(): 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.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) + simulation.setDetectorParameters(100, -1.0*deg, 1.0*deg, + 100, 0.0*deg, 2.0*deg) + simulation.setBeamParameters(1.0*angstrom, 0.2*deg, 0.0*deg) return simulation @@ -62,13 +62,13 @@ def run_fitting(): fit_suite.initPrint(10) # setting fitting parameters with starting values - fit_suite.addFitParameter("*Cylinder/Height", 4.*nanometer, + fit_suite.addFitParameter("*Cylinder/Height", 4.*nm, ba.AttLimits.lowerLimited(0.01)) - fit_suite.addFitParameter("*Cylinder/Radius", 6.*nanometer, + fit_suite.addFitParameter("*Cylinder/Radius", 6.*nm, ba.AttLimits.lowerLimited(0.01)) - fit_suite.addFitParameter("*Prism3/Height", 4.*nanometer, + fit_suite.addFitParameter("*Prism3/Height", 4.*nm, ba.AttLimits.lowerLimited(0.01)) - fit_suite.addFitParameter("*Prism3/Length", 12.*nanometer, + fit_suite.addFitParameter("*Prism3/Length", 12.*nm, ba.AttLimits.lowerLimited(0.01)) # running fit diff --git a/Examples/python/fitting/ex02_FitCylindersAndPrisms/FitCylindersPrisms_detailed.py b/Examples/python/fitting/ex02_FitCylindersAndPrisms/FitCylindersPrisms_detailed.py index e1255f70cbe0da6bf5c6a03cb6492d005348a3c4..2b591cb3d8f1a5935bfe86293c149822a3ca8b21 100644 --- a/Examples/python/fitting/ex02_FitCylindersAndPrisms/FitCylindersPrisms_detailed.py +++ b/Examples/python/fitting/ex02_FitCylindersAndPrisms/FitCylindersPrisms_detailed.py @@ -11,11 +11,11 @@ from matplotlib import pyplot as plt import math import random import bornagain as ba -from bornagain import degree, angstrom, nanometer +from bornagain import deg, angstrom, nm -def get_sample(cylinder_height=1.0*nanometer, cylinder_radius=1.0*nanometer, - prism_length=2.0*nanometer, prism_height=1.0*nanometer): +def get_sample(cylinder_height=1.0*nm, cylinder_radius=1.0*nm, + prism_length=2.0*nm, prism_height=1.0*nm): """ Returns a sample with uncorrelated cylinders and prisms on a substrate. """ @@ -52,7 +52,7 @@ def create_real_data(): 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) + sample = get_sample(5.0*nm, 5.0*nm, 5.0*nm, 5.0*nm) simulation = get_simulation() simulation.setSample(sample) @@ -80,9 +80,9 @@ def get_simulation(): 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.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) + simulation.setDetectorParameters(100, -1.0*deg, 1.0*deg, + 100, 0.0*deg, 2.0*deg) + simulation.setBeamParameters(1.0*angstrom, 0.2*deg, 0.0*deg) return simulation @@ -106,8 +106,8 @@ class DrawObserver(ba.IFitObserver): im = plt.imshow( data.getArray(), norm=matplotlib.colors.LogNorm(min, max), - extent=[data.getXmin()/degree, data.getXmax()/degree, - data.getYmin()/degree, data.getYmax()/degree]) + extent=[data.getXmin()/deg, data.getXmax()/deg, + data.getYmin()/deg, data.getYmax()/deg]) plt.colorbar(im) plt.title(title) @@ -165,13 +165,13 @@ def run_fitting(): fit_suite.attachObserver(draw_observer) # setting fitting parameters with starting values - fit_suite.addFitParameter("*Cylinder/Height", 4.*nanometer, + fit_suite.addFitParameter("*Cylinder/Height", 4.*nm, ba.AttLimits.lowerLimited(0.01)) - fit_suite.addFitParameter("*Cylinder/Radius", 6.*nanometer, + fit_suite.addFitParameter("*Cylinder/Radius", 6.*nm, ba.AttLimits.lowerLimited(0.01)) - fit_suite.addFitParameter("*Prism3/Height", 4.*nanometer, + fit_suite.addFitParameter("*Prism3/Height", 4.*nm, ba.AttLimits.lowerLimited(0.01)) - fit_suite.addFitParameter("*Prism3/BaseEdge", 12.*nanometer, + fit_suite.addFitParameter("*Prism3/BaseEdge", 12.*nm, ba.AttLimits.lowerLimited(0.01)) # running fit diff --git a/Examples/python/fitting/ex03_FitSpheresInHexLattice/FitSpheresInHexLattice.py b/Examples/python/fitting/ex03_FitSpheresInHexLattice/FitSpheresInHexLattice.py index 12546d287d55d833ecc7db72a98f067670f2098d..57b4e8ada2187069ebdf4253e2a57e884d8562ec 100644 --- a/Examples/python/fitting/ex03_FitSpheresInHexLattice/FitSpheresInHexLattice.py +++ b/Examples/python/fitting/ex03_FitSpheresInHexLattice/FitSpheresInHexLattice.py @@ -6,10 +6,10 @@ from matplotlib import pyplot as plt import math import random import bornagain as ba -from bornagain import degree, angstrom, nanometer +from bornagain import deg, angstrom, nm -def get_sample(radius=5*nanometer, lattice_constant=10*nanometer): +def get_sample(radius=5*nm, lattice_constant=10*nm): """ Returns a sample with cylinders and pyramids on a substrate, forming a hexagonal lattice. @@ -24,7 +24,7 @@ def get_sample(radius=5*nanometer, lattice_constant=10*nanometer): particle_layout.addParticle(sphere) interference = ba.InterferenceFunction2DLattice.createHexagonal(lattice_constant) - pdf = ba.FTDecayFunction2DCauchy(10*nanometer, 10*nanometer) + pdf = ba.FTDecayFunction2DCauchy(10*nm, 10*nm) interference.setDecayFunction(pdf) particle_layout.addInterferenceFunction(interference) @@ -43,9 +43,9 @@ 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.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) + simulation.setDetectorParameters(100, -1.0*deg, 1.0*deg, + 100, 0.0*deg, 2.0*deg) + simulation.setBeamParameters(1.0*angstrom, 0.2*deg, 0.0*deg) return simulation @@ -53,7 +53,7 @@ def create_real_data(): """ Generating "real" data by adding noise to the simulated data. """ - sample = get_sample(5.0*nanometer, 10.0*nanometer) + sample = get_sample(5.0*nm, 10.0*nm) simulation = get_simulation() simulation.setSample(sample) @@ -94,9 +94,9 @@ def run_fitting(): # this fit parameter will change both length_1 and length_2 simultaneously fit_suite.addFitParameter( - "*2DLattice/LatticeLength*", 8.*nanometer, ba.AttLimits.limited(4., 12.)) + "*2DLattice/LatticeLength*", 8.*nm, ba.AttLimits.limited(4., 12.)) fit_suite.addFitParameter( - "*/FullSphere/Radius", 8.*nanometer, ba.AttLimits.limited(4., 12.)) + "*/FullSphere/Radius", 8.*nm, ba.AttLimits.limited(4., 12.)) # running fit fit_suite.runFit() diff --git a/Examples/python/fitting/ex03_FitSpheresInHexLattice/FitSpheresInHexLattice_builder.py b/Examples/python/fitting/ex03_FitSpheresInHexLattice/FitSpheresInHexLattice_builder.py index 11d8e4a5a88c69cc412459a18ac6574d808669e6..864381332523959d4a36d2d314e8c22daf6f80bb 100644 --- a/Examples/python/fitting/ex03_FitSpheresInHexLattice/FitSpheresInHexLattice_builder.py +++ b/Examples/python/fitting/ex03_FitSpheresInHexLattice/FitSpheresInHexLattice_builder.py @@ -7,7 +7,7 @@ import math import random import ctypes import bornagain as ba -from bornagain import degree, angstrom, nanometer +from bornagain import deg, angstrom, nm class MySampleBuilder(ISampleBuilder): @@ -22,8 +22,8 @@ class MySampleBuilder(ISampleBuilder): ISampleBuilder.__init__(self) self.sample = None # parameters describing the sample - self.radius = ctypes.c_double(5.0*nanometer) - self.lattice_constant = ctypes.c_double(10.0*nanometer) + self.radius = ctypes.c_double(5.0*nm) + self.lattice_constant = ctypes.c_double(10.0*nm) # register parameters self.registerParameter("radius", ctypes.addressof(self.radius)) self.registerParameter("lattice_constant", @@ -42,7 +42,7 @@ class MySampleBuilder(ISampleBuilder): interference = ba.InterferenceFunction2DLattice.createHexagonal( self.lattice_constant.value) - pdf = ba.FTDecayFunction2DCauchy(10*nanometer, 10*nanometer) + pdf = ba.FTDecayFunction2DCauchy(10*nm, 10*nm) interference.setDecayFunction(pdf) particle_layout.addInterferenceFunction(interference) @@ -62,9 +62,9 @@ def get_simulation(): 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.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) + simulation.setDetectorParameters(100, -1.0*deg, 1.0*deg, + 100, 0.0*deg, 2.0*deg) + simulation.setBeamParameters(1.0*angstrom, 0.2*deg, 0.0*deg) return simulation @@ -74,8 +74,8 @@ def create_real_data(): Generating "real" data by adding noise to the simulated data. """ sample_builder = MySampleBuilder() - sample_builder.setParameterValue("radius", 5.0*nanometer) - sample_builder.setParameterValue("lattice_constant", 10.0*nanometer) + sample_builder.setParameterValue("radius", 5.0*nm) + sample_builder.setParameterValue("lattice_constant", 10.0*nm) simulation = get_simulation() simulation.setSampleBuilder(sample_builder) @@ -114,9 +114,9 @@ def run_fitting(): fit_suite.attachObserver(draw_observer) # setting fitting parameters with starting values - fit_suite.addFitParameter("*radius", 8.*nanometer, ba.AttLimits.limited(4., 12.)) + fit_suite.addFitParameter("*radius", 8.*nm, ba.AttLimits.limited(4., 12.)) fit_suite.addFitParameter("*lattice_constant", - 8.*nanometer, ba.AttLimits.limited(4., 12.)) + 8.*nm, ba.AttLimits.limited(4., 12.)) # running fit fit_suite.runFit() diff --git a/Examples/python/fitting/ex04_FitScaleAndShift/FitScaleAndShift.py b/Examples/python/fitting/ex04_FitScaleAndShift/FitScaleAndShift.py index c4b0b954c963b883c489e94f804d661b60681487..394450c93f75da6abf6a6ab72fa5334e029b77a6 100644 --- a/Examples/python/fitting/ex04_FitScaleAndShift/FitScaleAndShift.py +++ b/Examples/python/fitting/ex04_FitScaleAndShift/FitScaleAndShift.py @@ -12,10 +12,10 @@ import matplotlib import math import random import bornagain as ba -from bornagain import degree, angstrom, nanometer +from bornagain import deg, angstrom, nm -def get_sample(radius=5*nanometer, height=10*nanometer): +def get_sample(radius=5*nm, height=10*nm): """ Build the sample representing cylinders on top of substrate without interference. """ @@ -44,9 +44,9 @@ 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.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) + simulation.setDetectorParameters(100, -1.0*deg, 1.0*deg, + 100, 0.0*deg, 2.0*deg) + simulation.setBeamParameters(1.0*angstrom, 0.2*deg, 0.0*deg) simulation.setBeamIntensity(1e12) return simulation @@ -59,7 +59,7 @@ def create_real_data(): 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) + sample = get_sample(5.0*nm, 10.0*nm) simulation = get_simulation() simulation.setSample(sample) @@ -110,9 +110,9 @@ def run_fitting(): fit_suite.getFitObjects().printParameters() # setting fitting parameters with starting values - fit_suite.addFitParameter("*/Cylinder/Radius", 6.*nanometer, + fit_suite.addFitParameter("*/Cylinder/Radius", 6.*nm, ba.AttLimits.limited(4., 8.)) - fit_suite.addFitParameter("*/Cylinder/Height", 9.*nanometer, + fit_suite.addFitParameter("*/Cylinder/Height", 9.*nm, ba.AttLimits.limited(8., 12.)) fit_suite.addFitParameter("*/Normalizer/scale", 1.5, ba.AttLimits.limited(1.0, 3.0)) diff --git a/Examples/python/fitting/ex05_FitWithMasks/FitWithMasks.py b/Examples/python/fitting/ex05_FitWithMasks/FitWithMasks.py index d02982b5d06233ae3eeea2ba464b78b0f029ef45..e6a84dd3d12aa019c2fd24bb0043e31a276b4689 100644 --- a/Examples/python/fitting/ex05_FitWithMasks/FitWithMasks.py +++ b/Examples/python/fitting/ex05_FitWithMasks/FitWithMasks.py @@ -7,10 +7,10 @@ from matplotlib import pyplot as plt import math import random import bornagain as ba -from bornagain import degree, angstrom, nanometer +from bornagain import deg, angstrom, nm -def get_sample(radius=5*nanometer, height=10*nanometer): +def get_sample(radius=5*nm, height=10*nm): """ Build the sample representing cylinders on top of substrate without interference. @@ -40,9 +40,9 @@ 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.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) + simulation.setDetectorParameters(100, -1.0*deg, 1.0*deg, + 100, 0.0*deg, 2.0*deg) + simulation.setBeamParameters(1.0*angstrom, 0.2*deg, 0.0*deg) return simulation @@ -50,7 +50,7 @@ def create_real_data(): """ Generating "real" data by adding noise to the simulated data. """ - sample = get_sample(5.0*nanometer, 10.0*nanometer) + sample = get_sample(5.0*nm, 10.0*nm) simulation = get_simulation() simulation.setSample(sample) @@ -89,33 +89,33 @@ def add_mask_to_simulation(simulation): # set mask to simulate pacman's head simulation.addMask( - ba.Ellipse(0.0*degree, 1.0*degree, 0.5*degree, 0.5*degree), False) + ba.Ellipse(0.0*deg, 1.0*deg, 0.5*deg, 0.5*deg), False) # set mask for pacman's eye simulation.addMask( - ba.Ellipse(0.11*degree, 1.25*degree, 0.05*degree, 0.05*degree), True) + ba.Ellipse(0.11*deg, 1.25*deg, 0.05*deg, 0.05*deg), 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*deg, 1.0*deg], [0.5*deg, 1.2*deg], + [0.5*deg, 0.8*deg], [0.0*deg, 1.0*deg]] 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) + ba.Rectangle(0.45*deg, 0.95*deg, 0.55*deg, 1.05*deg), False) simulation.addMask( - ba.Rectangle(0.61*degree, 0.95*degree, 0.71*degree, 1.05*degree), False) + ba.Rectangle(0.61*deg, 0.95*deg, 0.71*deg, 1.05*deg), False) simulation.addMask( - ba.Rectangle(0.75*degree, 0.95*degree, 0.85*degree, 1.05*degree), False) + ba.Rectangle(0.75*deg, 0.95*deg, 0.85*deg, 1.05*deg), False) # other mask's shapes are possible too # simulation.removeMasks() # # 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) + # simulation.addMask(ba.Ellipse(0.11*deg, 1.25*deg, + # 1.0*deg, 0.5*deg, 45.0*deg), True) + # simulation.addMask(Line(-1.0*deg, 0.0*deg, 1.0*deg, 2.0*deg), True) + # simulation.addMask(ba.HorizontalLine(1.0*deg), False) + # simulation.addMask(ba.VerticalLine(0.0*deg), False) def run_fitting(): @@ -139,9 +139,9 @@ def run_fitting(): # setting fitting parameters with starting values fit_suite.addFitParameter( - "*/Cylinder/Radius", 6.*nanometer, ba.AttLimits.limited(4., 8.)) + "*/Cylinder/Radius", 6.*nm, ba.AttLimits.limited(4., 8.)) fit_suite.addFitParameter( - "*/Cylinder/Height", 9.*nanometer, ba.AttLimits.limited(8., 12.)) + "*/Cylinder/Height", 9.*nm, ba.AttLimits.limited(8., 12.)) # running fit fit_suite.runFit() diff --git a/Examples/python/fitting/ex06_FitStrategies/FitStrategyAdjustMinimizer.py b/Examples/python/fitting/ex06_FitStrategies/FitStrategyAdjustMinimizer.py index 55a0d9409e48089bc7048a85126b2152d9ac84a8..d74a96e64fdb641bdbb60adb7d7b9ffe2c5d90e0 100644 --- a/Examples/python/fitting/ex06_FitStrategies/FitStrategyAdjustMinimizer.py +++ b/Examples/python/fitting/ex06_FitStrategies/FitStrategyAdjustMinimizer.py @@ -15,10 +15,10 @@ import matplotlib import math import random import bornagain as ba -from bornagain import degree, angstrom, nanometer +from bornagain import deg, angstrom, nm -def get_sample(radius=5*nanometer, height=5*nanometer): +def get_sample(radius=5*nm, height=5*nm): """ Returns a sample with uncorrelated cylinders and pyramids on a substrate. """ @@ -47,9 +47,9 @@ def get_simulation(): 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.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) + simulation.setDetectorParameters(100, 0.0*deg, 2.0*deg, + 100, 0.0*deg, 2.0*deg) + simulation.setBeamParameters(1.0*angstrom, 0.2*deg, 0.0*deg) return simulation @@ -57,7 +57,7 @@ def create_real_data(): """ Generating "real" data by adding noise to the simulated data. """ - sample = get_sample(5.0*nanometer, 5.0*nanometer) + sample = get_sample(5.0*nm, 5.0*nm) simulation = get_simulation() simulation.setSample(sample) @@ -98,9 +98,9 @@ def run_fitting(): # 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) + "*Height", 1.*nm, ba.AttLimits.limited(0.01, 30.), 0.04*nm) fit_suite.addFitParameter( - "*Radius", 20.*nanometer, ba.AttLimits.limited(0.01, 30.), 0.06*nanometer) + "*Radius", 20.*nm, ba.AttLimits.limited(0.01, 30.), 0.06*nm) # Now we create first fig strategy which will run first minimization round # using the Genetic minimizer. diff --git a/Examples/python/fitting/ex07_FitAlongSlices/FitAlongSlices.py b/Examples/python/fitting/ex07_FitAlongSlices/FitAlongSlices.py index 41f9f6ff5cc3812c6716742ca039824dc350509b..1e6ae8aa304d70b3ae1f5935beb88abc1971845c 100644 --- a/Examples/python/fitting/ex07_FitAlongSlices/FitAlongSlices.py +++ b/Examples/python/fitting/ex07_FitAlongSlices/FitAlongSlices.py @@ -8,14 +8,14 @@ from matplotlib import pyplot as plt import math import random import bornagain as ba -from bornagain import degree, angstrom, nanometer +from bornagain import deg, angstrom, nm import numpy -phi_slice_value = 0.0*degree # position of vertical slice -alpha_slice_value = 0.2*degree # position of horizontal slice +phi_slice_value = 0.0*deg # position of vertical slice +alpha_slice_value = 0.2*deg # position of horizontal slice -def get_sample(radius=5*nanometer, height=10*nanometer): +def get_sample(radius=5*nm, height=10*nm): """ Returns a sample with uncorrelated cylinders on a substrate. """ @@ -44,9 +44,9 @@ 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.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) + simulation.setDetectorParameters(100, -1.0*deg, 1.0*deg, + 100, 0.0*deg, 2.0*deg) + simulation.setBeamParameters(1.0*angstrom, 0.2*deg, 0.0*deg) return simulation @@ -54,7 +54,7 @@ def create_real_data(): """ Generating "real" data by adding noise to the simulated data. """ - sample = get_sample(5.0*nanometer, 10.0*nanometer) + sample = get_sample(5.0*nm, 10.0*nm) simulation = get_simulation() simulation.setSample(sample) @@ -92,8 +92,8 @@ class DrawObserver(ba.IFitObserver): 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]) + extent=[data.getXmin()/deg, data.getXmax()/deg, + data.getYmin()/deg, data.getYmax()/deg]) plt.colorbar(im) plt.title("\"Real\" data") plt.xlabel(r'$\phi_f$', fontsize=12) @@ -111,9 +111,9 @@ class DrawObserver(ba.IFitObserver): plt.subplot(2, 2, nplot) plt.subplots_adjust(wspace=0.2, hspace=0.3) for label, slice in slices: - plt.semilogy(slice.getBinCenters()/degree, + plt.semilogy(slice.getBinCenters()/deg, slice.getBinValues(), label=label) - plt.xlim(slice.getXmin()/degree, slice.getXmax()/degree) + plt.xlim(slice.getXmin()/deg, slice.getXmax()/deg) plt.ylim(1.0, slice.getMaximum()*10.0) plt.legend(loc='upper right') plt.title(title) @@ -154,7 +154,7 @@ class DrawObserver(ba.IFitObserver): ("simul", simul_data.projectionX(alpha_slice_value)) ] title = ( "Horizontal slice at alpha =" + - '{:3.1f}'.format(alpha_slice_value/degree) ) + '{:3.1f}'.format(alpha_slice_value/deg) ) self.plot_slices(slices, title, nplot=2) # vertical slices @@ -162,7 +162,7 @@ class DrawObserver(ba.IFitObserver): ("real", real_data.projectionY(phi_slice_value)), ("simul", simul_data.projectionY(phi_slice_value)) ] - title = "Vertical slice at phi =" + '{:3.1f}'.format(phi_slice_value/degree) + title = "Vertical slice at phi =" + '{:3.1f}'.format(phi_slice_value/deg) self.plot_slices(slices, title, nplot=3) # display fit parameters @@ -198,9 +198,9 @@ def run_fitting(): # setting fitting parameters with starting values fit_suite.addFitParameter( - "*/Cylinder/Radius", 6.*nanometer, ba.AttLimits.limited(4., 8.)) + "*/Cylinder/Radius", 6.*nm, ba.AttLimits.limited(4., 8.)) fit_suite.addFitParameter( - "*/Cylinder/Height", 9.*nanometer, ba.AttLimits.limited(8., 12.)) + "*/Cylinder/Height", 9.*nm, 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 eeed493e497f71b103c27c889d4d5f69eec3c221..37cd0a4899600163985e76c6396159dc797f0504 100644 --- a/Examples/python/fitting/ex08_SimultaneousFitOfTwoDatasets/SimultaneousFitOfTwoDatasets.py +++ b/Examples/python/fitting/ex08_SimultaneousFitOfTwoDatasets/SimultaneousFitOfTwoDatasets.py @@ -9,10 +9,10 @@ import matplotlib.gridspec as gridspec import math import random import bornagain as ba -from bornagain import degree, angstrom, nanometer +from bornagain import deg, angstrom, nm -def get_sample(radius_a=4.0*nanometer, radius_b=4.0*nanometer, height=4.0*nanometer): +def get_sample(radius_a=4.0*nm, radius_b=4.0*nm, height=4.0*nm): """ Returns a sample with uncorrelated cylinders and pyramids. """ @@ -41,9 +41,9 @@ def get_simulation(incident_alpha=0.2): 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.setBeamParameters(1.0*angstrom, incident_alpha, 0.0*degree) + simulation.setDetectorParameters(50, -1.5*deg, 1.5*deg, + 50, 0.0*deg, 2.0*deg) + simulation.setBeamParameters(1.0*angstrom, incident_alpha, 0.0*deg) return simulation @@ -52,7 +52,7 @@ 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) + radius_a=5.0*nm, radius_b=6.0*nm, height=8.0*nm) simulation = get_simulation(incident_alpha) simulation.setSample(sample) @@ -87,8 +87,8 @@ class DrawObserver(ba.IFitObserver): im = plt.imshow( data.getArray(), norm=matplotlib.colors.LogNorm(min, max), - extent=[data.getXmin()/degree, data.getXmax()/degree, - data.getYmin()/degree, data.getYmax()/degree], + extent=[data.getXmin()/deg, data.getXmax()/deg, + data.getYmin()/deg, data.getYmax()/deg], aspect='auto') plt.colorbar(im) plt.title(title) @@ -147,7 +147,7 @@ def run_fitting(): main function to run fitting """ - incident_alpha_angles = [0.1*degree, 0.4*degree] + incident_alpha_angles = [0.1*deg, 0.4*deg] fit_suite = ba.FitSuite() sample = get_sample() @@ -163,11 +163,11 @@ def run_fitting(): # setting fitting parameters with starting values fit_suite.addFitParameter( - "*/HemiEllipsoid/RadiusX", 4.*nanometer, ba.AttLimits.limited(2., 10.)) + "*/HemiEllipsoid/RadiusX", 4.*nm, ba.AttLimits.limited(2., 10.)) fit_suite.addFitParameter( - "*/HemiEllipsoid/RadiusY", 6.*nanometer, ba.AttLimits.fixed()) + "*/HemiEllipsoid/RadiusY", 6.*nm, ba.AttLimits.fixed()) fit_suite.addFitParameter( - "*/HemiEllipsoid/Height", 4.*nanometer, ba.AttLimits.limited(2., 10.)) + "*/HemiEllipsoid/Height", 4.*nm, 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 97d4d56bc3abc1177363a6ad75ce6bb7978d61f7..cde1ee93b72cfc17e3dae00dc1359e35e5a2f534 100644 --- a/Examples/python/fitting/ex10_FitGALAXIData/FitGALAXIData.py +++ b/Examples/python/fitting/ex10_FitGALAXIData/FitGALAXIData.py @@ -8,7 +8,7 @@ import bornagain as ba from SampleBuilder import MySampleBuilder wavelength = 1.34*ba.angstrom -alpha_i = 0.463*ba.degree +alpha_i = 0.463*ba.deg # detector setup as given from instrument responsible pilatus_npx, pilatus_npy = 981, 1043 @@ -44,7 +44,7 @@ def create_simulation(): # ba.ResolutionFunction2DGaussian(0.5*pilatus_pixel_size, # 0.5*pilatus_pixel_size)) # beam divergence - # alpha_distr = ba.DistributionGaussian(alpha_i, 0.02*ba.degree) + # alpha_distr = ba.DistributionGaussian(alpha_i, 0.02*ba.deg) # simulation.addParameterDistribution("*/Beam/Alpha", alpha_distr, 5) return simulation @@ -73,13 +73,13 @@ def run_fitting(): # 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) + "*radius", 5.0*ba.nm, ba.AttLimits.limited(4.0, 6.0), + 0.1*ba.nm) fit_suite.addFitParameter( - "*sigma", 0.55, ba.AttLimits.limited(0.2, 0.8), 0.01*ba.nanometer) + "*sigma", 0.55, ba.AttLimits.limited(0.2, 0.8), 0.01*ba.nm) fit_suite.addFitParameter( - "*distance", 27.*ba.nanometer, ba.AttLimits.limited(20, 70), - 0.1*ba.nanometer) + "*distance", 27.*ba.nm, ba.AttLimits.limited(20, 70), + 0.1*ba.nm) use_two_minimizers_strategy = False if use_two_minimizers_strategy: diff --git a/Examples/python/fitting/ex10_FitGALAXIData/SampleBuilder.py b/Examples/python/fitting/ex10_FitGALAXIData/SampleBuilder.py index dfa154d7842d8f57853b71b219cec8be3ffa6839..6450d1b7e288bb788760dff20180a57fd34d9770 100644 --- a/Examples/python/fitting/ex10_FitGALAXIData/SampleBuilder.py +++ b/Examples/python/fitting/ex10_FitGALAXIData/SampleBuilder.py @@ -15,13 +15,13 @@ class MySampleBuilder(ba.ISampleBuilder): self.sample = None # parameters describing the sample - self.radius = ctypes.c_double(5.75*ba.nanometer) + self.radius = ctypes.c_double(5.75*ba.nm) self.sigma = ctypes.c_double(0.4) - self.distance = ctypes.c_double(53.6*ba.nanometer) - self.disorder = ctypes.c_double(10.5*ba.nanometer) + self.distance = ctypes.c_double(53.6*ba.nm) + self.disorder = ctypes.c_double(10.5*ba.nm) self.kappa = ctypes.c_double(17.5) - self.ptfe_thickness = ctypes.c_double(22.1*ba.nanometer) - self.hmdso_thickness = ctypes.c_double(18.5*ba.nanometer) + self.ptfe_thickness = ctypes.c_double(22.1*ba.nm) + self.hmdso_thickness = ctypes.c_double(18.5*ba.nm) # register parameters self.registerParameter("radius", ctypes.addressof(self.radius)) @@ -49,7 +49,7 @@ class MySampleBuilder(ba.ISampleBuilder): # 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, + position = ba.kvector_t(0*ba.nm, 0*ba.nm, -1.0*self.hmdso_thickness.value) sphere.setPosition(position) ln_distr = ba.DistributionLogNormal(self.radius.value, self.sigma.value) @@ -62,7 +62,7 @@ class MySampleBuilder(ba.ISampleBuilder): # interference function interference = ba.InterferenceFunctionRadialParaCrystal( - self.distance.value, 1e6*ba.nanometer) + self.distance.value, 1e6*ba.nm) interference.setKappa(self.kappa.value) interference.setDomainSize(20000.0) pdf = ba.FTDistribution1DGauss(self.disorder.value) @@ -76,8 +76,8 @@ class MySampleBuilder(ba.ISampleBuilder): particle_layout.setTotalParticleSurfaceDensity(1) # roughness - r_ptfe = ba.LayerRoughness(2.3*ba.nanometer, 0.3, 5.0*ba.nanometer) - r_hmdso = ba.LayerRoughness(1.1*ba.nanometer, 0.3, 5.0*ba.nanometer) + r_ptfe = ba.LayerRoughness(2.3*ba.nm, 0.3, 5.0*ba.nm) + r_hmdso = ba.LayerRoughness(1.1*ba.nm, 0.3, 5.0*ba.nm) # layers air_layer = ba.Layer(m_air) diff --git a/Examples/python/simulation/ex01_BasicParticles/AllFormFactorsAvailable.py b/Examples/python/simulation/ex01_BasicParticles/AllFormFactorsAvailable.py index 6e2af25cafde62d2a1a9b2246f4955adae1bea1e..1d79e4e710049afc60e8b411ccf551212fb51735 100644 --- a/Examples/python/simulation/ex01_BasicParticles/AllFormFactorsAvailable.py +++ b/Examples/python/simulation/ex01_BasicParticles/AllFormFactorsAvailable.py @@ -5,18 +5,18 @@ import numpy import matplotlib from matplotlib import pyplot as plt import bornagain as ba -from bornagain import degree, angstrom +from bornagain import deg, angstrom phi_min, phi_max = -2.0, 2.0 alpha_min, alpha_max = 0.0, 2.0 formfactors = [ - ba.FormFactorAnisoPyramid(20.0, 16.0, 13.0, 60.0*degree), + ba.FormFactorAnisoPyramid(20.0, 16.0, 13.0, 60.0*deg), ba.FormFactorBox(20.0, 16.0, 13.0), - ba.FormFactorCone(10.0, 13.0, 60.0*degree), - ba.FormFactorCone6(10.0, 13.0, 60.0*degree), - ba.FormFactorCuboctahedron(20.0, 13.0, 0.7, 60.0*degree), + ba.FormFactorCone(10.0, 13.0, 60.0*deg), + ba.FormFactorCone6(10.0, 13.0, 60.0*deg), + ba.FormFactorCuboctahedron(20.0, 13.0, 0.7, 60.0*deg), ba.FormFactorCylinder(8.0, 16.0), ba.FormFactorDodecahedron(5.0), ba.FormFactorEllipsoidalCylinder(8.0, 13.0, 16.0), @@ -26,10 +26,10 @@ formfactors = [ ba.FormFactorIcosahedron(8.0), ba.FormFactorPrism3(10.0, 13.0), ba.FormFactorPrism6(5.0, 11.0), - ba.FormFactorPyramid(18.0, 13.0, 60.0*degree), + ba.FormFactorPyramid(18.0, 13.0, 60.0*deg), ba.FormFactorRipple1(27.0, 20.0, 14.0), ba.FormFactorRipple2(36.0, 25.0, 14.0, 3.0), - ba.FormFactorTetrahedron(15.0, 6.0, 60.0*degree), + ba.FormFactorTetrahedron(15.0, 6.0, 60.0*deg), ba.FormFactorTruncatedSphere(5.0, 7.0), ba.FormFactorTruncatedSpheroid(7.5, 9.0, 1.2), ba.FormFactorTruncatedCube(15.0, 6.0) @@ -63,8 +63,8 @@ def get_simulation(): """ simulation = ba.GISASSimulation() 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) + 100, phi_min*deg, phi_max*deg, 100, alpha_min*deg, alpha_max*deg) + simulation.setBeamParameters(1.0*angstrom, 0.2*deg, 0.0*deg) return simulation @@ -95,8 +95,8 @@ def run_simulation(): 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], + extent=[result.getXmin()/deg, result.getXmax()/deg, + result.getYmin()/deg, result.getYmax()/deg], aspect='auto') plt.tick_params(axis='both', which='major', labelsize=8) plt.tick_params(axis='both', which='minor', labelsize=6) diff --git a/Examples/python/simulation/ex01_BasicParticles/CylindersAndPrisms.py b/Examples/python/simulation/ex01_BasicParticles/CylindersAndPrisms.py index 76e00b8dcf89a8f9478fecfb793417612190d80e..dfe9d5c71fd2552681ccd9806dc169f70bbbf5b0 100644 --- a/Examples/python/simulation/ex01_BasicParticles/CylindersAndPrisms.py +++ b/Examples/python/simulation/ex01_BasicParticles/CylindersAndPrisms.py @@ -5,7 +5,7 @@ import numpy import matplotlib from matplotlib import pyplot as plt import bornagain as ba -from bornagain import degree, angstrom, nanometer +from bornagain import deg, angstrom, nm phi_min, phi_max = -1.0, 1.0 alpha_min, alpha_max = 0.0, 2.0 @@ -21,9 +21,9 @@ def get_sample(): m_particle = ba.HomogeneousMaterial("Particle", 6e-4, 2e-8) # collection of particles - cylinder_ff = ba.FormFactorCylinder(5*nanometer, 5*nanometer) + cylinder_ff = ba.FormFactorCylinder(5*nm, 5*nm) cylinder = ba.Particle(m_particle, cylinder_ff) - prism_ff = ba.FormFactorPrism3(10*nanometer, 5*nanometer) + prism_ff = ba.FormFactorPrism3(10*nm, 5*nm) prism = ba.Particle(m_particle, prism_ff) particle_layout = ba.ParticleLayout() particle_layout.addParticle(cylinder, 0.5) @@ -47,9 +47,9 @@ def get_simulation(): 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.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) + simulation.setDetectorParameters(100, phi_min*deg, phi_max*deg, + 100, alpha_min*deg, alpha_max*deg) + simulation.setBeamParameters(1.0*angstrom, 0.2*deg, 0.0*deg) return simulation @@ -66,8 +66,8 @@ def run_simulation(): 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], + extent=[result.getXmin()/deg, result.getXmax()/deg, + result.getYmin()/deg, result.getYmax()/deg], aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) diff --git a/Examples/python/simulation/ex01_BasicParticles/CylindersInBA.py b/Examples/python/simulation/ex01_BasicParticles/CylindersInBA.py index 14d54d21e570543077c506077f7acb009bd22414..0b5aaba91257b30db67d44b3155fb1d2a91c3790 100644 --- a/Examples/python/simulation/ex01_BasicParticles/CylindersInBA.py +++ b/Examples/python/simulation/ex01_BasicParticles/CylindersInBA.py @@ -5,7 +5,7 @@ import numpy import matplotlib from matplotlib import pyplot as plt import bornagain as ba -from bornagain import degree, angstrom, nanometer +from bornagain import deg, angstrom, nm phi_min, phi_max = -2.0, 2.0 alpha_min, alpha_max = 0.0, 2.0 @@ -21,7 +21,7 @@ def get_sample(): m_particle = ba.HomogeneousMaterial("Particle", 6e-4, 2e-8) # collection of particles - cylinder_ff = ba.FormFactorCylinder(5*nanometer, 5*nanometer) + cylinder_ff = ba.FormFactorCylinder(5*nm, 5*nm) cylinder = ba.Particle(m_particle, cylinder_ff) particle_layout = ba.ParticleLayout() particle_layout.addParticle(cylinder, 1.0) @@ -39,9 +39,9 @@ def get_simulation(): 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.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) + simulation.setDetectorParameters(200, phi_min*deg, phi_max*deg, + 200, alpha_min*deg, alpha_max*deg) + simulation.setBeamParameters(1.0*angstrom, 0.2*deg, 0.0*deg) return simulation @@ -59,8 +59,8 @@ def run_simulation(): 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], + extent=[result.getXmin()/deg, result.getXmax()/deg, + result.getYmin()/deg, result.getYmax()/deg], aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) diff --git a/Examples/python/simulation/ex01_BasicParticles/CylindersInDWBA.py b/Examples/python/simulation/ex01_BasicParticles/CylindersInDWBA.py index 531d597481934144c23c21e00c1fdef11baa45ae..75495f7e03efa59c2756ec3e98d7deefaf44e0cd 100644 --- a/Examples/python/simulation/ex01_BasicParticles/CylindersInDWBA.py +++ b/Examples/python/simulation/ex01_BasicParticles/CylindersInDWBA.py @@ -5,7 +5,7 @@ import numpy import matplotlib from matplotlib import pyplot as plt import bornagain as ba -from bornagain import degree, angstrom, nanometer +from bornagain import deg, angstrom, nm phi_min, phi_max = -2.0, 2.0 alpha_min, alpha_max = 0.0, 2.0 @@ -21,7 +21,7 @@ def get_sample(): m_particle = ba.HomogeneousMaterial("Particle", 6e-4, 2e-8) # collection of particles - cylinder_ff = ba.FormFactorCylinder(5*nanometer, 5*nanometer) + cylinder_ff = ba.FormFactorCylinder(5*nm, 5*nm) cylinder = ba.Particle(m_particle, cylinder_ff) particle_layout = ba.ParticleLayout() particle_layout.addParticle(cylinder, 1.0) @@ -41,9 +41,9 @@ def get_simulation(): 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.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) + simulation.setDetectorParameters(200, phi_min*deg, phi_max*deg, + 200, alpha_min*deg, alpha_max*deg) + simulation.setBeamParameters(1.0*angstrom, 0.2*deg, 0.0*deg) return simulation @@ -61,8 +61,8 @@ def run_simulation(): 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], + extent=[result.getXmin()/deg, result.getXmax()/deg, + result.getYmin()/deg, result.getYmax()/deg], aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) diff --git a/Examples/python/simulation/ex01_BasicParticles/CylindersWithSizeDistribution.py b/Examples/python/simulation/ex01_BasicParticles/CylindersWithSizeDistribution.py index 16870c3f36c35f07588f34ac94ada78e6c4f16c6..dd48cbee4aa50f0a712b0e0b08719b41da6c29cb 100644 --- a/Examples/python/simulation/ex01_BasicParticles/CylindersWithSizeDistribution.py +++ b/Examples/python/simulation/ex01_BasicParticles/CylindersWithSizeDistribution.py @@ -5,7 +5,7 @@ import numpy import matplotlib from matplotlib import pyplot as plt import bornagain as ba -from bornagain import degree, angstrom, nanometer +from bornagain import deg, angstrom, nm phi_min, phi_max = 0.0, 2.0 alpha_min, alpha_max = 0.0, 2.0 @@ -20,7 +20,7 @@ def get_sample(): m_particle = ba.HomogeneousMaterial("Particle", 6e-4, 2e-8) # cylindrical particle - radius = 5*nanometer + radius = 5*nm height = radius cylinder_ff = ba.FormFactorCylinder(radius, height) cylinder = ba.Particle(m_particle, cylinder_ff) @@ -54,9 +54,9 @@ 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.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) + simulation.setDetectorParameters(200, phi_min*deg, phi_max*deg, + 200, alpha_min*deg, alpha_max*deg) + simulation.setBeamParameters(1.0*angstrom, 0.2*deg, 0.0*deg) return simulation @@ -75,8 +75,8 @@ def run_simulation(): 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], + extent=[result.getXmin()/deg, result.getXmax()/deg, + result.getYmin()/deg, result.getYmax()/deg], aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) diff --git a/Examples/python/simulation/ex01_BasicParticles/RotatedPyramids.py b/Examples/python/simulation/ex01_BasicParticles/RotatedPyramids.py index 502684c40fff9f382178f1e3892d158956a47575..0419ce274ff5b7aa13587b32ed150d59456a3673 100644 --- a/Examples/python/simulation/ex01_BasicParticles/RotatedPyramids.py +++ b/Examples/python/simulation/ex01_BasicParticles/RotatedPyramids.py @@ -5,7 +5,7 @@ import numpy import matplotlib from matplotlib import pyplot as plt import bornagain as ba -from bornagain import degree, angstrom, nanometer +from bornagain import deg, angstrom, nm phi_min, phi_max = -2.0, 2.0 alpha_min, alpha_max = 0.0, 2.0 @@ -21,9 +21,9 @@ def get_sample(): m_particle = ba.HomogeneousMaterial("Particle", 6e-4, 2e-8) # collection of particles - pyramid_ff = ba.FormFactorPyramid(10*nanometer, 5*nanometer, 54.73*degree) + pyramid_ff = ba.FormFactorPyramid(10*nm, 5*nm, 54.73*deg) pyramid = ba.Particle(m_particle, pyramid_ff) - transform = ba.RotationZ(45.*degree) + transform = ba.RotationZ(45.*deg) particle_layout = ba.ParticleLayout() particle_layout.addParticle( pyramid, 1.0, ba.kvector_t(0.0, 0.0, 0.0), transform) @@ -43,9 +43,9 @@ def get_simulation(): 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.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) + simulation.setDetectorParameters(200, phi_min*deg, phi_max*deg, + 200, alpha_min*deg, alpha_max*deg) + simulation.setBeamParameters(1.0*angstrom, 0.2*deg, 0.0*deg) return simulation @@ -63,8 +63,8 @@ def run_simulation(): 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], + extent=[result.getXmin()/deg, result.getXmax()/deg, + result.getYmin()/deg, result.getYmax()/deg], aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) diff --git a/Examples/python/simulation/ex01_BasicParticles/TwoTypesOfCylindersWithSizeDistribution.py b/Examples/python/simulation/ex01_BasicParticles/TwoTypesOfCylindersWithSizeDistribution.py index 1eb6a2d14f2c6ba6faeb830a172fe66a7013a8d3..17f0549640d23d8539cf6c6d15ced7c330eee5b5 100644 --- a/Examples/python/simulation/ex01_BasicParticles/TwoTypesOfCylindersWithSizeDistribution.py +++ b/Examples/python/simulation/ex01_BasicParticles/TwoTypesOfCylindersWithSizeDistribution.py @@ -5,7 +5,7 @@ import numpy import matplotlib from matplotlib import pyplot as plt import bornagain as ba -from bornagain import degree, angstrom, nanometer +from bornagain import deg, angstrom, nm phi_min, phi_max = 0.0, 2.0 alpha_min, alpha_max = 0.0, 2.0 @@ -24,7 +24,7 @@ def get_sample(): nfwhm = 3.0 # collection of particles #1 - radius1 = 5.0*nanometer + radius1 = 5.0*nm height1 = radius1 sigma1 = radius1*0.2 @@ -38,7 +38,7 @@ def get_sample(): part_coll1 = ba.ParticleDistribution(cylinder1, par_distr1) # collection of particles #2 - radius2 = 10.0*nanometer + radius2 = 10.0*nm height2 = radius2 sigma2 = radius2*0.02 @@ -69,9 +69,9 @@ 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.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) + simulation.setDetectorParameters(200, phi_min*deg, phi_max*deg, + 200, alpha_min*deg, alpha_max*deg) + simulation.setBeamParameters(1.0*angstrom, 0.2*deg, 0.0*deg) return simulation @@ -89,8 +89,8 @@ def run_simulation(): 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], + extent=[result.getXmin()/deg, result.getXmax()/deg, + result.getYmin()/deg, result.getYmax()/deg], aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) diff --git a/Examples/python/simulation/ex02_LayeredStructures/BuriedParticles.py b/Examples/python/simulation/ex02_LayeredStructures/BuriedParticles.py index 54e50e2187a93a01a0c9283b428d78710888d855..9aa741f89c914908934fd9c01a378553594ac6cb 100644 --- a/Examples/python/simulation/ex02_LayeredStructures/BuriedParticles.py +++ b/Examples/python/simulation/ex02_LayeredStructures/BuriedParticles.py @@ -5,7 +5,7 @@ import numpy import matplotlib from matplotlib import pyplot as plt import bornagain as ba -from bornagain import degree, angstrom, nanometer +from bornagain import deg, angstrom, nm phi_min, phi_max = -1.0, 1.0 alpha_min, alpha_max = 0.0, 2.0 @@ -22,7 +22,7 @@ def get_sample(): m_particle = ba.HomogeneousMaterial("Particle", 0.0, 0.0) # collection of particles - ff_sphere = ba.FormFactorFullSphere(10.2*nanometer) + ff_sphere = ba.FormFactorFullSphere(10.2*nm) sphere = ba.Particle(m_particle, ff_sphere) sphere.setPosition(0.0, 0.0, -25.2) particle_layout = ba.ParticleLayout() @@ -30,7 +30,7 @@ def get_sample(): # assembling the sample air_layer = ba.Layer(m_ambience) - intermediate_layer = ba.Layer(m_interm_layer, 30.*nanometer) + intermediate_layer = ba.Layer(m_interm_layer, 30.*nm) intermediate_layer.addLayout(particle_layout) substrate_layer = ba.Layer(m_substrate, 0) @@ -46,9 +46,9 @@ def get_simulation(): 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.setBeamParameters(1.5*angstrom, 0.15*degree, 0.0*degree) + simulation.setDetectorParameters(200, phi_min*deg, phi_max*deg, + 200, alpha_min*deg, alpha_max*deg) + simulation.setBeamParameters(1.5*angstrom, 0.15*deg, 0.0*deg) return simulation @@ -66,8 +66,8 @@ def run_simulation(): 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], + extent=[result.getXmin()/deg, result.getXmax()/deg, + result.getYmin()/deg, result.getYmax()/deg], aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) diff --git a/Examples/python/simulation/ex02_LayeredStructures/CorrelatedRoughness.py b/Examples/python/simulation/ex02_LayeredStructures/CorrelatedRoughness.py index da2fc5291119b43a9c20986eb62ea14993f54364..34aa42f5422d53975aa634d4808fb9f9041f6ebf 100644 --- a/Examples/python/simulation/ex02_LayeredStructures/CorrelatedRoughness.py +++ b/Examples/python/simulation/ex02_LayeredStructures/CorrelatedRoughness.py @@ -5,7 +5,7 @@ import numpy import matplotlib from matplotlib import pyplot as plt import bornagain as ba -from bornagain import degree, angstrom, nanometer +from bornagain import deg, angstrom, nm phi_min, phi_max = -0.5, 0.5 alpha_min, alpha_max = 0.0, 1.0 @@ -23,14 +23,14 @@ def get_sample(): # defining layers l_ambience = ba.Layer(m_ambience) - l_part_a = ba.Layer(m_part_a, 2.5*nanometer) - l_part_b = ba.Layer(m_part_b, 5.0*nanometer) + l_part_a = ba.Layer(m_part_a, 2.5*nm) + l_part_b = ba.Layer(m_part_b, 5.0*nm) l_substrate = ba.Layer(m_substrate) roughness = ba.LayerRoughness() - roughness.setSigma(1.0*nanometer) + roughness.setSigma(1.0*nm) roughness.setHurstParameter(0.3) - roughness.setLatteralCorrLength(5.0*nanometer) + roughness.setLatteralCorrLength(5.0*nm) my_sample = ba.MultiLayer() @@ -53,9 +53,9 @@ 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.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) + simulation.setDetectorParameters(200, phi_min*deg, phi_max*deg, + 200, alpha_min*deg, alpha_max*deg) + simulation.setBeamParameters(1.0*angstrom, 0.2*deg, 0.0*deg) return simulation @@ -74,8 +74,8 @@ def run_simulation(): result.getArray(), norm=matplotlib.colors.LogNorm(result.getMaximum()/1000., result.getMaximum()), - extent=[result.getXmin()/degree, result.getXmax()/degree, - result.getYmin()/degree, result.getYmax()/degree], + extent=[result.getXmin()/deg, result.getXmax()/deg, + result.getYmin()/deg, result.getYmax()/deg], aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) diff --git a/Examples/python/simulation/ex03_InterferenceFunctions/ApproximationDA.py b/Examples/python/simulation/ex03_InterferenceFunctions/ApproximationDA.py index fb962dde552d2647e8932fc31e83541ca5a465e6..9b7b072cf5da606094fb58fee7f328629b732871 100644 --- a/Examples/python/simulation/ex03_InterferenceFunctions/ApproximationDA.py +++ b/Examples/python/simulation/ex03_InterferenceFunctions/ApproximationDA.py @@ -5,7 +5,7 @@ import numpy import matplotlib from matplotlib import pyplot as plt import bornagain as ba -from bornagain import degree, angstrom, nanometer +from bornagain import deg, angstrom, nm phi_min, phi_max = 0.0, 2.0 alpha_min, alpha_max = 0.0, 2.0 @@ -21,21 +21,21 @@ def get_sample(): m_particle = ba.HomogeneousMaterial("Particle", 6e-4, 2e-8) # cylindrical particle 1 - radius1 = 5*nanometer + radius1 = 5*nm height1 = radius1 cylinder_ff1 = ba.FormFactorCylinder(radius1, height1) cylinder1 = ba.Particle(m_particle, cylinder_ff1) # cylindrical particle 2 - radius2 = 8*nanometer + radius2 = 8*nm height2 = radius2 cylinder_ff2 = ba.FormFactorCylinder(radius2, height2) cylinder2 = ba.Particle(m_particle, cylinder_ff2) # interference function interference = ba.InterferenceFunctionRadialParaCrystal( - 18.0*nanometer, 1e3*nanometer) - pdf = ba.FTDistribution1DGauss(3 * nanometer) + 18.0*nm, 1e3*nm) + pdf = ba.FTDistribution1DGauss(3 * nm) interference.setProbabilityDistribution(pdf) # assembling the sample @@ -58,9 +58,9 @@ 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.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) + simulation.setDetectorParameters(200, phi_min*deg, phi_max*deg, + 200, alpha_min*deg, alpha_max*deg) + simulation.setBeamParameters(1.0*angstrom, 0.2*deg, 0.0*deg) return simulation @@ -78,8 +78,8 @@ def run_simulation(): 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], + extent=[result.getXmin()/deg, result.getXmax()/deg, + result.getYmin()/deg, result.getYmax()/deg], aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) diff --git a/Examples/python/simulation/ex03_InterferenceFunctions/ApproximationLMA.py b/Examples/python/simulation/ex03_InterferenceFunctions/ApproximationLMA.py index 0645815525fd53e1822e3fba35da2c1d762318f9..aaa95e471b12ce928a99d18c6fdd11e9a8440d91 100644 --- a/Examples/python/simulation/ex03_InterferenceFunctions/ApproximationLMA.py +++ b/Examples/python/simulation/ex03_InterferenceFunctions/ApproximationLMA.py @@ -5,7 +5,7 @@ import numpy import matplotlib from matplotlib import pyplot as plt import bornagain as ba -from bornagain import degree, angstrom, nanometer +from bornagain import deg, angstrom, nm phi_min, phi_max = 0.0, 2.0 alpha_min, alpha_max = 0.0, 2.0 @@ -21,26 +21,26 @@ def get_sample(): m_particle = ba.HomogeneousMaterial("Particle", 6e-4, 2e-8) # cylindrical particle 1 - radius1 = 5*nanometer + radius1 = 5*nm height1 = radius1 cylinder_ff1 = ba.FormFactorCylinder(radius1, height1) cylinder1 = ba.Particle(m_particle, cylinder_ff1) # cylindrical particle 2 - radius2 = 8*nanometer + radius2 = 8*nm height2 = radius2 cylinder_ff2 = ba.FormFactorCylinder(radius2, height2) cylinder2 = ba.Particle(m_particle, cylinder_ff2) # interference function1 interference1 = ba.InterferenceFunctionRadialParaCrystal( - 16.8*nanometer, 1e3*nanometer) - pdf = ba.FTDistribution1DGauss(3 * nanometer) + 16.8*nm, 1e3*nm) + pdf = ba.FTDistribution1DGauss(3 * nm) interference1.setProbabilityDistribution(pdf) # interference function2 interference2 = ba.InterferenceFunctionRadialParaCrystal( - 22.8*nanometer, 1e3*nanometer) + 22.8*nm, 1e3*nm) interference2.setProbabilityDistribution(pdf) # assembling the sample @@ -67,9 +67,9 @@ 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.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) + simulation.setDetectorParameters(200, phi_min*deg, phi_max*deg, + 200, alpha_min*deg, alpha_max*deg) + simulation.setBeamParameters(1.0*angstrom, 0.2*deg, 0.0*deg) return simulation @@ -87,8 +87,8 @@ def run_simulation(): 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], + extent=[result.getXmin()/deg, result.getXmax()/deg, + result.getYmin()/deg, result.getYmax()/deg], aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) diff --git a/Examples/python/simulation/ex03_InterferenceFunctions/ApproximationSSCA.py b/Examples/python/simulation/ex03_InterferenceFunctions/ApproximationSSCA.py index 216179907cc3faa393139cfefd858048e569e49f..b3d5fb9a2eb5c4bdb94a220deb3cdfe4385bffca 100644 --- a/Examples/python/simulation/ex03_InterferenceFunctions/ApproximationSSCA.py +++ b/Examples/python/simulation/ex03_InterferenceFunctions/ApproximationSSCA.py @@ -5,7 +5,7 @@ import numpy import matplotlib from matplotlib import pyplot as plt import bornagain as ba -from bornagain import degree, angstrom, nanometer +from bornagain import deg, angstrom, nm phi_min, phi_max = 0.0, 2.0 alpha_min, alpha_max = 0.0, 2.0 @@ -21,21 +21,21 @@ def get_sample(): m_particle = ba.HomogeneousMaterial("Particle", 6e-4, 2e-8) # cylindrical particle 1 - radius1 = 5*nanometer + radius1 = 5*nm height1 = radius1 cylinder_ff1 = ba.FormFactorCylinder(radius1, height1) cylinder1 = ba.Particle(m_particle, cylinder_ff1) # cylindrical particle 2 - radius2 = 8*nanometer + radius2 = 8*nm height2 = radius2 cylinder_ff2 = ba.FormFactorCylinder(radius2, height2) cylinder2 = ba.Particle(m_particle, cylinder_ff2) # interference function interference = ba.InterferenceFunctionRadialParaCrystal( - 18.0*nanometer, 1e3*nanometer) - pdf = ba.FTDistribution1DGauss(3 * nanometer) + 18.0*nm, 1e3*nm) + pdf = ba.FTDistribution1DGauss(3 * nm) interference.setProbabilityDistribution(pdf) interference.setKappa(1.0) @@ -60,9 +60,9 @@ 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.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) + simulation.setDetectorParameters(200, phi_min*deg, phi_max*deg, + 200, alpha_min*deg, alpha_max*deg) + simulation.setBeamParameters(1.0*angstrom, 0.2*deg, 0.0*deg) return simulation @@ -80,8 +80,8 @@ def run_simulation(): 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], + extent=[result.getXmin()/deg, result.getXmax()/deg, + result.getYmin()/deg, result.getYmax()/deg], aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) diff --git a/Examples/python/simulation/ex03_InterferenceFunctions/CosineRipplesAtRectLattice.py b/Examples/python/simulation/ex03_InterferenceFunctions/CosineRipplesAtRectLattice.py index 6b23b8a098243cc0b0afab1b26b4483f10cf552c..c75c28200f80ee5dc147456ed0bbf3e7bb5717f2 100644 --- a/Examples/python/simulation/ex03_InterferenceFunctions/CosineRipplesAtRectLattice.py +++ b/Examples/python/simulation/ex03_InterferenceFunctions/CosineRipplesAtRectLattice.py @@ -5,7 +5,7 @@ import numpy import matplotlib from matplotlib import pyplot as plt import bornagain as ba -from bornagain import degree, angstrom, nanometer +from bornagain import deg, angstrom, nm phi_min, phi_max = -1.5, 1.5 alpha_min, alpha_max = 0.0, 2.5 @@ -22,16 +22,16 @@ def get_sample(): m_particle = ba.HomogeneousMaterial("Particle", 6e-4, 2e-8) # collection of particles - ripple1_ff = ba.FormFactorRipple1(100*nanometer, 20*nanometer, 4*nanometer) + ripple1_ff = ba.FormFactorRipple1(100*nm, 20*nm, 4*nm) ripple = ba.Particle(m_particle, ripple1_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) + 200.0*nm, 50.0*nm, 90.0*deg, 0.0*deg) pdf = ba.FTDecayFunction2DCauchy( - 1000.*nanometer/2./numpy.pi, 100.*nanometer/2./numpy.pi) + 1000.*nm/2./numpy.pi, 100.*nm/2./numpy.pi) interference.setDecayFunction(pdf) particle_layout.addInterferenceFunction(interference) @@ -51,9 +51,9 @@ 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.setBeamParameters(1.6*angstrom, 0.3*degree, 0.0*degree) + simulation.setDetectorParameters(100, phi_min*deg, phi_max*deg, + 100, alpha_min*deg, alpha_max*deg) + simulation.setBeamParameters(1.6*angstrom, 0.3*deg, 0.0*deg) return simulation @@ -71,8 +71,8 @@ def run_simulation(): 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], + extent=[result.getXmin()/deg, result.getXmax()/deg, + result.getYmin()/deg, result.getYmax()/deg], aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) diff --git a/Examples/python/simulation/ex03_InterferenceFunctions/Interference1DLattice.py b/Examples/python/simulation/ex03_InterferenceFunctions/Interference1DLattice.py index bf285dc8f2da647e4834389fbc3ed4d1c6f28d4a..fc7a833dd5a05fe3ca4c60d57368d2b05f87a2ad 100644 --- a/Examples/python/simulation/ex03_InterferenceFunctions/Interference1DLattice.py +++ b/Examples/python/simulation/ex03_InterferenceFunctions/Interference1DLattice.py @@ -5,7 +5,7 @@ import numpy import matplotlib from matplotlib import pyplot as plt import bornagain as ba -from bornagain import degree, angstrom, nanometer +from bornagain import deg, angstrom, nm phi_min, phi_max = -1.0, 1.0 alpha_min, alpha_max = 0.0, 2.0 @@ -22,16 +22,16 @@ def get_sample(): m_particle = ba.HomogeneousMaterial("Particle", 6e-4, 2e-8) # collection of particles - lattice_length = 30.0*nanometer - lattice_rotation_angle = 0.0*degree + lattice_length = 30.0*nm + lattice_rotation_angle = 0.0*deg interference = ba.InterferenceFunction1DLattice( lattice_length, lattice_rotation_angle) - pdf = ba.FTDecayFunction1DCauchy(20./2./numpy.pi*nanometer) + pdf = ba.FTDecayFunction1DCauchy(20./2./numpy.pi*nm) interference.setDecayFunction(pdf) - box_ff = ba.FormFactorBox(1000*nanometer, 10*nanometer, 15.0*nanometer) + box_ff = ba.FormFactorBox(1000*nm, 10*nm, 15.0*nm) box = ba.Particle(m_particle, box_ff) - transform = ba.RotationZ(25.0*degree) + transform = ba.RotationZ(25.0*deg) particle_layout = ba.ParticleLayout() particle_layout.addParticle(box, 1.0, ba.kvector_t(0.0, 0.0, 0.0), transform) particle_layout.addInterferenceFunction(interference) @@ -52,9 +52,9 @@ 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.setBeamParameters(24.0*angstrom, 0.2*degree, 0.0*degree) + simulation.setDetectorParameters(200, phi_min*deg, phi_max*deg, + 200, alpha_min*deg, alpha_max*deg) + simulation.setBeamParameters(24.0*angstrom, 0.2*deg, 0.0*deg) return simulation @@ -72,8 +72,8 @@ def run_simulation(): 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], + extent=[result.getXmin()/deg, result.getXmax()/deg, + result.getYmin()/deg, result.getYmax()/deg], aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) diff --git a/Examples/python/simulation/ex03_InterferenceFunctions/Interference1DRadialParaCrystal.py b/Examples/python/simulation/ex03_InterferenceFunctions/Interference1DRadialParaCrystal.py index 40115b90b024eb40c02f57cb3d0ac89c24e79a41..f6948fedfc1f537d8ba51349a7aca9b67036e0f8 100644 --- a/Examples/python/simulation/ex03_InterferenceFunctions/Interference1DRadialParaCrystal.py +++ b/Examples/python/simulation/ex03_InterferenceFunctions/Interference1DRadialParaCrystal.py @@ -5,7 +5,7 @@ import numpy import matplotlib from matplotlib import pyplot as plt import bornagain as ba -from bornagain import degree, angstrom, nanometer +from bornagain import deg, angstrom, nm phi_min, phi_max = -2.0, 2.0 alpha_min, alpha_max = 0.0, 2.0 @@ -21,12 +21,12 @@ def get_sample(): m_particle = ba.HomogeneousMaterial("Particle", 6e-4, 2e-8) # collection of particles - cylinder_ff = ba.FormFactorCylinder(5*nanometer, 5*nanometer) + cylinder_ff = ba.FormFactorCylinder(5*nm, 5*nm) cylinder = ba.Particle(m_particle, cylinder_ff) interference = ba.InterferenceFunctionRadialParaCrystal( - 20.0*nanometer, 1e3*nanometer) - pdf = ba.FTDistribution1DGauss(7 * nanometer) + 20.0*nm, 1e3*nm) + pdf = ba.FTDistribution1DGauss(7 * nm) interference.setProbabilityDistribution(pdf) particle_layout = ba.ParticleLayout() @@ -49,9 +49,9 @@ 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.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) + simulation.setDetectorParameters(200, phi_min*deg, phi_max*deg, + 200, alpha_min*deg, alpha_max*deg) + simulation.setBeamParameters(1.0*angstrom, 0.2*deg, 0.0*deg) return simulation @@ -69,8 +69,8 @@ def run_simulation(): 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], + extent=[result.getXmin()/deg, result.getXmax()/deg, + result.getYmin()/deg, result.getYmax()/deg], aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) diff --git a/Examples/python/simulation/ex03_InterferenceFunctions/Interference2DCenteredSquareLattice.py b/Examples/python/simulation/ex03_InterferenceFunctions/Interference2DCenteredSquareLattice.py index c06c126d4bcd785f8d92e9245ceda6324d701a38..7e6015079c934da94fca0b9e115b7951e47e1056 100644 --- a/Examples/python/simulation/ex03_InterferenceFunctions/Interference2DCenteredSquareLattice.py +++ b/Examples/python/simulation/ex03_InterferenceFunctions/Interference2DCenteredSquareLattice.py @@ -5,7 +5,7 @@ import numpy import matplotlib from matplotlib import pyplot as plt import bornagain as ba -from bornagain import degree, angstrom, nanometer +from bornagain import deg, angstrom, nm phi_min, phi_max = -2.0, 2.0 alpha_min, alpha_max = 0.0, 2.0 @@ -22,15 +22,15 @@ def get_sample(): m_particle = ba.HomogeneousMaterial("Particle", 6e-4, 2e-8) # 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) + interference = ba.InterferenceFunction2DLattice.createSquare(25.0*nm) + pdf = ba.FTDecayFunction2DCauchy(300.0*nm/2.0/numpy.pi, + 100.0*nm/2.0/numpy.pi) interference.setDecayFunction(pdf) particle_layout = ba.ParticleLayout() position1 = ba.kvector_t(0.0, 0.0, 0.0) - position2 = ba.kvector_t(12.5*nanometer, 12.5*nanometer, 0.0) - cylinder_ff = ba.FormFactorCylinder(3.*nanometer, 3.*nanometer) + position2 = ba.kvector_t(12.5*nm, 12.5*nm, 0.0) + cylinder_ff = ba.FormFactorCylinder(3.*nm, 3.*nm) cylinder = ba.Particle(m_particle, cylinder_ff) basis = ba.ParticleComposition() basis.addParticles(cylinder, [position1, position2]) @@ -53,9 +53,9 @@ 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.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) + simulation.setDetectorParameters(200, phi_min*deg, phi_max*deg, + 200, alpha_min*deg, alpha_max*deg) + simulation.setBeamParameters(1.0*angstrom, 0.2*deg, 0.0*deg) return simulation @@ -74,8 +74,8 @@ def run_simulation(): 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], + extent=[result.getXmin()/deg, result.getXmax()/deg, + result.getYmin()/deg, result.getYmax()/deg], aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) diff --git a/Examples/python/simulation/ex03_InterferenceFunctions/Interference2DLatticeSumOfRotated.py b/Examples/python/simulation/ex03_InterferenceFunctions/Interference2DLatticeSumOfRotated.py index 8f169a94022cbf2434aed690f8e488ea57d5b9ff..35765935e76b84b99377d91748a54099a96bede1 100644 --- a/Examples/python/simulation/ex03_InterferenceFunctions/Interference2DLatticeSumOfRotated.py +++ b/Examples/python/simulation/ex03_InterferenceFunctions/Interference2DLatticeSumOfRotated.py @@ -3,7 +3,7 @@ import numpy import matplotlib from matplotlib import pyplot as plt import bornagain as ba -from bornagain import degree, angstrom, nanometer +from bornagain import deg, angstrom, nm phi_min, phi_max = 0.0, 2.0 alpha_min, alpha_max = 0.0, 2.0 @@ -22,13 +22,13 @@ def get_sample(xi_value): 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) + 25.0*nm, xi_value) + pdf = ba.FTDecayFunction2DCauchy(300.0*nm/2.0/numpy.pi, + 100.0*nm/2.0/numpy.pi) p_interference_function.setDecayFunction(pdf) particle_layout = ba.ParticleLayout() - ff_cyl = ba.FormFactorCylinder(3.0*nanometer, 3.0*nanometer) + ff_cyl = ba.FormFactorCylinder(3.0*nm, 3.0*nm) position = ba.kvector_t(0.0, 0.0, 0.0) cylinder = ba.Particle(m_particle, ff_cyl.clone()) cylinder.setPosition(position) @@ -48,9 +48,9 @@ def get_simulation(): 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.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) + simulation.setDetectorParameters(100, phi_min*deg, phi_max*deg, + 100, alpha_min*deg, alpha_max*deg) + simulation.setBeamParameters(1.0*angstrom, 0.2*deg, 0.0*deg) return simulation @@ -65,8 +65,8 @@ def run_simulation(): OutputData_total = simulation.getIntensityData() nbins = 3 - xi_min = 0.0*degree - xi_max = 240.0*degree + xi_min = 0.0*deg + xi_max = 240.0*deg total_weight = 0.0 xi_distr = ba.DistributionGate(xi_min, xi_max) xi_samples = xi_distr.generateValueList(nbins, 0.0) @@ -89,8 +89,8 @@ def run_simulation(): 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], + extent=[result.getXmin()/deg, result.getXmax()/deg, + result.getYmin()/deg, result.getYmax()/deg], aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) diff --git a/Examples/python/simulation/ex03_InterferenceFunctions/Interference2DParaCrystal.py b/Examples/python/simulation/ex03_InterferenceFunctions/Interference2DParaCrystal.py index 6b3960dcc16e9d2859c6576fc35e0eb38a42319d..e62a48429e6a65bc7fedffdd356c12ae12d747c4 100644 --- a/Examples/python/simulation/ex03_InterferenceFunctions/Interference2DParaCrystal.py +++ b/Examples/python/simulation/ex03_InterferenceFunctions/Interference2DParaCrystal.py @@ -5,7 +5,7 @@ import numpy import matplotlib from matplotlib import pyplot as plt import bornagain as ba -from bornagain import degree, angstrom, nanometer +from bornagain import deg, angstrom, nm from bornagain import micrometer phi_min, phi_max = -2.0, 2.0 @@ -21,12 +21,12 @@ def get_sample(): m_particle = ba.HomogeneousMaterial("Particle", 6e-4, 2e-8) # collection of particles - cylinder_ff = ba.FormFactorCylinder(5*nanometer, 5*nanometer) + cylinder_ff = ba.FormFactorCylinder(5*nm, 5*nm) cylinder = ba.Particle(m_particle, cylinder_ff) interference = ba.InterferenceFunction2DParaCrystal.createSquare( - 20.0*nanometer, 0.0, 20.0*micrometer, 20.0*micrometer) - pdf = ba.FTDistribution2DCauchy(1.0*nanometer, 1.0*nanometer) + 20.0*nm, 0.0, 20.0*micrometer, 20.0*micrometer) + pdf = ba.FTDistribution2DCauchy(1.0*nm, 1.0*nm) interference.setProbabilityDistributions(pdf, pdf) particle_layout = ba.ParticleLayout() @@ -50,9 +50,9 @@ def get_simulation(): 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.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) + simulation.setDetectorParameters(200, phi_min*deg, phi_max*deg, + 200, alpha_min*deg, alpha_max*deg) + simulation.setBeamParameters(1.0*angstrom, 0.2*deg, 0.0*deg) return simulation @@ -70,8 +70,8 @@ def run_simulation(): 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], + extent=[result.getXmin()/deg, result.getXmax()/deg, + result.getYmin()/deg, result.getYmax()/deg], aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) diff --git a/Examples/python/simulation/ex03_InterferenceFunctions/Interference2DRotatedSquareLattice.py b/Examples/python/simulation/ex03_InterferenceFunctions/Interference2DRotatedSquareLattice.py index ffd483bda7f73981b66484c9fb355bb0f914f710..5d4e9391c1297f13366f35cb55cf432aa7ab55a9 100644 --- a/Examples/python/simulation/ex03_InterferenceFunctions/Interference2DRotatedSquareLattice.py +++ b/Examples/python/simulation/ex03_InterferenceFunctions/Interference2DRotatedSquareLattice.py @@ -5,7 +5,7 @@ import numpy import matplotlib from matplotlib import pyplot as plt import bornagain as ba -from bornagain import degree, angstrom, nanometer +from bornagain import deg, angstrom, nm phi_min, phi_max = -2.0, 2.0 alpha_min, alpha_max = 0.0, 2.0 @@ -22,13 +22,13 @@ def get_sample(): # collection of particles interference = ba.InterferenceFunction2DLattice.createSquare( - 25.0*nanometer, 30.0*degree) + 25.0*nm, 30.0*deg) pdf = ba.FTDecayFunction2DCauchy( - 300.0*nanometer/2.0/numpy.pi, 100.0*nanometer/2.0/numpy.pi) - pdf.setGamma(30.0*degree) + 300.0*nm/2.0/numpy.pi, 100.0*nm/2.0/numpy.pi) + pdf.setGamma(30.0*deg) interference.setDecayFunction(pdf) - cylinder_ff = ba.FormFactorCylinder(3.*nanometer, 3.*nanometer) + cylinder_ff = ba.FormFactorCylinder(3.*nm, 3.*nm) cylinder = ba.Particle(m_particle, cylinder_ff) particle_layout = ba.ParticleLayout() particle_layout.addParticle(cylinder) @@ -50,9 +50,9 @@ 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.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) + simulation.setDetectorParameters(200, phi_min*deg, phi_max*deg, + 200, alpha_min*deg, alpha_max*deg) + simulation.setBeamParameters(1.0*angstrom, 0.2*deg, 0.0*deg) return simulation @@ -71,8 +71,8 @@ def run_simulation(): 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], + extent=[result.getXmin()/deg, result.getXmax()/deg, + result.getYmin()/deg, result.getYmax()/deg], aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) diff --git a/Examples/python/simulation/ex03_InterferenceFunctions/Interference2DSquareLattice.py b/Examples/python/simulation/ex03_InterferenceFunctions/Interference2DSquareLattice.py index 0b20735548c2a059d30682475e7eb0a1142c6776..866575e8ee8fe785b8cf68c6db0dc6e6470e5dfb 100644 --- a/Examples/python/simulation/ex03_InterferenceFunctions/Interference2DSquareLattice.py +++ b/Examples/python/simulation/ex03_InterferenceFunctions/Interference2DSquareLattice.py @@ -5,7 +5,7 @@ import numpy import matplotlib from matplotlib import pyplot as plt import bornagain as ba -from bornagain import degree, angstrom, nanometer +from bornagain import deg, angstrom, nm phi_min, phi_max = -2.0, 2.0 alpha_min, alpha_max = 0.0, 2.0 @@ -21,12 +21,12 @@ def get_sample(): m_particle = ba.HomogeneousMaterial("Particle", 6e-4, 2e-8) # 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) + interference = ba.InterferenceFunction2DLattice.createSquare(25.0*nm) + pdf = ba.FTDecayFunction2DCauchy(300.0*nm/2.0/numpy.pi, + 100.0*nm/2.0/numpy.pi) interference.setDecayFunction(pdf) - cylinder_ff = ba.FormFactorCylinder(3.*nanometer, 3.*nanometer) + cylinder_ff = ba.FormFactorCylinder(3.*nm, 3.*nm) cylinder = ba.Particle(m_particle, cylinder_ff) particle_layout = ba.ParticleLayout() particle_layout.addParticle(cylinder) @@ -48,9 +48,9 @@ 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.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) + simulation.setDetectorParameters(200, phi_min*deg, phi_max*deg, + 200, alpha_min*deg, alpha_max*deg) + simulation.setBeamParameters(1.0*angstrom, 0.2*deg, 0.0*deg) return simulation @@ -68,8 +68,8 @@ def run_simulation(): 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], + extent=[result.getXmin()/deg, result.getXmax()/deg, + result.getYmin()/deg, result.getYmax()/deg], aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) diff --git a/Examples/python/simulation/ex03_InterferenceFunctions/RectangularGrating.py b/Examples/python/simulation/ex03_InterferenceFunctions/RectangularGrating.py index a835d76782af2694db6b5b2bc48b45c0dea97641..8649645f00e1ed4dbdef3445e849a7ec298a98b0 100644 --- a/Examples/python/simulation/ex03_InterferenceFunctions/RectangularGrating.py +++ b/Examples/python/simulation/ex03_InterferenceFunctions/RectangularGrating.py @@ -7,13 +7,13 @@ import numpy import matplotlib from matplotlib import pyplot as plt import bornagain as ba -from bornagain import degree, angstrom, nanometer +from bornagain import deg, angstrom, nm phi_min, phi_max = -1.0, 1.0 alpha_min, alpha_max = 0.0, 2.0 -def get_sample(lattice_rotation_angle=45.0*degree): +def get_sample(lattice_rotation_angle=45.0*deg): """ Returns a sample with a grating on a substrate, modelled by very long boxes forming a 1D lattice with Cauchy correlations. @@ -23,8 +23,8 @@ def get_sample(lattice_rotation_angle=45.0*degree): m_substrate = ba.HomogeneousMaterial("Substrate", 6e-6, 2e-8) m_particle = ba.HomogeneousMaterial("Particle", 6e-4, 2e-8) - box_length, box_width, box_height = 10*nanometer, 10000*nanometer, 10.0*nanometer - lattice_length = 30.0*nanometer + box_length, box_width, box_height = 10*nm, 10000*nm, 10.0*nm + lattice_length = 30.0*nm # collection of particles interference = ba.InterferenceFunction1DLattice( @@ -56,9 +56,9 @@ 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.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) + simulation.setDetectorParameters(200, phi_min*deg, phi_max*deg, + 200, alpha_min*deg, alpha_max*deg) + simulation.setBeamParameters(1.0*angstrom, 0.2*deg, 0.0*deg) if monte_carlo_integration: sim_pars = SimulationParameters() sim_pars.m_mc_integration = True @@ -72,7 +72,7 @@ def run_simulation(): """ Run simulation and plot results """ - sample = get_sample(lattice_rotation_angle=45.0*degree) + sample = get_sample(lattice_rotation_angle=45.0*deg) simulation = get_simulation(monte_carlo_integration=True) simulation.setSample(sample) simulation.runSimulation() @@ -82,8 +82,8 @@ def run_simulation(): 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], + extent=[result.getXmin()/deg, result.getXmax()/deg, + result.getYmin()/deg, result.getYmax()/deg], aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) diff --git a/Examples/python/simulation/ex03_InterferenceFunctions/SpheresAtHexLattice.py b/Examples/python/simulation/ex03_InterferenceFunctions/SpheresAtHexLattice.py index 7cf0c9b406df2306b83b396cca1c1ec3127fb145..7d2bfb8412d640a9ef5dec72a055678baa59ccc1 100644 --- a/Examples/python/simulation/ex03_InterferenceFunctions/SpheresAtHexLattice.py +++ b/Examples/python/simulation/ex03_InterferenceFunctions/SpheresAtHexLattice.py @@ -5,7 +5,7 @@ import numpy import matplotlib from matplotlib import pyplot as plt import bornagain as ba -from bornagain import degree, angstrom, nanometer +from bornagain import deg, angstrom, nm phi_min, phi_max = -1.0, 1.0 alpha_min, alpha_max = 0.0, 1.0 @@ -20,13 +20,13 @@ def get_sample(): m_substrate = ba.HomogeneousMaterial("Substrate", 6e-6, 2e-8) m_particle = ba.HomogeneousMaterial("Particle", 6e-4, 2e-8) - sphere_ff = ba.FormFactorFullSphere(10.0*nanometer) + sphere_ff = ba.FormFactorFullSphere(10.0*nm) sphere = ba.Particle(m_particle, sphere_ff) particle_layout = ba.ParticleLayout() particle_layout.addParticle(sphere) - interference = ba.InterferenceFunction2DLattice.createHexagonal(20.0*nanometer) - pdf = ba.FTDecayFunction2DCauchy(10*nanometer, 10*nanometer) + interference = ba.InterferenceFunction2DLattice.createHexagonal(20.0*nm) + pdf = ba.FTDecayFunction2DCauchy(10*nm, 10*nm) interference.setDecayFunction(pdf) particle_layout.addInterferenceFunction(interference) @@ -45,9 +45,9 @@ 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.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) + simulation.setDetectorParameters(200, phi_min*deg, phi_max*deg, + 200, alpha_min*deg, alpha_max*deg) + simulation.setBeamParameters(1.0*angstrom, 0.2*deg, 0.0*deg) return simulation @@ -65,8 +65,8 @@ def run_simulation(): 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], + extent=[result.getXmin()/deg, result.getXmax()/deg, + result.getYmin()/deg, result.getYmax()/deg], aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) diff --git a/Examples/python/simulation/ex03_InterferenceFunctions/TriangularRipple.py b/Examples/python/simulation/ex03_InterferenceFunctions/TriangularRipple.py index 1fb1f1937211e36f490d328b9e98bcda480658ee..aadd17175236d49c36969eb1efee0ecf4380df58 100644 --- a/Examples/python/simulation/ex03_InterferenceFunctions/TriangularRipple.py +++ b/Examples/python/simulation/ex03_InterferenceFunctions/TriangularRipple.py @@ -5,7 +5,7 @@ import numpy import matplotlib from matplotlib import pyplot as plt import bornagain as ba -from bornagain import degree, angstrom, nanometer +from bornagain import deg, angstrom, nm phi_min, phi_max = -1.5, 1.5 alpha_min, alpha_max = 0.0, 2.5 @@ -23,16 +23,16 @@ def get_sample(): # collection of particles ripple2_ff = ba.FormFactorRipple2( - 100*nanometer, 20*nanometer, 4*nanometer, -3.0*nanometer) + 100*nm, 20*nm, 4*nm, -3.0*nm) 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) + 200.0*nm, 50.0*nm, 90.0*deg, 0.0*deg) pdf = ba.FTDecayFunction2DGauss( - 1000.*nanometer/2./numpy.pi, 100.*nanometer/2./numpy.pi) + 1000.*nm/2./numpy.pi, 100.*nm/2./numpy.pi) interference.setDecayFunction(pdf) particle_layout.addInterferenceFunction(interference) @@ -52,9 +52,9 @@ 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.setBeamParameters(1.6*angstrom, 0.3*degree, 0.0*degree) + simulation.setDetectorParameters(400, phi_min*deg, phi_max*deg, + 400, alpha_min*deg, alpha_max*deg) + simulation.setBeamParameters(1.6*angstrom, 0.3*deg, 0.0*deg) return simulation @@ -72,8 +72,8 @@ def run_simulation(): 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], + extent=[result.getXmin()/deg, result.getXmax()/deg, + result.getYmin()/deg, result.getYmax()/deg], aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) diff --git a/Examples/python/simulation/ex04_ComplexShapes/CoreShellNanoparticles.py b/Examples/python/simulation/ex04_ComplexShapes/CoreShellNanoparticles.py index ea045ca4b02599057a30b00a2cc7a8e0d391888a..fbac277f48d534f023130ac15b8489b6ad5183ee 100644 --- a/Examples/python/simulation/ex04_ComplexShapes/CoreShellNanoparticles.py +++ b/Examples/python/simulation/ex04_ComplexShapes/CoreShellNanoparticles.py @@ -5,7 +5,7 @@ import numpy import matplotlib from matplotlib import pyplot as plt import bornagain as ba -from bornagain import degree, angstrom, nanometer +from bornagain import deg, angstrom, nm phi_min, phi_max = -1.0, 1.0 alpha_min, alpha_max = 0.0, 2.0 @@ -21,8 +21,8 @@ def get_sample(): m_core = ba.HomogeneousMaterial("Core", 6e-5, 2e-8 ) # collection of particles - parallelepiped1_ff = ba.FormFactorBox(16*nanometer, 16*nanometer, 8*nanometer) - parallelepiped2_ff = ba.FormFactorBox(12*nanometer, 12*nanometer, 7*nanometer) + parallelepiped1_ff = ba.FormFactorBox(16*nm, 16*nm, 8*nm) + parallelepiped2_ff = ba.FormFactorBox(12*nm, 12*nm, 7*nm) shell_particle = ba.Particle(m_shell, parallelepiped1_ff) core_particle = ba.Particle(m_core, parallelepiped2_ff) core_position = ba.kvector_t(0.0, 0.0, 0.0) @@ -47,9 +47,9 @@ def get_simulation(): 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.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) + simulation.setDetectorParameters(200, phi_min*deg, phi_max*deg, + 200, alpha_min*deg, alpha_max*deg) + simulation.setBeamParameters(1.0*angstrom, 0.2*deg, 0.0*deg) return simulation @@ -67,8 +67,8 @@ def run_simulation(): 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], + extent=[result.getXmin()/deg, result.getXmax()/deg, + result.getYmin()/deg, result.getYmax()/deg], aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) diff --git a/Examples/python/simulation/ex04_ComplexShapes/CustomFormFactor.py b/Examples/python/simulation/ex04_ComplexShapes/CustomFormFactor.py index b05003e384412978f2daba5745d7e93d1f703264..c52e3b242f0352f3db727a02c6436780fadcb3e3 100644 --- a/Examples/python/simulation/ex04_ComplexShapes/CustomFormFactor.py +++ b/Examples/python/simulation/ex04_ComplexShapes/CustomFormFactor.py @@ -5,7 +5,7 @@ import numpy import matplotlib from matplotlib import pyplot as plt import bornagain as ba -from bornagain import degree, angstrom, nanometer +from bornagain import deg, angstrom, nm import cmath phi_min, phi_max = -1.0, 1.0 @@ -61,7 +61,7 @@ def get_sample(): m_particle = ba.HomogeneousMaterial("Particle", 6e-4, 2e-8) # collection of particles - ff = CustomFormFactor(20.0*nanometer, 15.0*nanometer) + ff = CustomFormFactor(20.0*nm, 15.0*nm) particle = ba.Particle(m_particle, ff) particle_layout = ba.ParticleLayout() particle_layout.addParticle(particle, 1.0) @@ -84,9 +84,9 @@ def get_simulation(): """ simulation = ba.GISASSimulation() simulation.getOptions().setNumberOfThreads(-1) - 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.setDetectorParameters(100, phi_min*deg, phi_max*deg, + 100, alpha_min*deg, alpha_max*deg) + simulation.setBeamParameters(1.0*angstrom, 0.2*deg, 0.0*deg) return simulation @@ -104,8 +104,8 @@ def run_simulation(): 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], + extent=[result.getXmin()/deg, result.getXmax()/deg, + result.getYmin()/deg, result.getYmax()/deg], aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) diff --git a/Examples/python/simulation/ex04_ComplexShapes/HexagonalLatticesWithBasis.py b/Examples/python/simulation/ex04_ComplexShapes/HexagonalLatticesWithBasis.py index 89f5033bafdf0b40c7051ae0a42a08a132d4b642..bd56a32112318c5c06b598a93f1229ceaf240f79 100644 --- a/Examples/python/simulation/ex04_ComplexShapes/HexagonalLatticesWithBasis.py +++ b/Examples/python/simulation/ex04_ComplexShapes/HexagonalLatticesWithBasis.py @@ -5,7 +5,7 @@ import numpy import matplotlib from matplotlib import pyplot as plt import bornagain as ba -from bornagain import degree, angstrom, nanometer +from bornagain import deg, angstrom, nm phi_min, phi_max = -1.0, 1.0 alpha_min, alpha_max = 0.0, 1.0 @@ -20,7 +20,7 @@ def get_sample(): m_substrate = ba.HomogeneousMaterial("Substrate", 6e-6, 2e-8) m_particle = ba.HomogeneousMaterial("Particle", 6e-4, 2e-8) - radius = 10.0*nanometer + radius = 10.0*nm sphere_ff = ba.FormFactorFullSphere(radius) sphere = ba.Particle(m_particle, sphere_ff) particle_layout = ba.ParticleLayout() @@ -32,7 +32,7 @@ def get_sample(): particle_layout.addParticle(basis) interference = ba.InterferenceFunction2DLattice.createHexagonal(radius*2.0) - pdf = ba.FTDecayFunction2DCauchy(10*nanometer, 10*nanometer) + pdf = ba.FTDecayFunction2DCauchy(10*nm, 10*nm) interference.setDecayFunction(pdf) particle_layout.addInterferenceFunction(interference) @@ -51,9 +51,9 @@ def get_simulation(): 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.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) + simulation.setDetectorParameters(200, phi_min*deg, phi_max*deg, + 200, alpha_min*deg, alpha_max*deg) + simulation.setBeamParameters(1.0*angstrom, 0.2*deg, 0.0*deg) return simulation @@ -71,8 +71,8 @@ def run_simulation(): 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], + extent=[result.getXmin()/deg, result.getXmax()/deg, + result.getYmin()/deg, result.getYmax()/deg], aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) diff --git a/Examples/python/simulation/ex04_ComplexShapes/LargeParticlesFormFactor.py b/Examples/python/simulation/ex04_ComplexShapes/LargeParticlesFormFactor.py index cdbd3ef7246e39d015848c79e18aee62de59e79d..64f47d9d2890ddaa7df0039ac9069bee65e0ab6e 100644 --- a/Examples/python/simulation/ex04_ComplexShapes/LargeParticlesFormFactor.py +++ b/Examples/python/simulation/ex04_ComplexShapes/LargeParticlesFormFactor.py @@ -10,12 +10,12 @@ import numpy import matplotlib from matplotlib import pyplot as plt import bornagain as ba -from bornagain import degree, angstrom, nanometer +from bornagain import deg, angstrom, nm phi_min, phi_max = -2.0, 2.0 alpha_min, alpha_max = 0.0, 2.0 -default_cylinder_radius = 10*nanometer -default_cylinder_height = 20*nanometer +default_cylinder_radius = 10*nm +default_cylinder_height = 20*nm def get_sample(cylinder_radius, cylinder_height): @@ -50,8 +50,8 @@ def get_simulation(integration_flag): """ simulation = ba.GISASSimulation() 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) + 200, phi_min*deg, phi_max*deg, 200, alpha_min*deg, alpha_max*deg) + simulation.setBeamParameters(1.0*angstrom, 0.2*deg, 0.0*deg) simulation.getOptions().setMonteCarloIntegration(integration_flag, 50) return simulation @@ -95,8 +95,8 @@ for small and large cylinders, with and without integration 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], + extent=[result.getXmin()/deg, result.getXmax()/deg, + result.getYmin()/deg, result.getYmax()/deg], aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) diff --git a/Examples/python/simulation/ex05_BeamAndDetector/BeamDivergence.py b/Examples/python/simulation/ex05_BeamAndDetector/BeamDivergence.py index 998d78b4ab6f4f61903e9e3ce53af9a8ac72ff15..52c10e7634bc084e65950001934bc9918e955e0b 100644 --- a/Examples/python/simulation/ex05_BeamAndDetector/BeamDivergence.py +++ b/Examples/python/simulation/ex05_BeamAndDetector/BeamDivergence.py @@ -5,7 +5,7 @@ import numpy import matplotlib from matplotlib import pyplot as plt import bornagain as ba -from bornagain import degree, angstrom, nanometer +from bornagain import deg, angstrom, nm phi_min, phi_max = 0.0, 2.0 alpha_min, alpha_max = 0.0, 2.0 @@ -21,7 +21,7 @@ def get_sample(): m_particle = ba.HomogeneousMaterial("Particle", 6e-4, 2e-8) # collection of particles - cylinder_ff = ba.FormFactorCylinder(5*nanometer, 5*nanometer) + cylinder_ff = ba.FormFactorCylinder(5*nm, 5*nm) cylinder = ba.Particle(m_particle, cylinder_ff) particle_layout = ba.ParticleLayout() particle_layout.addParticle(cylinder, 1.0) @@ -42,12 +42,12 @@ def get_simulation(): 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.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) + simulation.setDetectorParameters(100, phi_min*deg, phi_max*deg, + 100, alpha_min*deg, alpha_max*deg) + simulation.setBeamParameters(1.0*angstrom, 0.2*deg, 0.0*deg) wavelength_distr = ba.DistributionLogNormal(1.0*angstrom, 0.1) - alpha_distr = ba.DistributionGaussian(0.2*degree, 0.1*degree) - phi_distr = ba.DistributionGaussian(0.0*degree, 0.1*degree) + alpha_distr = ba.DistributionGaussian(0.2*deg, 0.1*deg) + phi_distr = ba.DistributionGaussian(0.0*deg, 0.1*deg) simulation.addParameterDistribution("*/Beam/Wavelength", wavelength_distr, 5) simulation.addParameterDistribution("*/Beam/Alpha", alpha_distr, 5) simulation.addParameterDistribution("*/Beam/Phi", phi_distr, 5) @@ -70,8 +70,8 @@ def run_simulation(): 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], + extent=[result.getXmin()/deg, result.getXmax()/deg, + result.getYmin()/deg, result.getYmax()/deg], aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) diff --git a/Examples/python/simulation/ex05_BeamAndDetector/DetectorResolutionFunction.py b/Examples/python/simulation/ex05_BeamAndDetector/DetectorResolutionFunction.py index 2af85478f5fc86a622d3910c0666ad9444cfee2e..7f0e50c978625f2163ed0c26b39a84fdc0f408b6 100644 --- a/Examples/python/simulation/ex05_BeamAndDetector/DetectorResolutionFunction.py +++ b/Examples/python/simulation/ex05_BeamAndDetector/DetectorResolutionFunction.py @@ -5,7 +5,7 @@ import numpy import matplotlib from matplotlib import pyplot as plt import bornagain as ba -from bornagain import degree, angstrom, nanometer +from bornagain import deg, angstrom, nm phi_min, phi_max = 0.0, 2.0 alpha_min, alpha_max = 0.0, 2.0 @@ -21,7 +21,7 @@ def get_sample(): m_particle = ba.HomogeneousMaterial("Particle", 6e-4, 2e-8) # collection of particles - cylinder_ff = ba.FormFactorCylinder(5*nanometer, 5*nanometer) + cylinder_ff = ba.FormFactorCylinder(5*nm, 5*nm) cylinder = ba.Particle(m_particle, cylinder_ff) particle_layout = ba.ParticleLayout() particle_layout.addParticle(cylinder, 1.0) @@ -42,9 +42,9 @@ def get_simulation(): 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.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) + simulation.setDetectorParameters(100, phi_min*deg, phi_max*deg, + 100, alpha_min*deg, alpha_max*deg) + simulation.setBeamParameters(1.0*angstrom, 0.2*deg, 0.0*deg) simulation.setDetectorResolutionFunction( ba.ResolutionFunction2DGaussian(0.0025, 0.0025)) return simulation @@ -65,8 +65,8 @@ def run_simulation(): 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], + extent=[result.getXmin()/deg, result.getXmax()/deg, + result.getYmin()/deg, result.getYmax()/deg], aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) diff --git a/Examples/python/simulation/ex05_BeamAndDetector/OffSpecularSimulation.py b/Examples/python/simulation/ex05_BeamAndDetector/OffSpecularSimulation.py index 33008f0770e4a9bbea16aab61052c923a6f47398..8e1162ea1e05b3ffae96bd2838e196ce849153b5 100644 --- a/Examples/python/simulation/ex05_BeamAndDetector/OffSpecularSimulation.py +++ b/Examples/python/simulation/ex05_BeamAndDetector/OffSpecularSimulation.py @@ -5,7 +5,7 @@ import numpy import matplotlib from matplotlib import pyplot as plt import bornagain as ba -from bornagain import degree, angstrom, nanometer +from bornagain import deg, angstrom, nm phi_f_min, phi_f_max = -1.0, 1.0 alpha_f_min, alpha_f_max = 0.0, 10.0 @@ -24,16 +24,16 @@ def get_sample(): m_particle = ba.HomogeneousMaterial("Particle", 6e-4, 2e-8) # collection of particles - lattice_length = 100.0*nanometer - lattice_rotation_angle = 0.0*degree + lattice_length = 100.0*nm + lattice_rotation_angle = 0.0*deg interference = ba.InterferenceFunction1DLattice( lattice_length, lattice_rotation_angle) pdf = ba.FTDecayFunction1DCauchy(1e+6) interference.setDecayFunction(pdf) - box_ff = ba.FormFactorBox(1000*nanometer, 20*nanometer, 10.0*nanometer) + box_ff = ba.FormFactorBox(1000*nm, 20*nm, 10.0*nm) box = ba.Particle(m_particle, box_ff) - transform = ba.RotationZ(90.0*degree) + transform = ba.RotationZ(90.0*deg) particle_layout = ba.ParticleLayout() particle_layout.addParticle(box, 1.0, ba.kvector_t(0.0, 0.0, 0.0), transform) particle_layout.addInterferenceFunction(interference) @@ -54,12 +54,12 @@ def get_simulation(): 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) + simulation.setDetectorParameters(20, phi_f_min*deg, phi_f_max*deg, + 200, alpha_f_min*deg, alpha_f_max*deg) # 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) + "alpha_i", 200, alpha_i_min*deg, alpha_i_max*deg) + simulation.setBeamParameters(1.0*angstrom, alpha_i_axis, 0.0*deg) simulation.setBeamIntensity(1e9) return simulation @@ -78,8 +78,8 @@ def run_simulation(): 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], + extent=[result.getXmin()/deg, result.getXmax()/deg, + result.getYmin()/deg, result.getYmax()/deg], aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) diff --git a/Examples/python/simulation/ex05_BeamAndDetector/RectangularDetector.py b/Examples/python/simulation/ex05_BeamAndDetector/RectangularDetector.py index f50396e1dd44ca581049ec1b96f1bacc666bf1da..82ed24b2114de42f8e4a21306ad41a6cae922465 100644 --- a/Examples/python/simulation/ex05_BeamAndDetector/RectangularDetector.py +++ b/Examples/python/simulation/ex05_BeamAndDetector/RectangularDetector.py @@ -6,7 +6,7 @@ import numpy import matplotlib from matplotlib import pyplot as plt import bornagain as ba -from bornagain import degree, angstrom, nanometer +from bornagain import deg, angstrom, nm detector_distance = 2000.0 # in mm @@ -24,7 +24,7 @@ def get_sample(): m_particle = ba.HomogeneousMaterial("Particle", 6e-4, 2e-8) # collection of particles - cylinder_ff = ba.FormFactorCylinder(5*nanometer, 5*nanometer) + cylinder_ff = ba.FormFactorCylinder(5*nm, 5*nm) cylinder = ba.Particle(m_particle, cylinder_ff) particle_layout = ba.ParticleLayout() particle_layout.addParticle(cylinder, 1.0) @@ -71,7 +71,7 @@ def get_simulation(): Return a GISAXS simulation with defined beam """ simulation = ba.GISASSimulation() - simulation.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) + simulation.setBeamParameters(1.0*angstrom, 0.2*deg, 0.0*deg) return simulation @@ -86,8 +86,8 @@ def plot_results(result_sph, result_rect): 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], + extent=[result_sph.getXmin()/deg, result_sph.getXmax()/deg, + result_sph.getYmin()/deg, result_sph.getYmax()/deg], aspect='auto') cb = plt.colorbar(im, pad=0.025) plt.xlabel(r'$\phi_f ^{\circ}$', fontsize=16) diff --git a/Examples/python/simulation/ex05_BeamAndDetector/SpecularSimulation.py b/Examples/python/simulation/ex05_BeamAndDetector/SpecularSimulation.py index f82a5547883346b637021afa92ee3e633369332d..a39e341f37c3124099a48d6322f0f09b09052337 100644 --- a/Examples/python/simulation/ex05_BeamAndDetector/SpecularSimulation.py +++ b/Examples/python/simulation/ex05_BeamAndDetector/SpecularSimulation.py @@ -5,7 +5,7 @@ import numpy import matplotlib from matplotlib import pyplot as plt import bornagain as ba -from bornagain import degree, angstrom, nanometer +from bornagain import deg, angstrom, nm alpha_i_min, alpha_i_max = 0.0, 2.0 # incoming beam @@ -20,14 +20,14 @@ def get_sample(): m_substrate = ba.HomogeneousMaterial("substrate", 15e-6, 0.0) l_ambience = ba.Layer(m_ambience) - l_part_a = ba.Layer(m_part_a, 5.0*nanometer) - l_part_b = ba.Layer(m_part_b, 10.0*nanometer) + l_part_a = ba.Layer(m_part_a, 5.0*nm) + l_part_b = ba.Layer(m_part_b, 10.0*nm) l_substrate = ba.Layer(m_substrate) roughness = ba.LayerRoughness() - roughness.setSigma(1.0*nanometer) + roughness.setSigma(1.0*nm) roughness.setHurstParameter(0.3) - roughness.setLatteralCorrLength(500.0*nanometer) + roughness.setLatteralCorrLength(500.0*nm) my_sample = ba.MultiLayer() @@ -51,7 +51,7 @@ def get_simulation(): """ simulation = ba.SpecularSimulation() simulation.setBeamParameters( - 1.54*angstrom, 1000, alpha_i_min*degree, alpha_i_max*degree) + 1.54*angstrom, 1000, alpha_i_min*deg, alpha_i_max*deg) return simulation diff --git a/Examples/python/simulation/ex06_Miscellaneous/AccessingSimulationResults.py b/Examples/python/simulation/ex06_Miscellaneous/AccessingSimulationResults.py index a4262b1adbb92ae91f055f293c0c4cc71d36a331..a0c0108179216e85ecdd787789840996ed772382 100644 --- a/Examples/python/simulation/ex06_Miscellaneous/AccessingSimulationResults.py +++ b/Examples/python/simulation/ex06_Miscellaneous/AccessingSimulationResults.py @@ -8,7 +8,7 @@ import matplotlib import random from matplotlib import pyplot as plt import bornagain as ba -from bornagain import degree, angstrom, nanometer +from bornagain import deg, angstrom, nm phi_min, phi_max = -2.0, 2.0 alpha_min, alpha_max = 0.0, 2.0 @@ -24,7 +24,7 @@ def get_sample(): m_particle = ba.HomogeneousMaterial("Particle", 6e-4, 2e-8) # collection of particles - cylinder_ff = ba.FormFactorCylinder(5*nanometer, 5*nanometer) + cylinder_ff = ba.FormFactorCylinder(5*nm, 5*nm) cylinder = ba.Particle(m_particle, cylinder_ff) particle_layout = ba.ParticleLayout() particle_layout.addParticle(cylinder, 1.0) @@ -44,9 +44,9 @@ def get_simulation(): 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.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) + simulation.setDetectorParameters(200, phi_min*deg, phi_max*deg, + 200, alpha_min*deg, alpha_max*deg) + simulation.setBeamParameters(1.0*angstrom, 0.2*deg, 0.0*deg) return simulation @@ -63,8 +63,8 @@ def plot_as_colormap(hist, zmin=None, zmax=None): im = plt.imshow( hist.getArray(), norm=matplotlib.colors.LogNorm(zmin, zmax), - extent=[hist.getXmin()/degree, hist.getXmax()/degree, - hist.getYmin()/degree, hist.getYmax()/degree], + extent=[hist.getXmin()/deg, hist.getXmax()/deg, + hist.getYmin()/deg, hist.getYmax()/deg], aspect='auto') cb = plt.colorbar(im, pad=0.025) plt.xlabel(r'$\phi_f ^{\circ}$', fontsize=16) @@ -75,7 +75,7 @@ def plot_cropped_map(hist): """ Plot cropped version of intensity data """ - crop = hist.crop(-1.0*degree, 0.5*degree, 1.0*degree, 1.0*degree) + crop = hist.crop(-1.0*deg, 0.5*deg, 1.0*deg, 1.0*deg) plot_as_colormap(crop) @@ -110,24 +110,24 @@ def plot_slices(hist): noisy = get_noisy_image(hist) # projection along Y, slice at fixed x-value - proj1 = noisy.projectionY(0.0*degree) - plt.semilogy(proj1.getBinCenters()/degree, + proj1 = noisy.projectionY(0.0*deg) + plt.semilogy(proj1.getBinCenters()/deg, 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 = noisy.projectionY(0.5*deg) # slice at fixed value + plt.semilogy(proj2.getBinCenters()/deg, 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 = noisy.projectionY(0.4*deg, 0.6*deg) + plt.semilogy(proj3.getBinCenters()/deg, proj3.getArray(ba.IHistogram.AVERAGE), label=r'$<\phi>=0.5^{\circ}$') - plt.xlim(proj1.getXmin()/degree, proj1.getXmax()/degree) + plt.xlim(proj1.getXmin()/deg, proj1.getXmax()/deg) plt.ylim(1.0, proj1.getMaximum()*10.0) plt.xlabel(r'$\alpha_f ^{\circ}$', fontsize=16) plt.legend(loc='upper right') diff --git a/Examples/python/simulation/ex06_Miscellaneous/AxesInDifferentUnits.py b/Examples/python/simulation/ex06_Miscellaneous/AxesInDifferentUnits.py index dbd53c9ca8bbb2bd812d93fe99a2766494eab9f9..86dd47c622fcde3c18f9f4c42f41f51ea1ff3be2 100644 --- a/Examples/python/simulation/ex06_Miscellaneous/AxesInDifferentUnits.py +++ b/Examples/python/simulation/ex06_Miscellaneous/AxesInDifferentUnits.py @@ -1,12 +1,12 @@ """ In this example we demonstrate how to plot simulation results with -axes in different units (nbins, mm, degrees and QyQz). +axes in different units (nbins, mm, degs and QyQz). """ import numpy import matplotlib from matplotlib import pyplot as plt import bornagain as ba -from bornagain import degree, angstrom, nanometer +from bornagain import deg, angstrom, nm detector_distance = 2000.0 # in mm pilatus_pixel_size = 0.172 # in mm @@ -23,7 +23,7 @@ def get_sample(): m_particle = ba.HomogeneousMaterial("Particle", 6e-4, 2e-8) # collection of particles - cylinder_ff = ba.FormFactorCylinder(5*nanometer, 5*nanometer) + cylinder_ff = ba.FormFactorCylinder(5*nm, 5*nm) cylinder = ba.Particle(m_particle, cylinder_ff) particle_layout = ba.ParticleLayout() particle_layout.addParticle(cylinder, 1.0) @@ -54,7 +54,7 @@ def get_simulation(): Returns a GISAXS simulation with beam defined """ simulation = ba.GISASSimulation() - simulation.setBeamParameters(1.0*angstrom, 0.2*degree, 0.0*degree) + simulation.setBeamParameters(1.0*angstrom, 0.2*deg, 0.0*deg) simulation.setDetector(get_rectangular_detector()) return simulation @@ -100,7 +100,7 @@ def run_simulation(): plt.subplot(2, 2, 3) result = simulation.getIntensityData(ba.IDetector2D.DEGREES) - plot_as_colormap(result, "In degrees", + plot_as_colormap(result, "In degs", r'$\phi_f ^{\circ}$', r'$\alpha_f ^{\circ}$') plt.subplot(2, 2, 4) diff --git a/Examples/python/utils/plot_intensity_data.py b/Examples/python/utils/plot_intensity_data.py index 9ad7cce31f869d6e31ba5991fef54fad126a197a..561369973c2668daae6df3a070c700666a1f37c4 100755 --- a/Examples/python/utils/plot_intensity_data.py +++ b/Examples/python/utils/plot_intensity_data.py @@ -6,14 +6,14 @@ import numpy import matplotlib from matplotlib import pyplot as plt import bornagain as ba -from bornagain import degree, angstrom, nanometer +from bornagain import deg, angstrom, nm def plot_intensity_data(file_name): result = ba.IntensityDataIOFactory.readIntensityData(file_name) 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], + extent=[result.getXmin()/deg, result.getXmax()/deg, result.getYmin()/deg, result.getYmax()/deg], aspect='auto') cb = plt.colorbar(im) cb.set_label(r'Intensity (arb. u.)', size=16) diff --git a/Examples/python/utils/plot_intensity_data_diff.py b/Examples/python/utils/plot_intensity_data_diff.py index 854807ad5f43f27139c3fa28ef03f7d01b598872..ee1ef0264abb5150b4f3a7061ad7e55827c8cad3 100755 --- a/Examples/python/utils/plot_intensity_data_diff.py +++ b/Examples/python/utils/plot_intensity_data_diff.py @@ -6,13 +6,13 @@ import numpy import matplotlib from matplotlib import pyplot as plt import bornagain as ba -from bornagain import degree, angstrom, nanometer +from bornagain import deg, angstrom, nm def plot_intensity_data(ref, data): im = plt.imshow(data, norm=matplotlib.colors.LogNorm(), - extent=[ref.getXmin()/degree, ref.getXmax()/degree, ref.getYmin()/degree, ref.getYmax()/degree], + extent=[ref.getXmin()/deg, ref.getXmax()/deg, ref.getYmin()/deg, ref.getYmax()/deg], aspect='auto') cb = plt.colorbar(im)