|
36 | 36 | "\n",
|
37 | 37 | "from pathlib import Path\n",
|
38 | 38 | "import os\n",
|
| 39 | + "import numpy as np\n", |
39 | 40 | "\n",
|
40 | 41 | "from sed import SedProcessor\n",
|
41 | 42 | "from sed.dataset import dataset\n",
|
|
206 | 207 | "metadata": {},
|
207 | 208 | "outputs": [],
|
208 | 209 | "source": [
|
209 |
| - "sp_ph_peak.dataframe" |
| 210 | + "sp_ph_peak.dataframe[[\"dldTimeSteps\", \"dldSectorID\"]].head()" |
210 | 211 | ]
|
211 | 212 | },
|
212 | 213 | {
|
|
233 | 234 | "outputs": [],
|
234 | 235 | "source": [
|
235 | 236 | "axes = ['dldSectorID', 'dldTimeSteps','dldPosX','dldPosY']\n",
|
236 |
| - "ranges = [[0,8], [2360,2760], [435,885], [445,895]]\n", |
237 |
| - "bins = [8,400,225,225]\n", |
238 |
| - "res_ph_peak = sp_ph_peak.compute(bins=bins, axes=axes, ranges=ranges)\n", |
239 |
| - "\n", |
240 |
| - "res_ph_peak['dldPosX'].attrs['unit'] = 'µm'\n", |
241 |
| - "res_ph_peak['dldPosY'].attrs['unit'] = 'µm'\n", |
242 |
| - "\n", |
243 |
| - "fig,ax = plt.subplots(1,2,figsize=(6,2.25), layout='tight')\n", |
244 |
| - "res_ph_peak.sum(('dldSectorID','dldPosX','dldPosY')).plot(ax=ax[0])\n", |
245 |
| - "res_ph_peak.mean(('dldSectorID','dldTimeSteps')).plot(ax=ax[1], robust=True)" |
246 |
| - ] |
247 |
| - }, |
248 |
| - { |
249 |
| - "cell_type": "markdown", |
250 |
| - "id": "4fe4915e", |
251 |
| - "metadata": {}, |
252 |
| - "source": [ |
253 |
| - "### time-of-flight spectrum\n", |
254 |
| - "To see the photon peak on the ns scale we plot the time-of-flight spectrum. This is done here." |
255 |
| - ] |
256 |
| - }, |
257 |
| - { |
258 |
| - "cell_type": "code", |
259 |
| - "execution_count": null, |
260 |
| - "id": "ebdf8f75", |
261 |
| - "metadata": {}, |
262 |
| - "outputs": [], |
263 |
| - "source": [ |
264 |
| - "sp_ph_peak.append_tof_ns_axis()" |
| 237 | + "ranges = [[0,8], [2360,2460], [435,885], [445,895]]\n", |
| 238 | + "bins = [8,700,225,225]\n", |
| 239 | + "res_ph_peak = sp_ph_peak.compute(bins=bins, axes=axes, ranges=ranges)" |
265 | 240 | ]
|
266 | 241 | },
|
267 | 242 | {
|
268 | 243 | "cell_type": "code",
|
269 | 244 | "execution_count": null,
|
270 |
| - "id": "55c96a30", |
| 245 | + "id": "e326e279", |
271 | 246 | "metadata": {},
|
272 | 247 | "outputs": [],
|
273 | 248 | "source": [
|
274 |
| - "axes = ['dldSectorID', 'dldTime','dldPosX','dldPosY']\n", |
275 |
| - "ranges = [[0,8], [390,460], [435,885], [445,895]]\n", |
276 |
| - "bins = [8,700,225,225]\n", |
277 |
| - "res_ph_peak_ns = sp_ph_peak.compute(bins=bins, axes=axes, ranges=ranges)\n", |
278 |
| - "\n", |
279 |
| - "res_ph_peak_ns['dldPosX'].attrs['unit'] = 'µm'\n", |
280 |
| - "res_ph_peak_ns['dldPosY'].attrs['unit'] = 'µm'\n", |
281 |
| - "\n", |
| 249 | + "res_ph_peak['dldPosX'].attrs['unit'] = 'pixel'\n", |
| 250 | + "res_ph_peak['dldPosY'].attrs['unit'] = 'pixel'\n", |
282 | 251 | "fig,ax = plt.subplots(1,2,figsize=(6,2.25), layout='tight')\n",
|
283 |
| - "res_ph_peak_ns.sum(('dldSectorID','dldPosX','dldPosY')).plot(ax=ax[0])\n", |
284 |
| - "res_ph_peak_ns.mean(('dldSectorID','dldTime')).plot(ax=ax[1], robust=True)" |
| 252 | + "res_ph_peak.sum(('dldSectorID','dldPosX','dldPosY')).plot(ax=ax[0])\n", |
| 253 | + "res_ph_peak.sel(dldTimeSteps=slice(2380,2400)).mean(('dldSectorID','dldTimeSteps')).plot(ax=ax[1], robust=True)" |
285 | 254 | ]
|
286 | 255 | },
|
287 | 256 | {
|
|
299 | 268 | "metadata": {},
|
300 | 269 | "outputs": [],
|
301 | 270 | "source": [
|
302 |
| - "ph_peak_ns = res_ph_peak_ns.sel(dldTime=slice(390,397)).sum(('dldPosX','dldPosY'))\n", |
| 271 | + "ph_peak = res_ph_peak.sel(dldTimeSteps=slice(2380,2400)).sum(('dldPosX','dldPosY'))\n", |
303 | 272 | "plt.figure(figsize=(6,4))\n",
|
304 |
| - "ph_peak_ns.sum('dldSectorID').plot()" |
| 273 | + "ph_peak.sum('dldSectorID').plot()" |
305 | 274 | ]
|
306 | 275 | },
|
307 | 276 | {
|
|
312 | 281 | "Let's check the signal (photon peak) from every single sector"
|
313 | 282 | ]
|
314 | 283 | },
|
| 284 | + { |
| 285 | + "cell_type": "code", |
| 286 | + "execution_count": null, |
| 287 | + "id": "2fc9f73c", |
| 288 | + "metadata": {}, |
| 289 | + "outputs": [], |
| 290 | + "source": [ |
| 291 | + "plt.figure(figsize=(6,4))\n", |
| 292 | + "ph_peak.plot()" |
| 293 | + ] |
| 294 | + }, |
315 | 295 | {
|
316 | 296 | "cell_type": "code",
|
317 | 297 | "execution_count": null,
|
|
320 | 300 | "outputs": [],
|
321 | 301 | "source": [
|
322 | 302 | "plt.figure(figsize=(6,4))\n",
|
323 |
| - "for i, item in enumerate(ph_peak_ns):\n", |
| 303 | + "for i, item in enumerate(ph_peak):\n", |
324 | 304 | " item.plot(label=f'S{i}')\n",
|
325 | 305 | " plt.legend()"
|
326 | 306 | ]
|
|
330 | 310 | "id": "9a43f35b",
|
331 | 311 | "metadata": {},
|
332 | 312 | "source": [
|
333 |
| - "### Width of the photon peak" |
| 313 | + "### Position of the photon peak" |
334 | 314 | ]
|
335 | 315 | },
|
336 | 316 | {
|
|
342 | 322 | "source": [
|
343 | 323 | "Gauss_mod = GaussianModel()\n",
|
344 | 324 | "\n",
|
345 |
| - "x=ph_peak_ns['dldTime']\n", |
346 |
| - "y=ph_peak_ns.sum('dldSectorID')\n", |
| 325 | + "x=ph_peak['dldTimeSteps']\n", |
| 326 | + "y=ph_peak.sum('dldSectorID')\n", |
347 | 327 | "\n",
|
348 |
| - "pars = Gauss_mod.make_params(amplitude=1360.0, center=393.2, sigma=0.19)\n", |
| 328 | + "pars = Gauss_mod.make_params(amplitude=200, center=2390, sigma=1)\n", |
349 | 329 | "# pars = Gauss_mod.guess(y, x=x)\n",
|
350 | 330 | "out = Gauss_mod.fit(y, pars, x=x)\n",
|
351 | 331 | "\n",
|
352 | 332 | "print(out.fit_report())\n",
|
353 | 333 | "plt.figure(figsize=(6,4))\n",
|
354 | 334 | "plt.plot(x,y, 'rx')\n",
|
355 |
| - "plt.plot(x,out.best_fit, \"b\", label=\"FWHM = {:.3f} ns\".format(out.values['fwhm']))\n", |
| 335 | + "plt.plot(x,out.best_fit, \"b\", label=\"FWHM = {:.3f}\".format(out.values['fwhm']))\n", |
356 | 336 | "plt.title(f'Run {run_number}, full photon peak')\n",
|
357 | 337 | "plt.legend(loc=\"best\")\n",
|
358 | 338 | "plt.xlabel(\"dldTime [ns]\")"
|
|
374 | 354 | "outputs": [],
|
375 | 355 | "source": [
|
376 | 356 | "plt.figure(figsize=(6,4))\n",
|
377 |
| - "for i, item in enumerate(ph_peak_ns):\n", |
378 |
| - " x=ph_peak_ns['dldTime']\n", |
| 357 | + "sector_delays = np.zeros(8)\n", |
| 358 | + "for i, item in enumerate(ph_peak):\n", |
| 359 | + " x=ph_peak['dldTimeSteps']\n", |
379 | 360 | " y=item\n",
|
380 |
| - " pars = Gauss_mod.make_params(amplitude=800.1, center=393.0, sigma=0.3)\n", |
| 361 | + " pars = Gauss_mod.make_params(amplitude=200, center=2390, sigma=1)\n", |
381 | 362 | " out = Gauss_mod.fit(y, pars, x=x)\n",
|
382 |
| - " Center = 393.38961071\n", |
| 363 | + " Center = 2388.984276411258\n", |
383 | 364 | " Diff = \"{:.3f}\".format(Center - out.values['center'])\n",
|
| 365 | + " sector_delays[i] = (out.values['center'])\n", |
384 | 366 | " FWHM = \"{:.3f}\".format(out.values['fwhm'])\n",
|
385 |
| - " item.plot(label=f'S{i}={Diff}, FWHM = {FWHM} ns')\n", |
| 367 | + " item.plot(label=f'S{i}={Diff}, FWHM = {FWHM}')\n", |
386 | 368 | " plt.title(f'Run {run_number}, individual sectors, not aligned')\n",
|
387 | 369 | " plt.legend()"
|
388 | 370 | ]
|
389 | 371 | },
|
| 372 | + { |
| 373 | + "cell_type": "code", |
| 374 | + "execution_count": null, |
| 375 | + "id": "a41757a4", |
| 376 | + "metadata": {}, |
| 377 | + "outputs": [], |
| 378 | + "source": [ |
| 379 | + "sector_delays = sector_delays - np.mean(sector_delays)\n", |
| 380 | + "sector_delays" |
| 381 | + ] |
| 382 | + }, |
390 | 383 | {
|
391 | 384 | "cell_type": "markdown",
|
392 | 385 | "id": "ba4edbe6",
|
|
403 | 396 | "metadata": {},
|
404 | 397 | "outputs": [],
|
405 | 398 | "source": [
|
406 |
| - "sp_ph_peak.align_dld_sectors()" |
| 399 | + "sp_ph_peak.align_dld_sectors(sector_delays=sector_delays)" |
| 400 | + ] |
| 401 | + }, |
| 402 | + { |
| 403 | + "cell_type": "code", |
| 404 | + "execution_count": null, |
| 405 | + "id": "e1e7ed7a", |
| 406 | + "metadata": {}, |
| 407 | + "outputs": [], |
| 408 | + "source": [ |
| 409 | + "sp_ph_peak.dataframe[[\"dldTimeSteps\", \"dldSectorID\"]].head()" |
407 | 410 | ]
|
408 | 411 | },
|
409 | 412 | {
|
|
422 | 425 | "metadata": {},
|
423 | 426 | "outputs": [],
|
424 | 427 | "source": [
|
425 |
| - "axes = ['dldSectorID', 'dldTime','dldPosX','dldPosY']\n", |
426 |
| - "ranges = [[0,8], [390,460], [435,885], [445,895]]\n", |
| 428 | + "axes = ['dldSectorID', 'dldTimeSteps','dldPosX','dldPosY']\n", |
| 429 | + "ranges = [[0,8], [2360,2460], [435,885], [445,895]]\n", |
427 | 430 | "bins = [8,700,225,225]\n",
|
428 |
| - "res_ph_peak_ns_align = sp_ph_peak.compute(bins=bins, axes=axes, ranges=ranges)\n", |
| 431 | + "res_ph_peak_align = sp_ph_peak.compute(bins=bins, axes=axes, ranges=ranges)\n", |
429 | 432 | "\n",
|
430 |
| - "ph_peak_ns_align = res_ph_peak_ns_align.sel(dldTime=slice(390,397)).sum(('dldPosX','dldPosY'))\n", |
| 433 | + "ph_peak_align = res_ph_peak_align.sel(dldTimeSteps=slice(2380,2400)).sum(('dldPosX','dldPosY'))\n", |
431 | 434 | "\n",
|
432 | 435 | "fig,ax = plt.subplots(1,2,figsize=(6,3.25), layout='tight')\n",
|
433 |
| - "ph_peak_ns_align.sum('dldSectorID').plot(ax=ax[0])\n", |
434 |
| - "for i, item in enumerate(ph_peak_ns_align):\n", |
| 436 | + "ph_peak_align.sum('dldSectorID').plot(ax=ax[0])\n", |
| 437 | + "for i, item in enumerate(ph_peak_align):\n", |
435 | 438 | " item.plot(ax=ax[1], label=f'S{i}')\n",
|
436 | 439 | " plt.legend()"
|
437 | 440 | ]
|
|
445 | 448 | "source": [
|
446 | 449 | "Gauss_mod = GaussianModel()\n",
|
447 | 450 | "\n",
|
448 |
| - "x=ph_peak_ns_align['dldTime']\n", |
449 |
| - "y=ph_peak_ns_align.sum('dldSectorID')\n", |
| 451 | + "x=ph_peak_align['dldTimeSteps']\n", |
| 452 | + "y=ph_peak_align.sum('dldSectorID')\n", |
450 | 453 | "\n",
|
451 |
| - "pars = Gauss_mod.make_params(amplitude=1360.1, center=393.2, sigma=0.2)\n", |
452 |
| - "# pars = Gauss_mod.guess(y, x=x)\n", |
| 454 | + "pars = Gauss_mod.make_params(amplitude=200, center=2390, sigma=1)\n", |
453 | 455 | "out = Gauss_mod.fit(y, pars, x=x)\n",
|
454 | 456 | "\n",
|
455 | 457 | "print(out.fit_report())\n",
|
456 | 458 | "plt.figure(figsize=(6,4))\n",
|
457 | 459 | "plt.plot(x,y, 'rx')\n",
|
458 |
| - "plt.plot(x,out.best_fit, \"b\", label=\"FWHM = {:.3f} ns\".format(out.values['fwhm']))\n", |
| 460 | + "plt.plot(x,out.best_fit, \"b\", label=\"FWHM = {:.3f}\".format(out.values['fwhm']))\n", |
459 | 461 | "plt.title(f'Run {run_number}, full photon peak, sectors aligned')\n",
|
460 | 462 | "plt.legend(loc=\"best\")\n",
|
461 | 463 | "plt.xlabel(\"dldTime [ns]\")\n",
|
|
486 | 488 | "outputs": [],
|
487 | 489 | "source": [
|
488 | 490 | "plt.figure(figsize=(6,4))\n",
|
489 |
| - "for i, item in enumerate(ph_peak_ns):\n", |
490 |
| - " x=ph_peak_ns_align['dldTime']\n", |
| 491 | + "for i, item in enumerate(ph_peak_align):\n", |
| 492 | + " x=ph_peak_align['dldTimeSteps']\n", |
491 | 493 | " y=item\n",
|
492 |
| - " pars = Gauss_mod.make_params(amplitude=800.0, center=393.0, sigma=0.3)\n", |
| 494 | + " pars = Gauss_mod.make_params(amplitude=800.0, center=2390, sigma=1)\n", |
493 | 495 | " out = Gauss_mod.fit(y, pars, x=x)\n",
|
494 |
| - " Center = 393.3899565\n", |
| 496 | + " Center = 2388.984276411258\n", |
495 | 497 | " Diff = \"{:.3f}\".format(Center - out.values['center'])\n",
|
496 | 498 | " FWHM = \"{:.3f}\".format(out.values['fwhm'])\n",
|
497 | 499 | " item.plot(label=f'S{i}={Diff}, FWHM = {FWHM} ns')\n",
|
|
0 commit comments