Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
est
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mauro Rovezzi
est
Commits
40138bb6
Commit
40138bb6
authored
11 months ago
by
Loic Huder
Browse files
Options
Downloads
Patches
Plain Diff
Add test for loading from input info with HDF5 URIs
parent
06efa841
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/est/tests/test_input_information.py
+34
-6
34 additions, 6 deletions
src/est/tests/test_input_information.py
with
34 additions
and
6 deletions
src/est/tests/test_input_information.py
+
34
−
6
View file @
40138bb6
from
est.io.information
import
InputInformation
from
est.app.utils.xasobj
import
get_xas_obj
from
est.io.utils.ascii
import
build_ascii_data_url
,
split_ascii_url
from
silx.io.url
import
DataUrl
import
numpy
import
pytest
try
:
import
PyMca5
except
ImportError
:
PyMca5
=
None
from
silx.io.url
import
DataUrl
from
silx.io
import
h5py_utils
import
pytest
from
est.core.io
import
read_from_input_information
from
est.io.information
import
InputInformation
from
est.io.utils.ascii
import
build_ascii_data_url
,
split_ascii_url
@pytest.mark.skipif
(
PyMca5
is
None
,
reason
=
"
PyMca5 is not installed
"
)
...
...
@@ -28,7 +30,7 @@ def test_input_information(filename_cu_from_pymca):
data_slice
=
None
,
),
)
xas_obj
=
get_xas_obj
(
input_information
)
xas_obj
=
read_from_input_information
(
input_information
)
assert
xas_obj
.
energy
is
not
None
assert
xas_obj
.
spectra
.
data
.
flat
[
0
]
is
not
None
...
...
@@ -52,3 +54,29 @@ def test_spec_url():
"
col_name
"
:
col_name
,
"
data_slice
"
:
data_slice
,
}
@pytest.mark.skipif
(
PyMca5
is
None
,
reason
=
"
PyMca5 is not installed
"
)
def
test_input_information_from_h5
(
hdf5_filename_cu_from_pymca
):
energy_url
=
DataUrl
(
f
"
silx://
{
hdf5_filename_cu_from_pymca
}
::/1.1/measurement/energy
"
)
with
h5py_utils
.
open_item
(
energy_url
.
file_path
(),
energy_url
.
data_path
())
as
dset
:
energy
=
dset
[()]
mu_url
=
DataUrl
(
f
"
silx://
{
hdf5_filename_cu_from_pymca
}
::/1.1/measurement/mu
"
)
with
h5py_utils
.
open_item
(
mu_url
.
file_path
(),
mu_url
.
data_path
())
as
dset
:
mu
=
dset
[()]
I0_url
=
mu_url
I0
=
mu
input_information
=
InputInformation
(
channel_url
=
energy_url
,
spectra_url
=
mu_url
,
I0_url
=
I0_url
)
xas_obj
=
read_from_input_information
(
input_information
)
sp
=
xas_obj
.
get_spectrum
(
0
,
0
)
numpy
.
testing
.
assert_allclose
(
sp
.
energy
,
energy
)
numpy
.
testing
.
assert_allclose
(
sp
.
mu
,
mu
)
numpy
.
testing
.
assert_allclose
(
sp
.
I0
,
I0
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment