From 4ad0ce5f876fac4c42b43aef7aa23f2c4fdb8ace Mon Sep 17 00:00:00 2001 From: David Waterman Date: Wed, 11 Oct 2023 15:20:52 +0100 Subject: [PATCH] Electron probe tweaks (#661) * Do not overwrite Probe unless requested. Fixes #2515 * Use electron Probe in two ED format classes that were missed before --- newsfragments/661.bugfix | 1 + newsfragments/661.feature | 1 + src/dxtbx/format/FormatNXmxED.py | 2 ++ src/dxtbx/format/FormatSER.py | 2 ++ src/dxtbx/model/beam.py | 3 ++- 5 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 newsfragments/661.bugfix create mode 100644 newsfragments/661.feature diff --git a/newsfragments/661.bugfix b/newsfragments/661.bugfix new file mode 100644 index 000000000..2cfc35640 --- /dev/null +++ b/newsfragments/661.bugfix @@ -0,0 +1 @@ +The beam probe is no longer reset if any geometrical override is provided at import. diff --git a/newsfragments/661.feature b/newsfragments/661.feature new file mode 100644 index 000000000..19b0f32b5 --- /dev/null +++ b/newsfragments/661.feature @@ -0,0 +1 @@ +Set the beam probe to ``electron`` in both ``FormatNXmxED`` and ``FormatSER``. diff --git a/src/dxtbx/format/FormatNXmxED.py b/src/dxtbx/format/FormatNXmxED.py index c02cc63f6..ad70a20c8 100644 --- a/src/dxtbx/format/FormatNXmxED.py +++ b/src/dxtbx/format/FormatNXmxED.py @@ -9,6 +9,7 @@ from dxtbx.format.FormatNXmx import FormatNXmx from dxtbx.masking import mask_untrusted_circle, mask_untrusted_polygon from dxtbx.model import SimplePxMmStrategy +from dxtbx.model.beam import Probe class FormatNXmxED(FormatNXmx): @@ -65,6 +66,7 @@ def _beam(self, index=None): beam = super()._beam() beam.set_polarization_fraction(0.5) + beam.set_probe(Probe.electron) return beam diff --git a/src/dxtbx/format/FormatSER.py b/src/dxtbx/format/FormatSER.py index d04357f6f..7265323b6 100644 --- a/src/dxtbx/format/FormatSER.py +++ b/src/dxtbx/format/FormatSER.py @@ -22,6 +22,7 @@ from dxtbx import IncorrectFormatError from dxtbx.format.Format import Format from dxtbx.format.FormatMultiImage import FormatMultiImage +from dxtbx.model.beam import Probe # The read_emi and _parseEntry_emi functions are taken from openNCEM project @@ -334,6 +335,7 @@ def cal_wavelength(V0): wavelength=wavelength, polarization=(0, 1, 0), polarization_fraction=0.5, + probe=Probe.electron, ) def _get_raw_data(self, index): diff --git a/src/dxtbx/model/beam.py b/src/dxtbx/model/beam.py index 799d9be32..f16e1fb51 100644 --- a/src/dxtbx/model/beam.py +++ b/src/dxtbx/model/beam.py @@ -122,7 +122,8 @@ def from_phil( beam.set_flux(params.beam.flux) if params.beam.sample_to_source_distance is not None: beam.set_sample_to_source_distance(params.beam.sample_to_source_distance) - beam.set_probe(Beam.get_probe_from_name(params.beam.probe)) + if params.beam.probe != "x-ray": + beam.set_probe(Beam.get_probe_from_name(params.beam.probe)) return beam