Skip to content
Snippets Groups Projects

Add caldb_root as parameter for CalibrationData

Merged Thomas Kluyver requested to merge feat/calcatapi-root-dir into master
2 unresolved threads
1 file
+ 33
24
Compare changes
  • Side-by-side
  • Inline
"""Interfaces to calibration constant data."""
"""Interfaces to calibration constant data."""
import re
import socket
from datetime import date, datetime, time, timezone
from datetime import date, datetime, time, timezone
from functools import lru_cache
from functools import lru_cache
from os import getenv
from pathlib import Path
from pathlib import Path
from weakref import WeakKeyDictionary
from weakref import WeakKeyDictionary
@@ -367,6 +364,7 @@ class CalibrationData:
@@ -367,6 +364,7 @@ class CalibrationData:
calibrations = set()
calibrations = set()
default_client = None
default_client = None
 
_default_caldb_root = ...
def __init__(
def __init__(
self,
self,
@@ -375,6 +373,7 @@ class CalibrationData:
@@ -375,6 +373,7 @@ class CalibrationData:
client=None,
client=None,
event_at=None,
event_at=None,
module_naming="da",
module_naming="da",
 
caldb_root=None,
):
):
"""Initialize a new CalibrationData object.
"""Initialize a new CalibrationData object.
@@ -397,6 +396,8 @@ class CalibrationData:
@@ -397,6 +396,8 @@ class CalibrationData:
integers in karabo_da.
integers in karabo_da.
`qm`: QxMx naming convention is used. Virtual names for
`qm`: QxMx naming convention is used. Virtual names for
AGIPD, DSSC, and LPD.
AGIPD, DSSC, and LPD.
 
caldb_root (str or None): Path to the root directory for caldb
 
files, finds folder for production caldb by default.
**condition_params: Operating condition parameters defined
**condition_params: Operating condition parameters defined
on an instance level.
on an instance level.
"""
"""
@@ -406,6 +407,10 @@ class CalibrationData:
@@ -406,6 +407,10 @@ class CalibrationData:
self.event_at = event_at
self.event_at = event_at
self.pdu_snapshot_at = event_at
self.pdu_snapshot_at = event_at
self.module_naming = module_naming
self.module_naming = module_naming
 
if caldb_root is None:
 
self.caldb_root = self._get_default_caldb_root()
 
else:
 
self.caldb_root = Path(caldb_root)
if client is None:
if client is None:
@@ -486,29 +491,19 @@ class CalibrationData:
@@ -486,29 +491,19 @@ class CalibrationData:
)
)
return CalibrationData.default_client
return CalibrationData.default_client
@property
@staticmethod
def caldb_root(self):
def _get_default_caldb_root():
"""Root directory for calibration constant data.
if CalibrationData._default_caldb_root is ...:
onc_path = Path("/common/cal/caldb_store")
Returns:
maxwell_path = Path("/gpfs/exfel/d/cal/caldb_store")
(Path or None) Location of caldb store or
if onc_path.is_dir():
None if not available.
CalibrationData._default_caldb_root = onc_path
"""
elif maxwell_path.is_dir():
CalibrationData._default_caldb_root = maxwell_path
if not hasattr(CalibrationData, "_caldb_root"):
if getenv("SASE"):
# ONC
CalibrationData._caldb_root = Path("/common/cal/caldb_store")
elif re.match(r"^max-(.+)\.desy\.de$", socket.getfqdn()):
# Maxwell
CalibrationData._caldb_root = Path(
"/gpfs/exfel/d/cal/caldb_store"
)
else:
else:
# Probably unavailable
CalibrationData._default_caldb_root = None
CalibrationData._caldb_root = None
return CalibrationData._caldb_root
return CalibrationData._default_caldb_root
@property
@property
def client(self):
def client(self):
@@ -947,6 +942,7 @@ class AGIPD_CalibrationData(SplitConditionCalibrationData):
@@ -947,6 +942,7 @@ class AGIPD_CalibrationData(SplitConditionCalibrationData):
gain_setting=None,
gain_setting=None,
gain_mode=None,
gain_mode=None,
module_naming="da",
module_naming="da",
 
caldb_root=None,
integration_time=12,
integration_time=12,
source_energy=9.2,
source_energy=9.2,
pixels_x=512,
pixels_x=512,
@@ -958,6 +954,7 @@ class AGIPD_CalibrationData(SplitConditionCalibrationData):
@@ -958,6 +954,7 @@ class AGIPD_CalibrationData(SplitConditionCalibrationData):
client,
client,
event_at,
event_at,
module_naming,
module_naming,
 
caldb_root,
)
)
self.sensor_bias_voltage = sensor_bias_voltage
self.sensor_bias_voltage = sensor_bias_voltage
@@ -1021,6 +1018,7 @@ class LPD_CalibrationData(SplitConditionCalibrationData):
@@ -1021,6 +1018,7 @@ class LPD_CalibrationData(SplitConditionCalibrationData):
client=None,
client=None,
event_at=None,
event_at=None,
module_naming="da",
module_naming="da",
 
