psana/src/__init__.py

Go to the documentation of this file.
00001 #--------------------------------------------------------------------------
00002 # File and Version Information:
00003 #  $Id: __init__.py 12589 2016-09-08 20:16:55Z cpo@SLAC.STANFORD.EDU $
00004 #
00005 # Description:
00006 #  Module psana
00007 #
00008 #------------------------------------------------------------------------
00009 
00010 """High-level wrapper module for psana.
00011 
00012 Typical usage::
00013 
00014     from psana import *
00015     
00016     setConfigFile('config-file.cfg')   # optional, default is to use psana.cfg if present
00017     setOption("psana.modules", "EventKeys")   # can set/change options from script
00018 
00019     # define "data source" specifying experiment and run number
00020     datasrc = DataSource("exp=cxi63112:run=111")
00021 
00022     # specify source device for data   
00023     cam_src = Source("CxiDg4.0:Tm6740.0")
00024 
00025     # loop over all events in a data source
00026     for evt in datasrc.events():
00027         frame = evt.get(Camera.FrameV1, cam_src)
00028         image = frame.data16()
00029 
00030 This software was developed for the LCLS project.  If you use all or 
00031 part of it, please give an appropriate acknowledgment.
00032 
00033 @version $Id: __init__.py 12589 2016-09-08 20:16:55Z cpo@SLAC.STANFORD.EDU $
00034 
00035 @author Andy Salnikov
00036 """
00037 
00038 # We believe there is some non-ideal dependency behavior in this package.
00039 # the psana __init__.py depends on psana_python by importing _psana.
00040 # However _psana wraps the C++ code in the psana package, which
00041 # is circular.  Perhaps ideally the C++ code would be moved to a
00042 # different package, but this would break C++ users who would have
00043 # to change their include statements.  We certainly want to keep
00044 # __init__.py in psana so "import psana" works.
00045 # - TJ Lane and Christopher O'Grady
00046 
00047 import sys
00048 
00049 # we believe this must be the FIRST import of _psana, so it's important
00050 # that other software that imports _psana (like DataSource) happen
00051 # after this.  one symptom we see if the order is wrong is that some
00052 # of the boost converters stop working, but only on RHEL5.
00053 
00054 if sys.platform.startswith('linux'):
00055     # on Linux with g++ one needs RTLD_GLOBAL for dlopen
00056     # which Python does not set by default
00057     import DLFCN
00058     flags = sys.getdlopenflags()
00059     sys.setdlopenflags( flags | DLFCN.RTLD_GLOBAL )    
00060     import _psana
00061     sys.setdlopenflags( flags )    
00062     del flags
00063     del DLFCN
00064 else:
00065     import _psana
00066 del sys
00067 
00068 from datasource import DataSource, setOption, setOptions, setConfigFile
00069 from mpi_datasource import MPIDataSource
00070 from det_interface import Detector, DetNames
00071 
00072 #
00073 # import everything from _psana
00074 #
00075 from _psana import *
00076 
00077 #
00078 # Build the psana namespace from external packages
00079 #
00080 from XtcInput.PyLiveAvail import LiveAvail as LiveAvail

Generated on 19 Dec 2016 for PSANAclasses by  doxygen 1.4.7