snapred.backend.dao package

Subpackages

Submodules

snapred.backend.dao.CrystallographicInfo module

class snapred.backend.dao.CrystallographicInfo.CrystallographicInfo(hkl: List[Tuple[int, int, int]] = None, dSpacing: List[float] = None, fSquared: List[float] = None, multiplicities: List[int] = None, peaks=None)

Bases: BaseModel

Class to hold crystallographic parameters

property dSpacing: List[float]
property fSquared: List[float]
property hkl: List[Tuple[int, int, int]]
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

property multiplicities: List[int]
peaks: List[CrystallographicPeak]

snapred.backend.dao.CrystallographicPeak module

class snapred.backend.dao.CrystallographicPeak.CrystallographicPeak(*, hkl: Tuple[int, int, int], dSpacing: float, fSquared: float, multiplicity: int)

Bases: BaseModel

Class to hold crystallographic parameters

dSpacing: float
fSquared: float
hkl: Tuple[int, int, int]
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

multiplicity: int

snapred.backend.dao.DetectorPeak module

class snapred.backend.dao.DetectorPeak.DetectorPeak(*, position: LimitedValue[float], peak: CrystallographicPeak)

Bases: BaseModel

Class to hold diffraction peak position and limits in d-spacing

property maximum: float
property minimum: float
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

peak: CrystallographicPeak
position: LimitedValue[float]
classmethod validate_position(v: Any) LimitedValue[float]
property value: float

snapred.backend.dao.GroupPeakList module

class snapred.backend.dao.GroupPeakList.GroupPeakList(*, peaks: List[DetectorPeak], groupID: int, maxfwhm: float | None = None)

Bases: BaseModel

Class to hold diffraction peak positions of one group

groupID: int
maxfwhm: float | None
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

peaks: List[DetectorPeak]

snapred.backend.dao.GSASParameters module

class snapred.backend.dao.GSASParameters.GSASParameters(*, alpha: float, beta: Tuple[float, float])

Bases: BaseModel

Class for various GSAS parameters

alpha: float
beta: Tuple[float, float]
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

snapred.backend.dao.Limit module

class snapred.backend.dao.Limit.BinnedValue(*, minimum: T, binWidth: T, maximum: T, binningMode: BinningMode = BinningMode.LOG)

Bases: BaseModel, Generic[T]

BinnedValue defines a range and bin width for values of type T, alongside a binning mode (linear or logarithmic). It validates the range and bin width, adjusting bin width to positive if negative, ensuring logical binning behavior for data categorization or histogram generation.

class BinningMode(value)

Bases: IntEnum

LINEAR = 1
LOG = -1
binWidth: T
binningMode: BinningMode
maximum: T
minimum: T
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

property params: Tuple[float, float, float]
classmethod validate_binWidth(v)
validate_scalar_fields()
class snapred.backend.dao.Limit.Limit(*, minimum: T, maximum: T)

Bases: BaseModel, Generic[T]

The Limit class defines minimum and maximum limits for a given type T, ensuring through validation that the minimum is not greater than the maximum. This class is generic, allowing for the application of limits to various data types.

maximum: T
minimum: T
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

validate_scalar_fields()
class snapred.backend.dao.Limit.LimitedValue(*, value: T, minimum: T, maximum: T)

Bases: BaseModel, Generic[T]

LimitedValue ensures that a given value of type T falls within specified minimum and maximum limits. It enforces the constraint that the value must always be between these defined limits.

maximum: T
minimum: T
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

validate_scalar_fields()
value: T
class snapred.backend.dao.Limit.Pair(minimum: T = None, maximum: T = None, *, left: T, right: T)

Bases: BaseModel, Generic[T]

The Pair class primarily facilitates the mapping of two related values, adaptable to contexts where these values need to be interpreted or manipulated as a unit. This is also a generic class.

left: T
property maximum: T
property minimum: T
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

right: T

snapred.backend.dao.ObjectSHA module

