Changeset 14099


Ignore:
Timestamp:
06/07/12 10:53:41 (12 years ago)
Author:
neise
Message:
some more examples
File:
1 edited

Legend:

Unmodified
Added
Removed
  • fact/tools/pyscripts/doc/getting_started.rst

    r14097 r14099  
    179179===============
    180180
     181one may interactively play with the two most important classes *RawData* and
     182*SlowData* from module pyfact...
     183
    181184*datafilepath* and *calibfilepath* should be adjusted in case you are not working
    182185on the ISDC cluster.
     
    184187explore class RawData::
    185188
    186   import pyfact
    187   datafilepath = '/data00/fact-construction/raw/2012/03/04/20120304_018.fits.gz'
    188   calibfilepath = '/data00/fact-construction/raw/2012/03/04/20120304_012.drs.fits.gz'
    189   run = pyfact.RawData( datafilepath, calibfilepath, return_dict = True)
     189  from pyfact import RawData
     190  # or from pyfact import *
     191 
     192  datafilepath = '/fact/raw/2012/03/04/20120304_018.fits.gz'
     193  calibfilepath = '/fact/raw/2012/03/04/20120304_012.drs.fits.gz'
     194  run = RawData(datafilepath, calibfilepath)
    190195  event = run.next()
    191196 
     
    198203    print 70*'*'
    199204
     205for historical reasons, an event contains *data* and *acal_data*, where *acal_data*
     206would be the DRS amplitude calibrated data, and *data* would be uncalibrated.
     207But since the calibration was moved into a C++ class, for better performance,
     208these keys now contains the same data.
     209
    200210loop over RawData::
    201211
    202   import pyfact
    203   datafilepath = '/data00/fact-construction/raw/2012/03/04/20120304_018.fits.gz'
    204   calibfilepath = '/data00/fact-construction/raw/2012/03/04/20120304_012.drs.fits.gz'
    205   run = pyfact.RawData( datafilepath, calibfilepath, return_dict = True)
    206  
     212  from pyfact import RawData
     213  # or from pyfact import *
     214 
     215  datafilepath = '/fact/raw/2012/03/04/20120304_018.fits.gz'
     216  calibfilepath = '/fact/raw/2012/03/04/20120304_012.drs.fits.gz'
     217  run = RawData(datafilepath, calibfilepath)
     218
    207219  for event in run:
    208220    print 'event_id:', event['event_id']
    209     # the data can be found in event['acal_data']
     221    # the data can be found in event['data']
     222
     223have a look at some SlowData::
     224
     225  :~$ cd /fact/aux/2012/05/30
     226  :/fact/aux/2012/05/30$ python
     227 
     228  from pyfact import SlowData
     229  file = SlowData('20120530.FTM_CONTROL_TRIGGER_RATES.fits')
     230  file.show()
     231 
     232
     233have a look at the *columns*, that are available::
     234
     235  'columns': {'BoardRate': (40L, 4L, 'E', 'Hz'),
     236             'ElapsedTime': (1L, 4L, 'E', 'sec'),
     237             'FTMtimeStamp': (1L, 8L, 'K', 'us'),
     238             'OnTime': (1L, 4L, 'E', 'sec'),
     239             'OnTimeCounter': (1L, 8L, 'K', 'us'),
     240             'PatchRate': (160L, 4L, 'E', 'Hz'),
     241             'QoS': (1L, 4L, 'J', ''),
     242             'Time': (1L, 8L, 'D', 'MJD'),
     243             'TriggerCounter': (1L, 4L, 'J', 'int'),
     244             'TriggerRate': (1L, 4L, 'E', 'Hz')},
     245
     246choose the *columns* you would like to retrieve from the file::
     247
     248  file.register('TriggerRate')
     249  file.register('Time')
     250  # or in case you are unsure
     251  file.register('all')
     252
     253check, what happened. file has got some new members::
     254
     255  file.show()
     256
     257but they are all zero. Now one should call *next()* in order to get
     258the file contents row by row::
     259
     260  file.next()
     261  file.show()
     262
     263or loop over the file::
     264
     265  counter = 0
     266  for row in file::
     267    if counter > 10:
     268      break
     269   
     270    print row.Time, row. OnTime
     271    counter += 1
     272
    210273
    211274.. rubric:: Footnotes
Note: See TracChangeset for help on using the changeset viewer.