Files
Jungfraujoch/python-client/openapi_client/models/detector_settings.py
2024-10-08 21:04:09 +02:00

116 lines
5.9 KiB
Python

# coding: utf-8
"""
Jungfraujoch
Jungfraujoch Broker Web API
The version of the OpenAPI document: 1.0.0-rc.15
Contact: filip.leonarski@psi.ch
Generated by OpenAPI Generator (https://openapi-generator.tech)
Do not edit the class manually.
""" # noqa: E501
from __future__ import annotations
import pprint
import re # noqa: F401
import json
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from typing import Optional, Set
from typing_extensions import Self
class DetectorSettings(BaseModel):
"""
DetectorSettings
""" # noqa: E501
frame_time_us: Annotated[int, Field(strict=True, ge=450)] = Field(description="Interval between consecutive frames.")
count_time_us: Optional[StrictInt] = Field(default=None, description="Integration time of the detector. If not provided count time will be set to maximum value for a given frame time.")
storage_cell_count: Annotated[int, Field(le=16, strict=True, ge=1)]
internal_frame_generator: StrictBool = Field(description="Use internal frame generator in FPGA instead of getting data from a real detector")
internal_frame_generator_images: Annotated[int, Field(le=128, strict=True, ge=1)]
pedestal_g0_frames: Annotated[int, Field(strict=True, ge=0)]
pedestal_g1_frames: Annotated[int, Field(strict=True, ge=0)]
pedestal_g2_frames: Annotated[int, Field(strict=True, ge=0)]
pedestal_g0_rms_limit: Annotated[int, Field(strict=True, ge=0)] = Field(description="Pixels with pedestal G0 RMS above the threshold are marked as masked pixels")
pedestal_min_image_count: Annotated[int, Field(strict=True, ge=32)] = Field(description="Minimum number of collected images for pedestal to consider it viable")
storage_cell_delay_ns: Annotated[int, Field(strict=True, ge=2100)] = Field(description="Delay between two storage cells [ns]")
detector_trigger_delay_ns: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field(default=0, description="Delay between TTL trigger and acquisition start [ns]")
fixed_gain_g1: Optional[StrictBool] = Field(default=False, description="Fix gain to G1 (can be useful for storage cells)")
use_gain_hg0: Optional[StrictBool] = Field(default=False, description="Use high G0 (for low energy applications)")
__properties: ClassVar[List[str]] = ["frame_time_us", "count_time_us", "storage_cell_count", "internal_frame_generator", "internal_frame_generator_images", "pedestal_g0_frames", "pedestal_g1_frames", "pedestal_g2_frames", "pedestal_g0_rms_limit", "pedestal_min_image_count", "storage_cell_delay_ns", "detector_trigger_delay_ns", "fixed_gain_g1", "use_gain_hg0"]
model_config = ConfigDict(
populate_by_name=True,
validate_assignment=True,
protected_namespaces=(),
)
def to_str(self) -> str:
"""Returns the string representation of the model using alias"""
return pprint.pformat(self.model_dump(by_alias=True))
def to_json(self) -> str:
"""Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict())
@classmethod
def from_json(cls, json_str: str) -> Optional[Self]:
"""Create an instance of DetectorSettings from a JSON string"""
return cls.from_dict(json.loads(json_str))
def to_dict(self) -> Dict[str, Any]:
"""Return the dictionary representation of the model using alias.
This has the following differences from calling pydantic's
`self.model_dump(by_alias=True)`:
* `None` is only added to the output dict for nullable fields that
were set at model initialization. Other fields with value `None`
are ignored.
"""
excluded_fields: Set[str] = set([
])
_dict = self.model_dump(
by_alias=True,
exclude=excluded_fields,
exclude_none=True,
)
return _dict
@classmethod
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
"""Create an instance of DetectorSettings from a dict"""
if obj is None:
return None
if not isinstance(obj, dict):
return cls.model_validate(obj)
_obj = cls.model_validate({
"frame_time_us": obj.get("frame_time_us"),
"count_time_us": obj.get("count_time_us"),
"storage_cell_count": obj.get("storage_cell_count") if obj.get("storage_cell_count") is not None else 1,
"internal_frame_generator": obj.get("internal_frame_generator") if obj.get("internal_frame_generator") is not None else False,
"internal_frame_generator_images": obj.get("internal_frame_generator_images") if obj.get("internal_frame_generator_images") is not None else 1,
"pedestal_g0_frames": obj.get("pedestal_g0_frames") if obj.get("pedestal_g0_frames") is not None else 2000,
"pedestal_g1_frames": obj.get("pedestal_g1_frames") if obj.get("pedestal_g1_frames") is not None else 300,
"pedestal_g2_frames": obj.get("pedestal_g2_frames") if obj.get("pedestal_g2_frames") is not None else 300,
"pedestal_g0_rms_limit": obj.get("pedestal_g0_rms_limit") if obj.get("pedestal_g0_rms_limit") is not None else 100,
"pedestal_min_image_count": obj.get("pedestal_min_image_count") if obj.get("pedestal_min_image_count") is not None else 128,
"storage_cell_delay_ns": obj.get("storage_cell_delay_ns") if obj.get("storage_cell_delay_ns") is not None else 5000,
"detector_trigger_delay_ns": obj.get("detector_trigger_delay_ns") if obj.get("detector_trigger_delay_ns") is not None else 0,
"fixed_gain_g1": obj.get("fixed_gain_g1") if obj.get("fixed_gain_g1") is not None else False,
"use_gain_hg0": obj.get("use_gain_hg0") if obj.get("use_gain_hg0") is not None else False
})
return _obj