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
f17b2c92
Commit
f17b2c92
authored
Jul 22, 2021
by
payno
Browse files
[io][input_information] rework to insure url exists even if using a spec file
parent
04b410e8
Changes
2
Hide whitespace changes
Inline
Side-by-side
est/app/utils/__init__.py
View file @
f17b2c92
...
...
@@ -119,23 +119,8 @@ def get_xas_obj(
:param spec_input: tuple of Union[str, None, dict]
:param float timeout: read time out (for hdf5 only for now)
"""
if
input_information
.
is_spec_input
():
if
has_read_spectrum
:
energy
,
mu
=
read_spectrum
(
spec_file
=
input_information
.
spec_file
,
energy_col_name
=
input_information
.
input_energy_col_name
,
absorption_col_name
=
input_information
.
input_abs_col_name
,
monitor_col_name
=
input_information
.
input_monitor_col_name
,
energy_unit
=
input_information
.
energy_unit
,
scan_header_S
=
input_information
.
scan_title
,
)
spectrum
=
Spectrum
(
energy
=
energy
,
mu
=
mu
)
xas_obj
=
XASObject
(
energy
=
energy
,
spectra
=
(
spectrum
,),
dim1
=
1
,
dim2
=
1
)
else
:
raise
ValueError
(
"Unable to read spectrum"
)
else
:
sp
,
en
,
conf
=
read_xas
(
information
=
input_information
,
timeout
=
timeout
)
xas_obj
=
XASObject
(
spectra
=
sp
,
energy
=
en
,
configuration
=
conf
)
sp
,
en
,
conf
=
read_xas
(
information
=
input_information
,
timeout
=
timeout
)
xas_obj
=
XASObject
(
spectra
=
sp
,
energy
=
en
,
configuration
=
conf
)
attr_names
=
"I0"
,
"I1"
,
"I2"
,
"mu_ref"
attr_values
=
(
getattr
(
input_information
,
"I0"
,
None
),
...
...
est/io/utils/information.py
View file @
f17b2c92
...
...
@@ -57,6 +57,22 @@ class SpecInputInformation:
self
.
input_abs_col_name
=
input_abs_col_name
self
.
input_monitor_col_name
=
input_monitor_col_name
@
property
def
spectra_url
(
self
):
return
DataUrl
(
file_path
=
self
.
spec_file
,
scheme
=
"PyMca"
,
data_path
=
self
.
input_abs_col_name
,
)
@
property
def
channel_url
(
self
):
return
DataUrl
(
file_path
=
self
.
spec_file
,
scheme
=
"PyMca"
,
data_path
=
self
.
energy_abs_col_name
,
)
@
property
def
spec_file
(
self
):
return
self
.
__spec_file
...
...
@@ -165,23 +181,41 @@ class InputInformation:
def
is_valid
(
self
):
"""Return True if at least a spec file is provided or some url
information"""
return
self
.
spec_file
is
not
None
or
self
.
has_url_information
return
self
.
has_url_information
@
property
def
spectra_url
(
self
):
return
self
.
__spectra_url
if
self
.
is_spec_input
():
return
self
.
spec_info
.
spectra_url
else
:
return
self
.
__spectra_url
@
spectra_url
.
setter
def
spectra_url
(
self
,
url
):
if
url
is
not
None
and
self
.
is_spec_input
():
raise
ValueError
(
"You cannot set an url for channel because a "
"this instance is already associated to spec "
"information."
)
# TODO: maybe we want to add a check to create a DataUrl if this is a string...
self
.
__spectra_url
=
url
@
property
def
channel_url
(
self
):
return
self
.
__channel_url
if
self
.
is_spec_input
():
return
self
.
spec_info
.
channel_url
else
:
return
self
.
__channel_url
@
channel_url
.
setter
def
channel_url
(
self
,
url
):
if
url
is
not
None
and
self
.
is_spec_input
():
raise
ValueError
(
"You cannot set an url for channel because a "
"this instance is already associated to spec "
"information."
)
self
.
__channel_url
=
url
@
property
...
...
@@ -246,6 +280,12 @@ class InputInformation:
@
mu_ref_url
.
setter
def
mu_ref_url
(
self
,
url
):
if
url
is
not
None
and
self
.
is_spec_input
():
raise
ValueError
(
"You cannot set an url for channel because a "
"this instance is already associated to spec"
"information."
)
self
.
__mu_ref_url
=
url
@
property
...
...
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