Skip to content

Commit 73d7b5f

Browse files
committed
add data for testing and some spelling fixes
1 parent a571fa2 commit 73d7b5f

File tree

4 files changed

+179
-13
lines changed

4 files changed

+179
-13
lines changed

src/sed/loader/cfel/dataframe.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,10 @@ def df_timestamp(self) -> pd.DataFrame:
144144
Uses the first_event_time_stamp_key to get initial timestamp and the
145145
ms_markers_key which is a dataset of exposure times same size as the index."""
146146

147-
first_tstamp = self.h5_file[self._config.get("first_event_time_stamp_key")][
147+
first_timestamp = self.h5_file[self._config.get("first_event_time_stamp_key")][
148148
0
149149
] # single value
150-
ts_start = pd.to_datetime(first_tstamp.decode())
150+
ts_start = pd.to_datetime(first_timestamp.decode())
151151
# actually in seconds but using milliseconds for consistency with mpes loader
152152
exposure_time = self.h5_file[self._config.get("ms_markers_key")][()]
153153

170 KB
Binary file not shown.

tests/data/loader/cfel/config.yaml

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
# This file contains the default configuration for the flash loader.
2+
3+
core:
4+
# defines the loader
5+
loader: cfel
6+
# Since this will run on maxwell most probably, we have a lot of cores at our disposal
7+
num_cores: 10
8+
# the ID number of the beamtime
9+
beamtime_id: 11021732
10+
# the year of the beamtime
11+
year: 2025
12+
13+
# The paths to the raw and parquet data directories. If these are not
14+
# provided, the loader will try to find the data based on year beamtimeID etc
15+
paths:
16+
# location of the raw data.
17+
raw: "tests/data/loader/cfel/"
18+
# location of the intermediate parquet files.
19+
processed: "tests/data/loader/cfel/parquet"
20+
21+
# The beamtime directories for different DAQ systems.
22+
# (Not to be changed by user)
23+
beamtime_dir:
24+
pg2: "/asap3/flash/gpfs/pg2/"
25+
cfel: "/asap3/fs-flash-o/gpfs/hextof/"
26+
27+
28+
dataframe:
29+
daq: fl1user3 # DAQ system name to resolve filenames/paths
30+
ubid_offset: 5 # Offset correction to the pulseId
31+
forward_fill_iterations: 0 # Number of iterations to fill the pulseId forward
32+
split_sector_id_from_dld_time: True # Remove reserved bits for dldSectorID from dldTimeSteps column
33+
sector_id_reserved_bits: 3 # Bits reserved for dldSectorID in the dldTimeSteps column
34+
sector_delays: [0., 0., 0., 0., 0., 0., 0., 0.] # Sector delays
35+
36+
first_event_time_stamp_key: /ScanParam/StartTime
37+
ms_markers_key: /SlowData/exposure_time
38+
39+
# Time and binning settings
40+
tof_binwidth: 2.0576131995767355E-11 # Base time-of-flight bin width in seconds
41+
tof_binning: 8 # Binning parameter for time-of-flight data
42+
43+
# Columns used for jitter correction
44+
index: [countId]
45+
jitter_cols: [dldPosX, dldPosY, dldTimeSteps]
46+
formats: [per_file, per_train, per_electron]
47+
fill_formats: [per_train] # Channels with this format will be forward filled
48+
49+
# Column settings
50+
columns:
51+
x: dldPosX
52+
corrected_x: X
53+
kx: kx
54+
y: dldPosY
55+
corrected_y: Y
56+
ky: ky
57+
tof: dldTimeSteps
58+
tof_ns: dldTime
59+
corrected_tof: tm
60+
timestamp: timeStamp
61+
auxiliary: dldAux
62+
sector_id: dldSectorID
63+
delay: delayStage
64+
corrected_delay: pumpProbeTime
65+
66+
units:
67+
# These are the units of the columns
68+
dldPosX: 'step'
69+
dldPosY: 'step'
70+
dldTimeSteps: 'step'
71+
tof_voltage: 'V'
72+
extractorVoltage: 'V'
73+
extractorCurrent: 'A'
74+
cryoTemperature: 'K'
75+
sampleTemperature: 'K'
76+
dldTime: 'ns'
77+
delay: 'ps'
78+
timeStamp: 's'
79+
energy: 'eV'
80+
E: 'eV'
81+
kx: '1/A'
82+
ky: '1/A'
83+
84+
# The channels to load.
85+
# channels have the following structure:
86+
# <channelAlias>:
87+
# format: per_pulse/per_electron/per_train
88+
# index_key: the hdf5 index key
89+
# dataset_key: the hdf5 dataset key
90+
# slice: int to slice a multidimensional data along axis=1. If not defined, there is no slicing
91+
# dtype: the datatype of the data
92+
# subChannels: further aliases for if the data is multidimensional and needs to be split in different cols
93+
# used currently for the auxiliary channel
94+
# <subChannelAlias>:
95+
# slice: int to slice a multidimensional data along axis=1. Must be defined
96+
# dtype: the datatype of the data
97+
98+
channels:
99+
# event key
100+
countId:
101+
format: per_file
102+
dataset_key: /DLD/NumOfEvents
103+
# detector x position
104+
dldPosX:
105+
format: per_electron
106+
dataset_key: /DLD/DLD/xPos
107+
# dtype: uint32
108+
109+
# detector y position
110+
dldPosY:
111+
format: per_electron
112+
dataset_key: /DLD/DLD/yPos
113+
# dtype: uint32
114+
115+
# Detector time-of-flight channel
116+
# if split_sector_id_from_dld_time is set to True, This this will generate
117+
# also the dldSectorID channel
118+
dldTimeSteps:
119+
format: per_electron
120+
dataset_key: /DLD/DLD/times
121+
# dtype: uint32
122+
123+
# The auxiliary channel has a special structure where the group further contains
124+
# a multidimensional structure so further aliases are defined below
125+
dldAux:
126+
format: per_train
127+
dataset_key: "/SlowData/hextof/dld/info/Aux"
128+
sub_channels:
129+
sampleBias:
130+
slice: 0
131+
dtype: float32
132+
tofVoltage:
133+
slice: 1
134+
dtype: float64
135+
extractorVoltage:
136+
slice: 2
137+
extractorCurrent:
138+
slice: 3
139+
cryoTemperature:
140+
slice: 4
141+
sampleTemperature:
142+
slice: 5
143+
dldTimeBinSize:
144+
slice: 15
145+
146+
vuRead:
147+
format: per_train
148+
dataset_key: /SlowData/hextof/logic/kmic1/Sample_VURead
149+
150+
151+
152+
# metadata collection from scicat
153+
# metadata:
154+
# archiver_url: <URL>
155+
156+
# The nexus collection routine shall be finalized soon for both instruments
157+
# nexus:
158+
# reader: "mpes"
159+
# definition: "NXmpes"
160+
# input_files: ["NXmpes_config-HEXTOF.json"]

tests/loader/test_loaders.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,13 @@
2222
test_data_dir = os.path.join(test_dir, "data")
2323

2424
read_types = ["one_file", "files", "one_folder", "folders", "one_run", "runs"]
25-
runs = {"generic": None, "mpes": ["30", "50"], "flash": ["43878", "43878"], "sxp": ["0016", "0016"]}
25+
runs = {
26+
"generic": None,
27+
"mpes": ["30", "50"],
28+
"flash": ["43878", "43878"],
29+
"sxp": ["0016", "0016"],
30+
"cfel": ["123"],
31+
}
2632

2733

2834
def get_loader_name_from_loader_object(loader: BaseLoader) -> str:
@@ -94,7 +100,7 @@ def test_has_correct_read_dataframe_func(loader: BaseLoader, read_type: str) ->
94100
assert callable(loader.read_dataframe)
95101

96102
# Fix for race condition during parallel testing
97-
if loader.__name__ in {"flash", "sxp"}:
103+
if loader.__name__ in {"flash", "sxp", "cfel"}:
98104
config = deepcopy(loader._config) # pylint: disable=protected-access
99105
config["core"]["paths"]["processed"] = Path(
100106
config["core"]["paths"]["processed"],
@@ -167,7 +173,7 @@ def test_has_correct_read_dataframe_func(loader: BaseLoader, read_type: str) ->
167173
assert loaded_dataframe.npartitions == expected_size
168174
assert isinstance(loaded_metadata, dict)
169175

170-
if loader.__name__ in {"flash", "sxp"}:
176+
if loader.__name__ in {"flash", "sxp", "cfel"}:
171177
loader = cast(FlashLoader, loader)
172178
loader._initialize_dirs()
173179
for file in os.listdir(Path(loader.processed_dir, "buffer")):
@@ -183,7 +189,7 @@ def test_timed_dataframe(loader: BaseLoader) -> None:
183189
"""
184190

