Coverage for src/susi/base/config/calibdata.py: 81%

21 statements  

« prev     ^ index     » next       coverage.py v7.5.0, created at 2025-06-13 14:15 +0000

1#!/usr/bin/env python3 

2# -*- coding: utf-8 -*- 

3""" 

4Module to specify calibration data input files 

5 

6@author: hoelken 

7""" 

8 

9from dataclasses import dataclass 

10 

11from ..exceptions import MissConfigurationException 

12 

13 

14@dataclass 

15class CalibData: 

16 """ 

17 DataItem class to define paths to external calibration data files. 

18 """ 

19 

20 #: Dark field file to use (full path) 

21 dark: str = None 

22 

23 #: Modulation matrix to use (full path) 

24 mod_matrix: str = None 

25 

26 #: SmileMap (Offsets from curvature effect & rotation) to use (full path) 

27 offset_map: str = None 

28 

29 #: The slit flat to apply 

30 slit_flat: str = None 

31 

32 #: The sensor flat to apply 

33 sensor_flat: str = None 

34 

35 #: The soft flat to apply 

36 soft_flat: str = None 

37 

38 #: Grid target files list to use for shear and rotation correction 

39 grid_tgt_files: list = None 

40 

41 def __repr__(self) -> str: 

42 txt = f"== {self.__class__.__name__} ==\n" 

43 txt += "\n".join(["{:<21} = {}".format(k, v) for k, v in self.__dict__.items()]) 

44 return txt 

45 

46 def amend_from_dict(self, data: dict): 

47 """ 

48 Overwrites the parameters with the values from the given dictionary. 

49 All instance variable names are supported as keywords. 

50 All keywords are optional, if the keyword is not present the previous value will be kept. 

51 

52 ### Params 

53 - data: The dictionary to parse. 

54 - c_name: The name of the camera to set defaults for. 

55 

56 ### Returns 

57 the created Config 

58 """ 

59 for k, v in data.items(): 

60 if not hasattr(self, k): 

61 raise MissConfigurationException(f"{self.__class__.__name__} config has no attribute {k}") 

62 setattr(self, k, v)