- Timestamp:
- 04/29/14 16:41:03 (11 years ago)
- Location:
- fact/tools/pyscripts/pyfact
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/pyscripts/pyfact/calfactfits.h
r17691 r17730 53 53 #endif 54 54 55 #include " factfits.h"55 #include "extern_Mars_mcore/factfits.h" 56 56 57 57 class CalFactFits -
fact/tools/pyscripts/pyfact/pyfact.py
r17690 r17730 10 10 11 11 # get the ROOT stuff + my shared libs 12 from ROOT import gSystem 12 import ROOT 13 13 # factfits_h.so is made from factfits.h and is used to access the data 14 14 # make sure the location of factfits_h.so is in LD_LIBRARY_PATH. 15 15 # having it in PYTHONPATH is *not* sufficient 16 gSystem.Load('fits_h.so') 17 gSystem.Load('izstream_h.so') 18 gSystem.Load('zfits_h.so') 19 gSystem.Load('factfits_h.so') 20 gSystem.Load('calfactfits_h.so') 16 hostname = ROOT.gSystem.HostName() 17 if 'isdc' in hostname: 18 ROOT.gSystem.Load("/usr/lib64/libz.so") 19 elif ('neiseLenovo' in hostname or 'factcontrol' in hostname): 20 ROOT.gSystem.Load("/usr/lib/libz.so") 21 elif ("max-K50AB" in hostname or "watz" in hostname): 22 ROOT.gSystem.Load("/usr/lib/x86_64-linux-gnu/libz.so") 23 elif ("grolsch" in hostname): 24 ROOT.gSystem.Load("/usr/lib/i386-linux-gnu/libz.so") 25 else: 26 print "Error,Warning,Whatever libz stuff makes me crazy." 27 28 root_make_string = ROOT.gSystem.GetMakeSharedLib() 29 if not "-std=c++0x" in root_make_string: 30 root_make_string = root_make_string.replace('$Opt', '$Opt -std=c++0x -D HAVE_ZLIB') 31 ROOT.gSystem.SetMakeSharedLib(root_make_string) 32 33 ROOT.gROOT.ProcessLine(".L extern_Mars_mcore/izstream.h+O") 34 ROOT.gROOT.ProcessLine(".L extern_Mars_mcore/fits.h+O") 35 ROOT.gROOT.ProcessLine(".L extern_Mars_mcore/zfits.h+O") 36 ROOT.gROOT.ProcessLine(".L extern_Mars_mcore/factfits.h+O") 37 ROOT.gROOT.ProcessLine(".L calfactfits.h+O") 38 39 ROOT.gInterpreter.GenerateDictionary("map<string,fits::Entry>","map;string;extern_Mars_mcore/fits.h") 40 ROOT.gInterpreter.GenerateDictionary("pair<string,fits::Entry>","map;string;extern_Mars_mcore/fits.h") 41 ROOT.gInterpreter.GenerateDictionary("map<string,fits::Table::Column>","map;string;extern_Mars_mcore/fits.h") 42 ROOT.gInterpreter.GenerateDictionary("pair<string,fits::Table::Column>","map;string;extern_Mars_mcore/fits.h") 43 44 #ROOT.gSystem.Load('my_string_h.so') 45 ROOT.gSystem.Load('extern_Mars_mcore/fits_h.so') 46 ROOT.gSystem.Load('extern_Mars_mcore/izstream_h.so') 47 ROOT.gSystem.Load('extern_Mars_mcore/zfits_h.so') 48 ROOT.gSystem.Load('extern_Mars_mcore/factfits_h.so') 49 ROOT.gSystem.Load('calfactfits_h.so') 21 50 from ROOT import * 22 51 … … 520 549 self.stacked_cols = {} 521 550 522 def _make_meta_dict (self):551 def _make_meta_dict__old(self): 523 552 """ This method retrieves meta information about the fits file and 524 553 stores this information in a dict … … 564 593 meta_dict[keys[i]]=(value, comments[i]) 565 594 return meta_dict 595 596 def _make_meta_dict(self): 597 meta_dict = {} 598 for key,entry in self.f.GetKeys(): 599 type = entry.type 600 fitsString = entry.fitsString # the original 80-char line from the FITS header 601 comment = entry.comment 602 value = entry.value 603 604 if type == 'I': 605 value = int(value) 606 elif type == 'F': 607 value = float(value) 608 elif type == 'B': 609 if value == 'T': 610 value = True 611 elif value == 'F': 612 value = False 613 else: 614 raise TypeError("meta-type is 'B', but meta-value is neither 'T' nor 'F'. meta-value:",value) 615 elif type == 'T': 616 value = value 617 else: 618 raise TypeError("unknown meta-type: known meta types are: I,F,B and T. meta-type:",type) 619 meta_dict[key]=(value, comment) 620 return meta_dict 621 566 622 567 623 … … 579 635 unit - string like 'mV' or 'ADC count' 580 636 """ 581 # abbreviation 582 f = self.f 583 584 # intermediate variables for file table-metadata dict generation 585 keys=f.GetPy_ColumnKeys() 586 #offsets=self.GetPy_ColumnOffsets() #not needed on python level... 587 nums=f.GetPy_ColumnNums() 588 sizes=f.GetPy_ColumnSizes() 589 types=f.GetPy_ColumnTypes() 590 units=f.GetPy_ColumnUnits() 591 592 # zip the values 593 values = zip(nums,sizes,types,units) 594 # create the columns dictionary 595 columns = dict(zip(keys ,values)) 637 ## abbreviation 638 #f = self.f 639 # 640 ## intermediate variables for file table-metadata dict generation 641 #keys=f.GetPy_ColumnKeys() 642 ##offsets=self.GetPy_ColumnOffsets() #not needed on python level... 643 #nums=f.GetPy_ColumnNums() 644 #sizes=f.GetPy_ColumnSizes() 645 #types=f.GetPy_ColumnTypes() 646 #units=f.GetPy_ColumnUnits() 647 648 ## zip the values 649 #values = zip(nums,sizes,types,units) 650 ## create the columns dictionary 651 #columns = dict(zip(keys ,values)) 652 653 654 columns = {} 655 for key,col in self.f.GetColumns(): 656 columns[key]=( col.num, col.size, col.type, col.unit) 596 657 return columns 597 658 … … 945 1006 print 'data file:', data_file_name 946 1007 print 'calib file:', calib_file_name 947 # data_file_name = '/home/luster/win7/FACT/data/raw/20120114/20120114_028.fits.gz'948 # calib_file_name = '/home/luster/win7/FACT/data/raw/20120114/20120114_022.drs.fits.gz'949 1008 run = RawData( data_file_name, calib_file_name , return_dict=True) 950 1009 … … 957 1016 """ tests """ 958 1017 import sys 959 if len(sys.argv) == 1: 960 print 'showing test of iterator of RawData class' 961 print 'in order to test the SlowData classe please use:', sys.argv[0], 'fits-file-name' 962 _test_iter(10) 963 964 965 else: 966 print 'showing test of SlowData class' 967 print 'in case you wanted to test the RawData class, please give no commandline arguments' 968 file = SlowData(sys.argv[1]) 969 _test_SlowData(sys.argv[1]) 1018 1019 f = fits(sys.argv[1]) 1020 test_m1 = ROOT.std.map(str,ROOT.fits.Entry)() 1021 test_m2 = ROOT.std.map(str,ROOT.fits.Table.Column)() 1022 print "len(test_m1)", len(test_m1) 1023 print "len(test_m2)", len(test_m2) 1024 1025 for k1 in f.GetKeys(): 1026 pass 1027 print k1 1028 for k2 in f.GetColumns(): 1029 pass 1030 print k2 1031 1032 sd = SlowData(sys.argv[1])
Note:
See TracChangeset
for help on using the changeset viewer.