from XSDataFullFieldXAS     import XSDataInputFullFieldXAS, XSDataResultFullFieldXAS, \
                                XSDataInputAlignStack, XSDataHDF5Attributes
from XSDataNormalizeImage   import XSDataInputNormalize
from XSDataCommon           import XSDataString, XSDataInteger, \
                                XSDataDictionary, XSDataKeyValuePair, XSDataImageExt


################################################################################
# AutoBuilder for Numpy, PIL and Fabio
################################################################################
architecture = EDUtilsPlatform.architecture
fabioPath = os.path.join(EDUtilsPath.EDNA_HOME, "libraries", "FabIO-0.0.7", architecture)
imagingPath = os.path.join(EDUtilsPath.EDNA_HOME, "libraries", "20091115-PIL-1.1.7", architecture)
numpyPath = os.path.join(EDUtilsPath.EDNA_HOME, "libraries", "20090405-Numpy-1.3", architecture)
h5pyPath = os.path.join(EDUtilsPath.EDNA_HOME, "libraries", "H5Py-1.3.0", architecture)
Image = EDFactoryPluginStatic.preImport("Image", imagingPath)
numpy = EDFactoryPluginStatic.preImport("numpy", numpyPath, _strMethodVersion="version.version")
fabio = EDFactoryPluginStatic.preImport("fabio", fabioPath)
h5py = EDFactoryPluginStatic.preImport("h5py", h5pyPath)


