stoner_measurement.instruments.xray.simulated.SimulatedXrayDiffractometer

class stoner_measurement.instruments.xray.simulated.SimulatedXrayDiffractometer(*, mechanics: ~stoner_measurement.instruments.xray_diffractometer.DiffractometerMechanics | None = None, theta_deg: float = 0.0, two_theta_deg: float = 0.0, background_rate_hz: float = 40.0, peaks: ~collections.abc.Sequence[tuple[float, float, float]] = ((37.2, 12000.0, 0.16), (43.4, 6000.0, 0.2), (49.1, 15000.0, 0.15), (54.0, 7500.0, 0.22)), xrr_rate_hz: float = 100000.0, xrr_wavelength_nm: float = 0.15406, xrr_critical_angle_deg: float = 0.415, xrr_film_thickness_nm: float = 50.0, xrr_fringe_amplitude: float = 0.35, xrr_roughness_nm: float = 0.5, xrr_phase_rad: float = 0.0, xrr_resolution_deg: float = 0.01, xrr_beam_height_mm: float = 0.05, xrr_sample_length_mm: float = 10.0, poisson_noise: bool = False, seed: int = 1, realtime: bool = False, motion_time_scale: float = 1.0, sleep: ~collections.abc.Callable[[float], None] = <built-in function sleep>)[source]

Bases: XrayDiffractometer

Fast, reproducible simulation of motion, snapshots and scalar counts.

Peak tuples are (two_theta_degrees, peak_rate_hz, sigma_degrees). Counting is instantaneous by default so tests need not wait in real time.

DISPLAY_NAME = 'Simulated X-ray Diffractometer'
confirm_identity() → str[source]

Query and validate the identity string against expected tokens.

Returns:

The validated identity string, or an empty string when no expected tokens are configured for this driver.

Return type:

(str)

Raises:

InstrumentError – If configured expected identity tokens are missing from the instrument identity response.

count(duration_s: float, *, cancel: Event | Callable[[], bool] | None = None) → CountResult[source]

Generate counts from the current 2-theta-dependent diffraction rate.

detector_rate_hz(two_theta_deg: float | None = None) → float[source]

Return the synthetic XRR and powder-diffraction count rate.

disable_theta() → None[source]

Send the controller’s theta motor-disable operation.

disable_two_theta() → None[source]

Send the controller’s 2-theta motor-disable operation.

identify() → str[source]

Return the instrument identification string (*IDN?).

Sends the standard IEEE 488.2 *IDN? query and returns the response. Instruments that do not support *IDN? should override this method.

Returns:

Identification string returned by the instrument.

Return type:

(str)

Raises:

ConnectionError – If the transport is not open.

Examples

>>> from stoner_measurement.instruments.transport import NullTransport
>>> from stoner_measurement.instruments.protocol import ScpiProtocol
>>> from stoner_measurement.instruments.base_instrument import BaseInstrument
>>> t = NullTransport(responses=[b"ACME,Model1,SN001,v1.0\n"])
>>> instr = BaseInstrument(t, ScpiProtocol())
>>> instr.connect()
>>> instr.identify()
'ACME,Model1,SN001,v1.0'
>>> instr.disconnect()
move_coupled(theta_deg: float, speed_deg_per_min: float, *, two_theta_offset_deg: float = 0.0, cancel: Event | Callable[[], bool] | None = None) → XraySnapshot[source]

Move both axes while enforcing 2theta = 2 * theta + offset.

move_theta(angle_deg: float, speed_deg_per_min: float, *, cancel: Event | Callable[[], bool] | None = None, backlash: bool = True) → XraySnapshot[source]

Move theta to an absolute angular coordinate.

move_two_theta(angle_deg: float, speed_deg_per_min: float, *, cancel: Event | Callable[[], bool] | None = None, backlash: bool = True) → XraySnapshot[source]

Move 2-theta to an absolute angular coordinate.

read_snapshot() → XraySnapshot[source]

Return the current simulated controller state.

reset_limit_latch() → None[source]

Reset the controller’s hardware limit latch.

start_count() → None[source]

Start the scalar detector counter.

step_theta(direction: AxisDirection, steps: int = 1, *, interval_s: float = 0.01, cancel: Event | Callable[[], bool] | None = None) → XraySnapshot[source]

Step the theta axis by an integer number of hardware steps.

step_two_theta(direction: AxisDirection, steps: int = 1, *, interval_s: float = 0.01, cancel: Event | Callable[[], bool] | None = None) → XraySnapshot[source]

Step the 2-theta axis by an integer number of hardware steps.

stop_count() → None[source]

Stop the scalar detector counter.

xrr_critical_edge_weight(two_theta_deg: float | None = None) → float[source]

Return the resolution-broadened total-reflection edge weight.

xrr_footprint_factor(two_theta_deg: float | None = None) → float[source]

Return the illuminated-sample fraction for the configured geometry.

xrr_reflectivity(two_theta_deg: float | None = None) → float[source]

Return a bounded thin-film XRR reflectivity for a specular scan.

The ideal critical edge is broadened by the configured angular resolution and the whole curve is multiplied by the finite-sample beam-footprint factor. Above the edge, a Fresnel q_z**-4 envelope is modulated by roughness-damped Kiessig fringes. two_theta_deg is converted to the incident angle using theta = two_theta / 2.

zero_theta() → None[source]

Change the hardware theta datum to zero.

zero_two_theta() → None[source]

Change the hardware 2-theta datum to zero.