Ignore:
Timestamp:
04/29/14 16:41:03 (11 years ago)
Author:
dneise
Message:
Removed the dependency of SlowData class from the special Python Accessors in fits.h
So now we can use the C++ header files from Mars/mcore. 
makelibs.C is not needed anymore. 

In order to make the so-files just call pyfact.py 
For testing one can do:
   python -i pyfact.py <filename>
After a lot of compiler warnings one should get:

len(test_m1) 0
len(test_m2) 0
<ROOT.pair<string,fits::Entry> object at 0x...>
<ROOT.pair<string,fits::Table::Column> object at 0x...>

Well ... for now.
Location:
fact/tools/pyscripts/pyfact
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • fact/tools/pyscripts/pyfact/calfactfits.h

    r17691 r17730  
    5353#endif
    5454
    55 #include "factfits.h"
     55#include "extern_Mars_mcore/factfits.h"
    5656
    5757class CalFactFits
  • fact/tools/pyscripts/pyfact/pyfact.py

    r17690 r17730  
    1010
    1111# get the ROOT stuff + my shared libs
    12 from ROOT import gSystem
     12import ROOT
    1313# factfits_h.so is made from factfits.h and is used to access the data
    1414# make sure the location of factfits_h.so is in LD_LIBRARY_PATH.
    1515# 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')
     16hostname = ROOT.gSystem.HostName()
     17if 'isdc' in hostname:
     18    ROOT.gSystem.Load("/usr/lib64/libz.so")
     19elif ('neiseLenovo' in hostname or 'factcontrol' in hostname):
     20    ROOT.gSystem.Load("/usr/lib/libz.so")
     21elif ("max-K50AB" in hostname or "watz" in hostname):
     22    ROOT.gSystem.Load("/usr/lib/x86_64-linux-gnu/libz.so")
     23elif ("grolsch" in hostname):
     24    ROOT.gSystem.Load("/usr/lib/i386-linux-gnu/libz.so")
     25else:
     26    print "Error,Warning,Whatever libz stuff makes me crazy."
     27   
     28root_make_string = ROOT.gSystem.GetMakeSharedLib()
     29if not "-std=c++0x" in root_make_string:
     30    root_make_string = root_make_string.replace('$Opt', '$Opt -std=c++0x -D HAVE_ZLIB')
     31ROOT.gSystem.SetMakeSharedLib(root_make_string)
     32
     33ROOT.gROOT.ProcessLine(".L extern_Mars_mcore/izstream.h+O")
     34ROOT.gROOT.ProcessLine(".L extern_Mars_mcore/fits.h+O")
     35ROOT.gROOT.ProcessLine(".L extern_Mars_mcore/zfits.h+O")
     36ROOT.gROOT.ProcessLine(".L extern_Mars_mcore/factfits.h+O")
     37ROOT.gROOT.ProcessLine(".L calfactfits.h+O")
     38
     39ROOT.gInterpreter.GenerateDictionary("map<string,fits::Entry>","map;string;extern_Mars_mcore/fits.h")
     40ROOT.gInterpreter.GenerateDictionary("pair<string,fits::Entry>","map;string;extern_Mars_mcore/fits.h")
     41ROOT.gInterpreter.GenerateDictionary("map<string,fits::Table::Column>","map;string;extern_Mars_mcore/fits.h")
     42ROOT.gInterpreter.GenerateDictionary("pair<string,fits::Table::Column>","map;string;extern_Mars_mcore/fits.h")
     43
     44#ROOT.gSystem.Load('my_string_h.so')
     45ROOT.gSystem.Load('extern_Mars_mcore/fits_h.so')
     46ROOT.gSystem.Load('extern_Mars_mcore/izstream_h.so')
     47ROOT.gSystem.Load('extern_Mars_mcore/zfits_h.so')
     48ROOT.gSystem.Load('extern_Mars_mcore/factfits_h.so')
     49ROOT.gSystem.Load('calfactfits_h.so')
    2150from ROOT import *
    2251
     
    520549        self.stacked_cols = {}
    521550
    522     def _make_meta_dict(self):
     551    def _make_meta_dict__old(self):
    523552        """ This method retrieves meta information about the fits file and
    524553            stores this information in a dict
     
    564593            meta_dict[keys[i]]=(value, comments[i])
    565594        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       
    566622
    567623
     
    579635                    unit - string like 'mV' or 'ADC count'
    580636        """
    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)
    596657        return columns
    597658
     
    9451006    print 'data file:', data_file_name
    9461007    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'
    9491008    run = RawData( data_file_name, calib_file_name , return_dict=True)
    9501009
     
    9571016    """ tests  """
    9581017    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.