Exemplo n.º 1
0
def add_mask_to_simulation(simulation):
    """
    Here we demonstrate how to add masks to the simulation.
    Only unmasked areas will be simulated and then used during the fit.

    Masks can have different geometrical shapes (ba.Rectangle, ba.Ellipse, Line)
    with the mask value either "True" (detector bin is excluded from the simulation)
    or False (will be simulated).

    Every subsequent mask override previously defined masks in this area.

    In the code below we put masks in such way that simulated image will look like
    a Pac-Man from ancient arcade game.
    """
    # mask all detector (put mask=True to all detector channels)
    simulation.maskAll()

    # set mask to simulate pacman's head
    simulation.addMask(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 * deg, 1.25 * deg, 0.05 * deg, 0.05 * deg), True)

    # set mask for pacman's mouth
    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 * deg, 0.95 * deg, 0.55 * deg, 1.05 * deg), False)
    simulation.addMask(
        ba.Rectangle(0.61 * deg, 0.95 * deg, 0.71 * deg, 1.05 * deg), False)
    simulation.addMask(
        ba.Rectangle(0.75 * deg, 0.95 * deg, 0.85 * deg, 1.05 * deg), False)
def get_simulation(params):
    simulation = ba.GISASSimulation()

    detector = ba.RectangularDetector(981, 168.732, 1043, 179.396)
    detector.setPerpendicularToDirectBeam(3532.0, 103.234, 60.062)
    simulation.setDetector(detector)

    simulation.setRegionOfInterest(87, 70, 119, 130)
    simulation.addMask(ba.Rectangle(101.7, 72, 104.7, 107), True)

    simulation.setDetectorResolutionFunction(ba.ResolutionFunction2DGaussian(0.1, 0.1))
    simulation.setBeamParameters(0.1 * nm, 0.2 * deg, 0.0 * deg)
    simulation.setBeamIntensity(1.0e+08)

    simulation.setSample(get_sample(params))
    return simulation
Exemplo n.º 3
0
def create_simulation(params):
    """
    Creates and returns GISAS simulation with beam and detector defined
    """
    simulation = ba.GISASSimulation()
    simulation.setDetector(create_detector())
    simulation.setBeamParameters(wavelength, alpha_i, 0.0)
    simulation.setBeamIntensity(1.2e7)
    simulation.setRegionOfInterest(85.0, 70.0, 120.0, 92.)
    simulation.addMask(ba.Rectangle(101.9, 82.1, 103.7, 85.2),
                       True)  # mask on reflected beam

    sample_builder = SampleBuilder()
    sample = sample_builder.create_sample(params)
    simulation.setSample(sample)

    return simulation
def get_simulation():
    """
    define GISAS simulation
    :return: simulation
    """
    simulation = ba.GISASSimulation()
    simulation.setDetectorParameters(nbins, p_min, p_max, nbins, ai_min,
                                     ai_max)

    simulation.setBeamParameters(wavelength, ai, 0.0 * deg)
    simulation.setBeamIntensity(1.0e+08)
    # create a fake beam stop
    simulation.addMask(
        ba.Rectangle(-0.04 * deg, 0.0 * deg, 0.04 * deg, 0.5 * deg), True)
    simulation.addMask(
        ba.Ellipse(0.0 * deg, 0.17 * deg, 0.01 * deg, 0.15 * deg), False)

    return simulation
Exemplo n.º 5
0
def get_simulation():
    """
    define GISAS simulation
    :return: simulation
    """
    simulation = ba.GISASSimulation()

    # set detector parameters

    # set beam parameters

    # set region of interest

    # mask beam stop
    simulation.addMask(
        ba.Rectangle(-0.04 * deg, 0.0 * deg, 0.04 * deg, 0.5 * deg), True)

    return simulation
Exemplo n.º 6
0
def create_simulation():
    """
    Creates and returns GISAS simulation with beam and detector defined
    """
    simulation = ba.GISASSimulation()
    simulation.setDetector(create_detector())
    simulation.setBeamParameters(wavelength, alpha_i, 0.0)
    simulation.setBeamIntensity(1.2e7)
    simulation.setRegionOfInterest(85.0, 70.0, 120.0, 92.)
    # mask on reflected beam
    simulation.addMask(ba.Rectangle(101.9, 82.1, 103.7, 85.2), True)
    # detector resolution function
    # simulation.setDetectorResolutionFunction(
    #   ba.ResolutionFunction2DGaussian(0.5*pilatus_pixel_size,
    #      0.5*pilatus_pixel_size))
    # beam divergence
    # alpha_distr = ba.DistributionGaussian(alpha_i, 0.02*ba.deg)
    # simulation.addParameterDistribution("*/Beam/Alpha", alpha_distr, 5)
    return simulation
Exemplo n.º 7
0
def get_simulation():
    """
    define GISAS simulation
    :return: simulation
    """
    simulation = ba.GISASSimulation()

    # set detector parameters
    simulation.setDetectorParameters(nbins, p_min, p_max, nbins, ai_min, ai_max)

    # set beam parameters
    simulation.setBeamParameters(wavelength, ai, 0.0 * deg)
    simulation.setBeamIntensity(1.0e+08)

    # set region of interest
    simulation.setRegionOfInterest(roi_xmin, roi_ymin, roi_xmax, roi_ymax)

    # mask beam stop
    simulation.addMask(ba.Rectangle(-0.04*deg, 0.0*deg, 0.04*deg, 0.5*deg), True)

    return simulation
Exemplo n.º 8
0
def get_simulation():
    simulation = ba.GISASSimulation()

    detector = ba.RectangularDetector(981, 168.732, 1043, 179.396)
    detector.setPerpendicularToDirectBeam(3532.0, 103.234, 60.062)
    simulation.setDetector(detector)
    simulation.setTerminalProgressMonitor()
    background = ba.PoissonNoiseBackground()
    simulation.setBackground(background)
    simulation.getOptions().setIncludeSpecular(True)
    simulation.addMask(ba.Rectangle(82, 0.0, 86, 180), True)

    # distr_1 = ba.DistributionGaussian(0.2 * deg, 0.001 * deg)
    # simulation.addParameterDistribution("*/Beam/InclinationAngle", distr_1, 5, 2.0,
    #                                     ba.RealLimits.limited(0.0 * deg, 90.0 * deg))
    # distr_2 = ba.DistributionGaussian(0.0 * deg, 0.01 * deg)
    # simulation.addParameterDistribution("*/Beam/AzimuthalAngle", distr_2, 5, 2.0,
    #                                     ba.RealLimits.limited(-90.0 * deg, 90.0 * deg))
    simulation.setDetectorResolutionFunction(ba.ResolutionFunction2DGaussian(0.1, 0.1))
    simulation.setBeamParameters(0.1 * nm, 0.2 * deg, 0.0 * deg)
    simulation.setBeamIntensity(1.0e+08)
    return simulation