Skip to content
Snippets Groups Projects
Commit 4b1dc254 authored by Loïc Le Guyader's avatar Loïc Le Guyader
Browse files

Adds subset option on load to selectively load some trains with by_index

parent 8abfd8b9
No related branches found
No related tags found
No related merge requests found
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
Copyright (2019) SCS Team. Copyright (2019) SCS Team.
""" """
import numpy as np import numpy as np
from karabo_data import RunDirectory from karabo_data import RunDirectory by_index
import xarray as xr import xarray as xr
mnemonics = { mnemonics = {
...@@ -171,7 +171,8 @@ mnemonics = { ...@@ -171,7 +171,8 @@ mnemonics = {
} }
def load(fields, runNB, proposalNB, semesterNB, topic='SCS', display=False, def load(fields, runNB, proposalNB, semesterNB, topic='SCS', display=False,
validate=False, runpath='/gpfs/exfel/exp/{}/{}/{}/raw/r{:04d}/'): validate=False, runpath='/gpfs/exfel/exp/{}/{}/{}/raw/r{:04d}/',
subset=by_index[:]):
""" 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:
...@@ -186,13 +187,15 @@ def load(fields, runNB, proposalNB, semesterNB, topic='SCS', display=False, ...@@ -186,13 +187,15 @@ def load(fields, runNB, proposalNB, semesterNB, topic='SCS', display=False,
validate: boolean, whether to run karabo-data-validate or not validate: boolean, whether to run karabo-data-validate or not
runpath: a string to fromat the run folder path with topic, runpath: a string to fromat the run folder path with topic,
semesterNB, proposalNB and runNB semesterNB, proposalNB and runNB
subset: a subset of train that can be load with by_index[:5] for the
first 5 trains.
Outputs: Outputs:
res: an xarray DataSet with aligned trainIds res: an xarray DataSet with aligned trainIds
""" """
runFolder = runpath.format(topic, semesterNB, proposalNB, runNB) runFolder = runpath.format(topic, semesterNB, proposalNB, runNB)
run = RunDirectory(runFolder) run = RunDirectory(runFolder).select_trains(subset)
if validate: if validate:
get_ipython().system('karabo-data-validate ' + runFolder) get_ipython().system('karabo-data-validate ' + runFolder)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment