Skip to content

Commit

Permalink
Add Laue experiment type
Browse files Browse the repository at this point in the history
  • Loading branch information
toastisme committed May 1, 2024
1 parent 2732092 commit ca12559
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
1 change: 1 addition & 0 deletions newsfragments/XXX.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add Laue experiment type.
3 changes: 2 additions & 1 deletion src/dxtbx/model/boost_python/experiment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ namespace dxtbx { namespace model { namespace boost_python {
enum_<ExperimentType>("ExperimentType")
.value("STILL", STILL)
.value("ROTATION", ROTATION)
.value("TOF", TOF);
.value("TOF", TOF)
.value("LAUE", LAUE);

class_<Experiment>("Experiment")
.def(init<std::shared_ptr<BeamBase>,
Expand Down
9 changes: 8 additions & 1 deletion src/dxtbx/model/experiment.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

namespace dxtbx { namespace model {

enum ExperimentType { ROTATION = 1, STILL = 2, TOF = 3 };
enum ExperimentType { ROTATION = 1, STILL = 2, TOF = 3, LAUE = 4 };

/**
* A class to represent what's in an experiment.
Expand Down Expand Up @@ -156,6 +156,13 @@ namespace dxtbx { namespace model {
if (scan_ && scan_->contains("time_of_flight")) {
return TOF;
}

dxtbx::model::BeamBase &beam_base_ref = *beam_;
PolychromaticBeam *beam = dynamic_cast<PolychromaticBeam *>(&beam_base_ref);
if (beam != nullptr) {
return LAUE;
}

if (!goniometer_ || !scan_ || scan_->is_still()) {
return STILL;
} else {
Expand Down
18 changes: 18 additions & 0 deletions tests/model/test_experiment_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from dxtbx.imageset import ImageSetFactory
from dxtbx.model import (
Beam,
BeamFactory,
Crystal,
Detector,
Experiment,
Expand All @@ -26,6 +27,11 @@
Scan,
ScanFactory,
)

try:
from ..dxtbx_model_ext import Probe
except ModuleNotFoundError:
from dxtbx_model_ext import Probe # type: ignore
from dxtbx.model.experiment_list import ExperimentListDict, ExperimentListFactory


Expand Down Expand Up @@ -786,10 +792,22 @@ def test_experiment_type():
# Specifically test the bug from dxtbx#4 triggered by ending on 0°
experiment.scan = Scan((1, 1800), (-90, 0.05))
assert experiment.get_type() == ExperimentType.ROTATION

experiment.beam = BeamFactory.make_polychromatic_beam(
direction=(0, 0, -1),
sample_to_source_distance=(100),
probe=Probe.xray,
wavelength_range=(1, 10),
)

assert experiment.get_type() == ExperimentType.LAUE

experiment.scan = ScanFactory.make_scan_from_properties(
(1, 10), properties={"time_of_flight": list(range(10))}
)
assert experiment.get_type() == ExperimentType.TOF

experiment.beam = Beam()
experiment.scan = ScanFactory.make_scan_from_properties(
(1, 10), properties={"other_property": list(range(10))}
)
Expand Down

0 comments on commit ca12559

Please sign in to comment.