266def load_current(filename:str, n_modules:int) -> tuple[list[float],list[tuple[float,...]]]:
267 from datetime import datetime, timezone
268 from importlib.resources import files
269 data =
files(
'DCSCalculator2.subdetectors.data').joinpath(filename).read_bytes().decode().
strip().
split(
'\n')
270 result = {}
271 for line in data:
272 line = line.strip()
273 if not line or line[0] == '#': continue
274 line = line.split()
275 current = tuple(float(x) for x in line[1:])
276 if len(current) != n_modules:
277 log.warning(f"Wrong number of modules ({len(current)}) in resource '{filename}' from {line[0]}. Setting thresholds to 0...")
278 current = (0.,) * n_modules
279 time = datetime.fromisoformat(line[0])
280 if time.tzinfo is None: time = time.replace(tzinfo=timezone.utc)
281 time = time.timestamp()
282 result[time] = current
283 keys, values = zip(*sorted(result.items()))
284 if not values: keys, values = [0.], [(0.,) * n_modules]
285 return (list(keys), list(values))
286
std::vector< std::string > files
file names and file pointers
std::vector< std::string > split(const std::string &s, const std::string &t=":")