inclination.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
  6. <meta name="generator" content="pdoc 0.5.2" />
  7. <title>analysis.inclination API documentation</title>
  8. <meta name="description" content="Plot a survey of the inclination angle" />
  9. <link href='https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.0/normalize.min.css' rel='stylesheet'>
  10. <link href='https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/8.0.0/sanitize.min.css' rel='stylesheet'>
  11. <link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css" rel="stylesheet">
  12. <style>.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:30px;overflow:hidden}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:1em 0 .50em 0}h3{font-size:1.4em;margin:25px 0 10px 0}h4{margin:0;font-size:105%}a{color:#058;text-decoration:none;transition:color .3s ease-in-out}a:hover{color:#e82}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900}pre code{background:#f8f8f8;font-size:.8em;line-height:1.4em}code{background:#f2f2f1;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{background:#f8f8f8;border:0;border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0;padding:1ex}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{font-weight:bold}#index h4 + ul{margin-bottom:.6em}#index .two-column{column-count:2}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-weight:bold;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.name small{font-weight:normal}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source summary{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase;cursor:pointer}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{overflow:visible}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}.admonition{padding:.1em .5em}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
  13. <style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.item .name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul{padding-left:1.5em}.toc > ul > li{margin-top:.5em}}</style>
  14. <style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
  15. </head>
  16. <body>
  17. <main>
  18. <article id="content">
  19. <header>
  20. <h1 class="title"><code>analysis.inclination</code> module</h1>
  21. </header>
  22. <section id="section-intro">
  23. <p>Plot a survey of the inclination angle</p>
  24. <details class="source">
  25. <summary>Source code</summary>
  26. <pre><code class="python">&#34;&#34;&#34;Plot a survey of the inclination angle&#34;&#34;&#34;
  27. import matplotlib.pyplot as plt
  28. import numpy as np
  29. from analysis import utils
  30. def plotEdgeView(data, ax, axisOn):
  31. &#34;&#34;&#34;Plot the encounter as viewed from the edge of the galaxy
  32. Parameters:
  33. ax: the matplotlib axis where the data should be plotted
  34. data: a data dictionary in the format saved by the simulation
  35. axisOn (bool): whether to include the y axis in this subplot.
  36. It can be omitted when it is shared among subplots.
  37. &#34;&#34;&#34;
  38. r_vec = data[&#39;r_vec&#39;]
  39. theta, phi = data[&#39;CONFIG&#39;][&#39;galaxy1&#39;][&#39;orientation&#39;]
  40. # Obtain the edge view, rotate 90º around y axis
  41. spin = np.array([np.sin(theta)*np.cos(phi),
  42. np.sin(theta)*np.sin(phi),
  43. np.cos(theta)])
  44. phi = np.pi/2
  45. M = np.array([[np.cos(-phi), 0,np.sin(-phi)],
  46. [0, 1, 0],
  47. [-np.sin(-phi), 0, np.cos(-phi)]])
  48. r_vec = np.einsum(&#39;ai,ij-&gt;aj&#39;, r_vec, M)
  49. spin = np.einsum(&#39;i,ij-&gt;j&#39;, spin, M)
  50. data[&#39;tracks&#39;] = np.einsum(&#39;abi,ij-&gt;abj&#39;, data[&#39;tracks&#39;], M)
  51. data[&#39;tracks&#39;] -= r_vec[0,:] #Relative to center of galaxy
  52. r_vec[:,:] -= r_vec[0,:]
  53. # Flip y to be consistent with Toomre and Toomre
  54. r_vec[:,1] = -r_vec[:,1]
  55. data[&#39;tracks&#39;][:,:,1] *= -1
  56. # Plotting
  57. utils.plotCenterMasses(ax, {&#39;r_vec&#39;: r_vec, &#39;type&#39;:data[&#39;type&#39;]})
  58. ax.plot(data[&#39;tracks&#39;][1,:,0], data[&#39;tracks&#39;][1,:,1],
  59. c=&#39;black&#39;, alpha=1.0, linewidth=1)
  60. ax.scatter(r_vec[:,0], r_vec[:,1], s=0.01, marker=&#39;.&#39;,
  61. c=&#39;#c40f4c&#39;, alpha=.6)
  62. utils.setSize(ax, x=(-1.5, 1.5), y=(-1.5,3.5), mode=&#39;square&#39;)
  63. utils.stylizePlot([ax])
  64. utils.setAxes(ax, x=r&#39;x / $r_{min}$&#39;, y=r&#39;y / $r_{min}$&#39;,
  65. ycoords=(-0.2, .8), mode=(&#39;bottomleft&#39; if axisOn else &#39;bottom&#39;))
  66. def plotFrontalView(data, ax, axisOn):
  67. &#34;&#34;&#34;Plot the encounter as viewed normal to the galactic plane
  68. Parameters:
  69. ax: the matplotlib axis where the data should be plotted
  70. data: a data dictionary in the format saved by the simulation
  71. axisOn (bool): whether to include the y axis in this subplot.
  72. It can be omitted when it is shared among subplots.
  73. &#34;&#34;&#34;
  74. r_vec = data[&#39;r_vec&#39;]
  75. theta, phi = data[&#39;CONFIG&#39;][&#39;galaxy1&#39;][&#39;orientation&#39;]
  76. # Rotate the position vectors into the appropiate view
  77. M2 = np.array([[np.cos(-phi), np.sin(-phi), 0],
  78. [-np.sin(-phi), np.cos(-phi), 0],
  79. [0, 0, 1]])
  80. M1 = np.array([[1, 0, 0],
  81. [0, np.cos(-theta), np.sin(-theta)],
  82. [0, -np.sin(-theta), np.cos(-theta)]])
  83. r_vec = np.einsum(&#39;ai,ij-&gt;aj&#39;, np.einsum(&#39;ai,ij-&gt;aj&#39;, r_vec, M2), M1)
  84. data[&#39;tracks&#39;] = np.einsum(&#39;abi,ij-&gt;abj&#39;, data[&#39;tracks&#39;], M2)
  85. data[&#39;tracks&#39;] = np.einsum(&#39;abi,ij-&gt;abj&#39;, data[&#39;tracks&#39;], M1)
  86. data[&#39;tracks&#39;] -= data[&#39;tracks&#39;][0]
  87. r_vec[:,:] -= r_vec[0,:]
  88. #Plotting
  89. utils.plotCenterMasses(ax, {&#39;r_vec&#39;: r_vec, &#39;type&#39;:data[&#39;type&#39;]})
  90. utils.plotTracks(ax, data[&#39;tracks&#39;])
  91. ax.scatter(r_vec[:,0], r_vec[:,1], c=&#39;#c40f4c&#39;, s=0.01, marker=&#39;.&#39;)
  92. utils.setSize(ax, x=(-3, 2), y=(-1.5, 1.5), mode=&#39;square&#39;)
  93. utils.stylizePlot([ax])
  94. utils.setAxes(ax, x=r&#39;x / $r_{min}$&#39;, y=r&#39;y / $r_{min}$&#39;,
  95. ycoords=(-0.2, .8), mode=(&#39;bottomleft&#39; if axisOn else &#39;bottom&#39;))
  96. #########################################################
  97. # Select the inclinations
  98. inclinations = [15, 45, 60, 90, 135]
  99. f, axs = plt.subplots(2, len(inclinations), figsize=(11, 6),
  100. sharey=False, sharex=False, gridspec_kw = {&#39;height_ratios&#39;:[5/3, 1]})
  101. t = 5000 # time of plots
  102. # Plot both views for each encounter
  103. for i in range(len(inclinations)):
  104. data = utils.loadData(&#39;i{}&#39;.format(inclinations[i]), t)
  105. plotEdgeView(data, ax=axs[0,i], axisOn=True if i==0 else False)
  106. data = utils.loadData(&#39;i{}&#39;.format(inclinations[i]), t)
  107. plotFrontalView(data, ax=axs[1,i], axisOn=True if i==0 else False)
  108. f.subplots_adjust(hspace=0, wspace=0)
  109. plt.tight_layout()
  110. plt.show()</code></pre>
  111. </details>
  112. </section>
  113. <section>
  114. </section>
  115. <section>
  116. </section>
  117. <section>
  118. <h2 class="section-title" id="header-functions">Functions</h2>
  119. <dl>
  120. <dt id="analysis.inclination.plotEdgeView"><code class="name flex">
  121. <span>def <span class="ident">plotEdgeView</span></span>(<span>data, ax, axisOn)</span>
  122. </code></dt>
  123. <dd>
  124. <section class="desc"><p>Plot the encounter as viewed from the edge of the galaxy</p>
  125. <h2 id="parameters">Parameters</h2>
  126. <dl>
  127. <dt><strong><code>ax</code></strong></dt>
  128. <dd>the matplotlib axis where the data should be plotted</dd>
  129. <dt><strong><code>data</code></strong></dt>
  130. <dd>a data dictionary in the format saved by the simulation</dd>
  131. <dt><strong><code>axisOn</code></strong> :&ensp;<code>bool</code></dt>
  132. <dd>whether to include the y axis in this subplot.
  133. It can be omitted when it is shared among subplots.</dd>
  134. </dl></section>
  135. <details class="source">
  136. <summary>Source code</summary>
  137. <pre><code class="python">def plotEdgeView(data, ax, axisOn):
  138. &#34;&#34;&#34;Plot the encounter as viewed from the edge of the galaxy
  139. Parameters:
  140. ax: the matplotlib axis where the data should be plotted
  141. data: a data dictionary in the format saved by the simulation
  142. axisOn (bool): whether to include the y axis in this subplot.
  143. It can be omitted when it is shared among subplots.
  144. &#34;&#34;&#34;
  145. r_vec = data[&#39;r_vec&#39;]
  146. theta, phi = data[&#39;CONFIG&#39;][&#39;galaxy1&#39;][&#39;orientation&#39;]
  147. # Obtain the edge view, rotate 90º around y axis
  148. spin = np.array([np.sin(theta)*np.cos(phi),
  149. np.sin(theta)*np.sin(phi),
  150. np.cos(theta)])
  151. phi = np.pi/2
  152. M = np.array([[np.cos(-phi), 0,np.sin(-phi)],
  153. [0, 1, 0],
  154. [-np.sin(-phi), 0, np.cos(-phi)]])
  155. r_vec = np.einsum(&#39;ai,ij-&gt;aj&#39;, r_vec, M)
  156. spin = np.einsum(&#39;i,ij-&gt;j&#39;, spin, M)
  157. data[&#39;tracks&#39;] = np.einsum(&#39;abi,ij-&gt;abj&#39;, data[&#39;tracks&#39;], M)
  158. data[&#39;tracks&#39;] -= r_vec[0,:] #Relative to center of galaxy
  159. r_vec[:,:] -= r_vec[0,:]
  160. # Flip y to be consistent with Toomre and Toomre
  161. r_vec[:,1] = -r_vec[:,1]
  162. data[&#39;tracks&#39;][:,:,1] *= -1
  163. # Plotting
  164. utils.plotCenterMasses(ax, {&#39;r_vec&#39;: r_vec, &#39;type&#39;:data[&#39;type&#39;]})
  165. ax.plot(data[&#39;tracks&#39;][1,:,0], data[&#39;tracks&#39;][1,:,1],
  166. c=&#39;black&#39;, alpha=1.0, linewidth=1)
  167. ax.scatter(r_vec[:,0], r_vec[:,1], s=0.01, marker=&#39;.&#39;,
  168. c=&#39;#c40f4c&#39;, alpha=.6)
  169. utils.setSize(ax, x=(-1.5, 1.5), y=(-1.5,3.5), mode=&#39;square&#39;)
  170. utils.stylizePlot([ax])
  171. utils.setAxes(ax, x=r&#39;x / $r_{min}$&#39;, y=r&#39;y / $r_{min}$&#39;,
  172. ycoords=(-0.2, .8), mode=(&#39;bottomleft&#39; if axisOn else &#39;bottom&#39;))</code></pre>
  173. </details>
  174. </dd>
  175. <dt id="analysis.inclination.plotFrontalView"><code class="name flex">
  176. <span>def <span class="ident">plotFrontalView</span></span>(<span>data, ax, axisOn)</span>
  177. </code></dt>
  178. <dd>
  179. <section class="desc"><p>Plot the encounter as viewed normal to the galactic plane</p>
  180. <h2 id="parameters">Parameters</h2>
  181. <dl>
  182. <dt><strong><code>ax</code></strong></dt>
  183. <dd>the matplotlib axis where the data should be plotted</dd>
  184. <dt><strong><code>data</code></strong></dt>
  185. <dd>a data dictionary in the format saved by the simulation</dd>
  186. <dt><strong><code>axisOn</code></strong> :&ensp;<code>bool</code></dt>
  187. <dd>whether to include the y axis in this subplot.
  188. It can be omitted when it is shared among subplots.</dd>
  189. </dl></section>
  190. <details class="source">
  191. <summary>Source code</summary>
  192. <pre><code class="python">def plotFrontalView(data, ax, axisOn):
  193. &#34;&#34;&#34;Plot the encounter as viewed normal to the galactic plane
  194. Parameters:
  195. ax: the matplotlib axis where the data should be plotted
  196. data: a data dictionary in the format saved by the simulation
  197. axisOn (bool): whether to include the y axis in this subplot.
  198. It can be omitted when it is shared among subplots.
  199. &#34;&#34;&#34;
  200. r_vec = data[&#39;r_vec&#39;]
  201. theta, phi = data[&#39;CONFIG&#39;][&#39;galaxy1&#39;][&#39;orientation&#39;]
  202. # Rotate the position vectors into the appropiate view
  203. M2 = np.array([[np.cos(-phi), np.sin(-phi), 0],
  204. [-np.sin(-phi), np.cos(-phi), 0],
  205. [0, 0, 1]])
  206. M1 = np.array([[1, 0, 0],
  207. [0, np.cos(-theta), np.sin(-theta)],
  208. [0, -np.sin(-theta), np.cos(-theta)]])
  209. r_vec = np.einsum(&#39;ai,ij-&gt;aj&#39;, np.einsum(&#39;ai,ij-&gt;aj&#39;, r_vec, M2), M1)
  210. data[&#39;tracks&#39;] = np.einsum(&#39;abi,ij-&gt;abj&#39;, data[&#39;tracks&#39;], M2)
  211. data[&#39;tracks&#39;] = np.einsum(&#39;abi,ij-&gt;abj&#39;, data[&#39;tracks&#39;], M1)
  212. data[&#39;tracks&#39;] -= data[&#39;tracks&#39;][0]
  213. r_vec[:,:] -= r_vec[0,:]
  214. #Plotting
  215. utils.plotCenterMasses(ax, {&#39;r_vec&#39;: r_vec, &#39;type&#39;:data[&#39;type&#39;]})
  216. utils.plotTracks(ax, data[&#39;tracks&#39;])
  217. ax.scatter(r_vec[:,0], r_vec[:,1], c=&#39;#c40f4c&#39;, s=0.01, marker=&#39;.&#39;)
  218. utils.setSize(ax, x=(-3, 2), y=(-1.5, 1.5), mode=&#39;square&#39;)
  219. utils.stylizePlot([ax])
  220. utils.setAxes(ax, x=r&#39;x / $r_{min}$&#39;, y=r&#39;y / $r_{min}$&#39;,
  221. ycoords=(-0.2, .8), mode=(&#39;bottomleft&#39; if axisOn else &#39;bottom&#39;))</code></pre>
  222. </details>
  223. </dd>
  224. </dl>
  225. </section>
  226. <section>
  227. </section>
  228. </article>
  229. <nav id="sidebar">
  230. <h1>Index</h1>
  231. <div class="toc">
  232. <ul></ul>
  233. </div>
  234. <ul id="index">
  235. <li><h3><a href="#header-functions">Functions</a></h3>
  236. <ul class="">
  237. <li><code><a title="analysis.inclination.plotEdgeView" href="#analysis.inclination.plotEdgeView">plotEdgeView</a></code></li>
  238. <li><code><a title="analysis.inclination.plotFrontalView" href="#analysis.inclination.plotFrontalView">plotFrontalView</a></code></li>
  239. </ul>
  240. </li>
  241. </ul>
  242. </nav>
  243. </main>
  244. <footer id="footer">
  245. <p>Generated by <a href="https://pdoc3.github.io/pdoc"><cite>pdoc</cite> 0.5.2</a>.</p>
  246. </footer>
  247. <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
  248. <script>hljs.initHighlightingOnLoad()</script>
  249. </body>
  250. </html>