Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
ToolBox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
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
SCS
ToolBox
Commits
ade737bd
Commit
ade737bd
authored
3 years ago
by
Laurent Mercadier
Browse files
Options
Downloads
Patches
Plain Diff
Use extra-data read machinery
parent
c56d2302
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/toolbox_scs/detectors/dssc_processing.py
+3
-2
3 additions, 2 deletions
src/toolbox_scs/detectors/dssc_processing.py
src/toolbox_scs/load.py
+8
-7
8 additions, 7 deletions
src/toolbox_scs/load.py
src/toolbox_scs/util/data_access.py
+0
-65
0 additions, 65 deletions
src/toolbox_scs/util/data_access.py
with
11 additions
and
74 deletions
src/toolbox_scs/detectors/dssc_processing.py
+
3
−
2
View file @
ade737bd
...
...
@@ -12,7 +12,7 @@ import pandas as pd
import
extra_data
as
ed
from
..
constants
import
mnemonics
as
_mnemonics
from
..
mnemonics_machinery
import
mnemonics
_for_run
from
.dssc_data
import
save_xarray
log
=
logging
.
getLogger
(
__name__
)
...
...
@@ -125,7 +125,8 @@ def _load_chunk_xgm(sel, xgm_mnemonic, stride):
-------
xarray.DataArray
"""
d
=
sel
.
get_array
(
*
_mnemonics
[
xgm_mnemonic
].
values
())
mnemonics
=
mnemonics_for_run
(
sel
)
d
=
sel
.
get_array
(
*
mnemonics
[
xgm_mnemonic
].
values
())
d
=
d
.
rename
(
new_name_or_name_dict
=
{
'
XGMbunchId
'
:
'
pulse
'
})
frame_coords
=
np
.
linspace
(
0
,
(
d
.
shape
[
1
]
-
1
)
*
stride
,
d
.
shape
[
1
],
dtype
=
int
)
d
=
d
.
assign_coords
({
'
pulse
'
:
frame_coords
})
...
...
This diff is collapsed.
Click to expand it.
src/toolbox_scs/load.py
+
8
−
7
View file @
ade737bd
...
...
@@ -9,15 +9,16 @@
"""
import
logging
import
os
import
numpy
as
np
import
xarray
as
xr
import
extra_data
as
ed
from
extra_data.read_machinery
import
find_proposal
from
.constants
import
mnemonics
as
_mnemonics
from
.mnemonics_machinery
import
mnemonics_for_run
from
.util.exceptions
import
ToolBoxValueError
,
ToolBoxPathError
from
.util.data_access
import
find_run_dir
from
.util.exceptions
import
ToolBoxValueError
import
toolbox_scs.detectors
as
tbdet
log
=
logging
.
getLogger
(
__name__
)
...
...
@@ -104,11 +105,11 @@ def load(proposalNB=None, runNB=None,
>>>
run
,
data
=
tb
.
load
(
2212
,
208
,
[
'
SCS_SA3
'
,
'
MCP2apd
'
,
'
nrj
'
])
"""
try
:
run
Folder
=
find_run_dir
(
proposalNB
,
runNB
)
except
ToolBoxPathError
as
err
:
log
.
error
(
f
"
{
err
.
message
}
"
)
raise
if
isinstance
(
runNB
,
int
)
:
run
NB
=
'
r{:04d}
'
.
format
(
runNB
)
if
isinstance
(
proposalNB
,
int
)
:
proposalNB
=
'
p{:06d}
'
.
format
(
proposalNB
)
runFolder
=
os
.
path
.
join
(
find_proposal
(
proposalNB
),
subFolder
,
runNB
)
run
=
ed
.
RunDirectory
(
runFolder
).
select_trains
(
subset
)
if
fields
is
None
:
return
run
,
xr
.
Dataset
()
...
...
This diff is collapsed.
Click to expand it.
src/toolbox_scs/util/data_access.py
deleted
100644 → 0
+
0
−
65
View file @
c56d2302
'''
Extensions to the extra_data package.
contributions should comply with pep8 code structure guidelines.
'''
import
os
import
logging
import
extra_data
as
ed
from
extra_data.read_machinery
import
find_proposal
from
..util.exceptions
import
ToolBoxPathError
log
=
logging
.
getLogger
(
__name__
)
def
find_run_dir
(
proposal
,
run
):
"""
Get run directory for given run.
This method is an extension to
'
find_proposal
'
in the extra_data
package and should eventually be transferred to the latter.
Parameters
----------
proposal: str, int
Proposal number
run: str, int
Run number
Returns
-------
rdir : str
Run directory as a string
Raises
------
ToolBoxPathError: Exception
Error raised if the constructed path does not exist. This may
happen when entering a non-valid run number, or the folder has
been renamed/removed.
Comment
-------
The rather unspecified Exeption raised, when entering a invalid proposal
number stems from the ed package -> to be fixed externally.
"""
rdir
=
None
try
:
pdir
=
find_proposal
(
f
'
p
{
proposal
:
06
d
}
'
)
rdir
=
os
.
path
.
join
(
pdir
,
f
'
raw/r
{
run
:
04
d
}
'
)
if
os
.
path
.
isdir
(
rdir
)
is
False
:
log
.
warning
(
"
Invalid directory: raise ToolBoxPathError.
"
)
msg
=
'
The constructed path does not exist.
'
raise
ToolBoxPathError
(
msg
,
rdir
)
except
ToolBoxPathError
:
raise
except
Exception
as
err
:
log
.
error
(
"
Unexpected error:
"
,
exc_info
=
True
)
raise
return
rdir
\ No newline at end of file
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