Changeset 14470 for fact/tools


Ignore:
Timestamp:
10/11/12 00:20:04 (12 years ago)
Author:
neise
Message:
added example for stacking SlowData
File:
1 edited

Legend:

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

    r14119 r14470  
    101101I is just easier to understand for the reader, I think.
    102102
     103
     104Stack some slow Data into numpy arrays
     105======================================
     106
     107This example shows how to stack some columns from slow data into numpy arrays.
     108One first open the file as usual, and *registers* the columns one is interested in.
     109Then one informs the SlowData object about ones intention to have the data stacked.
     110Now the SlowData object will create 2D-arrays, which contain the registered data
     111while one loops over the slowdata file.
     112
     113The looping is important!
     114
     115Have a look::
     116
     117#!/usr/bin/python -tti
     118
     119import time
     120import numpy as np
     121from pyfact import SlowData
     122
     123f = SlowData('20120601.FTM_STATIC_DATA.fits')
     124#
     125# do here --> f.show() if you are not sure about the column names
     126#
     127f.register('PatchThresh')
     128f.register('Time')
     129f.stack()
     130
     131# now loop over the file and let SlowData do the magic
     132for 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
     137t = f.stacked_cols['Time'] * 24. * 3600
     138
     139# put the thresholds into another var, for convenience
     140dtr = f.stacked_cols['PatchThresh']
     141
     142# give the user some diagnostic info
     143print 'start time:', time.asctime(time.gmtime(t[0]))
     144print 'stop time:', time.asctime(time.gmtime(t[-1]))
     145
     146print 'mean/median threshold:', dtr.mean(), np.median(dtr)
     147print 'min/max threshold:', dtr.min(), dtr.max()
     148print 'std deviation:', dtr.std()
     149
     150
     151
     152
    103153calling a system command
    104154========================
Note: See TracChangeset for help on using the changeset viewer.