Changeset 17809 for fact/tools/pyscripts/new_pyfact
- Timestamp:
- 05/08/14 14:16:15 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/pyscripts/new_pyfact/pyfact.py
r17802 r17809 6 6 import os 7 7 import sys 8 import ctypes9 from ctypes import *10 8 import numpy as np 11 import pprint # for SlowData12 from scipy import signal13 14 9 import ROOT 15 hostname = ROOT.gSystem.HostName() 16 17 libz_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 } 26 libz_loaded = False 27 for 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 31 if 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. 10 11 12 ########## BUILDING OF THE SHARED OBJECT FILES ############################### 13 if __name__ == '__main__' and len(sys.argv) > 1 and 'build' in sys.argv[1]: 14 hostname = ROOT.gSystem.HostName() 15 libz_path_dict = { 16 # hostname : /path/to/libz.so 17 'isdc' : "/usr/lib64/libz.so", 18 'neiseLenovo' : "/usr/lib/libz.so", 19 'factcontrol' : "/usr/lib/libz.so", 20 "max-K50AB" : "/usr/lib/x86_64-linux-gnu/libz.so", 21 "watz" : "/usr/lib/x86_64-linux-gnu/libz.so", 22 "grolsch" : "/usr/lib/i386-linux-gnu/libz.so", 23 } 24 libz_loaded = False 25 for my_hostname in libz_path_dict: 26 if my_hostname in hostname: 27 ROOT.gSystem.Load(libz_path_dict[my_hostname]) 28 libz_loaded = True 29 if not libz_loaded: 30 print """Warning - Warning - Warning - Warning - Warning - Warning - Warning 31 I most probably need to load libz.so but I don't know where it is. 32 33 Please edit pyfact.py around line 16-24 and insert your hostname and your 34 path to your libz.so 35 Sorry for the inconvenience. 36 """ 37 sys.exit(-1) 38 39 40 root_make_string = ROOT.gSystem.GetMakeSharedLib() 41 if not "-std=c++0x" in root_make_string: 42 make_string = root_make_string.replace('$Opt', '$Opt -std=c++0x -D HAVE_ZLIB') 43 ROOT.gSystem.SetMakeSharedLib(make_string) 44 ROOT.gROOT.ProcessLine(".L extern_Mars_mcore/izstream.h+O") 45 ROOT.gROOT.ProcessLine(".L extern_Mars_mcore/fits.h+O") 46 ROOT.gROOT.ProcessLine(".L extern_Mars_mcore/zfits.h+O") 47 ROOT.gROOT.ProcessLine(".L extern_Mars_mcore/factfits.h+O") 48 if not "-std=c++0x" in root_make_string: 49 make_string = root_make_string.replace('$Opt', "$Opt -std=c++0x -D HAVE_ZLIB -D'PACKAGE_NAME=\"PACKAGE_NAME\"' " 50 "-D'PACKAGE_VERSION=\"PACKAGE_VERSION\"' -D'REVISION=\"REVISION\"' ") 51 ROOT.gSystem.SetMakeSharedLib(make_string) 52 ROOT.gROOT.ProcessLine(".L extern_Mars_mcore/DrsCalib.h+O") 53 54 ROOT.gInterpreter.GenerateDictionary("map<string,fits::Entry>","map;string;extern_Mars_mcore/fits.h") 55 ROOT.gInterpreter.GenerateDictionary("pair<string,fits::Entry>","map;string;extern_Mars_mcore/fits.h") 56 ROOT.gInterpreter.GenerateDictionary("map<string,fits::Table::Column>","map;string;extern_Mars_mcore/fits.h") 57 ROOT.gInterpreter.GenerateDictionary("pair<string,fits::Table::Column>","map;string;extern_Mars_mcore/fits.h") 58 ROOT.gInterpreter.GenerateDictionary("vector<DrsCalibrate::Step>","vector;extern_Mars_mcore/DrsCalib.h") 59 60 ########## USAGE ############################################################# 61 if __name__ == '__main__' and len(sys.argv) < 3: 62 print """ Usage: 63 ---------------------------------------------------------------------- 64 To just build the shared object libs call: 65 python pyfact.py build 66 67 To build (if necessary) and open an example file 68 python -i pyfact.py /path/to/data_file.zfits /path/to/calib_file.drs.fits.gz 69 70 Any of the 3 file 'types': fits.gz zfits fits 71 should be supported. 72 73 To clean all of automatically built files, do something like: 74 rm *.so *.d AutoDict_* extern_Mars_mcore/*.so extern_Mars_mcore/*.d 75 ---------------------------------------------------------------------- 38 76 """ 39 sys.exit(-1) 40 41 42 root_make_string = ROOT.gSystem.GetMakeSharedLib() 43 if not "-std=c++0x" in root_make_string: 44 make_string = root_make_string.replace('$Opt', '$Opt -std=c++0x -D HAVE_ZLIB') 45 ROOT.gSystem.SetMakeSharedLib(make_string) 46 ROOT.gROOT.ProcessLine(".L extern_Mars_mcore/izstream.h+O") 47 ROOT.gROOT.ProcessLine(".L extern_Mars_mcore/fits.h+O") 48 ROOT.gROOT.ProcessLine(".L extern_Mars_mcore/zfits.h+O") 49 ROOT.gROOT.ProcessLine(".L extern_Mars_mcore/factfits.h+O") 50 if not "-std=c++0x" in root_make_string: 51 make_string = root_make_string.replace('$Opt', "$Opt -std=c++0x -D HAVE_ZLIB -D'PACKAGE_NAME=\"PACKAGE_NAME\"' -D'PACKAGE_VERSION=\"PACKAGE_VERSION\"' -D'REVISION=\"REVISION\"' ") 52 ROOT.gSystem.SetMakeSharedLib(make_string) 53 ROOT.gROOT.ProcessLine(".L extern_Mars_mcore/DrsCalib.h+O") 54 55 ROOT.gInterpreter.GenerateDictionary("map<string,fits::Entry>","map;string;extern_Mars_mcore/fits.h") 56 ROOT.gInterpreter.GenerateDictionary("pair<string,fits::Entry>","map;string;extern_Mars_mcore/fits.h") 57 ROOT.gInterpreter.GenerateDictionary("map<string,fits::Table::Column>","map;string;extern_Mars_mcore/fits.h") 58 ROOT.gInterpreter.GenerateDictionary("pair<string,fits::Table::Column>","map;string;extern_Mars_mcore/fits.h") 59 ROOT.gInterpreter.GenerateDictionary("vector<DrsCalibrate::Step>","vector;extern_Mars_mcore/DrsCalib.h") 60 61 ROOT.gSystem.Load('extern_Mars_mcore/fits_h.so') 62 ROOT.gSystem.Load('extern_Mars_mcore/izstream_h.so') 63 ROOT.gSystem.Load('extern_Mars_mcore/zfits_h.so') 64 ROOT.gSystem.Load('extern_Mars_mcore/factfits_h.so') 65 ROOT.gSystem.Load('extern_Mars_mcore/DrsCalib_h.so') 66 from ROOT import * 77 sys.exit(1) 78 79 ######### START OF PYFACT MODULE ############################################ 80 path = os.path.dirname(os.path.realpath(__file__)) 81 ROOT.gSystem.Load(path+'/AutoDict_map_string_fits__Entry__cxx.so') 82 ROOT.gSystem.Load(path+'/AutoDict_map_string_fits__Table__Column__cxx.so') 83 ROOT.gSystem.Load(path+'/AutoDict_pair_string_fits__Entry__cxx.so') 84 ROOT.gSystem.Load(path+'/AutoDict_pair_string_fits__Table__Column__cxx.so') 85 ROOT.gSystem.Load(path+'/AutoDict_vector_DrsCalibrate__Step__cxx.so') 86 ROOT.gSystem.Load(path+'/extern_Mars_mcore/fits_h.so') 87 ROOT.gSystem.Load(path+'/extern_Mars_mcore/izstream_h.so') 88 ROOT.gSystem.Load(path+'/extern_Mars_mcore/zfits_h.so') 89 ROOT.gSystem.Load(path+'/extern_Mars_mcore/factfits_h.so') 90 ROOT.gSystem.Load(path+'/extern_Mars_mcore/DrsCalib_h.so') 91 del path 67 92 68 93 class Fits( object ): … … 79 104 if not os.path.exists(path): 80 105 raise IOError(path+' was not found') 81 self.f = factfits(path)106 self.f = ROOT.factfits(path) 82 107 self._make_header() 83 108 self._setup_columns() … … 142 167 if not self.cols['CalibData2D'].base is self.cols['CalibData']: 143 168 print "Error seomthing went wrong!" 144 self.drs_calibration = DrsCalibration()169 self.drs_calibration = ROOT.DrsCalibration() 145 170 self.drs_calibration.ReadFitsImp( calib_path ) 146 171 147 self.drs_calibrate = DrsCalibrate()172 self.drs_calibrate = ROOT.DrsCalibrate() 148 173 self.list_of_previous_start_cells = [] 149 174 … … 189 214 190 215 if __name__ == '__main__': 191 """ tests """ 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) 216 """ Example """ 209 217 print "Example for calibrated raw-file" 210 218 f = RawData(sys.argv[1], sys.argv[2])
Note:
See TracChangeset
for help on using the changeset viewer.