Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
workflow
ewoksapps
est
Commits
72f9a2c9
Commit
72f9a2c9
authored
Jun 27, 2022
by
payno
Browse files
Merge branch 'add_notebooks' into 'main'
Add notebooks See merge request
!75
parents
0fc99f62
cfebebea
Pipeline
#78523
passed with stages
in 15 minutes and 8 seconds
Changes
23
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
est/core/process/energyroi.py
View file @
72f9a2c9
...
...
@@ -13,8 +13,9 @@ def xas_energy_roi(xas_obj):
:return: spectra dict
:rtype: :class:`.XASObject`
"""
xas_roi_process
=
EnergyROIProcess
(
inputs
=
{
"xas_obj"
:
xas_obj
})
return
xas_roi_process
.
run
()
process
=
EnergyROIProcess
(
inputs
=
{
"xas_obj"
:
xas_obj
})
process
.
run
()
return
process
.
get_output_value
(
"xas_obj"
,
None
)
class
EnergyROIProcess
(
...
...
@@ -51,7 +52,6 @@ class EnergyROIProcess(
self
.
register_process
(
_xas_obj
,
data_keys
=
(
"Mu"
,
"energy"
))
self
.
outputs
.
xas_obj
=
_xas_obj
# .to_dict()
return
_xas_obj
def
_apply_roi
(
self
,
xas_obj
,
emin
,
emax
):
if
emin
is
None
and
emax
is
None
:
...
...
est/core/process/io.py
View file @
72f9a2c9
...
...
@@ -51,4 +51,3 @@ class ReadXasObject(
input_information
=
InputInformation
.
from_dict
(
self
.
inputs
.
input_information
)
xas_obj
=
XASReader
.
read_frm_url
(
input_information
)
self
.
outputs
.
xas_obj
=
xas_obj
return
xas_obj
est/core/process/larch/autobk.py
View file @
72f9a2c9
...
...
@@ -90,7 +90,7 @@ def process_spectr_autobk(
return
configuration
,
_spectrum
def
larch_autobk
(
xas_obj
,
config
:
dict
):
def
larch_autobk
(
xas_obj
,
**
optional_inputs
):
"""
:param xas_obj: object containing the configuration and spectra to process
...
...
@@ -98,8 +98,9 @@ def larch_autobk(xas_obj, config: dict):
:return: spectra dict
:rtype: XASObject
"""
mback_obj
=
Larch_autobk
(
inputs
=
{
"xas_obj"
:
xas_obj
,
"autobk_config"
:
config
})
return
mback_obj
.
run
()
process
=
Larch_autobk
(
inputs
=
{
"xas_obj"
:
xas_obj
,
**
optional_inputs
})
process
.
run
()
return
process
.
get_output_value
(
"xas_obj"
,
None
)
class
Larch_autobk
(
...
...
@@ -118,7 +119,6 @@ class Larch_autobk(
self
.
progress
=
100
self
.
register_process
(
_xas_obj
,
data_keys
=
(
_NexusDatasetDef
(
"bkg"
),))
self
.
outputs
.
xas_obj
=
_xas_obj
# .to_dict()
return
_xas_obj
def
_pool_process
(
self
,
xas_obj
):
assert
isinstance
(
xas_obj
,
XASObject
)
...
...
@@ -144,5 +144,3 @@ class Larch_autobk(
@
staticmethod
def
program_name
():
return
"larch_autobk"
__call__
=
run
est/core/process/larch/mback.py
View file @
72f9a2c9
...
...
@@ -81,7 +81,7 @@ def process_spectr_mback(
return
configuration
,
_spectrum
def
larch_mback
(
xas_obj
,
config
:
dict
):
def
larch_mback
(
xas_obj
,
**
optional_inputs
):
"""
:param xas_obj: object containing the configuration and spectra to process
...
...
@@ -89,8 +89,9 @@ def larch_mback(xas_obj, config: dict):
:return: spectra dict
:rtype: XASObject
"""
mback_obj
=
Larch_mback
(
inputs
=
{
"xas_obj"
:
xas_obj
,
"mback_config"
:
config
})
return
mback_obj
.
run
()
process
=
Larch_mback
(
inputs
=
{
"xas_obj"
:
xas_obj
,
**
optional_inputs
})
process
.
run
()
return
process
.
get_output_value
(
"xas_obj"
,
None
)
class
Larch_mback
(
...
...
@@ -115,7 +116,6 @@ class Larch_mback(
),
)
self
.
outputs
.
xas_obj
=
_xas_obj
# .to_dict()
return
_xas_obj
def
_pool_process
(
self
,
xas_obj
):
assert
isinstance
(
xas_obj
,
XASObject
)
...
...
@@ -141,5 +141,3 @@ class Larch_mback(
@
staticmethod
def
program_name
():
return
"larch_mback"
__call__
=
run
est/core/process/larch/mback_norm.py
View file @
72f9a2c9
...
...
@@ -87,7 +87,7 @@ def process_spectr_mback_norm(
return
configuration
,
_spectrum
def
larch_mback_norm
(
xas_obj
,
config
:
dict
):
def
larch_mback_norm
(
xas_obj
,
**
optional_inputs
):
"""
:param xas_obj: object containing the configuration and spectra to process
...
...
@@ -95,10 +95,9 @@ def larch_mback_norm(xas_obj, config: dict):
:return: spectra dict
:rtype: XASObject
"""
mback_obj
=
Larch_mback_norm
(
inputs
=
{
"xas_obj"
:
xas_obj
,
"mback_norm_config"
:
config
}
)
return
mback_obj
.
run
()
process
=
Larch_mback_norm
(
inputs
=
{
"xas_obj"
:
xas_obj
,
**
optional_inputs
})
process
.
run
()
return
process
.
get_output_value
(
"xas_obj"
,
None
)
class
Larch_mback_norm
(
...
...
@@ -123,7 +122,6 @@ class Larch_mback_norm(
data_keys
+=
[
"norm"
]
self
.
register_process
(
_xas_obj
,
data_keys
=
data_keys
)
self
.
outputs
.
xas_obj
=
_xas_obj
# .to_dict()
return
_xas_obj
def
_pool_process
(
self
,
xas_obj
):
assert
isinstance
(
xas_obj
,
XASObject
)
...
...
@@ -149,5 +147,3 @@ class Larch_mback_norm(
@
staticmethod
def
program_name
():
return
"larch_mback_norm"
__call__
=
run
est/core/process/larch/pre_edge.py
View file @
72f9a2c9
...
...
@@ -87,7 +87,7 @@ def process_spectr_pre_edge(
return
configuration
,
_spectrum
def
larch_pre_edge
(
xas_obj
,
config
:
dict
):
def
larch_pre_edge
(
xas_obj
,
**
optional_inputs
):
"""
:param xas_obj: object containing the configuration and spectra to process
...
...
@@ -95,8 +95,9 @@ def larch_pre_edge(xas_obj, config: dict):
:return: spectra dict
:rtype: XASObject
"""
mback_obj
=
Larch_pre_edge
(
inputs
=
{
"xas_obj"
:
xas_obj
,
"pre_edge_config"
:
config
})
return
mback_obj
.
run
()
process
=
Larch_pre_edge
(
inputs
=
{
"xas_obj"
:
xas_obj
,
**
optional_inputs
})
process
.
run
()
return
process
.
get_output_value
(
"xas_obj"
,
None
)
class
Larch_pre_edge
(
...
...
@@ -177,7 +178,6 @@ class Larch_pre_edge(
),
)
self
.
outputs
.
xas_obj
=
_xas_obj
# .to_dict()
return
_xas_obj
def
_pool_process
(
self
,
xas_obj
):
assert
isinstance
(
xas_obj
,
XASObject
)
...
...
@@ -203,5 +203,3 @@ class Larch_pre_edge(
@
staticmethod
def
program_name
():
return
"larch_pre_edge"
__call__
=
run
est/core/process/larch/xftf.py
View file @
72f9a2c9
...
...
@@ -114,7 +114,7 @@ def process_spectr_xftf(
return
configuration
,
_spectrum
def
larch_xftf
(
xas_obj
,
config
:
dict
):
def
larch_xftf
(
xas_obj
,
**
optional_inputs
):
"""
:param xas_obj: object containing the configuration and spectra to process
...
...
@@ -122,8 +122,9 @@ def larch_xftf(xas_obj, config: dict):
:return: spectra dict
:rtype: XASObject
"""
mback_obj
=
Larch_xftf
(
inputs
=
{
"xas_obj"
:
xas_obj
,
"xftf_config"
:
config
})
return
mback_obj
.
run
()
process
=
Larch_xftf
(
inputs
=
{
"xas_obj"
:
xas_obj
,
**
optional_inputs
})
process
.
run
()
return
process
.
get_output_value
(
"xas_obj"
,
None
)
class
Larch_xftf
(
...
...
@@ -203,7 +204,6 @@ class Larch_xftf(
),
)
self
.
outputs
.
xas_obj
=
_xas_obj
# .to_dict()
return
_xas_obj
def
_pool_process
(
self
,
xas_obj
):
assert
isinstance
(
xas_obj
,
XASObject
)
...
...
@@ -229,5 +229,3 @@ class Larch_xftf(
@
staticmethod
def
program_name
():
return
"larch_xftf"
__call__
=
run
est/core/process/noise.py
View file @
72f9a2c9
...
...
@@ -156,5 +156,3 @@ class NoiseProcess(
@
staticmethod
def
program_name
():
return
"noise_savgol"
__call__
=
run
est/core/process/pymca/exafs.py
View file @
72f9a2c9
...
...
@@ -97,7 +97,7 @@ def process_spectr_exafs(
return
configuration
,
get_output
(
spectrum
,
res_spectrum
)
def
pymca_exafs
(
xas_obj
):
def
pymca_exafs
(
xas_obj
,
**
optional_inputs
):
"""
:param xas_obj: object containing the configuration and spectra to process
...
...
@@ -105,8 +105,9 @@ def pymca_exafs(xas_obj):
:return: spectra dict
:rtype: XASObject
"""
exafs_obj
=
PyMca_exafs
(
inputs
=
{
"xas_obj"
:
xas_obj
})
return
exafs_obj
.
run
()
process
=
PyMca_exafs
(
inputs
=
{
"xas_obj"
:
xas_obj
,
**
optional_inputs
})
process
.
run
()
return
process
.
get_output_value
(
"xas_obj"
,
None
)
class
PyMca_exafs
(
...
...
@@ -144,7 +145,6 @@ class PyMca_exafs(
),
)
self
.
outputs
.
xas_obj
=
_xas_obj
# .to_dict()
return
_xas_obj
def
_pool_process
(
self
,
xas_obj
):
assert
isinstance
(
xas_obj
,
XASObject
)
...
...
@@ -171,5 +171,3 @@ class PyMca_exafs(
@
staticmethod
def
program_name
():
return
"pymca_exafs"
__call__
=
run
est/core/process/pymca/ft.py
View file @
72f9a2c9
...
...
@@ -101,7 +101,7 @@ def process_spectr_ft(
return
configuration
,
spectrum_
def
pymca_ft
(
xas_obj
):
def
pymca_ft
(
xas_obj
,
**
optional_inputs
):
"""
:param xas_obj: object containing the configuration and spectra to process
...
...
@@ -109,9 +109,9 @@ def pymca_ft(xas_obj):
:return: spectra dict
:rtype: dict
"""
assert
xas_obj
is
not
None
ft_obj
=
PyMca_ft
(
inputs
=
{
"xas_obj"
:
xas_obj
}
)
return
ft_obj
.
run
(
)
process
=
PyMca_ft
(
inputs
=
{
"xas_obj"
:
xas_obj
,
**
optional_inputs
})
process
.
run
(
)
return
process
.
get_output_value
(
"xas_obj"
,
None
)
class
PyMca_ft
(
...
...
@@ -158,7 +158,6 @@ class PyMca_ft(
),
)
self
.
outputs
.
xas_obj
=
_xas_obj
# .to_dict()
return
_xas_obj
def
_pool_process
(
self
,
xas_obj
):
assert
isinstance
(
xas_obj
,
XASObject
)
...
...
@@ -183,5 +182,3 @@ class PyMca_ft(
@
staticmethod
def
program_name
():
return
"pymca_ft"
__call__
=
run
est/core/process/pymca/k_weight.py
View file @
72f9a2c9
...
...
@@ -90,7 +90,7 @@ def process_spectr_k(
return
configuration_
,
spectrum_
def
pymca_k_weight
(
xas_obj
):
def
pymca_k_weight
(
xas_obj
,
**
optional_inputs
):
"""
Set weight for exafs values
...
...
@@ -99,8 +99,9 @@ def pymca_k_weight(xas_obj):
:return: spectra dict
:rtype: :class:`.XASObject`
"""
k_weight_obj
=
PyMca_k_weight
(
inputs
=
{
"xas_obj"
:
xas_obj
})
return
k_weight_obj
.
run
()
process
=
PyMca_k_weight
(
inputs
=
{
"xas_obj"
:
xas_obj
,
**
optional_inputs
})
process
.
run
()
return
process
.
get_output_value
(
"xas_obj"
,
None
)
class
PyMca_k_weight
(
...
...
@@ -160,7 +161,6 @@ class PyMca_k_weight(
self
.
progress
=
100.0
self
.
register_process
(
xas_obj
=
_xas_obj
,
data_keys
=
tuple
())
self
.
outputs
.
xas_obj
=
_xas_obj
# .to_dict()
return
_xas_obj
def
_pool_process
(
self
,
xas_obj
):
"""process normalization from a pool"""
...
...
@@ -188,5 +188,3 @@ class PyMca_k_weight(
@
staticmethod
def
program_name
():
return
"pymca_k_weight"
__call__
=
run
est/core/process/pymca/normalization.py
View file @
72f9a2c9
...
...
@@ -75,7 +75,7 @@ def process_spectr_norm(
return
configuration
,
get_output
(
spectrum
,
spectrum_
)
def
pymca_normalization
(
xas_obj
):
def
pymca_normalization
(
xas_obj
,
**
optional_inputs
):
"""
:param xas_obj: object containing the configuration and spectra to process
...
...
@@ -84,8 +84,9 @@ def pymca_normalization(xas_obj):
:return: spectra dict
:rtype: dict
"""
normalization_obj
=
PyMca_normalization
(
inputs
=
{
"xas_obj"
:
xas_obj
})
return
normalization_obj
.
run
()
process
=
PyMca_normalization
(
inputs
=
{
"xas_obj"
:
xas_obj
,
**
optional_inputs
})
process
.
run
()
return
process
.
get_output_value
(
"xas_obj"
,
None
)
class
PyMca_normalization
(
...
...
@@ -133,9 +134,7 @@ class PyMca_normalization(
_NexusDatasetDef
(
"NormalizedSignal"
),
),
)
xas_obj_as_dict
=
_xas_obj
.
to_dict
()
self
.
outputs
.
xas_obj
=
xas_obj_as_dict
return
_xas_obj
self
.
outputs
.
xas_obj
=
_xas_obj
# .to_dict()
def
_pool_process
(
self
,
xas_obj
):
"""process normalization from a pool"""
...
...
@@ -161,5 +160,3 @@ class PyMca_normalization(
@
staticmethod
def
program_name
():
return
"pymca_normalization"
__call__
=
run
est/core/process/roi.py
View file @
72f9a2c9
...
...
@@ -19,8 +19,9 @@ def xas_roi(xas_obj):
:return: spectra dict
:rtype: :class:`.XASObject`
"""
xas_roi_process
=
ROIProcess
(
inputs
=
{
"xas_obj"
:
xas_obj
})
return
xas_roi_process
.
run
()
process
=
ROIProcess
(
inputs
=
{
"xas_obj"
:
xas_obj
})
process
.
run
()
return
process
.
get_output_value
(
"xas_obj"
,
None
)
class
_ROI
:
...
...
@@ -162,10 +163,7 @@ class ROIProcess(
origin
,
size
=
roi_dict
[
"origin"
],
roi_dict
[
"size"
]
_xas_obj
=
self
.
_apply_roi
(
xas_obj
=
_xas_obj
,
roi
=
_ROI
(
origin
,
size
))
self
.
outputs
.
xas_obj
=
_xas_obj
# .to_dict()
return
_xas_obj
@
staticmethod
def
program_name
():
return
"roi"
__call__
=
run
est/tests/larch/test_autobk.py
View file @
72f9a2c9
...
...
@@ -34,7 +34,7 @@ def xas_object(spectrum_cu_from_larch):
@
pytest
.
mark
.
skipif
(
larch
is
None
,
reason
=
"xraylarch not installed"
)
def
test_multiple_spectra
(
xas_object
):
"""Make sure computation on spectra is valid (n spectrum)"""
res
=
larch_autobk
(
xas_object
,
{}
)
res
=
larch_autobk
(
xas_object
)
assert
isinstance
(
res
,
XASObject
)
spectrum0
=
res
.
spectra
.
data
.
flat
[
0
]
assert
hasattr
(
spectrum0
,
"k"
)
...
...
@@ -44,7 +44,7 @@ def test_multiple_spectra(xas_object):
@
pytest
.
mark
.
skipif
(
larch
is
None
,
reason
=
"xraylarch not installed"
)
def
test_multiple_spectra_as_dict
(
xas_object
):
"""Make sure computation on spectra is valid (n spectrum)"""
res
=
larch_autobk
(
xas_object
.
to_dict
()
,
{}
)
res
=
larch_autobk
(
xas_object
.
to_dict
())
assert
isinstance
(
res
,
XASObject
)
spectrum0
=
res
.
spectra
.
data
.
flat
[
0
]
assert
hasattr
(
spectrum0
,
"k"
)
...
...
est/tests/larch/test_larch_
workflow
.py
→
est/tests/larch/test_larch_
chain
.py
View file @
72f9a2c9
File moved
est/tests/larch/test_mback.py
View file @
72f9a2c9
...
...
@@ -35,7 +35,7 @@ def xas_object(spectrum_cu_from_larch):
@
pytest
.
mark
.
skipif
(
larch
is
None
,
reason
=
"xraylarch not installed"
)
def
test_multiple_spectra
(
xas_object
):
"""Make sure computation on spectra is valid (n spectrum)"""
res
=
larch_mback
(
xas_object
,
{
"z"
:
29
})
res
=
larch_mback
(
xas_object
,
mback_config
=
{
"z"
:
29
})
assert
isinstance
(
res
,
XASObject
)
spectrum0
=
res
.
spectra
.
data
.
flat
[
0
]
assert
hasattr
(
spectrum0
,
"fpp"
)
...
...
@@ -45,7 +45,7 @@ def test_multiple_spectra(xas_object):
@
pytest
.
mark
.
skipif
(
larch
is
None
,
reason
=
"xraylarch not installed"
)
def
test_multiple_spectra_asdict
(
xas_object
):
"""Make sure computation on spectra is valid (n spectrum)"""
res
=
larch_mback
(
xas_object
.
to_dict
(),
{
"z"
:
29
})
res
=
larch_mback
(
xas_object
.
to_dict
(),
mback_config
=
{
"z"
:
29
})
assert
isinstance
(
res
,
XASObject
)
spectrum0
=
res
.
spectra
.
data
.
flat
[
0
]
assert
hasattr
(
spectrum0
,
"fpp"
)
...
...
est/tests/larch/test_mback_norm.py
View file @
72f9a2c9
...
...
@@ -48,7 +48,7 @@ def xas_object(spectrum_cu_from_larch):
@
pytest
.
mark
.
skipif
(
larch
is
None
,
reason
=
"xraylarch not installed"
)
def
test_multiple_spectra
(
xas_object
):
"""Make sure computation on spectra is valid (n spectrum)"""
res
=
larch_mback_norm
(
xas_object
,
{}
)
res
=
larch_mback_norm
(
xas_object
)
assert
isinstance
(
res
,
XASObject
)
spectrum0
=
res
.
spectra
.
data
.
flat
[
0
]
assert
hasattr
(
spectrum0
,
"mback_mu"
)
...
...
@@ -58,7 +58,7 @@ def test_multiple_spectra(xas_object):
@
pytest
.
mark
.
skipif
(
larch
is
None
,
reason
=
"xraylarch not installed"
)
def
test_multiple_spectra_asdict
(
xas_object
):
"""Make sure computation on spectra is valid (n spectrum)"""
res
=
larch_mback_norm
(
xas_object
.
to_dict
()
,
{}
)
res
=
larch_mback_norm
(
xas_object
.
to_dict
())
assert
isinstance
(
res
,
XASObject
)
spectrum0
=
res
.
spectra
.
data
.
flat
[
0
]
assert
hasattr
(
spectrum0
,
"mback_mu"
)
...
...
est/tests/larch/test_pre_edge.py
View file @
72f9a2c9
...
...
@@ -35,7 +35,7 @@ def xas_object(spectrum_cu_from_larch):
@
pytest
.
mark
.
skipif
(
larch
is
None
,
reason
=
"xraylarch not installed"
)
def
test_multiple_spectra
(
xas_object
):
"""Make sure computation on spectra is valid (n spectrum)"""
res
=
larch_pre_edge
(
xas_object
,
{}
)
res
=
larch_pre_edge
(
xas_object
)
assert
isinstance
(
res
,
XASObject
)
spectrum0
=
res
.
spectra
.
data
.
flat
[
0
]
assert
hasattr
(
spectrum0
,
"pre_edge"
)
...
...
@@ -45,7 +45,7 @@ def test_multiple_spectra(xas_object):
@
pytest
.
mark
.
skipif
(
larch
is
None
,
reason
=
"xraylarch not installed"
)
def
test_multiple_spectra_asdict
(
xas_object
):
"""Make sure computation on spectra is valid (n spectrum)"""
res
=
larch_pre_edge
(
xas_object
.
to_dict
()
,
{}
)
res
=
larch_pre_edge
(
xas_object
.
to_dict
())
assert
isinstance
(
res
,
XASObject
)
spectrum0
=
res
.
spectra
.
data
.
flat
[
0
]
assert
hasattr
(
spectrum0
,
"pre_edge"
)
...
...
est/tests/larch/test_xftf.py
View file @
72f9a2c9
...
...
@@ -53,7 +53,7 @@ def xas_object(spectrum_cu_from_larch):
@
pytest
.
mark
.
skipif
(
larch
is
None
,
reason
=
"xraylarch not installed"
)
def
test_multiple_spectra
(
xas_object
):
"""Make sure computation on spectra is valid (n spectrum)"""
res
=
larch_xftf
(
xas_object
,
{}
)
res
=
larch_xftf
(
xas_object
)
assert
isinstance
(
res
,
XASObject
)
spectrum
=
res
.
spectra
.
data
.
flat
[
0
]
assert
hasattr
(
spectrum
,
"chir_re"
)
...
...
@@ -65,7 +65,7 @@ def test_multiple_spectra(xas_object):
@
pytest
.
mark
.
skipif
(
larch
is
None
,
reason
=
"xraylarch not installed"
)
def
test_multiple_spectra_asdict
(
xas_object
):
"""Make sure computation on spectra is valid (n spectrum)"""
res
=
larch_xftf
(
xas_object
.
to_dict
()
,
{}
)
res
=
larch_xftf
(
xas_object
.
to_dict
())
assert
isinstance
(
res
,
XASObject
)
spectrum
=
res
.
spectra
.
data
.
flat
[
0
]
assert
hasattr
(
spectrum
,
"chir_re"
)
...
...
est/tests/notebooks/larch_xas_processing.ipynb
0 → 100644
View file @
72f9a2c9
This diff is collapsed.
Click to expand it.
Prev
1
2
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment