예제 #1
0
def estimated_builder(builder):
    program_mock_added = False
    if not builder.programs:
        builder.add_program(ProgramMock())
        program_mock_added = True

    beam_mock_added = False
    if not builder.beams:
        builder.add_beam(PencilBeam(10e3))
        beam_mock_added = True

    sample_mock_added = False
    if not builder.samples:
        builder.add_sample(SubstrateSample(Material.pure(26)))
        sample_mock_added = True

    try:
        yield builder

    finally:
        if program_mock_added:
            builder.programs.clear()
        if beam_mock_added:
            builder.beams.clear()
        if sample_mock_added:
            builder.samples.clear()
예제 #2
0
def simulation():
    program = ProgramMock()
    beam = GaussianBeam(15e3, 10e-9)
    sample = SubstrateSample(Material.pure(29))
    detector = PhotonDetector("xray", math.radians(40.0))
    analyses = [PhotonIntensityAnalysis(detector)]
    tags = ["basic", "test"]
    options = Options(program, beam, sample, analyses, tags)

    results = []

    analysis = PhotonIntensityAnalysis(detector)
    builder = EmittedPhotonIntensityResultBuilder(analysis)
    builder.add_intensity((29, "Ka1"), 1.0, 0.1)
    builder.add_intensity((29, "Ka2"), 2.0, 0.2)
    builder.add_intensity((29, "Kb1"), 4.0, 0.5)
    builder.add_intensity((29, "Kb3"), 5.0, 0.7)
    builder.add_intensity((29, "Kb5I"), 1.0, 0.1)
    builder.add_intensity((29, "Kb5II"), 0.5, 0.1)
    builder.add_intensity((29, "Ll"), 3.0, 0.1)
    results.append(builder.build())

    analysis = KRatioAnalysis(detector)
    builder = KRatioResultBuilder(analysis)
    builder.add_kratio((29, "Ka1"), 1.0, 1.0)
    builder.add_kratio((29, "Ka2"), 2.0, 1.0)
    builder.add_kratio((29, "Kb1"), 0.5, 1.0)
    builder.add_kratio((29, "Kb3"), 1.5, 1.0)
    builder.add_kratio((29, "Kb5I"), 1.0, 1.0)
    builder.add_kratio((29, "Kb5II"), 0.5, 1.0)
    builder.add_kratio((29, "Ll"), 2.0, 1.0)
    results.append(builder.build())

    return Simulation(options, results)
예제 #3
0
def test_validate_program_invalid(exporter, options):
    program = ProgramMock("bar", ElasticCrossSectionModel.ELSEPA2005)

    erracc = ErrorAccumulator()
    exporter._validate_program(program, options, erracc)

    assert len(erracc.exceptions) == 1
    assert len(erracc.warnings) == 0
예제 #4
0
def test_validate_program_invalid2(exporter, options):
    program = ProgramMock("bar",
                          MassAbsorptionCoefficientModel.POUCHOU_PICHOIR1991)

    erracc = ErrorAccumulator()
    exporter._validate_program(program, options, erracc)

    assert len(erracc.exceptions) == 1
    assert len(erracc.warnings) == 0
예제 #5
0
def options():
    """
    Creates basic options using the mock program.
    """
    program = ProgramMock()
    beam = GaussianBeam(15e3, 10e-9)
    sample = SubstrateSample(Material.pure(29))
    detector = PhotonDetector("xray", math.radians(40.0))
    analyses = [PhotonIntensityAnalysis(detector)]
    tags = ["basic", "test"]
    return Options(program, beam, sample, analyses, tags)
예제 #6
0
    def __init__(self):
        default_program = ProgramMock()
        super().__init__(default_program)

        self.field_foo = FooField()
        self.addLabelField(self.field_foo)

        self.field_elastic_cross_section_model = ElasticCrossSectionModelField()
        for model in self._validator.valid_models[ElasticCrossSectionModel]:
            checked = model == default_program.elastic_cross_section_model
            self.field_elastic_cross_section_model.addModel(model, checked)
        self.addGroupField(self.field_elastic_cross_section_model)
예제 #7
0
    def setUp(self):
        super().setUp()

        self.tmpdirs = []

        self.program = ProgramMock()
예제 #8
0
def program():
    return ProgramMock()