Skip to content

Commit 94a0b7d

Browse files
committed
exclude notebooks from format
1 parent 06bbf74 commit 94a0b7d

14 files changed

Lines changed: 52 additions & 107 deletions

packages/essimaging/docs/odin/odin-data-reduction.ipynb

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -201,14 +201,8 @@
201201
"outputs": [],
202202
"source": [
203203
"wf[MaskingRules] = {\n",
204-
" 'x_pixel_offset': lambda x: (\n",
205-
" (x < sc.scalar(-5.8e-3, unit='m').to(unit=x.unit))\n",
206-
" | (x > sc.scalar(5.8e-3, unit='m').to(unit=x.unit))\n",
207-
" ),\n",
208-
" 'y_pixel_offset': lambda y: (\n",
209-
" (y < sc.scalar(-5.8e-3, unit='m').to(unit=y.unit))\n",
210-
" | (y > sc.scalar(5.8e-3, unit='m').to(unit=y.unit))\n",
211-
" ),\n",
204+
" 'x_pixel_offset': lambda x: (x < sc.scalar(-5.8e-3, unit='m').to(unit=x.unit)) | (x > sc.scalar(5.8e-3, unit='m').to(unit=x.unit)),\n",
205+
" 'y_pixel_offset': lambda y: (y < sc.scalar(-5.8e-3, unit='m').to(unit=y.unit)) | (y > sc.scalar(5.8e-3, unit='m').to(unit=y.unit))\n",
212206
"}"
213207
]
214208
},
@@ -244,9 +238,10 @@
244238
"source": [
245239
"wbins = sc.linspace('wavelength', 1.1, 9.4, 301, unit='angstrom')\n",
246240
"\n",
247-
"normalized = wf.compute(CorrectedDetector[SampleRun]).bins.concat().hist(\n",
248-
" wavelength=wbins\n",
249-
") / wf.compute(CorrectedDetector[OpenBeamRun]).bins.concat().hist(wavelength=wbins)\n",
241+
"normalized = (\n",
242+
" wf.compute(CorrectedDetector[SampleRun]).bins.concat().hist(wavelength=wbins) /\n",
243+
" wf.compute(CorrectedDetector[OpenBeamRun]).bins.concat().hist(wavelength=wbins)\n",
244+
")\n",
250245
"\n",
251246
"normalized.plot()"
252247
]

packages/essimaging/docs/odin/odin-make-tof-lookup-table.ipynb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@
4242
"wf = time_of_flight.TofLookupTableWorkflow()\n",
4343
"wf[time_of_flight.DiskChoppers[AnyRun]] = disk_choppers\n",
4444
"wf[time_of_flight.SourcePosition] = source_position\n",
45-
"wf[time_of_flight.NumberOfSimulatedNeutrons] = (\n",
46-
" 200_000 # Increase this number for more reliable results\n",
47-
")\n",
45+
"wf[time_of_flight.NumberOfSimulatedNeutrons] = 200_000 # Increase this number for more reliable results\n",
4846
"wf[time_of_flight.SimulationSeed] = 1234\n",
4947
"wf[time_of_flight.PulseStride] = 2\n",
5048
"wf[time_of_flight.LtotalRange] = sc.scalar(5.0, unit=\"m\"), sc.scalar(65.0, unit=\"m\")\n",

