Esempio n. 1
0
 def test_plugin_from_function(self):
     "Test a plugin from a function"
     def cube(a):
         return a * a * a
     plugin_name = plugin_from_function(cube)
     logger.debug(plugin_name)
     plugin = plugin_factory(plugin_name)
     # plugin from functions are callable:
     assert plugin(a=5) == 125
Esempio n. 2
0
    def test_plugin_from_function(self):
        "Test a plugin from a function"

        def cube(a):
            return a * a * a

        plugin_name = plugin_from_function(cube)
        logger.debug(plugin_name)
        plugin = plugin_factory(plugin_name)
        #plugin from functions are callable:
        assert plugin(a=5) == 125
Esempio n. 3
0
                 "HS32Depth": HS32Depth,
                 "HSI0Factor": HSI0Factor,
                 "HSI1Factor": HSI1Factor,
                 "ShutterOpeningTime": ShutterOpeningTime,
                 "ShutterClosingTime": ShutterClosingTime,
                 'instrument': 'id02',
                 'c216': 'id02/c216/0',
                 'HS32F': list_f,
                 'HS32Z': list_z,
                 'HS32N': list_n,
                 'Info': info_dir}
    for key in ['HMStartEpoch', 'HMStartTime', "hdf5_filename", "entry", "HSTime", "HSI0", "HSI1"]:
        if key in dd:
            final_dir[key] = dd[key]
    return final_dir
plugin_from_function(preproc)


@register
class Metadata(Plugin):
    """Plugin in charge of retrieving all metadata for ID02 and storing them into a HDF5 file

    TODO: rewrite using Nexus class from pyFAI: shorter code

    NOTA: pin number are 1-based (I0, I1, time)

    Structure of the input data:
input = {
        "hdf5_filename":"/nobackup/lid02gpu11/metadata/test.h5",
        "entry": "entry",
        "instrument":"ESRF-ID02",
Esempio n. 4
0
except ImportError:
    logger.error("Failed to import Fabio: download and install it from pypi")

import pyFAI, fabio


def integrate_simple(poni_file, image_file, curve_file):
    ai = pyFAI.load(poni_file)
    img = fabio.open(image_file).data
    ai.integrate1d(img, 1000, filename=curve_file, unit="2th_deg")
    return {"out_file": curve_file}


from dahu.plugin import plugin_from_function

plugin_from_function(integrate_simple)


#@register
class PluginIntegrate(Plugin):
    """
    This is the basic plugin of PyFAI for azimuthal integration
    """
    _dictGeo = {}  #key:tuple(ai.param), value= ai
    _sem = Semaphore()

    def __init__(self):
        """
        """
        Plugin.__init__(self)
        self.shared = None
Esempio n. 5
0
#!/usr/bin/env python
# -*- coding: utf8 -*-

"""
Example of plugins made from functions 
"""

from __future__ import with_statement, print_function
__authors__ = ["Jérôme Kieffer"]
__contact__ = "*****@*****.**"
__license__ = "MIT"
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
__date__ = "20140319"
__status__ = "development"
version = "0.1"

import os
import numpy
from dahu.plugin import plugin_from_function
import logging
logger = logging.getLogger("plugin.pyFAI")

def square(x):
    return x * x

plugin_from_function(square)
Esempio n. 6
0
        'c216': 'id02/c216/0',
        'HS32F': list_f,
        'HS32Z': list_z,
        'HS32N': list_n,
        'Info': info_dir
    }
    for key in [
            'HMStartEpoch', 'HMStartTime', "hdf5_filename", "entry", "HSTime",
            "HSI0", "HSI1"
    ]:
        if key in dd:
            final_dir[key] = dd[key]
    return final_dir


plugin_from_function(preproc)


@register
class Metadata(Plugin):
    """Plugin in charge of retrieving all metadata for ID02 and storing them into a HDF5 file

    TODO: rewrite using Nexus class from pyFAI: shorter code

    NOTA: pin number are 1-based (I0, I1, time)

    Structure of the input data:
input = {
        "hdf5_filename":"/nobackup/lid02gpu11/metadata/test.h5",
        "entry": "entry",
        "instrument":"ESRF-ID02",
Esempio n. 7
0
File: pyfai.py Progetto: kif/UPBL09a
except ImportError:
    logger.error("Failed to import PyFAI: download and install it from pypi")
try:
    import fabio
except ImportError:
    logger.error("Failed to import Fabio: download and install it from pypi")

import pyFAI, fabio
def integrate_simple(poni_file, image_file, curve_file):
    ai = pyFAI.load(poni_file)
    img = fabio.open(image_file).data
    ai.integrate1d(img, 1000, filename=curve_file, unit="2th_deg")
    return {"out_file":curve_file}
    
from dahu.plugin import plugin_from_function
plugin_from_function(integrate_simple)

#@register
class PluginIntegrate(Plugin):
    """
    This is the basic plugin of PyFAI for azimuthal integration
    """
    _dictGeo = {} #key:tuple(ai.param), value= ai
    _sem = Semaphore()
    def __init__(self):
        """
        """
        Plugin.__init__(self)
        self.shared = None
        self.strOutputFile = None
        self.ai = None #this is the azimuthal integrator to use
Esempio n. 8
0
@register
class Cube(Plugin):
    def process(self):
        Plugin.process(self)
        if self.input is None:
            logger.warning("input is None")
        x = self.input.get("x", 0)
        self.output["result"] = x * x * x


def square(x):
    return x * x


plugin_from_function(square)


@register
class Sleep(Plugin):
    """
    Plugin hat sleeps for a while ...
    """
    def process(self):
        if self.input is None:
            logger.warning("input is None, defaulting to 10 sec")
            t = 10
        else:
            t = self.input.get("t", 10)
        time.sleep(t)