|
335 | 335 | " # Compute event arrival times at wfm choppers 1 and 2\n",
|
336 | 336 | " slopes = 1.0 / (alpha * item[\"wavelengths\"])\n",
|
337 | 337 | " intercepts = -slopes * item[\"birth_times\"]\n",
|
338 |
| - " times_at_wfm1 = (sc.norm(near_wfm_chopper[\"position\"].data) - intercepts) / slopes\n", |
339 |
| - " times_at_wfm2 = (sc.norm(far_wfm_chopper[\"position\"].data) - intercepts) / slopes\n", |
| 338 | + " times_at_wfm1 = (sc.norm(near_wfm_chopper[\"position\"]) - intercepts) / slopes\n", |
| 339 | + " times_at_wfm2 = (sc.norm(far_wfm_chopper[\"position\"]) - intercepts) / slopes\n", |
340 | 340 | " # Create a mask to see if neutrons go through one of the openings\n",
|
341 | 341 | " mask = sc.zeros(dims=times_at_wfm1.dims, shape=times_at_wfm1.shape, dtype=bool)\n",
|
342 | 342 | " for i in range(len(frames[\"time_min\"])):\n",
|
343 | 343 | " mask |= (\n",
|
344 | 344 | " (times_at_wfm1 >= near_time_open[\"frame\", i])\n",
|
345 | 345 | " & (times_at_wfm1 <= near_time_close[\"frame\", i])\n",
|
346 |
| - " & (item[\"wavelengths\"] >= frames[\"wavelength_min\"][\"frame\", i]).data\n", |
347 |
| - " & (item[\"wavelengths\"] <= frames[\"wavelength_max\"][\"frame\", i]).data\n", |
| 346 | + " & (item[\"wavelengths\"] >= frames[\"wavelength_min\"][\"frame\", i])\n", |
| 347 | + " & (item[\"wavelengths\"] <= frames[\"wavelength_max\"][\"frame\", i])\n", |
348 | 348 | " )\n",
|
349 | 349 | " item[\"valid_indices\"] = np.ravel(np.where(mask.values))"
|
350 | 350 | ]
|
|
387 | 387 | ")\n",
|
388 | 388 | "\n",
|
389 | 389 | "# Histogram the data\n",
|
| 390 | + "histogrammed_data = {}\n", |
390 | 391 | "for key, item in events.items():\n",
|
391 | 392 | " da = sc.DataArray(\n",
|
392 | 393 | " data=sc.ones(\n",
|
|
401 | 402 | " )\n",
|
402 | 403 | " },\n",
|
403 | 404 | " )\n",
|
404 |
| - " ds[key] = da.hist(time=time_coord)\n", |
| 405 | + " histogrammed_data[key] = da.hist(time=time_coord)\n", |
405 | 406 | "\n",
|
| 407 | + "ds = sc.Dataset(histogrammed_data, coords=ds.coords)\n", |
406 | 408 | "ds"
|
407 | 409 | ]
|
408 | 410 | },
|
|
700 | 702 | " unit=events_no_wfm[\"sample\"][\"arrival_times\"].unit,\n",
|
701 | 703 | ")\n",
|
702 | 704 | "\n",
|
703 |
| - "ds_no_wfm = sc.Dataset(coords=coords)\n", |
| 705 | + "data_no_wfm = {}\n", |
704 | 706 | "\n",
|
705 | 707 | "# Histogram the data\n",
|
706 | 708 | "for key, item in events_no_wfm.items():\n",
|
|
717 | 719 | " )\n",
|
718 | 720 | " },\n",
|
719 | 721 | " )\n",
|
720 |
| - " ds_no_wfm[key] = da.hist(tof=time_coord_no_wfm)\n", |
| 722 | + " data_no_wfm[key] = da.hist(tof=time_coord_no_wfm)\n", |
721 | 723 | "\n",
|
| 724 | + "ds_no_wfm = sc.Dataset(data_no_wfm, coords=coords)\n", |
722 | 725 | "ds_no_wfm"
|
723 | 726 | ]
|
724 | 727 | },
|
|
875 | 878 | " unit=events[\"sample\"][\"arrival_times\"].unit,\n",
|
876 | 879 | ")\n",
|
877 | 880 | "\n",
|
878 |
| - "ds_event = sc.Dataset(coords=coords)\n", |
| 881 | + "data_event = {}\n", |
879 | 882 | "\n",
|
880 | 883 | "# Bin the data\n",
|
881 | 884 | "for key, item in events.items():\n",
|
|
892 | 895 | " )\n",
|
893 | 896 | " },\n",
|
894 | 897 | " )\n",
|
895 |
| - " ds_event[key] = da.bin(time=time_coord)\n", |
| 898 | + " data_event[key] = da.bin(time=time_coord)\n", |
896 | 899 | "\n",
|
| 900 | + "ds_event = sc.Dataset(data_event, coords=coords)\n", |
897 | 901 | "ds_event"
|
898 | 902 | ]
|
899 | 903 | },
|
|
1114 | 1118 | "mimetype": "text/x-python",
|
1115 | 1119 | "name": "python",
|
1116 | 1120 | "nbconvert_exporter": "python",
|
1117 |
| - "pygments_lexer": "ipython3" |
| 1121 | + "pygments_lexer": "ipython3", |
| 1122 | + "version": "3.8.17" |
1118 | 1123 | }
|
1119 | 1124 | },
|
1120 | 1125 | "nbformat": 4,
|
|
0 commit comments