packages/essimaging/docs/tbl/orca-image-normalization.ipynb

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -133,20 +133,16 @@
133133
"metadata": {},
134134
"outputs": [],
135135
"source": [
136-
"results = wf.compute(\n",
137-
" [\n",
138-
" RawDetector[SampleRun],\n",
139-
" CorrectedDetector[SampleRun],\n",
140-
" BackgroundSubtractedDetector[SampleRun],\n",
141-
" ]\n",
142-
")\n",
136+
"results = wf.compute([\n",
137+
" RawDetector[SampleRun],\n",
138+
" CorrectedDetector[SampleRun],\n",
139+
" BackgroundSubtractedDetector[SampleRun]\n",
140+
"])\n",
143141
"\n",
144142
"fig = pp.tiled(2, 2, hspace=0.3, wspace=0.3)\n",
145143
"fig[0, 0] = results[RawDetector[SampleRun]]['time', 0].plot(title='Raw data')\n",
146144
"fig[0, 1] = results[CorrectedDetector[SampleRun]]['time', 0].plot(title='Masks applied')\n",
147-
"fig[1, 0] = results[BackgroundSubtractedDetector[SampleRun]]['time', 0].plot(\n",
148-
" title='Background subtracted'\n",
149-
")\n",
145+
"fig[1, 0] = results[BackgroundSubtractedDetector[SampleRun]]['time', 0].plot(title='Background subtracted')\n",
150146
"fig[1, 1] = image['time', 0].plot(title='Final image')\n",
151147
"fig"
152148
]

packages/essimaging/docs/tbl/tbl-data-reduction.ipynb

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,7 @@
8181
"metadata": {},
8282
"outputs": [],
8383
"source": [
84-
"ngem['dim_0', 0].hist().plot(aspect='equal', title='First detection') + ngem[\n",
85-
" 'dim_0', 1\n",
86-
"].hist().plot(aspect='equal', title='Last detection')"
84+
"ngem['dim_0', 0].hist().plot(aspect='equal', title='First detection') + ngem['dim_0', 1].hist().plot(aspect='equal', title='Last detection')"
8785
]
8886
},
8987
{
@@ -141,10 +139,7 @@
141139
"ngem_tofs = wf.compute(TofDetector[SampleRun])\n",
142140
"ngem_wavs = wf.compute(WavelengthDetector[SampleRun])\n",
143141
"\n",
144-
"(\n",
145-
" ngem_tofs.bins.concat().hist(tof=100).plot()\n",
146-
" + ngem_wavs.bins.concat().hist(wavelength=100).plot()\n",
147-
")"
142+
"ngem_tofs.bins.concat().hist(tof=100).plot() + ngem_wavs.bins.concat().hist(wavelength=100).plot()"
148143
]
149144
},
150145
{
@@ -179,9 +174,7 @@
179174
"source": [
180175
"lims = {'vmin': 0, 'vmax': 4500}\n",
181176
"\n",
182-
"he3['he3_detector_bank0'].hist().plot(title='he3_bank0', **lims) + he3[\n",
183-
" 'he3_detector_bank1'\n",
184-
"].hist().plot(title='he3_bank1', **lims)"
177+
"he3['he3_detector_bank0'].hist().plot(title='he3_bank0', **lims) + he3['he3_detector_bank1'].hist().plot(title='he3_bank1', **lims)"
185178
]
186179
},
187180
{
@@ -205,9 +198,7 @@
205198
"for bank in ('he3_detector_bank0', 'he3_detector_bank1'):\n",
206199
" he3_wf[NeXusDetectorName] = bank\n",
207200
" he3_tofs[bank] = he3_wf.compute(TofDetector[SampleRun]).bins.concat().hist(tof=100)\n",
208-
" he3_wavs[bank] = (\n",
209-
" he3_wf.compute(WavelengthDetector[SampleRun]).bins.concat().hist(wavelength=100)\n",
210-
" )\n",
201+
" he3_wavs[bank] = he3_wf.compute(WavelengthDetector[SampleRun]).bins.concat().hist(wavelength=100)\n",
211202
"\n",
212203
"pp.plot(he3_tofs) + pp.plot(he3_wavs)"
213204
]

