Changeset 14470
- Timestamp:
- 10/11/12 00:20:04 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/pyscripts/doc/examples.rst
r14119 r14470 101 101 I is just easier to understand for the reader, I think. 102 102 103 104 Stack some slow Data into numpy arrays 105 ====================================== 106 107 This example shows how to stack some columns from slow data into numpy arrays. 108 One first open the file as usual, and *registers* the columns one is interested in. 109 Then one informs the SlowData object about ones intention to have the data stacked. 110 Now the SlowData object will create 2D-arrays, which contain the registered data 111 while one loops over the slowdata file. 112 113 The looping is important! 114 115 Have a look:: 116 117 #!/usr/bin/python -tti 118 119 import time 120 import numpy as np 121 from pyfact import SlowData 122 123 f = SlowData('20120601.FTM_STATIC_DATA.fits') 124 # 125 # do here --> f.show() if you are not sure about the column names 126 # 127 f.register('PatchThresh') 128 f.register('Time') 129 f.stack() 130 131 # now loop over the file and let SlowData do the magic 132 for row in f: 133 pass 134 135 # the stacked data can be found in the dict SlowData.stacked_cols 136 # put the Time array into a variable and convert into seconds since 01.01.1970 137 t = f.stacked_cols['Time'] * 24. * 3600 138 139 # put the thresholds into another var, for convenience 140 dtr = f.stacked_cols['PatchThresh'] 141 142 # give the user some diagnostic info 143 print 'start time:', time.asctime(time.gmtime(t[0])) 144 print 'stop time:', time.asctime(time.gmtime(t[-1])) 145 146 print 'mean/median threshold:', dtr.mean(), np.median(dtr) 147 print 'min/max threshold:', dtr.min(), dtr.max() 148 print 'std deviation:', dtr.std() 149 150 151 152 103 153 calling a system command 104 154 ========================
Note:
See TracChangeset
for help on using the changeset viewer.