{"id":820,"date":"2025-07-20T04:43:21","date_gmt":"2025-07-20T04:43:21","guid":{"rendered":"https:\/\/synchrotron-light.net\/wp\/?page_id=820"},"modified":"2025-07-20T04:43:21","modified_gmt":"2025-07-20T04:43:21","slug":"chapter-12-quantum-optics-of-synchrotron-light","status":"publish","type":"page","link":"https:\/\/synchrotron-light.net\/wp\/?page_id=820","title":{"rendered":"Chapter 12: Quantum optics of synchrotron light"},"content":{"rendered":"<p>Below is a set of python codes associated with Chapter 12 of Daniele Pelliccia and David M. Paganin, &#8220;Synchrotron Light: A Physics Journey from Laboratory to Cosmos&#8221; (Oxford University Press, 2025).<\/p>\n<p>In order to run any of these python codes, you will need to include the following header.<\/p>\n<pre class=\"theme:obsidian lang:python decode:true\">import numpy as np\r\nimport matplotlib.pyplot as plt\r\nfrom scipy.stats import poisson\r\n\r\nsynchrotron_style = {\r\n    'font.family': 'FreeSerif',\r\n    'font.size': 30,\r\n    'axes.linewidth': 2.0,\r\n    'axes.edgecolor': 'black',\r\n    'grid.color': '#5b5b5b',\r\n    'grid.linewidth': 1.2,\r\n}<\/pre>\n<h2 id=\"The-basics:-plotting-a-radial-field\">Poisson distribution<\/h2>\n<p>See Fig. 12.5<\/p>\n<pre class=\"theme:obsidian lang:python decode:true\">n = np.arange(0,80,1)\r\nP = np.zeros_like(n).astype('float32')\r\nlinecol = ['r', 'g', 'b', 'm']\r\nmk = ['ro','sg', 'db', '*m'] \r\nwith plt.style.context(('seaborn-v0_8-whitegrid')):\r\n    plt.rcParams.update(synchrotron_style)\r\n    fig = plt.figure(figsize=(18,9.6))\r\n    \r\n    for k, mu in enumerate([2,5,10,50]):\r\n        for i,j in enumerate(n):\r\n\r\n            P[i] = poisson.pmf(j, mu)\r\n        \r\n        markerline, stemline, baseline = plt.stem(n, P, linefmt=linecol[k], basefmt =linecol[k], markerfmt=mk[k], label=\"$\\mu = $\"+str(mu))\r\n        plt.setp(markerline, markersize = 10)  \r\n\r\n\r\n        plt.xticks(fontsize = 28)\r\n        plt.yticks(fontsize = 28)\r\n    plt.legend(fontsize=30, frameon=True, framealpha=1)\r\n    plt.show()<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-821\" src=\"https:\/\/synchrotron-light.net\/wp\/wp-content\/uploads\/2025\/07\/shynchrotron-light-12.5-1024x545.png\" alt=\"\" width=\"700\" height=\"373\" \/><\/p>\n<h2>Poisson statistics<\/h2>\n<p>The different panels of Fig. 12.7 can be produced with the code below, by changing the value of N.<\/p>\n<pre class=\"theme:obsidian lang:python decode:true\">N = 5\r\nfunc = 0.1+N*noiseless.reshape(-1,1).flatten()\r\n\r\nfunc1 = np.zeros_like(func)\r\nfor i,j in enumerate(func):\r\n    func1[i] = poisson.rvs(j, size=1)[0]\r\n\r\nnoisy = func1.reshape(101,101)    \r\n\r\nfig = plt.figure(figsize=(10,10))\r\nplt.imshow(noisy, cmap = 'gray')\r\nplt.axis('equal')\r\nplt.axis('off')\r\nplt.show()<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-822\" src=\"https:\/\/synchrotron-light.net\/wp\/wp-content\/uploads\/2025\/07\/shynchrotron-light-12.7.png\" alt=\"\" width=\"572\" height=\"558\" srcset=\"https:\/\/synchrotron-light.net\/wp\/wp-content\/uploads\/2025\/07\/shynchrotron-light-12.7.png 572w, https:\/\/synchrotron-light.net\/wp\/wp-content\/uploads\/2025\/07\/shynchrotron-light-12.7-480x468.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 572px, 100vw\" \/><\/p>\n<h2>Time boxes<\/h2>\n<p>See Fig. 12.8.<\/p>\n<pre class=\"theme:obsidian lang:python decode:true\">boxes = [0,0,0,1,0,0,0,0,1,0,1,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0]\r\ntime = np.arange(0, len(boxes),1)\r\n\r\nwith plt.style.context(('seaborn-v0_8-whitegrid')):\r\n    plt.rcParams.update(synchrotron_style)\r\n    fig = plt.figure(figsize=(14,7))\r\n    \r\n    plt.plot(time, boxes, 'o-', lw=4)<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-823\" src=\"https:\/\/synchrotron-light.net\/wp\/wp-content\/uploads\/2025\/07\/shynchrotron-light-12.8-1024x527.png\" alt=\"\" width=\"700\" height=\"360\" \/><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Below is a set of python codes associated with Chapter 12 of Daniele Pelliccia and David M. Paganin, &#8220;Synchrotron Light: A Physics Journey from Laboratory to Cosmos&#8221; (Oxford University Press, 2025). In order to run any of these python codes, you will need to include the following header. import numpy as np import matplotlib.pyplot as [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":79,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"class_list":["post-820","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/synchrotron-light.net\/wp\/index.php?rest_route=\/wp\/v2\/pages\/820","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/synchrotron-light.net\/wp\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/synchrotron-light.net\/wp\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/synchrotron-light.net\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/synchrotron-light.net\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=820"}],"version-history":[{"count":1,"href":"https:\/\/synchrotron-light.net\/wp\/index.php?rest_route=\/wp\/v2\/pages\/820\/revisions"}],"predecessor-version":[{"id":824,"href":"https:\/\/synchrotron-light.net\/wp\/index.php?rest_route=\/wp\/v2\/pages\/820\/revisions\/824"}],"up":[{"embeddable":true,"href":"https:\/\/synchrotron-light.net\/wp\/index.php?rest_route=\/wp\/v2\/pages\/79"}],"wp:attachment":[{"href":"https:\/\/synchrotron-light.net\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=820"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}