packages/essimaging/docs/tbl/tbl-make-tof-lookup-table.ipynb

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@
4040
"wf = time_of_flight.TofLookupTableWorkflow()\n",
4141
"wf[time_of_flight.DiskChoppers[AnyRun]] = {}\n",
4242
"wf[time_of_flight.SourcePosition] = source_position\n",
43-
"wf[time_of_flight.NumberOfSimulatedNeutrons] = (\n",
44-
" 200_000 # Increase this number for more reliable results\n",
45-
")\n",
43+
"wf[time_of_flight.NumberOfSimulatedNeutrons] = 200_000 # Increase this number for more reliable results\n",
4644
"wf[time_of_flight.SimulationSeed] = 1234\n",
4745
"wf[time_of_flight.PulseStride] = 1\n",
4846
"wf[time_of_flight.LtotalRange] = sc.scalar(5.0, unit=\"m\"), sc.scalar(35.0, unit=\"m\")\n",
@@ -76,9 +74,7 @@
7674
"metadata": {},
7775
"outputs": [],
7876
"source": [
79-
"table.plot(title=\"Predicted time-of-flight\") + sc.stddevs(table.array).plot(\n",
80-
" title=\"Standard deviation\"\n",
81-
")"
77+
"table.plot(title=\"Predicted time-of-flight\") + sc.stddevs(table.array).plot(title=\"Standard deviation\")"
8278
]
8379
},
8480
{

packages/essimaging/tools/make-tbl-images-from-ymir.ipynb

Lines changed: 23 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@
5353
"path = 'entry/instrument/histogram_mode_detectors/orca/data/'\n",
5454
"\n",
5555
"with h5.File(ymir_lego_images_path()) as f:\n",
56-
" lego_data = f[path + 'value'][()]\n",
57-
" lego_time = f[path + 'time'][()]"
56+
" lego_data = f[path+'value'][()]\n",
57+
" lego_time = f[path+'time'][()]"
5858
]
5959
},
6060
{
@@ -93,29 +93,17 @@
9393
"metadata": {},
9494
"outputs": [],
9595
"source": [
96-
"exposure_time = int(5e8) # 0.5s (made up)\n",
97-
"period = 1e9 / 14\n",
96+
"exposure_time = int(5e8) # 0.5s (made up)\n",
97+
"period = 1e9/14\n",
9898
"\n",
99-
"dark_charge_time = np.arange(\n",
100-
" float(dark_time[0]), float(dark_time[-1] + exposure_time), period\n",
101-
").astype('uint64')\n",
102-
"dark_charge_value = np.random.uniform(0.99, 1.01, size=len(dark_charge_time)).astype(\n",
103-
" 'float64'\n",
104-
")\n",
99+
"dark_charge_time = np.arange(float(dark_time[0]), float(dark_time[-1] + exposure_time), period).astype('uint64')\n",
100+
"dark_charge_value = np.random.uniform(0.99, 1.01, size=len(dark_charge_time)).astype('float64')\n",
105101
"\n",
106-
"ob_charge_time = np.arange(\n",
107-
" float(ob_time[0]), float(ob_time[-1] + exposure_time), period\n",
108-
").astype('uint64')\n",
109-
"ob_charge_value = np.random.uniform(0.99, 1.01, size=len(ob_charge_time)).astype(\n",
110-
" 'float64'\n",
111-
")\n",
102+
"ob_charge_time = np.arange(float(ob_time[0]), float(ob_time[-1] + exposure_time), period).astype('uint64')\n",
103+
"ob_charge_value = np.random.uniform(0.99, 1.01, size=len(ob_charge_time)).astype('float64')\n",
112104
"\n",
113-
"sample_charge_time = np.arange(\n",
114-
" float(sample_time[0]), float(sample_time[-1] + exposure_time), period\n",
115-
").astype('uint64')\n",
116-
"sample_charge_value = np.random.uniform(\n",
117-
" 0.99, 1.01, size=len(sample_charge_time)\n",
118-
").astype('float64')"
105+
"sample_charge_time = np.arange(float(sample_time[0]), float(sample_time[-1] + exposure_time), period).astype('uint64')\n",
106+
"sample_charge_value = np.random.uniform(0.99, 1.01, size=len(sample_charge_time)).astype('float64')"
119107
]
120108
},
121109
{
@@ -157,32 +145,31 @@
157145
" dset = entry.create_dataset(name, data=values)\n",
158146
" dset.attrs.update(attrs)\n",
159147
"\n",
160-
"\n",
161148
"def make_new_file(template_nexus_file, outfile, data, proton_charge):\n",
162149
" import shutil\n",
163-
"\n",
164150
" shutil.copyfile(template_nexus_file, outfile)\n",
165151
"\n",
166152
" # detector_path = 'entry/instrument/histogram_mode_detectors/orca' # ODIN\n",
167153
" detector_path = 'entry/instrument/orca_detector/' # TBL\n",
168154
" proton_charge_path = 'entry/neutron_prod_info/pulse_charge'\n",
169155
"\n",
170156
" with h5.File(outfile, \"r+\") as f:\n",
171-
" detector_data = f[detector_path + \"data\"]\n",
157+
"\n",
158+
" detector_data = f[detector_path+\"data\"]\n",
172159
" replace_dataset(detector_data, name=\"value\", values=data[\"value\"])\n",
173160
" replace_dataset(detector_data, name=\"time\", values=data[\"time\"])\n",
174161
"\n",
175162
" detector = f[detector_path]\n",
176163
" detector.copy('intensifier', detector, 'camera_exposure')\n",
177-
" exp = f[detector_path + \"camera_exposure\"]\n",
164+
" exp = f[detector_path+\"camera_exposure\"]\n",
178165
" replace_dataset(exp, name=\"value\", values=np.array([exposure_time]))\n",
179166
" replace_dataset(exp, name=\"average_value\", values=exposure_time)\n",
180167
" replace_dataset(exp, name=\"minimum_value\", values=exposure_time)\n",
181168
" replace_dataset(exp, name=\"maximum_value\", values=exposure_time)\n",
182-
" f[detector_path + \"camera_exposure/value\"].attrs['units'] = 'ns'\n",
183-
" f[detector_path + \"camera_exposure/average_value\"].attrs['units'] = 'ns'\n",
184-
" f[detector_path + \"camera_exposure/minimum_value\"].attrs['units'] = 'ns'\n",
185-
" f[detector_path + \"camera_exposure/maximum_value\"].attrs['units'] = 'ns'\n",
169+
" f[detector_path+\"camera_exposure/value\"].attrs['units'] = 'ns'\n",
170+
" f[detector_path+\"camera_exposure/average_value\"].attrs['units'] = 'ns'\n",
171+
" f[detector_path+\"camera_exposure/minimum_value\"].attrs['units'] = 'ns'\n",
172+
" f[detector_path+\"camera_exposure/maximum_value\"].attrs['units'] = 'ns'\n",
186173
"\n",
187174
" xoff = detector.create_dataset('x_pixel_offset', data=x_pixel_offset.values)\n",
188175
" xoff.attrs['units'] = str(x_pixel_offset.unit)\n",
@@ -195,15 +182,9 @@
195182
" pcharge = f[proton_charge_path]\n",
196183
" replace_dataset(pcharge, name=\"value\", values=proton_charge[\"value\"])\n",
197184
" replace_dataset(pcharge, name=\"time\", values=proton_charge[\"time\"])\n",
198-
" replace_dataset(\n",
199-
" pcharge, name=\"average_value\", values=proton_charge[\"value\"].mean()\n",
200-
" )\n",
201-
" replace_dataset(\n",
202-
" pcharge, name=\"minimum_value\", values=proton_charge[\"value\"].min()\n",
203-
" )\n",
204-
" replace_dataset(\n",
205-
" pcharge, name=\"maximum_value\", values=proton_charge[\"value\"].max()\n",
206-
" )"
185+
" replace_dataset(pcharge, name=\"average_value\", values=proton_charge[\"value\"].mean())\n",
186+
" replace_dataset(pcharge, name=\"minimum_value\", values=proton_charge[\"value\"].min())\n",
187+
" replace_dataset(pcharge, name=\"maximum_value\", values=proton_charge[\"value\"].max())"
207188
]
208189
},
209190
{
@@ -219,7 +200,7 @@
219200
" template_nexus_file=template_nexus_file,\n",
220201
" outfile=\"ymir_lego_dark_run.hdf\",\n",
221202
" data={\"value\": dark_data, \"time\": dark_time},\n",
222-
" proton_charge={\"value\": dark_charge_value, \"time\": dark_charge_time},\n",
203+
" proton_charge={\"value\": dark_charge_value, \"time\": dark_charge_time}\n",
223204
")"
224205
]
225206
},
@@ -234,7 +215,7 @@
234215
" template_nexus_file=template_nexus_file,\n",
235216
" outfile=\"ymir_lego_openbeam_run.hdf\",\n",
236217
" data={\"value\": ob_data, \"time\": ob_time},\n",
237-
" proton_charge={\"value\": ob_charge_value, \"time\": ob_charge_time},\n",
218+
" proton_charge={\"value\": ob_charge_value, \"time\": ob_charge_time}\n",
238219
")"
239220
]
240221
},
@@ -249,7 +230,7 @@
249230
" template_nexus_file=template_nexus_file,\n",
250231
" outfile=\"ymir_lego_sample_run.hdf\",\n",
251232
" data={\"value\": sample_data, \"time\": sample_time},\n",
252-
" proton_charge={\"value\": sample_charge_value, \"time\": sample_charge_time},\n",
233+
" proton_charge={\"value\": sample_charge_value, \"time\": sample_charge_time}\n",
253234
")"
254235
]
255236
}

