46 lines
1.3 KiB
Python
46 lines
1.3 KiB
Python
from typing import Annotated, List
|
|
|
|
from jfjoch_client.models.scan_result import ScanResult
|
|
from pydantic import Field, AfterValidator, BaseModel
|
|
|
|
from aaredaqlib.coordinate import Coordinate, positive_coords, SmargonCoordinate
|
|
from aaredaqlib.sample_geometry import SampleGeometryModel
|
|
|
|
|
|
class RasterGridRequest(BaseModel):
|
|
dtz: float | None = None
|
|
transmission: float | None = None
|
|
file_prefix: str | None = None
|
|
exp_time_s: float
|
|
|
|
# Number of grid elements - 0 is allowed for empty grid
|
|
n_x: Annotated[int, Field(ge=0)]
|
|
n_y: Annotated[int, Field(ge=0)]
|
|
|
|
# Size of grid elements
|
|
grid_size_mm: Annotated[Coordinate, AfterValidator(positive_coords)]
|
|
|
|
# Coordinates of top left corner in Smargon (SH...) coordinates
|
|
smargon: SmargonCoordinate
|
|
|
|
# omega angle
|
|
omega_deg: float = 0.0
|
|
|
|
visible: bool = True
|
|
|
|
def get_image_number(self) -> int:
|
|
return self.n_x * self.n_y
|
|
|
|
def grid_size_pxl(self, geom: SampleGeometryModel) -> Coordinate:
|
|
return self.grid_size_mm / geom.pixel_in_mm
|
|
|
|
def start_pxl(self, geom: SampleGeometryModel) -> Coordinate:
|
|
return geom.smargon_to_beamline(self.smargon.sh_mm)
|
|
|
|
class CompletedRasterGridElem(BaseModel):
|
|
request: RasterGridRequest
|
|
result: ScanResult
|
|
|
|
class CompletedRasterGrid(BaseModel):
|
|
r: List[CompletedRasterGridElem]
|