caldb_root=None,
):
):
super().__init__(
super().__init__(
detector_name,
detector_name,
@@ -1028,6 +1026,7 @@ class LPD_CalibrationData(SplitConditionCalibrationData):
@@ -1028,6 +1026,7 @@ class LPD_CalibrationData(SplitConditionCalibrationData):
client,
client,
event_at,
event_at,
module_naming,
module_naming,
 
caldb_root,
)
)
self.sensor_bias_voltage = sensor_bias_voltage
self.sensor_bias_voltage = sensor_bias_voltage
@@ -1072,6 +1071,7 @@ class DSSC_CalibrationData(CalibrationData):
@@ -1072,6 +1071,7 @@ class DSSC_CalibrationData(CalibrationData):
client=None,
client=None,
event_at=None,
event_at=None,
module_naming="da",
module_naming="da",
 
caldb_root=None,
):
):
super().__init__(
super().__init__(
detector_name,
detector_name,
@@ -1079,6 +1079,7 @@ class DSSC_CalibrationData(CalibrationData):
@@ -1079,6 +1079,7 @@ class DSSC_CalibrationData(CalibrationData):
client,
client,
event_at,
event_at,
module_naming,
module_naming,
 
caldb_root,
)
)
self.sensor_bias_voltage = sensor_bias_voltage
self.sensor_bias_voltage = sensor_bias_voltage
@@ -1126,6 +1127,7 @@ class JUNGFRAU_CalibrationData(CalibrationData):
@@ -1126,6 +1127,7 @@ class JUNGFRAU_CalibrationData(CalibrationData):
client=None,
client=None,
event_at=None,
event_at=None,
module_naming="da",
module_naming="da",
 
caldb_root=None,
):
):
super().__init__(
super().__init__(
detector_name,
detector_name,
@@ -1133,6 +1135,7 @@ class JUNGFRAU_CalibrationData(CalibrationData):
@@ -1133,6 +1135,7 @@ class JUNGFRAU_CalibrationData(CalibrationData):
client,
client,
event_at,
event_at,
module_naming,
module_naming,
 
caldb_root,
)
)
self.sensor_bias_voltage = sensor_bias_voltage
self.sensor_bias_voltage = sensor_bias_voltage
@@ -1193,6 +1196,7 @@ class PNCCD_CalibrationData(SplitConditionCalibrationData):
@@ -1193,6 +1196,7 @@ class PNCCD_CalibrationData(SplitConditionCalibrationData):
client=None,
client=None,
event_at=None,
event_at=None,
module_naming="da",
module_naming="da",
 
caldb_root=None,
):
):
# Ignore modules for this detector.
# Ignore modules for this detector.
super().__init__(
super().__init__(
@@ -1201,6 +1205,7 @@ class PNCCD_CalibrationData(SplitConditionCalibrationData):
@@ -1201,6 +1205,7 @@ class PNCCD_CalibrationData(SplitConditionCalibrationData):
client,
client,
event_at,
event_at,
module_naming,
module_naming,
 
caldb_root,
)
)
self.sensor_bias_voltage = sensor_bias_voltage
self.sensor_bias_voltage = sensor_bias_voltage
@@ -1249,6 +1254,7 @@ class EPIX100_CalibrationData(SplitConditionCalibrationData):
@@ -1249,6 +1254,7 @@ class EPIX100_CalibrationData(SplitConditionCalibrationData):
client=None,
client=None,
event_at=None,
event_at=None,
module_naming="da",
module_naming="da",
 
caldb_root=None,
):
):
# Ignore modules for this detector.
# Ignore modules for this detector.
super().__init__(
super().__init__(
@@ -1257,6 +1263,7 @@ class EPIX100_CalibrationData(SplitConditionCalibrationData):
@@ -1257,6 +1263,7 @@ class EPIX100_CalibrationData(SplitConditionCalibrationData):
client,
client,
event_at,
event_at,
module_naming,
module_naming,
 
caldb_root,
)
)
self.sensor_bias_voltage = sensor_bias_voltage
self.sensor_bias_voltage = sensor_bias_voltage
@@ -1299,6 +1306,7 @@ class GOTTHARD2_CalibrationData(CalibrationData):
@@ -1299,6 +1306,7 @@ class GOTTHARD2_CalibrationData(CalibrationData):
client=None,
client=None,
event_at=None,
event_at=None,
module_naming="da",
module_naming="da",
 
caldb_root=None,
):
):
# Ignore modules for this detector.
# Ignore modules for this detector.
super().__init__(
super().__init__(
@@ -1307,6 +1315,7 @@ class GOTTHARD2_CalibrationData(CalibrationData):
@@ -1307,6 +1315,7 @@ class GOTTHARD2_CalibrationData(CalibrationData):
client,
client,
event_at,
event_at,
module_naming,
module_naming,
 
caldb_root,
)
)
self.sensor_bias_voltage = sensor_bias_voltage
self.sensor_bias_voltage = sensor_bias_voltage
Loading