normalization.py 2.13 KB
Newer Older
payno's avatar
payno committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# coding: utf-8
# /*##########################################################################
#
# Copyright (c) 2016-2017 European Synchrotron Radiation Facility
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
# ###########################################################################*/

__authors__ = ["H. Payno"]
__license__ = "MIT"
__date__ = "06/11/2019"


from PyMca5.PyMcaPhysics.xas.XASClass import XASClass
import logging
_logger = logging.getLogger(__name__)


36
def pymca_normalization(xas_process_io):
payno's avatar
payno committed
37
38
39
40
41
42
    """
    
    :param dict configuration: should contain the  
    :return: configuration dict
    """
    pymca_xas = XASClass()
43
    if 'Energy' not in xas_process_io.spectrum or 'Mu' not in xas_process_io.spectrum:
payno's avatar
payno committed
44
45
46
        _logger.error('Energy and or Mu is/are not specified, unable to '
                      'normalize')
        return
47
48
49
50
    pymca_xas.setSpectrum(energy=xas_process_io.spectrum['Energy'],
                          mu=xas_process_io.spectrum['Mu'])
    pymca_xas.setConfiguration(xas_process_io.configuration)
    pymca_xas.processSpectrum()
payno's avatar
payno committed
51
52

    res = pymca_xas.normalize()
payno's avatar
payno committed
53
54
    res.update(xas_process_io.spectrum)
    return res
55