@@ -45,7 +45,29 @@ def __str__(self):
4545 return table .get_string ()
4646
4747
48- class Background (RATModel ):
48+ class Signal (RATModel ):
49+ """Base model for background & resolution signals."""
50+
51+ name : str = Field (default = "New Signal" , min_length = 1 )
52+ type : TypeOptions = TypeOptions .Constant
53+ source : str = ""
54+ value_1 : str = ""
55+ value_2 : str = ""
56+ value_3 : str = ""
57+ value_4 : str = ""
58+ value_5 : str = ""
59+
60+ def __setattr__ (self , name , value ):
61+ if name == "type" :
62+ for attr in ["source" , "value_1" , "value_2" , "value_3" , "value_4" , "value_5" ]:
63+ with warnings .catch_warnings ():
64+ warnings .simplefilter ("ignore" )
65+ super ().__setattr__ (attr , "" )
66+
67+ super ().__setattr__ (name , value )
68+
69+
70+ class Background (Signal ):
4971 """A background signal.
5072
5173 Parameters
@@ -68,13 +90,6 @@ class Background(RATModel):
6890 """
6991
7092 name : str = Field (default_factory = lambda : f"New Background { next (background_number )} " , min_length = 1 )
71- type : TypeOptions = TypeOptions .Constant
72- source : str = ""
73- value_1 : str = ""
74- value_2 : str = ""
75- value_3 : str = ""
76- value_4 : str = ""
77- value_5 : str = ""
7893
7994 @model_validator (mode = "after" )
8095 def warn_parameters (self ):
@@ -96,15 +111,6 @@ def warn_parameters(self):
96111
97112 return self
98113
99- def __setattr__ (self , name , value ):
100- if name == "type" :
101- for attr in ["source" , "value_1" , "value_2" , "value_3" , "value_4" , "value_5" ]:
102- with warnings .catch_warnings ():
103- warnings .simplefilter ("ignore" )
104- super ().__setattr__ (attr , "" )
105-
106- super ().__setattr__ (name , value )
107-
108114
109115class Contrast (RATModel ):
110116 """A group of all of the components of a model.
@@ -539,7 +545,7 @@ class ProtectedParameter(Parameter):
539545 name : str = Field (frozen = True , min_length = 1 )
540546
541547
542- class Resolution (RATModel ):
548+ class Resolution (Signal ):
543549 """An instrument resolution.
544550
545551 Parameters
@@ -563,13 +569,6 @@ class Resolution(RATModel):
563569 """
564570
565571 name : str = Field (default_factory = lambda : f"New Resolution { next (resolution_number )} " , min_length = 1 )
566- type : TypeOptions = TypeOptions .Constant
567- source : str = ""
568- value_1 : str = ""
569- value_2 : str = ""
570- value_3 : str = ""
571- value_4 : str = ""
572- value_5 : str = ""
573572
574573 @field_validator ("type" )
575574 @classmethod
@@ -601,12 +600,3 @@ def warn_parameters(self):
601600 )
602601
603602 return self
604-
605- def __setattr__ (self , name , value ):
606- if name == "type" :
607- for attr in ["source" , "value_1" , "value_2" , "value_3" , "value_4" , "value_5" ]:
608- with warnings .catch_warnings ():
609- warnings .simplefilter ("ignore" )
610- super ().__setattr__ (attr , "" )
611-
612- super ().__setattr__ (name , value )
0 commit comments