185191
# Fix for race condition during parallel testing
186-
if loader.__name__ in {"flash", "sxp"}:
192+
if loader.__name__ in {"flash", "sxp", "cfel"}:
187193
config = deepcopy(loader._config) # pylint: disable=protected-access
188194
config["core"]["paths"]["processed"] = Path(
189195
config["core"]["paths"]["processed"],
@@ -201,7 +207,7 @@ def test_timed_dataframe(loader: BaseLoader) -> None:
201207
collect_metadata=False,
202208
)
203209
if loaded_timed_dataframe is None:
204-
if loader.__name__ in {"flash", "sxp"}:
210+
if loader.__name__ in {"flash", "sxp", "cfel"}:
205211
loader = cast(FlashLoader, loader)
206212
loader._initialize_dirs()
207213
for file in os.listdir(Path(loader.processed_dir, "buffer")):
@@ -211,7 +217,7 @@ def test_timed_dataframe(loader: BaseLoader) -> None:
211217
assert set(loaded_timed_dataframe.columns).issubset(set(loaded_dataframe.columns))
212218
assert loaded_timed_dataframe.npartitions == loaded_dataframe.npartitions
213219

214-
if loader.__name__ in {"flash", "sxp"}:
220+
if loader.__name__ in {"flash", "sxp", "cfel"}:
215221
loader = cast(FlashLoader, loader)
216222
loader._initialize_dirs()
217223
for file in os.listdir(Path(loader.processed_dir, "buffer")):
@@ -227,7 +233,7 @@ def test_get_count_rate(loader: BaseLoader) -> None:
227233
"""
228234

229235
# Fix for race condition during parallel testing
230-
if loader.__name__ in {"flash", "sxp"}:
236+
if loader.__name__ in {"flash", "sxp", "cfel"}:
231237
config = deepcopy(loader._config) # pylint: disable=protected-access
232238
config["core"]["paths"]["processed"] = Path(
233239
config["core"]["paths"]["processed"],
@@ -246,7 +252,7 @@ def test_get_count_rate(loader: BaseLoader) -> None:
246252
)
247253
loaded_time, loaded_countrate = loader.get_count_rate()
248254
if loaded_time is None and loaded_countrate is None:
249-
if loader.__name__ in {"flash", "sxp"}:
255+
if loader.__name__ in {"flash", "sxp", "cfel"}:
250256
loader = cast(FlashLoader, loader)
251257
loader._initialize_dirs()
252258
for file in os.listdir(Path(loader.processed_dir, "buffer")):
@@ -261,7 +267,7 @@ def test_get_count_rate(loader: BaseLoader) -> None:
261267
with pytest.raises(TypeError):
262268
loader.get_count_rate(illegal_kwd=True)
263269

264-
if loader.__name__ in {"flash", "sxp"}:
270+
if loader.__name__ in {"flash", "sxp", "cfel"}:
265271
loader = cast(FlashLoader, loader)
266272
loader._initialize_dirs()
267273
for file in os.listdir(Path(loader.processed_dir, "buffer")):
@@ -277,7 +283,7 @@ def test_get_elapsed_time(loader: BaseLoader) -> None:
277283
"""
278284

279285
# Fix for race condition during parallel testing
280-
if loader.__name__ in {"flash", "sxp"}:
286+
if loader.__name__ in {"flash", "sxp", "cfel"}:
281287
config = deepcopy(loader._config) # pylint: disable=protected-access
282288
config["core"]["paths"]["processed"] = Path(
283289
config["core"]["paths"]["processed"],
@@ -311,7 +317,7 @@ def test_get_elapsed_time(loader: BaseLoader) -> None:
311317
with pytest.raises(TypeError):
312318
loader.get_elapsed_time(illegal_kwd=True)
313319

314-
if loader.__name__ in {"flash", "sxp"}:
320+
if loader.__name__ in {"flash", "sxp", "cfel"}:
315321
loader = cast(FlashLoader, loader)
316322
loader._initialize_dirs()
317323
for file in os.listdir(Path(loader.processed_dir, "buffer")):

0 commit comments

Comments
 (0)