Changeset 14102 for fact/tools/pyscripts
- Timestamp:
- 06/07/12 11:03:02 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/pyscripts/doc/getting_started.rst
r14100 r14102 65 65 66 66 67 4 a. Create the needed *.so libs @ ISDC67 4. Create the needed *.so libs @ ISDC 68 68 ====================================== 69 69 … … 87 87 calfactfits_h.so factfits_h.so izstream_h.so 88 88 89 4b. Create pyfits_h.so library 90 ============================= 89 5. Test if everything is running 90 ================================= 91 92 Now you can check if the reading rawdata is working:: 93 94 neise@isdc-viewer00:~/py/pyfact$ pyfact.py 95 showing test of iterator of RawData class 96 in order to test the SlowData classe please use: ./pyfact.py fits-file-name 97 ev 1 data[0,0] = -7.68806196438 start_cell[0] = 426 trigger type = 416 98 ev 2 data[0,0] = 0.792280672486 start_cell[0] = 437 trigger type = 416 99 ev 3 data[0,0] = 54.9490855517 start_cell[0] = 449 trigger type = 416 100 ev 4 data[0,0] = 3.9482592671 start_cell[0] = 461 trigger type = 416 101 ev 5 data[0,0] = -66.4329317281 start_cell[0] = 474 trigger type = 416 102 ev 6 data[0,0] = 8.2917625181 start_cell[0] = 485 trigger type = 416 103 ev 7 data[0,0] = -41.6565116079 start_cell[0] = 498 trigger type = 416 104 ev 8 data[0,0] = 33.4668984163 start_cell[0] = 509 trigger type = 416 105 ev 9 data[0,0] = -28.520090549 start_cell[0] = 522 trigger type = 416 106 ev 10 data[0,0] = -20.4925692795 start_cell[0] = 533 trigger type = 416 107 108 This should work at ISDC only, but if it does not work, please ask somebody for help. 109 110 6. Tiny examples 111 =============== 112 113 one may interactively play with the two most important classes *RawData* and 114 *SlowData* from module pyfact... 115 116 *datafilepath* and *calibfilepath* should be adjusted in case you are not working 117 on the ISDC cluster. 118 119 explore class RawData:: 120 121 from pyfact import RawData 122 # or from pyfact import * 123 124 datafilepath = '/fact/raw/2012/03/04/20120304_018.fits.gz' 125 calibfilepath = '/fact/raw/2012/03/04/20120304_012.drs.fits.gz' 126 run = RawData(datafilepath, calibfilepath) 127 event = run.next() 128 129 type(event) 130 131 print 70*'*' 132 for key in event: 133 print 'key :', key 134 print 'value:', event[key] 135 print 70*'*' 136 137 for historical reasons, an event contains *data* and *acal_data*, where *acal_data* 138 would be the DRS amplitude calibrated data, and *data* would be uncalibrated. 139 But since the calibration was moved into a C++ class, for better performance, 140 these keys now contains the same data. 141 142 loop over RawData:: 143 144 from pyfact import RawData 145 # or from pyfact import * 146 147 datafilepath = '/fact/raw/2012/03/04/20120304_018.fits.gz' 148 calibfilepath = '/fact/raw/2012/03/04/20120304_012.drs.fits.gz' 149 run = RawData(datafilepath, calibfilepath) 150 151 for event in run: 152 print 'event_id:', event['event_id'] 153 # the data can be found in event['data'] 154 155 have a look at some SlowData:: 156 157 :~$ cd /fact/aux/2012/05/30 158 :/fact/aux/2012/05/30$ python 159 160 from pyfact import SlowData 161 file = SlowData('20120530.FTM_CONTROL_TRIGGER_RATES.fits') 162 file.show() 163 164 165 have a look at the *columns*, that are available:: 166 167 'columns': {'BoardRate': (40L, 4L, 'E', 'Hz'), 168 'ElapsedTime': (1L, 4L, 'E', 'sec'), 169 'FTMtimeStamp': (1L, 8L, 'K', 'us'), 170 'OnTime': (1L, 4L, 'E', 'sec'), 171 'OnTimeCounter': (1L, 8L, 'K', 'us'), 172 'PatchRate': (160L, 4L, 'E', 'Hz'), 173 'QoS': (1L, 4L, 'J', ''), 174 'Time': (1L, 8L, 'D', 'MJD'), 175 'TriggerCounter': (1L, 4L, 'J', 'int'), 176 'TriggerRate': (1L, 4L, 'E', 'Hz')}, 177 178 choose the *columns* you would like to retrieve from the file:: 179 180 file.register('TriggerRate') 181 file.register('Time') 182 # or in case you are unsure 183 file.register('all') 184 185 check, what happened. file has got some new members:: 186 187 file.show() 188 189 but they are all zero. Now one should call *next()* in order to get 190 the file contents row by row:: 191 192 file.next() 193 file.show() 194 195 or loop over the file:: 196 197 counter = 0 198 for row in file:: 199 if counter > 10: 200 break 201 202 print row.Time, row. OnTime 203 counter += 1 204 205 7. Old way of creating the so files 206 =================================== 91 207 92 208 -----------This is a depricated section--------------- … … 160 276 pyfits.h pyfits_h.d pyfits_h.so 161 277 162 Now you can check if the reading rawdata is working::163 164 neise@isdc-viewer00:~/py/pyfact$ pyfact.py165 showing test of iterator of RawData class166 in order to test the SlowData classe please use: ./pyfact.py fits-file-name167 ev 1 data[0,0] = -7.68806196438 start_cell[0] = 426 trigger type = 416168 ev 2 data[0,0] = 0.792280672486 start_cell[0] = 437 trigger type = 416169 ev 3 data[0,0] = 54.9490855517 start_cell[0] = 449 trigger type = 416170 ev 4 data[0,0] = 3.9482592671 start_cell[0] = 461 trigger type = 416171 ev 5 data[0,0] = -66.4329317281 start_cell[0] = 474 trigger type = 416172 ev 6 data[0,0] = 8.2917625181 start_cell[0] = 485 trigger type = 416173 ev 7 data[0,0] = -41.6565116079 start_cell[0] = 498 trigger type = 416174 ev 8 data[0,0] = 33.4668984163 start_cell[0] = 509 trigger type = 416175 ev 9 data[0,0] = -28.520090549 start_cell[0] = 522 trigger type = 416176 ev 10 data[0,0] = -20.4925692795 start_cell[0] = 533 trigger type = 416177 178 179 5. Run examples180 ===============181 182 one may interactively play with the two most important classes *RawData* and183 *SlowData* from module pyfact...184 185 *datafilepath* and *calibfilepath* should be adjusted in case you are not working186 on the ISDC cluster.187 188 explore class RawData::189 190 from pyfact import RawData191 # or from pyfact import *192 193 datafilepath = '/fact/raw/2012/03/04/20120304_018.fits.gz'194 calibfilepath = '/fact/raw/2012/03/04/20120304_012.drs.fits.gz'195 run = RawData(datafilepath, calibfilepath)196 event = run.next()197 198 type(event)199 200 print 70*'*'201 for key in event:202 print 'key :', key203 print 'value:', event[key]204 print 70*'*'205 206 for historical reasons, an event contains *data* and *acal_data*, where *acal_data*207 would be the DRS amplitude calibrated data, and *data* would be uncalibrated.208 But since the calibration was moved into a C++ class, for better performance,209 these keys now contains the same data.210 211 loop over RawData::212 213 from pyfact import RawData214 # or from pyfact import *215 216 datafilepath = '/fact/raw/2012/03/04/20120304_018.fits.gz'217 calibfilepath = '/fact/raw/2012/03/04/20120304_012.drs.fits.gz'218 run = RawData(datafilepath, calibfilepath)219 220 for event in run:221 print 'event_id:', event['event_id']222 # the data can be found in event['data']223 224 have a look at some SlowData::225 226 :~$ cd /fact/aux/2012/05/30227 :/fact/aux/2012/05/30$ python228 229 from pyfact import SlowData230 file = SlowData('20120530.FTM_CONTROL_TRIGGER_RATES.fits')231 file.show()232 233 234 have a look at the *columns*, that are available::235 236 'columns': {'BoardRate': (40L, 4L, 'E', 'Hz'),237 'ElapsedTime': (1L, 4L, 'E', 'sec'),238 'FTMtimeStamp': (1L, 8L, 'K', 'us'),239 'OnTime': (1L, 4L, 'E', 'sec'),240 'OnTimeCounter': (1L, 8L, 'K', 'us'),241 'PatchRate': (160L, 4L, 'E', 'Hz'),242 'QoS': (1L, 4L, 'J', ''),243 'Time': (1L, 8L, 'D', 'MJD'),244 'TriggerCounter': (1L, 4L, 'J', 'int'),245 'TriggerRate': (1L, 4L, 'E', 'Hz')},246 247 choose the *columns* you would like to retrieve from the file::248 249 file.register('TriggerRate')250 file.register('Time')251 # or in case you are unsure252 file.register('all')253 254 check, what happened. file has got some new members::255 256 file.show()257 258 but they are all zero. Now one should call *next()* in order to get259 the file contents row by row::260 261 file.next()262 file.show()263 264 or loop over the file::265 266 counter = 0267 for row in file::268 if counter > 10:269 break270 271 print row.Time, row. OnTime272 counter += 1273 274 278 275 279 .. rubric:: Footnotes
Note:
See TracChangeset
for help on using the changeset viewer.