class EDPluginControlFullFieldXASv1_0(EDPluginControl):
    """
    Plugin to control  Full Field XRay Absorption Spectroscopy Experiment, ID21 ESRF
    """
    _semaphore = Semaphore()
    TITLE = "FullField XANES mapping"
    start_time = time.time()
    DSenergy = "energy"
    DSstack = "data"
    energyAttr = {"unit":"keV",
Exemplo n.º 2
0
    sys.path.append(kernel_src)

from EDVerbose                  import EDVerbose
from EDUtilsPlatform            import EDUtilsPlatform
from EDUtilsLibraryInstaller    import EDUtilsLibraryInstaller, installLibrary
from EDFactoryPluginStatic      import EDFactoryPluginStatic

moduleName = "numpy"
modulePath = os.path.join(os.environ["EDNA_HOME"], "libraries", "NumPy-1.5.1", EDUtilsPlatform.architecture)
moduleVersion = "1.4.0"

################################################################################
# Import the right version of numpy 
################################################################################

oModule = EDFactoryPluginStatic.preImport(moduleName, _strMethodVersion="version.version")
if not oModule:
    oModule = EDFactoryPluginStatic.preImport(moduleName, modulePath, _strMethodVersion="version.version")
    if oModule is None:
        installLibrary(modulePath)
        oModule = EDFactoryPluginStatic.preImport(moduleName, modulePath, _strMethodVersion="version.version")
try:
    version = oModule.version.version
except AttributeError:
    version = "0.0.0"

if version.split(".") < moduleVersion.split("."):
    EDVerbose.screen("Wrong %s library:  %s " % (moduleName, version))
    EDFactoryPluginStatic.unImport(moduleName)
    oModule = EDFactoryPluginStatic.preImport(moduleName, modulePath, moduleVersion, _strMethodVersion="version.version")
Exemplo n.º 3
0
sys.path.append(os.path.join(os.environ["EDNA_HOME"], "kernel", "src"))
from EDVerbose import EDVerbose

if "EDNA_SITE" not in os.environ:
    os.environ["EDNA_SITE"] = "ESRF"
    EDVerbose.WARNING("EDNA_SITE not defined: Resetting to 'ESRF'")

from EDParallelExecute import EDParallelExecute
from EDUtilsPlatform import EDUtilsPlatform
from EDFactoryPluginStatic import EDFactoryPluginStatic
from EDJob import EDJob
from EDShare import EDShare

numpyPath = os.path.join(os.environ["EDNA_HOME"], "libraries", "20090405-Numpy-1.3", EDUtilsPlatform.architecture)
numpy = EDFactoryPluginStatic.preImport("numpy", numpyPath, _strMethodVersion="version.version")
fabioPath = os.path.join(os.environ["EDNA_HOME"], "libraries", "FabIO-0.0.7", EDUtilsPlatform.architecture)
fabio = EDFactoryPluginStatic.preImport("fabio", fabioPath, _strMethodVersion="version")
h5pyPath = os.path.join(os.environ["EDNA_HOME"], "libraries", "H5Py-1.3.0", EDUtilsPlatform.architecture)
h5py = EDFactoryPluginStatic.preImport(
    "h5py", h5pyPath, _strMethodVersion="version.api_version", _strForceVersion="1.8"
)
from EDShare import EDShare

EDFactoryPluginStatic.loadModule("EDPluginHDF5StackImagesv10")
EDFactoryPluginStatic.loadModule("EDPluginControlAlignStackv1_0")
EDFactoryPluginStatic.loadModule("EDPluginAccumulatorv1_0")
from EDPluginAccumulatorv1_0 import EDPluginAccumulatorv1_0
from EDPluginControlAlignStackv1_0 import EDPluginControlAlignStackv1_0
from EDPluginControlFullFieldXASv1_0 import EDPluginControlFullFieldXASv1_0
from EDPluginHDF5StackImagesv10 import EDPluginHDF5StackImagesv10
Exemplo n.º 4
0
from EDUtilsPath                import EDUtilsPath
from XSDataCommon               import XSDataString, XSDataImage, \
                         XSDataDouble, XSDataLength, XSDataWavelength, \
                         XSDataTime, XSDataInteger, XSDataTime
from XSDataBioSaxsv1_0          import XSDataInputBioSaxsMetadatav1_0, \
                                     XSDataResultBioSaxsMetadatav1_0, \
                                     XSDataBioSaxsExperimentSetup, \
                                     XSDataBioSaxsSample
from EDUtilsPlatform            import EDUtilsPlatform

architecture = EDUtilsPlatform.architecture
fabioPath = os.path.join(EDUtilsPath.EDNA_HOME, "libraries", "FabIO-0.0.7", architecture)
imagingPath = os.path.join(EDUtilsPath.EDNA_HOME, "libraries", "20091115-PIL-1.1.7", architecture)
numpyPath = os.path.join(EDUtilsPath.EDNA_HOME, "libraries", "20090405-Numpy-1.3", architecture)

numpy = EDFactoryPluginStatic.preImport("numpy", numpyPath)
Image = EDFactoryPluginStatic.preImport("Image", imagingPath)
fabio = EDFactoryPluginStatic.preImport("fabio", fabioPath)

if fabio is None:
    EDVerbose.ERROR("Unable to import Fabio: Please re-run the tests EDTestSuiteBioSaxs")


class EDPluginBioSaxsMetadatav1_1(EDPluginExec):
    """
    Plugin for reading, updating and writing Metadata. 
    """


    def __init__(self):
        """
Exemplo n.º 5
0
from EDVerbose import EDVerbose
from EDPluginControl import EDPluginControl
from EDUtilsBioSaxs import EDUtilsBioSaxs
from EDUtilsPath import EDUtilsPath
from EDFactoryPluginStatic import EDFactoryPluginStatic
from XSDataCommon       import XSDataString, XSDataImage, XSDataDouble, XSDataLength, \
    XSDataWavelength
from XSDataBioSaxsv1_0 import XSDataInputBioSaxsMetadatav1_0, XSDataResultBioSaxsMetadatav1_0
EDFactoryPluginStatic.loadModule("XSDataSaxsv1_0")
from XSDataSaxsv1_0 import XSDataInputSaxsAddMetadatav1_0
from EDUtilsPlatform import EDUtilsPlatform

architecture = EDUtilsPlatform.architecture
edfFilePath = os.path.join(EDUtilsPath.EDNA_HOME, "libraries", "EdfFile",
                           architecture)
EdfFileMod = EDFactoryPluginStatic.preImport("EdfFile", edfFilePath)
if EdfFileMod is None:
    EDVerbose.ERROR(
        "Unable to import EdfFile: Please re-run the tests EDTestSuiteBioSaxs")
else:
    from EdfFile import EdfFile


class EDPluginBioSaxsMetadatav1_0(EDPluginControl):
    """
    Plugin for reading, updating and writing Metadata. 
    """
    def __init__(self):
        """
        """
        EDPluginControl.__init__(self)
Exemplo n.º 6
0
    sys.path.append(kernel_src)

from EDVerbose import EDVerbose
from EDUtilsPlatform import EDUtilsPlatform
from EDUtilsLibraryInstaller import EDUtilsLibraryInstaller, installLibrary
from EDFactoryPluginStatic import EDFactoryPluginStatic

################################################################################
# Import the right version of Scipy
################################################################################
moduleName = "scipy"
modulePath = os.path.join(os.environ["EDNA_HOME"], "libraries",
                          "20090711-SciPy-0.7.1", EDUtilsPlatform.architecture)
moduleVersion = "0.7.0"

oModule = EDFactoryPluginStatic.preImport(moduleName,
                                          _strMethodVersion="version.version")
if not oModule:
    oModule = EDFactoryPluginStatic.preImport(
        moduleName, modulePath, _strMethodVersion="version.version")
    if oModule is None:
        installLibrary(modulePath)
        oModule = EDFactoryPluginStatic.preImport(
            moduleName, modulePath, _strMethodVersion="version.version")
try:
    version = oModule.version.version
except AttributeError:
    version = "0.0.0"

if version.split(".") < moduleVersion.split("."):
    EDVerbose.screen("Wrong %s library:  %s " % (moduleName, version))
    EDFactoryPluginStatic.unImport(moduleName)
Exemplo n.º 7
0
# BIG FAT WARNING
# HDF5 does not like unicode string and crashes with cryptic error messages
###############################################################################

import os, threading, time, locale
from EDVerbose                  import EDVerbose
from EDPluginHDF5               import EDPluginHDF5
from EDAssert                   import EDAssert
from EDUtilsPlatform            import EDUtilsPlatform
from XSDataHDF5v1_0             import XSDataInputHDF5MapSpectra, XSDataResultHDF5MapSpectra
from XSDataCommon               import XSDataFile, XSDataString
from EDConfiguration            import EDConfiguration
from EDUtilsArray               import EDUtilsArray
from EDFactoryPluginStatic      import EDFactoryPluginStatic
from EDPluginHDF5               import numpyPath, h5pyPath, fabioPath
numpy = EDFactoryPluginStatic.preImport("numpy", numpyPath, _strMethodVersion="__version__")
h5py = EDFactoryPluginStatic.preImport("h5py", h5pyPath, _strMethodVersion="version.version")
fabio = EDFactoryPluginStatic.preImport("fabio", fabioPath, _strMethodVersion="version")



class EDPluginHDF5MapOfSpectrav10(EDPluginHDF5):
    """
    This plugin is made for putting together 1D spectra comming from a 2D scan  in a 3D cube, 
    read using various libraries ... , and put them together in an NeXus/HDF5 file
    """
    HDF5_DATASET_MAPSPECTRA_ATTRIBUTES = {"interpretation": "spectrum", # "spectrum", "scalar", "image" or "vertex"
                                               "signal":"1",
                                               }

    def __init__(self):
from XSDataShiftv1_0 import XSDataResultMeasureOffset
from EDAssert import EDAssert
from EDFactoryPluginStatic import EDFactoryPluginStatic
from EDUtilsPlatform import EDUtilsPlatform


################################################################################
# AutoBuilder for Numpy, PIL and Fabio
################################################################################
architecture = EDUtilsPlatform.architecture
fabioPath = os.path.join(os.environ["EDNA_HOME"], "edna-libraries", "FabIO-0.0.7", architecture)
imagingPath = os.path.join(os.environ["EDNA_HOME"], "edna-libraries", "20091115-PIL-1.1.7", architecture)
numpyPath = os.path.join(os.environ["EDNA_HOME"], "edna-libraries", "20090405-Numpy-1.3", architecture)
scipyPath = os.path.join(os.environ["EDNA_HOME"], "edna-libraries", "20090711-SciPy-0.7.1", architecture)
fftw3Path = os.path.join(os.environ["EDNA_HOME"], "edna-libraries", "pyfftw3-0.2.1", architecture)
numpy = EDFactoryPluginStatic.preImport("numpy", numpyPath)
EDFactoryPluginStatic.preImport("scipy.ndimage", scipyPath)
EDFactoryPluginStatic.preImport("scipy.fftpack", scipyPath)
EDFactoryPluginStatic.preImport("scipy.interpolate", scipyPath)
EDFactoryPluginStatic.preImport("scipy.signal", scipyPath)
Image = EDFactoryPluginStatic.preImport("Image", imagingPath)
fabio = EDFactoryPluginStatic.preImport("fabio", fabioPath)
fftw3 = EDFactoryPluginStatic.preImport("fftw3", fftw3Path)

try:
    import scipy.ndimage, scipy.fftpack, scipy.interpolate  # , scipy.signal
    from scipy.ndimage import sobel
except:
    EDVerbose.ERROR(
        "Error in loading numpy, Scipy, PIL or Fabio,\n\
    Please re-run the test suite for EDTestSuitePluginExecShift \
Exemplo n.º 9
0
except ImportError:
    print("No socket opened for debuging -> please install rfoo")

sys.path.append(os.path.join(os.environ["EDNA_HOME"], "kernel", "src"))
from EDVerbose              import EDVerbose
if "EDNA_SITE" not in  os.environ:
    os.environ["EDNA_SITE"] = "ESRF"
    EDVerbose.WARNING("EDNA_SITE not defined: Resetting to 'ESRF'")

from EDParallelExecute      import EDParallelExecute
from EDUtilsPlatform        import EDUtilsPlatform
from EDFactoryPluginStatic  import EDFactoryPluginStatic
from EDJob                  import EDJob
from EDShare                import EDShare
numpyPath = os.path.join(os.environ["EDNA_HOME"], "libraries", "20090405-Numpy-1.3", EDUtilsPlatform.architecture)
numpy = EDFactoryPluginStatic.preImport("numpy", numpyPath, _strMethodVersion="version.version")
fabioPath = os.path.join(os.environ["EDNA_HOME"], "libraries", "FabIO-0.0.7", EDUtilsPlatform.architecture)
fabio = EDFactoryPluginStatic.preImport("fabio", fabioPath, _strMethodVersion="version")
h5pyPath = os.path.join(os.environ["EDNA_HOME"], "libraries", "H5Py-1.3.0", EDUtilsPlatform.architecture)
h5py = EDFactoryPluginStatic.preImport("h5py", h5pyPath, _strMethodVersion="version.api_version", _strForceVersion="1.8")
from EDShare                import EDShare
EDFactoryPluginStatic.loadModule('EDPluginHDF5StackImagesv10')
EDFactoryPluginStatic.loadModule('EDPluginControlAlignStackv1_0')
EDFactoryPluginStatic.loadModule("EDPluginAccumulatorv1_0")
from EDPluginAccumulatorv1_0            import EDPluginAccumulatorv1_0
from EDPluginControlAlignStackv1_0      import EDPluginControlAlignStackv1_0
from EDPluginControlFullFieldXASv1_0    import EDPluginControlFullFieldXASv1_0
from EDPluginHDF5StackImagesv10         import EDPluginHDF5StackImagesv10
from XSDataFullFieldXAS                 import MeasureOffset, XSDataInputAlignStack, XSDataInputFullFieldXAS
from XSDataCommon                       import XSDataTime, XSDataFile, XSDataImageExt, XSDataString, XSDataInteger, XSDataBoolean, XSDataDouble
Exemplo n.º 10
0
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
__author__ = "Jerome Kieffer"
__license__ = "GPLv3+"
__copyright__ = "2011, ESRF, Grenoble"
__date__ = "2011/05/09"
import os
from EDPluginControl import EDPluginControl
from XSDataShiftv1_0 import XSDataInputStitchImage, XSDataInteger, \
    XSDataResultStitchImage, XSDataFile, XSDataString, XSDataBoolean, XSDataInputMeasureOffset, \
    XSDataInputStitchOffsetedImage, OffsetedImage, XSDataDouble, XSDataImageExt, XSDataArray

from EDFactoryPluginStatic  import EDFactoryPluginStatic
from EDUtilsPlatform        import EDUtilsPlatform
numpyPath = os.path.join(os.environ["EDNA_HOME"], "libraries", "20090405-Numpy-1.3", EDUtilsPlatform.architecture)
numpy = EDFactoryPluginStatic.preImport("numpy", numpyPath)

class EDPluginControlStitchImagev1_0(EDPluginControl):
    """
    Control plugin doing automatic image alignment and stitching.
    """


    def __init__(self):
        """
        """
        EDPluginControl.__init__(self)
        self.setXSDataInputClass(XSDataInputStitchImage)
        self.__strControlledPluginMeasure = "EDPluginExecMeasureOffsetv1_0"
        self.__strControlledPluginStitch = "EDPluginExecStitchOffsetedImagev1_0"
        self.lInputFiles = []
Exemplo n.º 11
0
try:
    import numpy
except ImportError:
    numpy = None

TEMPDIR = tempfile.gettempdir()

BACKEND = "numpy"  # None

if not BACKEND and os.name in ["posix", "nt"]:
    h5pyPath = os.path.join(EDUtilsPath.EDNA_HOME, "libraries", "H5Py-1.3.0",
                            EDUtilsPlatform.architecture)
    h5py = EDFactoryPluginStatic.preImport(
        "h5py",
        _strPath=h5pyPath,
        _strForceVersion="1.8",
        _strMethodVersion="version.api_version")
    if h5py is not None:
        BACKEND = "hdf5"
if numpy and not BACKEND:
    BACKEND = "numpy"
if not BACKEND:
    BACKEND = "dict"


class DirStorage():
    """
    Simple class that behaves like like an HDF5 file but as a directory with numpy files.
    """
    def __init__(self, filename):
Exemplo n.º 12
0
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"

import os, sys
from EDVerbose                           import EDVerbose
from EDTestCase                          import EDTestCase
from EDAssert                            import EDAssert
from EDUtilsArray                        import EDUtilsArray
from XSDataCommon                        import XSDataArray
from EDUtilsLibraryInstaller             import EDUtilsLibraryInstaller
from EDFactoryPluginStatic               import EDFactoryPluginStatic
from EDUtilsPlatform                     import EDUtilsPlatform

#EDVerbose.screen("Check Install Numpy")
EDFactoryPluginStatic.loadModule("EDInstallNumpyv1_3")
numpyPath = os.path.join(os.environ["EDNA_HOME"], "libraries", "20090405-Numpy-1.3", EDUtilsPlatform.architecture)
numpy = EDFactoryPluginStatic.preImport("numpy", numpyPath, _strMethodVersion="__version__")
if numpy is None:
    EDVerbose.WARNING("Numpy is not directly available, I will run all tests without it")

#EDVerbose.screen("Check Install PIL")
EDFactoryPluginStatic.loadModule("EDInstallPILv1_1_7")
#ImagePath = os.path.join(os.environ["EDNA_HOME"], "libraries", "20091115-PIL-1.1.7", EDUtilsPlatform.architecture)
#Image = EDFactoryPluginStatic.preImport("Image", ImagePath, _strMethodVersion="VERSION")
#if Image is None:
#    EDVerbose.WARNING("Image is not directly available, I will run all tests without it")


#EDVerbose.screen("Check Install Fabio")
EDFactoryPluginStatic.loadModule("EDInstallFabio_v0_0_7")
#fabioPath = os.path.join(os.environ["EDNA_HOME"], "libraries", "FabIO-0.0.7", EDUtilsPlatform.architecture)
#fabio = EDFactoryPluginStatic.preImport("fabio", fabioPath, _strMethodVersion="version")
Exemplo n.º 13
0
#
__author__ = "Jerome Kieffer"
__license__ = "GPLv3+"
__copyright__ = "2011, ESRF, Grenoble"
__date__ = "2011/05/09"
import os
from EDPluginControl import EDPluginControl
from XSDataShiftv1_0 import XSDataInputStitchImage, XSDataInteger, \
    XSDataResultStitchImage, XSDataFile, XSDataString, XSDataBoolean, XSDataInputMeasureOffset, \
    XSDataInputStitchOffsetedImage, OffsetedImage, XSDataDouble, XSDataImageExt, XSDataArray

from EDFactoryPluginStatic import EDFactoryPluginStatic
from EDUtilsPlatform import EDUtilsPlatform
numpyPath = os.path.join(os.environ["EDNA_HOME"], "libraries",
                         "20090405-Numpy-1.3", EDUtilsPlatform.architecture)
numpy = EDFactoryPluginStatic.preImport("numpy", numpyPath)


class EDPluginControlStitchImagev1_0(EDPluginControl):
    """
    Control plugin doing automatic image alignment and stitching.
    """
    def __init__(self):
        """
        """
        EDPluginControl.__init__(self)
        self.setXSDataInputClass(XSDataInputStitchImage)
        self.__strControlledPluginMeasure = "EDPluginExecMeasureOffsetv1_0"
        self.__strControlledPluginStitch = "EDPluginExecStitchOffsetedImagev1_0"
        self.lInputFiles = []
        self.xDummy = None
Exemplo n.º 14
0
from XSDataCommon           import XSPluginItem, XSDataDouble
from XSDataShiftv1_0        import XSDataInputMeasureOffset
from XSDataShiftv1_0        import XSDataResultMeasureOffset
from EDAssert               import EDAssert
from EDFactoryPluginStatic  import EDFactoryPluginStatic
from EDUtilsPlatform        import EDUtilsPlatform
from EDUtilsPath            import EDUtilsPath
from EDThreading import Semaphore
################################################################################
# AutoBuilder for Numpy, PIL and Fabio
################################################################################
architecture = EDUtilsPlatform.architecture
fabioPath = os.path.join(EDUtilsPath.EDNA_HOME, "libraries", "FabIO-0.0.7", architecture)
imagingPath = os.path.join(EDUtilsPath.EDNA_HOME, "libraries", "20091115-PIL-1.1.7", architecture)
numpyPath = os.path.join(EDUtilsPath.EDNA_HOME, "libraries", "20090405-Numpy-1.3", architecture)
numpy = EDFactoryPluginStatic.preImport("numpy", numpyPath)
Image = EDFactoryPluginStatic.preImport("Image", imagingPath)
fabio = EDFactoryPluginStatic.preImport("fabio", fabioPath)
feature = EDFactoryPluginStatic.preImport("feature")
sift_pyocl = EDFactoryPluginStatic.preImport("sift_pyocl")
if not sift_pyocl:
    EDVerbose.WARNING("Try to load sift_pyocl from sift: You should update your sift installation")
    sift_pyocl = EDFactoryPluginStatic.preImport("sift")
#
if (feature or sift_pyocl) is None:
    strErr = "Error in loading feature (https://github.com/kif/imageAlignment) AND sift_pyocl (https://github.com/kif/sift_pyocl)"
    EDVerbose.ERROR(strErr)
    raise ImportError(strErr)
import scipy.interpolate

srcDir = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "src")
Exemplo n.º 15
0
from EDAssert import EDAssert
from EDFactoryPluginStatic import EDFactoryPluginStatic
from EDUtilsPlatform import EDUtilsPlatform
from EDUtilsPath import EDUtilsPath
from EDThreading import Semaphore
################################################################################
# AutoBuilder for Numpy, PIL and Fabio
################################################################################
architecture = EDUtilsPlatform.architecture
fabioPath = os.path.join(EDUtilsPath.EDNA_HOME, "libraries", "FabIO-0.0.7",
                         architecture)
imagingPath = os.path.join(EDUtilsPath.EDNA_HOME, "libraries",
                           "20091115-PIL-1.1.7", architecture)
numpyPath = os.path.join(EDUtilsPath.EDNA_HOME, "libraries",
                         "20090405-Numpy-1.3", architecture)
numpy = EDFactoryPluginStatic.preImport("numpy", numpyPath)
Image = EDFactoryPluginStatic.preImport("Image", imagingPath)
fabio = EDFactoryPluginStatic.preImport("fabio", fabioPath)
feature = EDFactoryPluginStatic.preImport("feature")
sift_pyocl = EDFactoryPluginStatic.preImport("sift")
#
if (feature or sift_pyocl) is None:
    strErr = "Error in loading feature (https://github.com/kif/imageAlignment) AND sift_pyocl (https://github.com/kif/sift_pyocl)"
    EDVerbose.ERROR(strErr)
    raise ImportError(strErr)


class EDPluginExecAlignFramev1_0(EDPluginExec):
    """
    An exec plugin that taked an images and a reference and alines the frame on the reference based on the SIFT algorithm.
    
Exemplo n.º 16
0
    sys.path.append(kernel_src)

from EDVerbose import EDVerbose
from EDUtilsPlatform import EDUtilsPlatform
from EDUtilsLibraryInstaller import EDUtilsLibraryInstaller, installLibrary
from EDFactoryPluginStatic import EDFactoryPluginStatic

moduleName = "fabio"
modulePath = os.path.join(os.environ["EDNA_HOME"], "libraries", "FabIO-0.0.7",
                          EDUtilsPlatform.architecture)
moduleVersion = "0.0.7"
################################################################################
# Import the good version of FabIO ...
################################################################################
if os.name == "posix":
    oModule = EDFactoryPluginStatic.preImport(moduleName)
    if not oModule:
        oModule = EDFactoryPluginStatic.preImport(moduleName, modulePath)
        if oModule is None:
            installLibrary(modulePath)
            oModule = EDFactoryPluginStatic.preImport(moduleName, modulePath)
    try:
        version = oModule.version
    except AttributeError:
        version = "0.0.0"

    if version.split(".") < moduleVersion.split("."):
        EDVerbose.screen("Wrong %s library:  %s " % (moduleName, version))
        EDFactoryPluginStatic.unImport(moduleName)
        oModule = EDFactoryPluginStatic.preImport(moduleName, modulePath,
                                                  moduleVersion)
Exemplo n.º 17
0
if kernel_src not in sys.path:
    sys.path.append(kernel_src)

from EDVerbose                  import EDVerbose
from EDUtilsPlatform            import EDUtilsPlatform
from EDUtilsLibraryInstaller    import EDUtilsLibraryInstaller, installLibrary
from EDFactoryPluginStatic      import EDFactoryPluginStatic

moduleName = "fabio"
modulePath = os.path.join(os.environ["EDNA_HOME"], "libraries", "FabIO-0.0.6", EDUtilsPlatform.architecture)
moduleVersion = "0.0.6"
################################################################################
# Import the good version of FabIO ... 
################################################################################

oModule = EDFactoryPluginStatic.preImport(moduleName)
if not oModule:
    oModule = EDFactoryPluginStatic.preImport(moduleName, modulePath)
    if oModule is None:
        installLibrary(modulePath)
        oModule = EDFactoryPluginStatic.preImport(moduleName, modulePath)
try:
    version = oModule.version
except AttributeError:
    version = "0.0.0"

if version.split(".") < moduleVersion.split("."):
    EDVerbose.screen("Wrong %s library:  %s " % (moduleName, version))
    EDFactoryPluginStatic.unImport(moduleName)
    oModule = EDFactoryPluginStatic.preImport(moduleName, modulePath, moduleVersion)
Exemplo n.º 18
0
__license__ = "LGPLv3+"
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
__date__ = "20120228"

import os, tempfile
from EDLogging              import EDLogging
from EDFactoryPluginStatic  import EDFactoryPluginStatic
from EDUtilsPlatform        import EDUtilsPlatform
from EDSession              import EDSession
from EDUtilsPath            import EDUtilsPath

TEMPDIR = tempfile.gettempdir()

if os.name in ["posix", "nt"]:
    h5pyPath = os.path.join(EDUtilsPath.EDNA_HOME, "libraries", "H5Py-1.3.0", EDUtilsPlatform.architecture)
    h5py = EDFactoryPluginStatic.preImport("h5py", _strPath=h5pyPath, _strForceVersion="1.8", _strMethodVersion="version.api_version")
#    h5py = None
    if h5py is None:
        BACKEND = "dict"
    else:
        BACKEND = "hdf5"
else:
    BACKEND = "dict"
if BACKEND == "dict":
    import pickle


class EDShare(EDLogging, EDSession):
    """
    This class implements methods to share (large) arrays between plugins.
    
Exemplo n.º 19
0
import os, shutil
from EDVerbose          import EDVerbose
from EDPluginControl    import EDPluginControl
from EDUtilsBioSaxs     import EDUtilsBioSaxs
from EDUtilsPath        import EDUtilsPath
from EDFactoryPluginStatic      import EDFactoryPluginStatic
from XSDataCommon       import XSDataString, XSDataImage, XSDataDouble, XSDataLength, \
    XSDataWavelength
from XSDataBioSaxsv1_0  import XSDataInputBioSaxsMetadatav1_0, XSDataResultBioSaxsMetadatav1_0
EDFactoryPluginStatic.loadModule("XSDataSaxsv1_0")
from XSDataSaxsv1_0             import XSDataInputSaxsAddMetadatav1_0
from EDUtilsPlatform   import EDUtilsPlatform

architecture = EDUtilsPlatform.architecture
edfFilePath = os.path.join(EDUtilsPath.EDNA_HOME, "libraries", "EdfFile", architecture)
EdfFileMod = EDFactoryPluginStatic.preImport("EdfFile", edfFilePath)
if EdfFileMod is None:
    EDVerbose.ERROR("Unable to import EdfFile: Please re-run the tests EDTestSuiteBioSaxs")
else:
    from EdfFile import EdfFile


class EDPluginBioSaxsMetadatav1_0(EDPluginControl):
    """
    Plugin for reading, updating and writing Metadata. 
    """


    def __init__(self):
        """
        """
Exemplo n.º 20
0
from XSDataCommon import XSDataImage, XSDataString
from XSDataImageFilter import XSDataInputMedianFilter
from XSDataImageFilter import XSDataResultMedianFilter
from EDFactoryPluginStatic import EDFactoryPluginStatic
from EDUtilsPlatform import EDUtilsPlatform


################################################################################
# AutoBuilder for Numpy, PIL and Fabio
################################################################################
architecture = EDUtilsPlatform.architecture
fabioPath = os.path.join(os.environ["EDNA_HOME"], "libraries", "FabIO-0.0.7", architecture)
imagingPath = os.path.join(os.environ["EDNA_HOME"], "libraries", "20091115-PIL-1.1.7", architecture)
numpyPath = os.path.join(os.environ["EDNA_HOME"], "libraries", "20090405-Numpy-1.3", architecture)
scipyPath = os.path.join(os.environ["EDNA_HOME"], "libraries", "20090711-SciPy-0.7.1", architecture)
EDFactoryPluginStatic.preImport("numpy", numpyPath)
EDFactoryPluginStatic.preImport("scipy", scipyPath)
EDFactoryPluginStatic.preImport("fabio", fabioPath)
EDFactoryPluginStatic.preImport("Image", imagingPath)

try:
    import fabio
    import scipy
    import numpy
except Exception:
    EDVerbose.ERROR(
        "Error in loading numpy, Scipy, PIL or Fabio,\n\
    Please re-run the test suite for EDTestSuitePluginFilterImage \
    to ensure that all modules are compiled for you computer as they don't seem to be installed"
    )
Exemplo n.º 21
0
import os, sys

from EDVerbose import EDVerbose
from EDUtilsPlatform import EDUtilsPlatform
from EDUtilsLibraryInstaller import EDUtilsLibraryInstaller, installLibrary
from EDFactoryPluginStatic import EDFactoryPluginStatic

################################################################################
# Import the right version of Scipy
################################################################################
moduleName = "matplotlib"
modulePath = os.path.join(os.environ["EDNA_HOME"], "libraries", "Matplotlib-1.0.1", EDUtilsPlatform.architecture)
moduleVersion = "0.9.0"  # minimum version to be compatible

oModule = EDFactoryPluginStatic.preImport(moduleName)
if not oModule:
    oModule = EDFactoryPluginStatic.preImport(moduleName, modulePath)
    if oModule is None:
        installLibrary(modulePath)
        oModule = EDFactoryPluginStatic.preImport(moduleName, modulePath)
try:
    version = oModule.__version__
except AttributeError:
    version = "0.0.0"

if version.split(".") < moduleVersion.split("."):
    EDVerbose.screen("Wrong %s library:  %s " % (moduleName, version))
    EDFactoryPluginStatic.unImport(moduleName)
    oModule = EDFactoryPluginStatic.preImport(moduleName, modulePath, moduleVersion, _strMethodVersion="__version__")
Exemplo n.º 22
0
# HDF5 does not like unicode string and crashes with cryptic error messages
###############################################################################

import os, threading, time, locale
from EDVerbose import EDVerbose
from EDPluginHDF5 import EDPluginHDF5
from EDAssert import EDAssert
from EDUtilsPlatform import EDUtilsPlatform
from XSDataHDF5v1_0 import XSDataInputHDF5MapSpectra, XSDataResultHDF5MapSpectra
from XSDataCommon import XSDataFile, XSDataString
from EDConfiguration import EDConfiguration
from EDUtilsArray import EDUtilsArray
from EDFactoryPluginStatic import EDFactoryPluginStatic
from EDPluginHDF5 import numpyPath, h5pyPath, fabioPath
numpy = EDFactoryPluginStatic.preImport("numpy",
                                        numpyPath,
                                        _strMethodVersion="__version__")
h5py = EDFactoryPluginStatic.preImport("h5py",
                                       h5pyPath,
                                       _strMethodVersion="version.version")
fabio = EDFactoryPluginStatic.preImport("fabio",
                                        fabioPath,
                                        _strMethodVersion="version")


class EDPluginHDF5MapOfSpectrav10(EDPluginHDF5):
    """
    This plugin is made for putting together 1D spectra comming from a 2D scan  in a 3D cube, 
    read using various libraries ... , and put them together in an NeXus/HDF5 file
    """
    HDF5_DATASET_MAPSPECTRA_ATTRIBUTES = {
Exemplo n.º 23
0
    sys.path.append(kernel_src)

from EDVerbose import EDVerbose
from EDUtilsPlatform import EDUtilsPlatform
from EDUtilsLibraryInstaller import EDUtilsLibraryInstaller, installLibrary
from EDFactoryPluginStatic import EDFactoryPluginStatic

################################################################################
# Import the right version of Scipy
################################################################################
moduleName = "matplotlib"
modulePath = os.path.join(os.environ["EDNA_HOME"], "libraries",
                          "Matplotlib-1.0.1", EDUtilsPlatform.architecture)
moduleVersion = "0.9.0"  #minimum version to be compatible

oModule = EDFactoryPluginStatic.preImport(moduleName)
if not oModule:
    oModule = EDFactoryPluginStatic.preImport(moduleName, modulePath)
    if oModule is None:
        installLibrary(modulePath)
        oModule = EDFactoryPluginStatic.preImport(moduleName, modulePath)
try:
    version = oModule.__version__
except AttributeError:
    version = "0.0.0"

if version.split(".") < moduleVersion.split("."):
    EDVerbose.screen("Wrong %s library:  %s " % (moduleName, version))
    EDFactoryPluginStatic.unImport(moduleName)
    oModule = EDFactoryPluginStatic.preImport(moduleName,
                                              modulePath,
Exemplo n.º 24
0
import os, threading, time, locale
from EDVerbose                  import EDVerbose
from EDPluginExec               import EDPluginExec
from EDAssert                   import EDAssert
from EDUtilsPlatform            import EDUtilsPlatform
from EDConfiguration            import EDConfiguration
from EDModule                   import EDModule
from XSDataHDF5v1_0             import XSDataInputHDF5Writer
from EDFactoryPluginStatic      import EDFactoryPluginStatic
architecture = EDUtilsPlatform.architecture
numpyPath = os.path.join(os.environ["EDNA_HOME"], "edna-libraries", "20090405-Numpy-1.3", architecture)
h5pyPath = os.path.join(os.environ["EDNA_HOME"], "edna-libraries", "H5Py-1.3.0", architecture)
fabioPath = os.path.join(os.environ["EDNA_HOME"], "edna-libraries", "FabIO-0.0.7", architecture)
imagingPath = os.path.join(os.environ["EDNA_HOME"], "edna-libraries", "20091115-PIL-1.1.7", architecture)

numpy = EDFactoryPluginStatic.preImport("numpy", numpyPath, _strMethodVersion="__version__")
h5py = EDFactoryPluginStatic.preImport("h5py", h5pyPath, _strMethodVersion="version.api_version", _strForceVersion="1.8")
Image = EDFactoryPluginStatic.preImport("Image", imagingPath, _strMethodVersion="VERSION")
fabio = EDFactoryPluginStatic.preImport("fabio", fabioPath, _strMethodVersion="version")

if h5py is None:
    EDVerbose.error("h5py is None ... please investigate why !!!")
    EDVerbose.writeErrorTrace()
#    raise ImportError("EDPluginHDF5 cannot work without h5py !!!")


if "EDNA_SITE" not in os.environ:
    os.environ["EDNA_SITE"] = "edna-site"


class EDPluginHDF5(EDPluginExec):
Exemplo n.º 25
0
from EDThreading import Semaphore
################################################################################
# AutoBuilder for Numpy, PIL and Fabio
################################################################################
architecture = EDUtilsPlatform.architecture
fabioPath = os.path.join(EDUtilsPath.EDNA_HOME, "libraries", "FabIO-0.0.7",
                         architecture)
imagingPath = os.path.join(EDUtilsPath.EDNA_HOME, "libraries",
                           "20091115-PIL-1.1.7", architecture)
numpyPath = os.path.join(EDUtilsPath.EDNA_HOME, "libraries",
                         "20090405-Numpy-1.3", architecture)
scipyPath = os.path.join(EDUtilsPath.EDNA_HOME, "libraries",
                         "20090711-SciPy-0.7.1", architecture)
fftw3Path = os.path.join(EDUtilsPath.EDNA_HOME, "libraries", "pyfftw3-0.2.1",
                         architecture)
numpy = EDFactoryPluginStatic.preImport("numpy", numpyPath)
EDFactoryPluginStatic.preImport("scipy.ndimage", scipyPath)
EDFactoryPluginStatic.preImport("scipy.fftpack", scipyPath)
EDFactoryPluginStatic.preImport("scipy.interpolate", scipyPath)
EDFactoryPluginStatic.preImport("scipy.signal", scipyPath)
Image = EDFactoryPluginStatic.preImport("Image", imagingPath)
fabio = EDFactoryPluginStatic.preImport("fabio", fabioPath)
fftw3 = EDFactoryPluginStatic.preImport("fftw3", fftw3Path)

try:
    import scipy.ndimage, scipy.interpolate
except Exception:
    EDVerbose.ERROR("Error in loading numpy, Scipy, PIL or Fabio,\n\
    Please re-run the test suite for EDTestSuitePluginExecShift \
    to ensure that all modules are compiled for you computer as they don't seem to be installed"
                    )
Exemplo n.º 26
0
from EDConfiguration import EDConfiguration

from XSDataCommon import XSPluginItem

# import the DriverFactory - either from edna's xia2core or a separate
# one configured in the environment as XIA2CORE_ROOT.

if "XIA2CORE_ROOT" in os.environ and os.environ['XIA2CORE_ROOT'] != '':
    pathxia2core = os.path.join(os.environ['XIA2CORE_ROOT'], 'Python')
else:
    pathxia2core = EDFactoryPluginStatic.getModuleLocation('XIA2CoreVersion')
    os.environ["XIA2CORE_ROOT"] = os.path.dirname(pathxia2core)

EDVerbose.DEBUG('Found xia2core in %s' % pathxia2core)

EDFactoryPluginStatic.preImport("Driver", pathxia2core)

from Driver.DriverFactory import DriverFactory

class EDPluginExecProcessXIA2CORE(EDPluginExec):

    # static class variables

    CONF_EXEC_PROCESS_EXECUTABLE = "execProcessExecutable"
    CONF_EXEC_PROCESS_XIA2CORE_TYPE = "execProcessXIA2COREType"
    CONF_EXEC_PROCESS_VERSION_STRING = "execProcessXIA2COREVersionString"

    def __init__ (self):
        """
        Initializes process related attributes described above
        """
Exemplo n.º 27
0
from XSDataNormalizeImage       import XSDataInputNormalize, XSDataResultNormalize
from EDAssert                   import EDAssert
from EDUtilsPlatform            import EDUtilsPlatform
from EDShare                    import EDShare
from EDUtilsPath                import EDUtilsPath
from EDThreading import Semaphore

################################################################################
# AutoBuilder for Numpy, PIL and Fabio
################################################################################
architecture = EDUtilsPlatform.architecture
fabioPath = os.path.join(EDUtilsPath.EDNA_HOME, "libraries", "FabIO-0.0.7", architecture)
imagingPath = os.path.join(EDUtilsPath.EDNA_HOME, "libraries", "20091115-PIL-1.1.7", architecture)
numpyPath = os.path.join(EDUtilsPath.EDNA_HOME, "libraries", "20090405-Numpy-1.3", architecture)

EDFactoryPluginStatic.preImport("Image", imagingPath)
numpy = EDFactoryPluginStatic.preImport("numpy", numpyPath, _strMethodVersion="version.version")
fabio = EDFactoryPluginStatic.preImport("fabio", fabioPath)


class EDPluginExecNormalizeImagev1_1(EDPluginExec):
    """
    Plugin that normalizes an image (subtract dark current and divide by flat-field image, taking into account the exposure time)
    
    v1.1 is compatible with EDShare -> lower memory footprint 
    """
    dictDark = {} #Nota: the key is a string: str(exposutTime)
#    listDarkExposure = []
#    listDarkArray = []
    semaphore = Semaphore()
    dtype = None #
Exemplo n.º 28
0
import base64, hashlib, sys, struct, threading, os

from EDVerbose              import EDVerbose
from EDObject               import EDObject
from XSDataCommon           import XSDataArray, XSDataString, XSDataImageExt, XSDataFile
from EDAssert               import EDAssert
from EDShare                import EDShare
from EDUtilsPlatform        import EDUtilsPlatform
from EDFactoryPluginStatic  import EDFactoryPluginStatic

architecture = EDUtilsPlatform.architecture
fabioPath = os.path.join(os.environ["EDNA_HOME"], "edna-libraries", "FabIO-0.0.7", architecture)
imagingPath = os.path.join(os.environ["EDNA_HOME"], "edna-libraries", "20091115-PIL-1.1.7", architecture)
numpyPath = os.path.join(os.environ["EDNA_HOME"], "edna-libraries", "20090405-Numpy-1.3", architecture)

EDFactoryPluginStatic.preImport("Image", imagingPath)
numpy = EDFactoryPluginStatic.preImport("numpy", numpyPath, _strForceVersion="1.2", _strMethodVersion="version.version")
fabio = EDFactoryPluginStatic.preImport("fabio", fabioPath, _strForceVersion="0.0.7", _strMethodVersion="version")

if (numpy is not None) and ("floating" in dir(numpy)):
    bHaveNumpy = True
    floatType = (float, numpy.floating)
else:
    bHaveNumpy = False
    floatType = float

if  fabio is not None:
    bHaveFabio = True
else:
    bHaveFabio = False
Exemplo n.º 29
0
from EDUtilsPlatform import EDUtilsPlatform

################################################################################
# AutoBuilder for Numpy, PIL and Fabio
################################################################################
architecture = EDUtilsPlatform.architecture
fabioPath = os.path.join(os.environ["EDNA_HOME"], "libraries", "FabIO-0.0.7",
                         architecture)
imagingPath = os.path.join(os.environ["EDNA_HOME"], "libraries",
                           "20091115-PIL-1.1.7", architecture)
numpyPath = os.path.join(os.environ["EDNA_HOME"], "libraries",
                         "20090405-Numpy-1.3", architecture)
scipyPath = os.path.join(os.environ["EDNA_HOME"], "libraries",
                         "20090711-SciPy-0.7.1", architecture)

EDFactoryPluginStatic.preImport("numpy", numpyPath)
EDFactoryPluginStatic.preImport("fabio", fabioPath)
EDFactoryPluginStatic.preImport("Image", imagingPath)
EDFactoryPluginStatic.preImport("scipy", scipyPath)
EDFactoryPluginStatic.preImport("scipy.ndimage.morphology", scipyPath)

try:
    import numpy, Image, fabio, scipy, scipy.ndimage.morphology
except Exception:
    EDVerbose.ERROR("Error in loading numpy, PIL, fabio or scipy,\n\
    Please re-run the test suite for EDTestSuitePluginExecThumbnailv10 \
    to ensure that all modules are compiled for you computer as they don't seem to be installed"
                    )
    raise

import ImageFile, ImageOps
Exemplo n.º 30
0
from EDShare import EDShare
from EDUtilsPlatform import EDUtilsPlatform

EDFactoryPluginStatic.loadModule("EDInstallNumpyv1_3")
EDFactoryPluginStatic.loadModule("EDInstallPILv1_1_7")
EDFactoryPluginStatic.loadModule("EDInstallFabio_v0_0_7")

architecture = EDUtilsPlatform.architecture
fabioPath = os.path.join(os.environ["EDNA_HOME"], "libraries", "FabIO-0.0.7",
                         architecture)
imagingPath = os.path.join(os.environ["EDNA_HOME"], "libraries",
                           "20091115-PIL-1.1.7", architecture)
numpyPath = os.path.join(os.environ["EDNA_HOME"], "libraries",
                         "20090405-Numpy-1.3", architecture)

EDFactoryPluginStatic.preImport("Image", imagingPath)
numpy = EDFactoryPluginStatic.preImport("numpy", numpyPath)
fabio = EDFactoryPluginStatic.preImport("fabio", fabioPath)

if "USER" not in os.environ:
    os.environ["USER"] = "******"
destDir = os.path.join(tempfile.gettempdir(), "edna-%s" % os.environ["USER"])
EDShare.initialize(destDir)


class EDTestCasePluginExecuteExecMatrixInvertv2_0_path(EDTestCasePluginExecute
                                                       ):
    """
    Those are all execution tests for the EDNA Exec plugin MatrixInvertv2_0 (Using shared arrays via HDF5)
    """
    def __init__(self, _strTestName=None):
Exemplo n.º 31
0
from EDConfiguration import EDConfiguration

from XSDataCommon import XSPluginItem

# import the DriverFactory - either from edna's xia2core or a separate
# one configured in the environment as XIA2CORE_ROOT.

if "XIA2CORE_ROOT" in os.environ and os.environ['XIA2CORE_ROOT'] != '':
    pathxia2core = os.path.join(os.environ['XIA2CORE_ROOT'], 'Python')
else:
    pathxia2core = EDFactoryPluginStatic.getModuleLocation('XIA2CoreVersion')
    os.environ["XIA2CORE_ROOT"] = os.path.dirname(pathxia2core)

EDVerbose.DEBUG('Found xia2core in %s' % pathxia2core)

EDFactoryPluginStatic.preImport("Driver", pathxia2core)

from Driver.DriverFactory import DriverFactory


class EDPluginExecProcessXIA2CORE(EDPluginExec):

    # static class variables

    CONF_EXEC_PROCESS_EXECUTABLE = "execProcessExecutable"
    CONF_EXEC_PROCESS_XIA2CORE_TYPE = "execProcessXIA2COREType"
    CONF_EXEC_PROCESS_VERSION_STRING = "execProcessXIA2COREVersionString"

    def __init__(self):
        """
        Initializes process related attributes described above