Commit 70a46db3 authored by payno's avatar payno

Merge branch 'master' of gitlab.esrf.fr:workflow/xas

parents c8ccb99e bb3da9c4
Pipeline #12160 passed with stage
in 13 minutes and 8 seconds
......@@ -44,3 +44,32 @@ test:python3.5-stretch-pyqt5:
test:python3.5-stretch-pyside2:
image: docker-registry.esrf.fr/dau/tomwer:python3.5_stretch_pyqt5
<<: *test_linux_template
test:test-xas-tutorials:
type: test
image: docker-registry.esrf.fr/dau/tomwer:python3.5_stretch_pyqt5
before_script:
- arch
- apt-get install octave --yes
- export PYTHONPATH="${PYTHONPATH}:/usr/lib/python3/dist-packages/"
- export LD_LIBRARY_PATH=/lib/i386-linux-gnu/:${LD_LIBRARY_PATH}
- export LD_LIBRARY_PATH=/lib/x86_64-linux-gnu/:${LD_LIBRARY_PATH}
- export ORANGE_WEB_LOG='False'
- python --version
- python -m pip install pip --upgrade
- python -m pip install setuptools --upgrade
- python -m pip install numpy --upgrade
- python -m pip install matplotlib
- python -m pip install jupyter_client
- python -m pip install nbconvert
- python -m pip install ipykernel
- python -m pip install -r requirements.txt
- python -m pip install -r requirements-dev.txt
- cd xas
- git clone https://gitlab.esrf.fr/payno/pushworkflow.git
- cd -
- python -m pip install .
script:
- /usr/bin/xvfb-run --server-args="-screen 0 1024x768x24" -a jupyter nbconvert --to notebook --execute doc/tutorials/xas_process.ipynb
============
Applications
============
.. toctree::
:maxdepth: 1
process
process
-------
You can use the workflow definition from a .ows (orange) file with it configuration to process different spectrum.
For this you should execute the `process` application
.. code-block:: bash
xas process pymca_workflow.ows -i [input_spectrum_file] -o [output_file]
......@@ -34,6 +34,7 @@ sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'ext'))
# ones.
extensions = [
'sphinx.ext.autodoc',
'nbsphinx',
]
# Add any paths that contain templates here, relative to this directory.
......
......@@ -9,32 +9,20 @@ TODO
:hidden:
tutorials/index.rst
install.rst
app/index.rst
:doc:`install`
Installation
:doc:`app/index`
Applications
:doc:`tutorials/index`
tutorials for using the xas library
-----------------------------
xas on esrf official debian 8
-----------------------------
A xas module for debian 8 is provided.
This mean that if you have an esrf official debian 8 distribution you can load the module:
.. code-block:: bash
module load xas_orange
and execute xas.
.. code-block:: bash
xas_orange [myworkflow.ows]
--------------
Orange Widgets
......
installation
::::::::::::
xas is library made to link several xas libraries together and define treatment workflows.
This is the recommended way to install xas.
Step 1 - Create a virtual env
'''''''''''''''''''''''''''''
It is recommended to create a python virtual environment to run the workflow tool.
Virtual environment might avoid some conflict between python packages. But you can also install it on your 'current' python environment and move to step 1.
.. code-block:: bash
virtualenv --python=python3 --system-site-packages myvirtualenv
Then activate the virtual environment
.. code-block:: bash
source myvirtualenv/bin/activate
.. note:: To quit the virtual environment
.. code-block:: bash
deactivate
Step 2 installation
'''''''''''''''''''
You can install from the code source (https://gitlab.esrf.fr/workflow/xas)
.. code-block:: bash
pip install .[full]
Or install it from pypi:
.. code-block:: bash
pip install xas[full]
Launching Orange
::::::::::::::::
xas is offering an orange add-on for having a convenient and user friendly way to define a treatment workflow.
To launch orange and access the xas add-on you can simply launch Orange2 with the command:
.. code-block:: bash
orange-canvas
.. note:: if your installed a virtual environment do not forget to active it :
.. code-block:: bash
source myvirtualenv/bin/activate
Documentation
:::::::::::::
.. code-block:: bash
cd doc
make html
The documentation is build in doc/build/html and the entry point is index.html
.. code-block:: bash
firefox build/html/index.html
.. note:: the build of the documentation need sphinx to be installed. This is not an hard dependency. So you might need to install it.
You also should generate documentation to be accessible from Orange GUI (pressing the F1 key).
.. code-block:: bash
cd doc
make htmlhelp
To get more information about help from Orange see :
:doc:`other/help`
accessing documentation from the interface
Warning
:::::::
the xas GUI is using silx from the silx.gui.qt module which try to use PyQt5, then PySide2, then PyQt4
Order is different for AnyQt, used by Orange3. So some incoherence might append (will bring errors) in the Signal/SLOT connection
during widget instantiation.
You should be careful about it if more than one Qt binding is available (one quick and durty fix is to change the AnyQt/__init__.py file - 'availableapi' function for example)
=========
Tutorials
=========
pymca xas
---------
.. toctree::
:maxdepth: 1
xas_process
......@@ -127,24 +127,6 @@
"output should be"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%gui qt\n",
"from silx.gui.plot import Plot1D\n",
"\n",
"plotNorm = Plot1D()\n",
"plotNorm.addCurve(ddict_norm[\"NormalizedEnergy\"],\n",
" ddict_norm[\"NormalizedMu\"],\n",
" legend=\"Mu\",\n",
" yaxis=\"right\")\n",
"plotNorm.setWindowTitle('normalization')\n",
"plotNorm.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
......@@ -166,19 +148,6 @@
"print(ddict_pe)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"plotPostEdge = Plot1D()\n",
"plotPostEdge.addCurve(ddict_pe[\"NormalizedEnergy\"],\n",
" ddict_pe[\"NormalizedSignal\"], legend=\"Mu\")\n",
"plotPostEdge.setWindowTitle('post edge')\n",
"plotPostEdge.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
......@@ -211,30 +180,6 @@
"ddict = pymca_xas.fourierTransform(k=kValues, mu=mu, kMin=None, kMax=None)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"plotFT = Plot1D()\n",
"plotFT.addCurve(ddict[\"FTRadius\"],\n",
" ddict[\"FTIntensity\"],\n",
" legend=\"FT Intensity\",\n",
" xlabel=\"R (Angstrom)\",\n",
" ylabel=\"Arbitrary Units\")\n",
"plotFT.setActiveCurve(\"FT Intensity\")\n",
"plotFT.addCurve(ddict[\"FTRadius\"],\n",
" ddict[\"FTImaginary\"],\n",
" legend=\"FT Imaginary\",\n",
" xlabel=\"R (Angstrom)\",\n",
" ylabel=\"Arbitrary Units\",\n",
" color=\"red\")\n",
"\n",
"plotFT.setWindowTitle('Fourier transform')\n",
"plotFT.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
......@@ -276,7 +221,7 @@
"metadata": {},
"outputs": [],
"source": [
"from xas.core.process.io import read_pymca_xas\n",
"from xas.io import read_pymca_xas\n",
"from silx.io.url import DataUrl\n",
"spec_url = DataUrl(file_path=data_file, scheme='PyMca')\n",
"print(spec_url.scheme())\n",
......@@ -298,8 +243,8 @@
"outputs": [],
"source": [
"from xas.core.process.normalization import pymca_normalization\n",
"spectrum = pymca_normalization(xas_obj.copy())\n",
"assert 'NormalizedMu' in spectrum"
"xas_obj = pymca_normalization(xas_obj.copy())\n",
"assert 'NormalizedMu' in xas_obj.spectrum"
]
},
{
......@@ -316,8 +261,8 @@
"outputs": [],
"source": [
"from xas.core.process.exafs import pymca_exafs\n",
"spectrum = pymca_exafs(xas_obj.copy())\n",
"assert 'PostEdgeB' in spectrum"
"xas_obj = pymca_exafs(xas_obj.copy())\n",
"assert 'PostEdgeB' in xas_obj.spectrum"
]
},
{
......@@ -337,8 +282,8 @@
"l_xas_obj = xas_obj.copy()\n",
"l_xas_obj.configuration['SET_KWEIGHT'] = 1\n",
"\n",
"spectrum = pymca_k_weight(l_xas_obj)\n",
"assert spectrum['KWeight'] == 1"
"xas_obj = pymca_k_weight(l_xas_obj)\n",
"assert xas_obj.spectrum['KWeight'] == 1"
]
},
{
......@@ -355,8 +300,8 @@
"outputs": [],
"source": [
"from xas.core.process.ft import pymca_ft\n",
"spectrum = pymca_ft(xas_obj.copy())\n",
"assert 'FTRadius' in spectrum"
"xas_obj = pymca_ft(xas_obj.copy())\n",
"assert 'FTRadius' in xas_obj.spectrum['FT']"
]
},
{
......@@ -380,10 +325,10 @@
"import xas.core.process.k_weight\n",
"import xas.core.process.exafs\n",
"import xas.core.process.ft\n",
"import xas.core.process.io\n",
"import xas.io\n",
"\n",
"\n",
"read_task = Node(callback=xas.core.process.io.read_pymca_xas)\n",
"read_task = Node(callback=xas.io.read_pymca_xas)\n",
"normalization_task = Node(callback=xas.core.process.normalization.pymca_normalization)\n",
"k_weight_task = Node(callback=xas.core.process.k_weight.pymca_k_weight)\n",
"exafs_task = Node(callback=xas.core.process.exafs.pymca_exafs)\n",
......@@ -425,7 +370,7 @@
"data_file = os.path.join(PYMCA_DATA_DIR, \"EXAFS_Cu.dat\")\n",
"out = exec_workflow(scheme=scheme, input_=data_file)\n",
"assert isinstance(out, dict)\n",
"assert 'FTRadius' in out['FT']"
"assert 'FTRadius' in out['spectrum']['FT']"
]
},
{
......
......@@ -37,7 +37,7 @@ from silx.io.url import DataUrl
import h5py
import os
import logging
import xas.core.process.io
import xas.io
_logger = logging.getLogger(__file__)
......@@ -60,7 +60,7 @@ class XASInputOW(OWWidget):
_input_file_setting = Setting(str())
process_function = xas.core.process.io.read_pymca_xas
process_function = xas.io.read_pymca_xas
def __init__(self):
super().__init__()
......@@ -134,15 +134,14 @@ class XASInputOW(OWWidget):
def _interpreteInput(self, file_path):
if file_path.endswith('.dat'):
return xas.core.process.io.read_pymca_xas(DataUrl(file_path=self._input_file_setting,
scheme='PyMca'))
return xas.io.read_pymca_xas(DataUrl(file_path=self._input_file_setting,
scheme='PyMca'))
elif h5py.is_hdf5(file_path):
return xas.core.process.io.read_pymca_xas(
spectrum_url=DataUrl(file_path=file_path,
scheme='PyMca',
data_path='spectrum'),
config_url=DataUrl(file_path=file_path,
scheme='silx',
data_path='configuration'))
return xas.io.read_pymca_xas(spectrum_url=DataUrl(file_path=file_path,
scheme='PyMca',
data_path='spectrum'),
config_url=DataUrl(file_path=file_path,
scheme='silx',
data_path='configuration'))
else:
raise ValueError('file type not managed, unable to load')
......@@ -34,7 +34,7 @@ from silx.gui import qt
from Orange.widgets.settings import Setting
from xas.core.types import XASBase
from xas.core.types import XASFactory
import xas.core.process.io
import xas.io
import logging
_logger = logging.getLogger(__file__)
......@@ -57,7 +57,7 @@ class XASOutputOW(OWWidget):
inputs = [("spectrum", XASBase, 'process')]
_output_file_setting = Setting(str())
process_function = xas.core.process.io.Writer_pymca_cas
process_function = xas.io.Writer_pymca_cas
def __init__(self):
super().__init__()
......
......@@ -28,7 +28,7 @@ __date__ = "06/11/2019"
import unittest
from xas.core.process.io import read_pymca_xas
from xas.io import read_pymca_xas
from silx.io.url import DataUrl
from PyMca5.PyMcaDataDir import PYMCA_DATA_DIR
from xas.core.types import PyMcaXAS, XASFactory
......
......@@ -33,7 +33,7 @@ from PyMca5.PyMcaDataDir import PYMCA_DATA_DIR
from silx.io.url import DataUrl
from xas.core.process.exafs import pymca_exafs, PyMca_exafs
from xas.core.process.ft import pymca_ft, PyMca_ft
from xas.core.process.io import read_pymca_xas
from xas.io import read_pymca_xas
from xas.core.process.k_weight import pymca_k_weight, PyMca_k_weight
from xas.core.process.normalization import pymca_normalization, PyMca_normalization
......
from .io import *
......@@ -93,14 +93,14 @@ class Writer_pymca_cas(object):
def dump_pymca_xas(self, xas_obj):
if not self._output_file:
print('no output file defined, please give path to the output file')
_logger.warning('no output file defined, please give path to the output file')
self._output_file = input()
_logger.info('dumping xas obj... to', self._output_file)
if isinstance(xas_obj, dict):
_xas_obj = PyMcaXAS().load_frm_dict(xas_obj)
else:
_xas_obj = xas_obj
print('dump xas obj to', self._output_file)
_logger.info('dump xas obj to', self._output_file)
_xas_obj.dump(self._output_file)
__call__ = dump_pymca_xas
......@@ -32,13 +32,12 @@ from PyMca5.PyMcaDataDir import PYMCA_DATA_DIR
from xas.pushworkflow.scheme.node import Node
from xas.pushworkflow.scheme.link import Link
from xas.pushworkflow.scheme.scheme import Scheme
from xas.core.process.io import read_pymca_xas
from xas.app.process import exec_ as exec_workflow
import xas.core.process.normalization
import xas.core.process.k_weight
import xas.core.process.exafs
import xas.core.process.ft
import xas.core.process.io
import xas.io
import os
......@@ -47,7 +46,7 @@ class TestWorkflowFunctions(unittest.TestCase):
def setUp(self):
unittest.TestCase.setUp(self)
read_task = Node(callback=xas.core.process.io.read_pymca_xas)
read_task = Node(callback=xas.io.read_pymca_xas)
normalization_task = Node(
callback=xas.core.process.normalization.pymca_normalization)
k_weight_task = Node(callback=xas.core.process.k_weight.pymca_k_weight)
......@@ -84,7 +83,7 @@ class TestWorkflowCallableClasses(unittest.TestCase):
def setUp(self):
unittest.TestCase.setUp(self)
read_task = Node(callback=xas.core.process.io.read_pymca_xas)
read_task = Node(callback=xas.io.read_pymca_xas)
normalization_task = Node(
callback=xas.core.process.normalization.PyMca_normalization)
k_weight_task = Node(callback=xas.core.process.k_weight.PyMca_k_weight)
......
......@@ -36,6 +36,7 @@ def configuration(parent_package='', top_path=None):
config.add_subpackage('app')
config.add_subpackage('core')
config.add_subpackage('gui')
config.add_subpackage('io')
config.add_subpackage('pushworkflow')
config.add_subpackage('pushworkflowactors')
config.add_subpackage('resources')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment