Files
Jungfraujoch/python-client/jfjoch_client/models/spot_finding_settings.py
2024-10-18 20:17:29 +02:00

110 lines
5.1 KiB
Python

# coding: utf-8
"""
Jungfraujoch
API to control Jungfraujoch developed by the Paul Scherrer Institute (Switzerland). Jungfraujoch is a data acquisition and analysis system for pixel array detectors, primarly PSI JUNGFRAU. Jungfraujoch uses FPGA boards to acquire data at high data rates.
The version of the OpenAPI document: 1.0.0-rc.19
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, StrictFloat, StrictInt
from typing import Any, ClassVar, Dict, List, Optional, Union
from typing_extensions import Annotated
from typing import Optional, Set
from typing_extensions import Self
class SpotFindingSettings(BaseModel):
"""
SpotFindingSettings
""" # noqa: E501
enable: StrictBool = Field(description="Enable spot finding. This is temporary setting, i.e. can be changed anytime during data collection. Even if disabled spot finding information will still be send and written, though always with zero spots. ")
indexing: StrictBool = Field(description="Enable indexing. This is temporary setting, i.e. can be changed anytime during data collection. ")
filter_powder_rings: Optional[StrictBool] = Field(default=False, description="Filter spots which form powder rings (e.g., ice rings)")
min_spot_count_powder_ring: Optional[Annotated[int, Field(strict=True, ge=5)]] = Field(default=None, description="Minimum number of spots to consider a thin resolution shell (0.01 A^-1) a powder ring and filter out.")
signal_to_noise_threshold: Union[Annotated[float, Field(strict=True, ge=0)], Annotated[int, Field(strict=True, ge=0)]]
photon_count_threshold: Annotated[int, Field(strict=True, ge=0)]
min_pix_per_spot: Annotated[int, Field(strict=True, ge=1)]
max_pix_per_spot: Annotated[int, Field(strict=True, ge=1)]
high_resolution_limit: Union[StrictFloat, StrictInt]
low_resolution_limit: Union[StrictFloat, StrictInt]
indexing_tolerance: Union[Annotated[float, Field(le=1.0, strict=True, ge=0.0)], Annotated[int, Field(le=1, strict=True, ge=0)]] = Field(description="Acceptance tolerance for spots after the indexing run - the larger the number, the more spots will be accepted")
__properties: ClassVar[List[str]] = ["enable", "indexing", "filter_powder_rings", "min_spot_count_powder_ring", "signal_to_noise_threshold", "photon_count_threshold", "min_pix_per_spot", "max_pix_per_spot", "high_resolution_limit", "low_resolution_limit", "indexing_tolerance"]
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 SpotFindingSettings 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 SpotFindingSettings from a dict"""
if obj is None:
return None
if not isinstance(obj, dict):
return cls.model_validate(obj)
_obj = cls.model_validate({
"enable": obj.get("enable") if obj.get("enable") is not None else True,
"indexing": obj.get("indexing") if obj.get("indexing") is not None else True,
"filter_powder_rings": obj.get("filter_powder_rings") if obj.get("filter_powder_rings") is not None else False,
"min_spot_count_powder_ring": obj.get("min_spot_count_powder_ring"),
"signal_to_noise_threshold": obj.get("signal_to_noise_threshold"),
"photon_count_threshold": obj.get("photon_count_threshold"),
"min_pix_per_spot": obj.get("min_pix_per_spot"),
"max_pix_per_spot": obj.get("max_pix_per_spot"),
"high_resolution_limit": obj.get("high_resolution_limit"),
"low_resolution_limit": obj.get("low_resolution_limit"),
"indexing_tolerance": obj.get("indexing_tolerance")
})
return _obj