class snapred.backend.dao.ObjectSHA.ObjectSHA(*, hex: Annotated[str, MinLen(min_length=16), _PydanticGeneralMetadata(pattern='[0-9a-f]+')], decodedKey: str | None = None)

Bases: BaseModel

Provides a standardized object identifier digest to support filesystem-as-database requirements.

This class allows for:

  • Verification that JSON files representing objects have not been arbitrarily moved. This is ensured by making the SHA a component of the object’s path on the filesystem.

  • Verification of nested objects where components may be loaded from separate JSON files. This is achieved by marking both nested object and its parent with the SHA from some common reference object, for example, a DetectorState.

decodedKey: str | None
static fromObject(obj: Any, length=16)
hex: str
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

snapred.backend.dao.ParticleBounds module

class snapred.backend.dao.ParticleBounds.ParticleBounds(*, wavelength: Limit, tof: Limit)

Bases: BaseModel

ParticleBounds specifies the allowable ranges for wavelength and time-of-flight (TOF) parameters for particles, using the Limit class to define the upper and lower bounds for each.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

tof: Limit
wavelength: Limit

snapred.backend.dao.ReductionState module

class snapred.backend.dao.ReductionState.ReductionState(*, instrumentConfig: InstrumentConfig, stateConfig: StateConfig, overrides: InstrumentConfig | None = None)

Bases: BaseModel

Class to hold the instrument configuration.

instrumentConfig: InstrumentConfig
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

overrides: InstrumentConfig | None
stateConfig: StateConfig

snapred.backend.dao.RunConfig module

class snapred.backend.dao.RunConfig.RunConfig(*, runNumber: str, IPTS: str | None = None, useLiteMode: bool | None = None, maskFileName: str | None = None, maskFileDirectory: str | None = None, gsasFileDirectory: str | None = None, calibrationState: str | None = None)

Bases: BaseModel

Class to hold the instrument configuration.

IPTS: str | None
calibrationState: str | None
gsasFileDirectory: str | None
maskFileDirectory: str | None
maskFileName: str | None
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

runNumber: str
useLiteMode: bool | None

snapred.backend.dao.SNAPRequest module

class snapred.backend.dao.SNAPRequest.SNAPRequest(*, path: str, payload: Any | None = None, hooks: dict[str, List[Hook]] | None = None)

Bases: BaseModel

SNAPRequest represents the structure of a request within the SNAPRed, containing a path indicating the target of the request and an optional payload that carries the request’s data.

hooks: dict[str, List[Hook]] | None
model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

path: str
payload: Any | None

snapred.backend.dao.SNAPResponse module

class snapred.backend.dao.SNAPResponse.ResponseCode(value)

Bases: IntEnum

ResponseCode defines a set of standardized response codes representing various outcomes of a request. ranging from successful operations (OK) to various levels of errors, including recoverable states and general errors.

CONTINUE_WARNING = 301
ERROR = 500
LIVE_DATA_STATE = 351
MAX_OK = 300
OK = 200
RECOVERABLE = 400
USER_CANCELLATION = 326
class snapred.backend.dao.SNAPResponse.SNAPResponse(*, code: ResponseCode, message: str | None = None, data: Any | None = None)

Bases: BaseModel

SNAPResponse encapsulates the structure of a response generated by the SNAP application, including a response code (using the ResponseCode enum for clarity and consistency), an optional message providing additional context or details about the response, and an optional data field that can carry any response data.

code: ResponseCode
data: Any | None
message: str | None
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

snapred.backend.dao.StateConfig module

class snapred.backend.dao.StateConfig.StateConfig(*, calibration: Calibration, vanadiumFilePath: str = '', groupingMap: GroupingMap | None = None, stateId: ObjectSHA)

Bases: BaseModel

attachGroupingMap(groupingMap: GroupingMap, coerceStateId=False)
calibration: Calibration
enforceStateId()
groupingMap: GroupingMap | None
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

stateId: ObjectSHA
classmethod str_to_ObjectSHA(v: str) str
vanadiumFilePath: str

Module contents