packages/essimaging/tools/mcstas_to_nexus.ipynb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@
176176
" shutil.copyfile(template_nexus_file, outfile)\n",
177177
"\n",
178178
" with h5.File(outfile, \"r+\") as f:\n",
179+
"\n",
179180
" # Detector data\n",
180181
" if detector_entry_path is not None:\n",
181182
" # remove translation offset\n",

packages/essnmx/docs/developer/test-dataset.ipynb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
" zip(*[global_rng.integers(*HKL_RANGE, size=100) for _ in range(3)], strict=False)\n",
5353
")\n",
5454
"\n",
55-
"\n",
5655
"def create_mtz_data_frame(random_seed: int) -> pd.DataFrame:\n",
5756
" rng = np.random.default_rng(random_seed)\n",
5857
" intensities = np.sort(rng.normal(50, 20, size=10_000))[::-1] + (\n",

packages/essnmx/docs/user-guide/mcstas_workflow.ipynb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,7 @@
103103
"from cyclebane.graph import NodeName, IndexValues\n",
104104
"\n",
105105
"# Data from all selected detectors binned by panel, pixel and timeslice\n",
106-
"targets = [\n",
107-
" NodeName(NMXReducedDataGroup, IndexValues((\"panel\",), (i,))) for i in range(3)\n",
108-
"]\n",
106+
"targets = [NodeName(NMXReducedDataGroup, IndexValues((\"panel\",), (i,))) for i in range(3)]\n",
109107
"dg = merge_panels(*wf.compute(targets).values())\n",
110108
"dg"
111109
]

packages/essnmx/docs/user-guide/scaling_workflow.ipynb

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,9 @@
7373
"import sciline as sl\n",
7474
"import scipp as sc\n",
7575
"\n",
76-
"from ess.nmx.mtz_io import (\n",
77-
" providers as mtz_io_providers,\n",
78-
" default_parameters as mtz_io_params,\n",
79-
")\n",
76+
"from ess.nmx.mtz_io import providers as mtz_io_providers, default_parameters as mtz_io_params\n",
8077
"from ess.nmx.mtz_io import SpaceGroupDesc\n",
81-
"from ess.nmx.scaling import (\n",
82-
" providers as scaling_providers,\n",
83-
" default_parameters as scaling_params,\n",
84-
")\n",
78+
"from ess.nmx.scaling import providers as scaling_providers, default_parameters as scaling_params\n",
8579
"from ess.nmx.scaling import (\n",
8680
" WavelengthBins,\n",
8781
" FilteredEstimatedScaledIntensities,\n",

0 commit comments

Comments
 (0)