@@ -93,26 +93,26 @@ def powgen_tutorial_sample_file(*, small: bool = False) -> str:
9393 The small version of the file was created using the following code, which keeps
9494 only 7 columns out of 154 (154 / 7 = 22):
9595
96- ``` python
97- import scipp as sc
98-
99- fname = 'PG3_4844_event.h5'
100- dg = sc.io.load_hdf5(fname)
101-
102- sizes = {"bank": 23, "column": 154, "row": 7}
103-
104- def foldme(x, dim):
105- return x.fold(dim=dim, sizes=sizes)['column', ::22].flatten(
106- dims=list(sizes.keys()), to=dim)
107-
108- small = sc.DataGroup({
109- 'data': foldme(dg['data'], 'spectrum'),
110- 'detector_info ': sc.Dataset(
111- coords={key: foldme(c, 'detector')
112- for key, c in dg['detector_info'].coords.items()} )
113- })
114- sc.io.save_hdf5(small, 'TEST_PG3_4844_event.h5' )
115- ```
96+ .. code-block:: python
97+
98+ import scipp as sc
99+
100+ fname = 'PG3_4844_event.h5'
101+ dg = sc.io.load_hdf5(fname)
102+
103+ sizes = {"bank": 23, "column": 154, "row": 7}
104+
105+ def foldme(x, dim):
106+ return x.fold(dim=dim, sizes=sizes)['column', ::22].flatten(
107+ dims=list(sizes.keys()), to=dim)
108+
109+ small = sc.DataGroup({
110+ 'data ': foldme(dg['data'], 'spectrum'),
111+ 'detector_info': sc.Dataset(
112+ coords={ key: foldme(c, 'detector' )
113+ for key, c in dg['detector_info'].coords.items() })
114+ } )
115+ sc.io.save_hdf5(small, 'TEST_PG3_4844_event.h5')
116116 """
117117 prefix = "TEST_" if small else ""
118118 ext = ".h5" if small else ".zip"
@@ -130,24 +130,24 @@ def powgen_tutorial_vanadium_file(*, small: bool = False) -> str:
130130 The small version of the file was created using the following code, which keeps
131131 only 7 columns out of 154 (154 / 7 = 22):
132132
133- ```python
134- import scipp as sc
133+ .. code-block:: python
134+
135+ import scipp as sc
135136
136- fname = 'PG3_4866_event.h5'
137- dg = sc.io.load_hdf5(fname)
137+ fname = 'PG3_4866_event.h5'
138+ dg = sc.io.load_hdf5(fname)
138139
139- sizes = {"bank": 23, "column": 154, "row": 7}
140+ sizes = {"bank": 23, "column": 154, "row": 7}
140141
141- def foldme(x, dim):
142- return x.fold(dim=dim, sizes=sizes)['column', ::22].flatten(
143- dims=list(sizes.keys()), to=dim)
142+ def foldme(x, dim):
143+ return x.fold(dim=dim, sizes=sizes)['column', ::22].flatten(
144+ dims=list(sizes.keys()), to=dim)
144145
145- small = sc.DataGroup({
146- 'data': foldme(dg['data'], 'spectrum'),
147- 'proton_charge': dg['proton_charge']['pulse_time', ::10]
148- })
149- sc.io.save_hdf5(small, 'TEST_PG3_4866_event.h5')
150- ```
146+ small = sc.DataGroup({
147+ 'data': foldme(dg['data'], 'spectrum'),
148+ 'proton_charge': dg['proton_charge']['pulse_time', ::10]
149+ })
150+ sc.io.save_hdf5(small, 'TEST_PG3_4866_event.h5')
151151 """
152152 prefix = "TEST_" if small else ""
153153 ext = ".h5" if small else ".zip"
@@ -165,24 +165,24 @@ def powgen_tutorial_calibration_file(*, small: bool = False) -> str:
165165 The small version of the file was created using the following code, which keeps
166166 only 7 columns out of 154 (154 / 7 = 22):
167167
168- ```python
169- import scipp as sc
168+ .. code-block:: python
169+
170+ import scipp as sc
170171
171- fname = 'PG3_FERNS_d4832_2011_08_24_spectrum.h5'
172- dg = sc.io.load_hdf5(fname)
172+ fname = 'PG3_FERNS_d4832_2011_08_24_spectrum.h5'
173+ dg = sc.io.load_hdf5(fname)
173174
174- sizes = {"bank": 23, "column": 154, "row": 7}
175+ sizes = {"bank": 23, "column": 154, "row": 7}
175176
176- def foldme(x, dim):
177- return x.fold(dim=dim, sizes=sizes)['column', ::22].flatten(
178- dims=list(sizes.keys()), to=dim)
177+ def foldme(x, dim):
178+ return x.fold(dim=dim, sizes=sizes)['column', ::22].flatten(
179+ dims=list(sizes.keys()), to=dim)
179180
180- small = sc.Dataset(
181- data={k: foldme(a, 'spectrum') for k, a in ds.items()},
182- coords={k: foldme(c, 'spectrum') for k, c in ds.coords.items()}
183- )
184- sc.io.save_hdf5(small, 'TEST_PG3_FERNS_d4832_2011_08_24_spectrum.h5')
185- ```
181+ small = sc.Dataset(
182+ data={k: foldme(a, 'spectrum') for k, a in ds.items()},
183+ coords={k: foldme(c, 'spectrum') for k, c in ds.coords.items()}
184+ )
185+ sc.io.save_hdf5(small, 'TEST_PG3_FERNS_d4832_2011_08_24_spectrum.h5')
186186 """
187187 prefix = "TEST_" if small else ""
188188 return _get_path (f"{ prefix } PG3_FERNS_d4832_2011_08_24_spectrum.h5" )
0 commit comments