@@ -197,7 +197,14 @@ def update_beam_conditions(run, log=log):
197197
198198 try :
199199 # also, get the average CDC gas pressure
200- cmds = ["myStats" , "-b" , begin_time_str , "-e" , end_time_str , "-l" , "RESET:i:GasPanelBarPress1" ]
200+ cmds = ["myStats" , "-b" , begin_time_str , "-e" , end_time_str , "-l" , "RESET:i:GasPanelBarPress1,GAS:i::CDC_Temps-CDC_D1_Temp,GAS:i::CDC_Temps-CDC_D2_Temp,GAS:i::CDC_Temps-CDC_D3_Temp,GAS:i::CDC_Temps-CDC_D4_Temp,GAS:i::CDC_Temps-CDC_D5_Temp" ]
201+
202+ cdc_temp_1 = - 10.
203+ cdc_temp_2 = - 10.
204+ cdc_temp_3 = - 10.
205+ cdc_temp_4 = - 10.
206+ cdc_temp_5 = - 10.
207+
201208 log .debug (Lf ("Requesting cdc_gas_pressure subprocess flags: '{}'" , cmds ))
202209 # execute external command
203210 p = subprocess .Popen (cmds , stdout = subprocess .PIPE )
@@ -216,11 +223,42 @@ def update_beam_conditions(run, log=log):
216223 if key == b"RESET:i:GasPanelBarPress1" :
217224 log .debug (Lf ("Saving cdc_gas_pressure = '{}'" , float (value )))
218225 conditions ["cdc_gas_pressure" ] = float (value )
219- log .debug ("Done with cdc_gas_pressure" )
226+ if key == "GAS:i::CDC_Temps-CDC_D1_Temp" :
227+ cdc_temp_1 = float (value )
228+ if key == "GAS:i::CDC_Temps-CDC_D2_Temp" :
229+ cdc_temp_2 = float (value )
230+ if key == "GAS:i::CDC_Temps-CDC_D3_Temp" :
231+ cdc_temp_3 = float (value )
232+ if key == "GAS:i::CDC_Temps-CDC_D4_Temp" :
233+ cdc_temp_4 = float (value )
234+ if key == "GAS:i::CDC_Temps-CDC_D5_Temp" :
235+ cdc_temp_5 = float (value )
236+ log .debug ("Done with cdc_gas_pressure" )
220237 except Exception as e :
221238 log .warn (Lf ("Error in a cdc_gas_pressure request : '{}'" , e ))
222239 conditions ["cdc_gas_pressure" ] = - 1.
223240
241+ ## calculate P/T for CDC
242+ if (conditions ["cdc_gas_pressure" ] > 0. ):
243+ # average and check ranges
244+ ntemps = 0
245+ temp_avg = 0.
246+ temps = [cdc_temp_1 , cdc_temp_2 , cdc_temp_3 , cdc_temp_4 , cdc_temp_5 ]
247+ for temp in temps :
248+ if (temp > 20. and temp < 30. ):
249+ ntemps += 1
250+ temp_avg += (temp + 273. ) # don't forget to convert deg C -> deg K
251+
252+ if ntemps > 0 :
253+ temp_avg /= float (ntemps )
254+
255+ # do calc
256+ conditions ["cdc_povert" ] = conditions ["cdc_gas_pressure" ] / temp_avg
257+ else :
258+ conditions ["cdc_povert" ] = - 1.
259+ else :
260+ conditions ["cdc_povert" ] = - 1.
261+
224262 return conditions
225263
226264
0 commit comments