@@ -722,7 +722,7 @@ def state_vals(self):
722
722
class ValidateACISStatePower (ValidateSingleMsid ):
723
723
state_name = "dpa_power"
724
724
msids = ["dpa_power" ]
725
- state_keys_extra = ["ccd_count" , "clocking" , "feps" , "ccds" , "fep_count" , "simpos " ]
725
+ state_keys_extra = ["ccd_count" , "clocking" , "feps" , "ccds" , "fep_count" , "si_mode " ]
726
726
plot_attrs = PlotAttrs (title = "DPA Power" , ylabel = "DPA Power (W)" )
727
727
min_violation_duration = 600.0 # seconds
728
728
max_delta_val = 2.0 # W
@@ -744,24 +744,37 @@ def states(self):
744
744
745
745
@functools .cached_property
746
746
def state_vals (self ):
747
- istates = interpolate_states (self .states , self .times )
748
- # create on-off states for FEPs
747
+ int_states = interpolate_states (self .states , self .times )
748
+
749
+ # create on-off states for FEPs and CCDs
749
750
ccds = [f"I{ i } " for i in range (4 )] + [f"S{ i } " for i in range (6 )]
750
751
ccdsfeps = defaultdict (list )
751
- for row in istates :
752
+ for row in int_states :
752
753
for i in range (6 ):
753
- ccdsfeps [f"FEP{ i } " ].append (float ( str (i ) in row ["feps" ]) )
754
- for ccd in ccds :
755
- ccdsfeps [ccd ].append (float ( str ( ccd ) in row ["ccds" ]) )
754
+ ccdsfeps [f"FEP{ i } " ].append (str (i ) in row ["feps" ])
755
+ for key in ccds :
756
+ ccdsfeps [key ].append (key in row ["ccds" ])
756
757
for key in ccdsfeps :
757
- istates [key ] = ccdsfeps [key ]
758
- df = istates .to_pandas ()
759
- keep_cols = list (ccdsfeps .keys ())
760
- XX = df .drop ([col for col in istates .colnames if col not in keep_cols ], axis = 1 )
758
+ int_states [key ] = np .array (ccdsfeps [key ], dtype = "float64" )
759
+
760
+ # check for continuous clocking mode
761
+ int_states ["cc" ] = np .char .startswith (int_states ["si_mode" ], "CC" ).astype (
762
+ "float64"
763
+ )
764
+ int_states ["cc" ] *= ~ int_states ["clocking" ].astype ("bool" )
765
+
766
+ # Convert to pandas DataFrame, so we can use sklearn
767
+ df = int_states .to_pandas ()
768
+ keep_cols = ["cc" ] + list (ccdsfeps .keys ())
769
+ XX = df .drop (
770
+ [col for col in int_states .colnames if col not in keep_cols ], axis = 1
771
+ )
761
772
XX = self .scaler_X .fit_transform (XX .values )
762
773
yy = self .model .predict (XX )
774
+
763
775
# Inverse transform the predictions and actual values
764
776
_state_vals = self .scaler_y .inverse_transform (yy .reshape (- 1 , 1 )).flatten ()
777
+
765
778
return _state_vals
766
779
767
780
def add_exclude_intervals (self ):
0 commit comments