Changeset 17802 for fact/tools


Ignore:
Timestamp:
05/07/14 20:20:51 (11 years ago)
Author:
dneise
Message:
some help text
File:
1 edited

Legend:

Unmodified
Added
Removed
  • fact/tools/pyscripts/new_pyfact/pyfact.py

    r17801 r17802  
    55#
    66import os
     7import sys
    78import ctypes
    89from ctypes import *
     
    1314import ROOT
    1415hostname = ROOT.gSystem.HostName()
    15 if 'isdc' in hostname:
    16     ROOT.gSystem.Load("/usr/lib64/libz.so")
    17 elif ('neiseLenovo' in hostname or 'factcontrol' in hostname):
    18     ROOT.gSystem.Load("/usr/lib/libz.so")
    19 elif ("max-K50AB" in hostname or "watz" in hostname):
    20     ROOT.gSystem.Load("/usr/lib/x86_64-linux-gnu/libz.so")
    21 elif ("grolsch" in hostname):
    22     ROOT.gSystem.Load("/usr/lib/i386-linux-gnu/libz.so")
    23 else:
    24     print "Error,Warning,Whatever libz stuff makes me crazy."
     16
     17libz_path_dict = {
     18    # hostname  :   /path/to/libz.so
     19    'isdc'          : "/usr/lib64/libz.so",
     20    'neiseLenovo'   : "/usr/lib/libz.so",
     21    'factcontrol'   : "/usr/lib/libz.so",
     22    "max-K50AB"     : "/usr/lib/x86_64-linux-gnu/libz.so",
     23    "watz"          : "/usr/lib/x86_64-linux-gnu/libz.so",
     24    "grolsch"       : "/usr/lib/i386-linux-gnu/libz.so",
     25}
     26libz_loaded = False
     27for my_hostname in libz_path_dict:
     28    if my_hostname in hostname:
     29        ROOT.gSystem.Load(libz_path_dict[my_hostname])
     30        libz_loaded = True
     31if not libz_loaded:
     32    print """Warning - Warning - Warning - Warning - Warning - Warning - Warning
     33    I most probably need to load libz.so but I don't know where it is.
     34   
     35    Please edit pyfact.py around line 16-24 and insert your hostname and your
     36    path to your libz.so
     37    Sorry for the inconvenience.
     38    """
     39    sys.exit(-1)
     40
    2541   
    2642root_make_string = ROOT.gSystem.GetMakeSharedLib()
     
    174190if __name__ == '__main__':
    175191    """ tests  """
    176     import sys
    177     if len(sys.argv) == 2:
    178         print "Example for aux-file or uncalibrated raw-file"
    179         f = Fits(sys.argv[1])
    180     elif len(sys.argv) == 3:
    181         print "Example for calibrated raw-file"
    182         f = RawData(sys.argv[1], sys.argv[2])
    183     else:
    184         f = None
    185        
     192    if len(sys.argv) < 3:
     193        print """ Usage:
     194        ----------------------------------------------------------------------
     195        To just build the shared object libs call:
     196        python pyfact.py
     197       
     198        To build (if necessary) and open an example file
     199        python -i pyfact.py /path/to/data_file.zfits /path/to/calib_file.drs.fits.gz
     200       
     201        Any of the 3 file 'types': fits.gz    zfits    fits
     202        should be supported.
     203       
     204        To clean all of automatically built files, do something like:
     205        rm *.so *.d AutoDict_* extern_Mars_mcore/*.so extern_Mars_mcore/*.d
     206        ----------------------------------------------------------------------
     207        """
     208        sys.exit(1)
     209    print "Example for calibrated raw-file"
     210    f = RawData(sys.argv[1], sys.argv[2])
     211   
    186212    print "number of events:", f.header['NAXIS2']
    187213    print "date of observation:", f.header['DATE']
     
    204230    print "Event Id:", f.cols['EventNum']
    205231   
    206     if len(sys.argv) == 3:
    207         import matplotlib.pyplot as plt
    208         plt.ion()
    209         for i in range(f.header['NPIX']):
    210             plt.cla()
    211             plt.plot(f.cols['CalibData2D'][i], '.:', label='pixel %d'%i)
    212             plt.legend()
    213             answer = raw_input('anykey for next pixel; "q" to quit. :')
    214             if 'q' in answer.lower():
    215                 break
    216    
     232    import matplotlib.pyplot as plt
     233    plt.ion()
     234    for i in range(f.header['NPIX']):
     235        plt.cla()
     236        plt.title("Event %d"%(f.cols['EventNum']))
     237        plt.plot(f.cols['CalibData2D'][i], '.:', label='pixel %d'%i)
     238        plt.legend()
     239        answer = raw_input('anykey for next pixel; "q" to quit. :')
     240        if 'q' in answer.lower():
     241            break
     242
Note: See TracChangeset for help on using the changeset viewer.