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
61e4a8d5
Commit
61e4a8d5
authored
5 years ago
by
Loïc Le Guyader
Browse files
Options
Downloads
Plain Diff
Merge branch 'open_data' into 'master'
Open data See merge request
!47
parents
5a43559e
22ed9436
No related branches found
No related tags found
1 merge request
!47
Open data
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Load.py
+17
-15
17 additions, 15 deletions
Load.py
with
17 additions
and
15 deletions
Load.py
+
17
−
15
View file @
61e4a8d5
...
@@ -6,8 +6,10 @@
...
@@ -6,8 +6,10 @@
Copyright (2019) SCS Team.
Copyright (2019) SCS Team.
"""
"""
import
numpy
as
np
import
numpy
as
np
from
karabo_data
import
RunDirectory
,
by_index
from
karabo_data
import
by_index
,
RunDirectory
from
karabo_data.read_machinery
import
find_proposal
import
xarray
as
xr
import
xarray
as
xr
import
os
mnemonics
=
{
mnemonics
=
{
# Machine
# Machine
...
@@ -362,23 +364,20 @@ mnemonics = {
...
@@ -362,23 +364,20 @@ mnemonics = {
'
dim
'
:
[
'
gott_pId
'
,
'
pixelId
'
]}
'
dim
'
:
[
'
gott_pId
'
,
'
pixelId
'
]}
}
}
def
load
(
fields
,
runNB
,
proposalNB
,
semesterNB
,
topic
=
'
SCS
'
,
display
=
False
,
def
load
(
fields
,
runNB
,
proposalNB
,
subFolder
=
'
raw
'
,
display
=
False
,
validate
=
False
,
validate
=
False
,
runpath
=
'
/gpfs/exfel/exp/{}/{}/{}/raw/r{:04d}/
'
,
subset
=
by_index
[:],
rois
=
{}):
subset
=
by_index
[:],
rois
=
{}):
"""
Load a run and extract the data. Output is an xarray with aligned trainIds
"""
Load a run and extract the data. Output is an xarray with aligned trainIds
Inputs:
Inputs:
fields: list of mnemonic strings to load specific data such as
"
fastccd
"
,
"
SCS_XGM
"
,
fields: list of mnemonic strings to load specific data such as
"
fastccd
"
,
"
SCS_XGM
"
,
or dictionnaries defining a custom mnemonic such as
or dictionnaries defining a custom mnemonic such as
{
"
extra
"
: {
'
SCS_CDIFFT_MAG/SUPPLY/CURRENT
'
,
'
actual_current.value
'
, None}}
{
"
extra
"
: {
'
SCS_CDIFFT_MAG/SUPPLY/CURRENT
'
,
'
actual_current.value
'
, None}}
runNB: run number as integer
runNB: (str, int) run number as integer
proposalNB: string or int of the proposal number e.g.
'
p002252
'
or 2252
proposalNB: (str, int) of the proposal number e.g.
'
p002252
'
or 2252
semesterNB: string or int of the semester number where the proposal data are saved
subFolder: (str) sub-folder from which to load the data. Use
'
raw
'
for raw
topic: string of the topic
data or
'
proc
'
for processed data.
display: boolean, whether to show the run.info or not
display: (bool) whether to show the run.info or not
validate: boolean, whether to run karabo-data-validate or not
validate: (bool) whether to run karabo-data-validate or not
runpath: a string to fromat the run folder path with topic,
semesterNB, proposalNB and runNB
subset: a subset of train that can be load with by_index[:5] for the
subset: a subset of train that can be load with by_index[:5] for the
first 5 trains
first 5 trains
rois: a dictionnary of mnemonics with a list of rois definition and the desired
rois: a dictionnary of mnemonics with a list of rois definition and the desired
...
@@ -389,15 +388,18 @@ def load(fields, runNB, proposalNB, semesterNB, topic='SCS', display=False,
...
@@ -389,15 +388,18 @@ def load(fields, runNB, proposalNB, semesterNB, topic='SCS', display=False,
Outputs:
Outputs:
res: an xarray DataSet with aligned trainIds
res: an xarray DataSet with aligned trainIds
"""
"""
if
type
(
proposalNB
)
==
int
:
if
isinstance
(
runNB
,
int
):
runNB
=
'
r{:04d}
'
.
format
(
runNB
)
if
isinstance
(
proposalNB
,
int
):
proposalNB
=
'
p{:06d}
'
.
format
(
proposalNB
)
proposalNB
=
'
p{:06d}
'
.
format
(
proposalNB
)
runFolder
=
run
path
.
format
(
topic
,
semesterNB
,
proposalNB
,
runNB
)
runFolder
=
os
.
path
.
join
(
find_proposal
(
proposalNB
),
subFolder
,
runNB
)
run
=
RunDirectory
(
runFolder
).
select_trains
(
subset
)
run
=
RunDirectory
(
runFolder
).
select_trains
(
subset
)
if
validate
:
if
validate
:
get_ipython
().
system
(
'
karabo-data-validate
'
+
runFolder
)
get_ipython
().
system
(
'
karabo-data-validate
'
+
runFolder
)
if
display
:
if
display
:
print
(
'
Loading data from {}
'
.
format
(
runFolder
))
run
.
info
()
run
.
info
()
keys
=
[]
keys
=
[]
...
...
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