source: fact/tools/pyscripts/fscvolt1.py@ 13151

Last change on this file since 13151 was 12610, checked in by lusterma, 13 years ago
added pyscripts folder to tools added fsc3.py, fscvolt1.py for plotting voltages and temperature added paux.py for running on a set of data files
File size: 2.6 KB
Line 
1#!/usr/bin/python26
2#
3# FACT SLOW CONTROL DATA
4# FSC_CONTROL_TEMPERATURE DATA
5#
6# Plot temperatures versus time
7# Save plots to disk
8#
9# Werner Lustermann
10# ETH Zurich
11
12import pyfits # module for reading fits files
13
14import numpy as np
15import numpy.ma as ma # masked array module
16
17import matplotlib.pyplot as plt # for plotting
18
19class FSC_VOLTAGE( object ):
20
21 def __init__(self, dpath = '../voltage/', dfile = '20111102.FSC_CONTROL_VOLTAGE.fits', plot_groups = True, show_plots = True ):
22
23 self.dfile = dfile
24 self.dpath = dpath
25 self.fname = dpath + dfile
26
27 self.Dgroups = ['FAD_Ud', 'FAD_U+', 'FAD_U-', 'FPA_Ud', 'FPA_U+', 'FPA_U-', 'ETH_U', 'FTM_U', 'FFC_U', 'FLP_U' ]
28 # self.Dgroups = ['FAD_Ud', 'FAD_U+', 'FAD_U-', 'FPA_Ud', 'FPA_U+', 'FPA_U-', 'ETH_U', 'FTM_U' ]
29
30 self.rData()
31
32 def rData( self ):
33
34 try:
35 hdu = pyfits.open( self.fname )
36 except:
37 print 'file: ', fname, ' does not exist! ==> BREAK!!!'
38 exit( 'unknown data file' )
39
40 self.tbdata = hdu[1].data
41 hdu.close()
42
43 self.time = self.tbdata.field( 'Time' )
44#
45#
46#
47 def vplot_all( self ):
48
49 for i, group in enumerate( self.Dgroups ):
50
51 #print 'i = ', i, group
52 T = self.tbdata.field( group )
53 # maska = self.tbdata.field( group ) == 0.0
54 # maskb = self.tbdata.field( group ) > 50.
55 # mask = maska | maskb
56 # mT = ma.masked_array( T, mask )
57 mT = T
58
59 plt.figure(111)
60 ax = plt.subplot(111)
61 if i < 8:
62 ax.plot( self.time, np.mean(mT,1) , '.', label = group, markersize = 2 )
63 else:
64 ax.plot( self.time, mT , '.', label = group, markersize = 2 )
65
66 ax.grid( 'on' )
67 plt.title( 'DC Voltages: ' + self.dfile[0:12], fontsize = 18 )
68 plt.xlabel( 'time', fontsize = 14 )
69 plt.ylabel( 'Voltage in V', fontsize = 14 )
70
71 # Shink current axis by 20%
72 box = ax.get_position()
73 ax.set_position([box.x0, box.y0, box.width * 0.97, box.height])
74 plt.legend( fancybox=True, loc='center left', bbox_to_anchor=(1, 0.5), numpoints = 7 )
75 plt.savefig( self.dfile[0:-5] + '.png' )
76
77
78
79 def tshow_plots( self ):
80 plt.show()
81
82if __name__ == '__main__':
83
84 print 'FACT FAD_CONTROL TEMPERATURE DATA'
85
86 fadt = FSC_VOLTAGE()
87 fadt.vplot_all()
88 #fadt.tshow_plots()
89
90 #fadt = FSC_VOLTAGE()
91 #fadt.vplot_all()
92 #fadt.tshow_plots()
93
94
95
96
97
98
Note: See TracBrowser for help on using the repository browser.