<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title type="text">The yt Project Blog</title>
  <id>/atom/</id>
  <updated>2015-08-20T06:30:29Z</updated>
  <link href="/" />
  <link href="/atom/" rel="self" />
  <author>
    <name>The yt Project</name>
  </author>
  <subtitle type="text">Everything going on with yt</subtitle>
  <generator>blohg</generator>
  <entry>
    <title type="text">Line Integral Convolution for Vector Field Visualization</title>
    <id>/post/LineIntegralConvolution/</id>
    <updated>2015-08-20T06:30:29Z</updated>
    <published>2015-08-20T06:30:29Z</published>
    <link href="/post/LineIntegralConvolution/" />
    <author>
      <name>Suoqing Ji</name>
      <email>jisuoqing@gmail.com</email>
    </author>
    <summary type="html">&lt;div class=&quot;section&quot; id=&quot;visualization-of-vector-fields&quot;&gt;
&lt;h3&gt;Visualization of Vector Fields&lt;/h3&gt;
&lt;p&gt;When I was working on my first publication with Prof. &lt;a class=&quot;reference external&quot; href=&quot;http://www.umassd.edu/engineering/phy/people/facultyandstaff/robertfisher/&quot;&gt;Robert Fisher&lt;/a&gt;, we explored several ways to visualize the magnetic field in our simulations of white dwarf binary merger. Finally we drew magnetic field in the form of streamlines, which did a satisfactory job. However, since the streamlines could not be arbitrarily dense, the magnetic field geometry was not spatially continuous and the information near pixel scale was lost.&lt;/p&gt;
&lt;p&gt;Until recently, I got to know the method of line integral convolution (LIC) and adapted the &lt;a class=&quot;reference external&quot; href=&quot;http://wiki.scipy.org/Cookbook/LineIntegralConvolution&quot;&gt;SciPy cookbook example&lt;/a&gt; to yt. The basic idea of LIC is to convolute vector field orientation with local texture over a certain kernel length, thus all the details of vector field geometry can be preserved.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;draw-lic-with-one-line-of-code&quot;&gt;
&lt;h3&gt;Draw LIC with ONE Line of Code&lt;/h3&gt;
&lt;p&gt;Drawing LIC for your data with yt is extremely easy -- just with a single line of code:&lt;/p&gt;
&lt;pre class=&quot;code python literal-block&quot;&gt;
&lt;span class=&quot;keyword namespace&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;name namespace&quot;&gt;yt&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;ds&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;yt&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;load&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;literal string double&quot;&gt;&amp;quot;IsolatedGalaxy/galaxy0030/galaxy0030&amp;quot;&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;s&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;yt&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;SlicePlot&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;ds&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;literal string single&quot;&gt;'z'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;literal string single&quot;&gt;'density'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;center&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;literal string single&quot;&gt;'c'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;literal number integer&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;literal string single&quot;&gt;'kpc'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;annotate_line_integral_convolution&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;literal string single&quot;&gt;'velocity_x'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;literal string single&quot;&gt;'velocity_y'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;lim&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;literal number float&quot;&gt;0.5&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;literal number float&quot;&gt;0.65&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;save&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;()&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;Here &lt;tt class=&quot;docutils literal&quot;&gt;velocity_x&lt;/tt&gt; and &lt;tt class=&quot;docutils literal&quot;&gt;velocity_y&lt;/tt&gt; tell yt to visualize the velocity field, which is overlaid onto the original density slice plot. Adjusting &lt;tt class=&quot;docutils literal&quot;&gt;lim&lt;/tt&gt; will &amp;quot;squeeze&amp;quot; the range of LIC magnitude and change the visibility of LIC plot. The code will produce the following image:&lt;/p&gt;
&lt;img alt=&quot;/attachments/lic_velocity.png&quot; src=&quot;/attachments/lic_velocity.png&quot; /&gt;
&lt;p&gt;There are &lt;a class=&quot;reference external&quot; href=&quot;http://yt-project.org/docs/dev/visualizing/callbacks.html#overplot-line-integral-convolution&quot;&gt;more parameters&lt;/a&gt; you can play with to generate a perfect image. For instance, although &lt;tt class=&quot;docutils literal&quot;&gt;const_alpha&lt;/tt&gt; is set to &lt;tt class=&quot;docutils literal&quot;&gt;False&lt;/tt&gt; as default to generate a semitransparent LIC image over original plot, you can also set &lt;tt class=&quot;docutils literal&quot;&gt;const_alpha&lt;/tt&gt; to &lt;tt class=&quot;docutils literal&quot;&gt;True&lt;/tt&gt; and use &lt;tt class=&quot;docutils literal&quot;&gt;alpha=1&lt;/tt&gt; to get a pure LIC image. The following code visualizes LIC of the magnetic field in white dwarf binary simulation:&lt;/p&gt;
&lt;pre class=&quot;code python literal-block&quot;&gt;
&lt;span class=&quot;keyword namespace&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;name namespace&quot;&gt;yt&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;ds&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;yt&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;load&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;literal string double&quot;&gt;&amp;quot;WDMerger_hdf5_chk_1000/WDMerger_hdf5_chk_1000.hdf5&amp;quot;&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;s&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;yt&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;SlicePlot&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;ds&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;literal string single&quot;&gt;'theta'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;literal string single&quot;&gt;'magnetic_field_strength'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;origin&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;literal string single&quot;&gt;'native'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;annotate_line_integral_convolution&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;literal string single&quot;&gt;'magnetic_field_x'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;literal string single&quot;&gt;'magnetic_field_y'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;lim&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;literal number float&quot;&gt;0.45&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;literal number float&quot;&gt;0.55&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;cmap&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;literal string single&quot;&gt;'YlGnBu'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;alpha&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;literal number float&quot;&gt;1.&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;const_alpha&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;name builtin pseudo&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;hide_colorbar&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;save&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;()&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;and the following image is produced:&lt;/p&gt;
&lt;img alt=&quot;/attachments/lic_Bfield.png&quot; src=&quot;/attachments/lic_Bfield.png&quot; /&gt;
&lt;/div&gt;
</summary>
    <content type="html">&lt;div class=&quot;section&quot; id=&quot;visualization-of-vector-fields&quot;&gt;
&lt;h3&gt;Visualization of Vector Fields&lt;/h3&gt;
&lt;p&gt;When I was working on my first publication with Prof. &lt;a class=&quot;reference external&quot; href=&quot;http://www.umassd.edu/engineering/phy/people/facultyandstaff/robertfisher/&quot;&gt;Robert Fisher&lt;/a&gt;, we explored several ways to visualize the magnetic field in our simulations of white dwarf binary merger. Finally we drew magnetic field in the form of streamlines, which did a satisfactory job. However, since the streamlines could not be arbitrarily dense, the magnetic field geometry was not spatially continuous and the information near pixel scale was lost.&lt;/p&gt;
&lt;p&gt;Until recently, I got to know the method of line integral convolution (LIC) and adapted the &lt;a class=&quot;reference external&quot; href=&quot;http://wiki.scipy.org/Cookbook/LineIntegralConvolution&quot;&gt;SciPy cookbook example&lt;/a&gt; to yt. The basic idea of LIC is to convolute vector field orientation with local texture over a certain kernel length, thus all the details of vector field geometry can be preserved.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;draw-lic-with-one-line-of-code&quot;&gt;
&lt;h3&gt;Draw LIC with ONE Line of Code&lt;/h3&gt;
&lt;p&gt;Drawing LIC for your data with yt is extremely easy -- just with a single line of code:&lt;/p&gt;
&lt;pre class=&quot;code python literal-block&quot;&gt;
&lt;span class=&quot;keyword namespace&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;name namespace&quot;&gt;yt&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;ds&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;yt&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;load&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;literal string double&quot;&gt;&amp;quot;IsolatedGalaxy/galaxy0030/galaxy0030&amp;quot;&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;s&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;yt&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;SlicePlot&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;ds&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;literal string single&quot;&gt;'z'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;literal string single&quot;&gt;'density'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;center&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;literal string single&quot;&gt;'c'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;literal number integer&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;literal string single&quot;&gt;'kpc'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;annotate_line_integral_convolution&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;literal string single&quot;&gt;'velocity_x'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;literal string single&quot;&gt;'velocity_y'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;lim&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;literal number float&quot;&gt;0.5&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;literal number float&quot;&gt;0.65&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;save&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;()&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;Here &lt;tt class=&quot;docutils literal&quot;&gt;velocity_x&lt;/tt&gt; and &lt;tt class=&quot;docutils literal&quot;&gt;velocity_y&lt;/tt&gt; tell yt to visualize the velocity field, which is overlaid onto the original density slice plot. Adjusting &lt;tt class=&quot;docutils literal&quot;&gt;lim&lt;/tt&gt; will &amp;quot;squeeze&amp;quot; the range of LIC magnitude and change the visibility of LIC plot. The code will produce the following image:&lt;/p&gt;
&lt;img alt=&quot;/attachments/lic_velocity.png&quot; src=&quot;/attachments/lic_velocity.png&quot; /&gt;
&lt;p&gt;There are &lt;a class=&quot;reference external&quot; href=&quot;http://yt-project.org/docs/dev/visualizing/callbacks.html#overplot-line-integral-convolution&quot;&gt;more parameters&lt;/a&gt; you can play with to generate a perfect image. For instance, although &lt;tt class=&quot;docutils literal&quot;&gt;const_alpha&lt;/tt&gt; is set to &lt;tt class=&quot;docutils literal&quot;&gt;False&lt;/tt&gt; as default to generate a semitransparent LIC image over original plot, you can also set &lt;tt class=&quot;docutils literal&quot;&gt;const_alpha&lt;/tt&gt; to &lt;tt class=&quot;docutils literal&quot;&gt;True&lt;/tt&gt; and use &lt;tt class=&quot;docutils literal&quot;&gt;alpha=1&lt;/tt&gt; to get a pure LIC image. The following code visualizes LIC of the magnetic field in white dwarf binary simulation:&lt;/p&gt;
&lt;pre class=&quot;code python literal-block&quot;&gt;
&lt;span class=&quot;keyword namespace&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;name namespace&quot;&gt;yt&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;ds&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;yt&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;load&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;literal string double&quot;&gt;&amp;quot;WDMerger_hdf5_chk_1000/WDMerger_hdf5_chk_1000.hdf5&amp;quot;&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;s&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;yt&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;SlicePlot&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;ds&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;literal string single&quot;&gt;'theta'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;literal string single&quot;&gt;'magnetic_field_strength'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;origin&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;literal string single&quot;&gt;'native'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;annotate_line_integral_convolution&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;literal string single&quot;&gt;'magnetic_field_x'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;literal string single&quot;&gt;'magnetic_field_y'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;lim&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;literal number float&quot;&gt;0.45&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;literal number float&quot;&gt;0.55&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;cmap&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;literal string single&quot;&gt;'YlGnBu'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;alpha&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;literal number float&quot;&gt;1.&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;const_alpha&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;name builtin pseudo&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;hide_colorbar&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;save&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;()&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;and the following image is produced:&lt;/p&gt;
&lt;img alt=&quot;/attachments/lic_Bfield.png&quot; src=&quot;/attachments/lic_Bfield.png&quot; /&gt;
&lt;/div&gt;
</content>
  </entry>
  <entry>
    <title type="text">Much Ado About Governance</title>
    <id>/post/governance/</id>
    <updated>2014-10-10T20:43:17Z</updated>
    <published>2014-10-10T20:43:17Z</published>
    <link href="/post/governance/" />
    <author>
      <name>Matthew Turk</name>
      <email>matthewturk@gmail.com</email>
    </author>
    <summary type="html">&lt;p&gt;This blog post is long overdue!  (And I can't believe it's been so long since
we had a blog post here, either.)  Over the last few months, particularly after
the release of yt 3.0, on the yt-dev mailing list we've had discussions about
how to institute some form of governance of the project.  This has been one of
the hardest transitions yt has had to make -- it used to be that we could fit
everybody who had a stake in it into a small office, but that's no longer the
case.&lt;/p&gt;
&lt;p&gt;Over the course of several long email threads, as well as discussions in the
comments for &lt;a class=&quot;reference external&quot; href=&quot;https://bitbucket.org/yt_analysis/ytep/pull-request/40/ytep-1776-team-infrastructure&quot;&gt;pull request 40&lt;/a&gt;
to the YTEP repository, Britton Smith developed &lt;a class=&quot;reference external&quot; href=&quot;https://ytep.readthedocs.org/en/latest/YTEPs/YTEP-1776.html&quot;&gt;YTEP-1776&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;This establishes a framework for a few things:&lt;/p&gt;
&lt;blockquote&gt;
&lt;ul class=&quot;simple&quot;&gt;
&lt;li&gt;Decision making -- particularly when there are conflicts between individuals
about how to proceed with code changes, with release information, and the
like.&lt;/li&gt;
&lt;li&gt;Identification of individuals as &amp;quot;&lt;a class=&quot;reference external&quot; href=&quot;http://yt-project.org/members.html&quot;&gt;project members&lt;/a&gt;,&amp;quot; which is not only useful for
participation in decision making, but also for placing on a CV, which is
especially useful for younger researchers.&lt;/li&gt;
&lt;li&gt;Establish liaisons between platforms and codes and yt&lt;/li&gt;
&lt;li&gt;Establish mechanisms for regular checkins and meetings to discuss goings-on&lt;/li&gt;
&lt;li&gt;Develop standards and processes for code review&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;p&gt;One of the original goals of the governance discussion was to attempt to ensure
that individuals who had contributed to yt, and who might otherwise &lt;em&gt;not&lt;/em&gt; get
recognition for their efforts (be they in code or time spent helping others)
would be able to be recognized in some sort of semi-official way.&lt;/p&gt;
&lt;p&gt;I'm so proud of everyone in the community for putting this together.  I think
that this is a delicate transition, and everyone has been incredible during it
-- especially Britton Smith, who essentially drove the entire discussion.&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;This blog post is long overdue!  (And I can't believe it's been so long since
we had a blog post here, either.)  Over the last few months, particularly after
the release of yt 3.0, on the yt-dev mailing list we've had discussions about
how to institute some form of governance of the project.  This has been one of
the hardest transitions yt has had to make -- it used to be that we could fit
everybody who had a stake in it into a small office, but that's no longer the
case.&lt;/p&gt;
&lt;p&gt;Over the course of several long email threads, as well as discussions in the
comments for &lt;a class=&quot;reference external&quot; href=&quot;https://bitbucket.org/yt_analysis/ytep/pull-request/40/ytep-1776-team-infrastructure&quot;&gt;pull request 40&lt;/a&gt;
to the YTEP repository, Britton Smith developed &lt;a class=&quot;reference external&quot; href=&quot;https://ytep.readthedocs.org/en/latest/YTEPs/YTEP-1776.html&quot;&gt;YTEP-1776&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;This establishes a framework for a few things:&lt;/p&gt;
&lt;blockquote&gt;
&lt;ul class=&quot;simple&quot;&gt;
&lt;li&gt;Decision making -- particularly when there are conflicts between individuals
about how to proceed with code changes, with release information, and the
like.&lt;/li&gt;
&lt;li&gt;Identification of individuals as &amp;quot;&lt;a class=&quot;reference external&quot; href=&quot;http://yt-project.org/members.html&quot;&gt;project members&lt;/a&gt;,&amp;quot; which is not only useful for
participation in decision making, but also for placing on a CV, which is
especially useful for younger researchers.&lt;/li&gt;
&lt;li&gt;Establish liaisons between platforms and codes and yt&lt;/li&gt;
&lt;li&gt;Establish mechanisms for regular checkins and meetings to discuss goings-on&lt;/li&gt;
&lt;li&gt;Develop standards and processes for code review&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;p&gt;One of the original goals of the governance discussion was to attempt to ensure
that individuals who had contributed to yt, and who might otherwise &lt;em&gt;not&lt;/em&gt; get
recognition for their efforts (be they in code or time spent helping others)
would be able to be recognized in some sort of semi-official way.&lt;/p&gt;
&lt;p&gt;I'm so proud of everyone in the community for putting this together.  I think
that this is a delicate transition, and everyone has been incredible during it
-- especially Britton Smith, who essentially drove the entire discussion.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title type="text">Relicensing yt from GPLv3 to BSD</title>
    <id>/post/Relicensing/</id>
    <updated>2013-09-12T23:53:18Z</updated>
    <published>2013-09-12T23:53:18Z</published>
    <link href="/post/Relicensing/" />
    <author>
      <name>Matthew Turk</name>
      <email>matthewturk@gmail.com</email>
    </author>
    <summary type="html">&lt;p&gt;Today, I hit the merge button on a relicensing of yt from GPLv3 to the 3-clause
BSD license.  Below is a blog post, largely drawn from an email I sent to
yt-dev several months ago, describing why this process began and what it means
for both users and developers.&lt;/p&gt;
&lt;p&gt;This was an effort we started several months ago, following discussions at the
SciPy 2013 conference.  Nathan Goldbaum, Sam Skillman and I discussed it
somewhat at length, and eventually decided to begin exploring this with the
other key stakeholders of yt.  It wasn't a decision or process that we took
lightly, nor was it particularly seamless, but it was mostly smooth and I think
overall it is going to be a positive change for the community.&lt;/p&gt;
&lt;p&gt;When I originally created yt in the Summer of 2006 (then called Raven) I placed
it under the then-new GPLv3 license.  This license brought with it an ideology
that I support -- free (as in freedom) and open source software, and attempts
to ensure that the spread of software spreads those freedoms as well.  This is
done through terms of licensing; while there are several subtleties to how this
plays out, and the goals of FLOSS and the GPL align very well with my own, at
some point I began to believe that yt would be better suited under a
permissive, non-copyleft license rather than the GPLv3.  As such, through
discussions with the other developers, and through consent from every
contributor to yt over its history, we have relicensed it under the 3-clause
BSD license.&lt;/p&gt;
&lt;div class=&quot;section&quot; id=&quot;why&quot;&gt;
&lt;h3&gt;Why?&lt;/h3&gt;
&lt;p&gt;In the scientific software community, for the most part codes and platforms are
released under a permissive, BSD-like license.  This is not universally true,
but within the scientific python ecosystem (including projects such as AstroPy,
NumPy, IPython and so on), BSD-like licenses are especially prevalent.  These
licenses place no restrictions on redistribution, passing on freedoms to end
users, or making a piece of software closed-source.  A side effect is that if a
piece of software is BSD licensed, it cannot rely on GPL'd software without
itself being subject to those terms.  Specifically, a BSD licensed package that
requires an import of a GPL'd package may then be subject to the GPL -- this is
why it has been termed &amp;quot;viral&amp;quot; in the past.  As examples, many BSD-licensed
packages exist in the scientific software community: VisIt, ParaView, MayaVi,
NumPy, Matplotlib, IPython, Python itself, mpi4py, h5py, SymPy, SciPy, most of
the scikits, scikits-learn, NetworkX and so on.  Collaboration with these
projects is currently one-way because of our license.&lt;/p&gt;
&lt;p&gt;When I initially decided on a license for yt (seven years ago) it seemed
appropriate to use the licensing terms as a mechanism to encourage
contributions upstream.  However, within the current ecosystem, it is clear
that because of the virality of the GPL and the prevailing mindsets of
developers, it is actually an impediment to receiving contributions and
receiving mindshare.  John Hunter described it very clearly in his &amp;quot;&lt;a class=&quot;reference external&quot; href=&quot;http://nipy.sourceforge.net/software/license/johns_bsd_pitch.html#johns-bsd-pitch&quot;&gt;BSD Pitch&lt;/a&gt;&amp;quot;.&lt;/p&gt;
&lt;p&gt;While John focuses on commercial utilization, I believe that within the
scientific python ecosystem the picture can be broadened to include any piece
of software that is under a permissive license.  yt cannot be used or relied
upon as a primary component without that piece of software then becoming
subject to the terms of the GPL.  Additionally, some private and public
institutions are averse to providing code under the GPL, specifically version 3
of the GPL.&lt;/p&gt;
&lt;p&gt;By transitioning to a permissive license, we may be able to receive more
contributions and collaborate more widely.  As a few examples, this could
include more direct collaborations with packages such as &lt;a class=&quot;reference external&quot; href=&quot;http://glueviz.org/&quot;&gt;Glue&lt;/a&gt;, &lt;a class=&quot;reference external&quot; href=&quot;http://ipython.org/&quot;&gt;IPython&lt;/a&gt;, &lt;a class=&quot;reference external&quot; href=&quot;http://visit.llnl.gov/&quot;&gt;VisIt&lt;/a&gt;, &lt;a class=&quot;reference external&quot; href=&quot;http://paraview.org/&quot;&gt;ParaView&lt;/a&gt;, and even
utilization and exposing of yt methods and operations in other,
permissively-licensed packages.  For example, deep integration between
permissively-licensed simulation codes will benefit from this.  Furthermore,
individuals who otherwise could not contribute code under the GPL (due to
employer restrictions) will be able to contribute code under a permissive
license.&lt;/p&gt;
&lt;p&gt;The GPL is designed to prevent turning FLOSS code proprietary.  Changing to a
BSD license does not allow another entity to prevent us from continuing to
develop or make available any yt code.  It simply means that others can utilize
it however they see fit.&lt;/p&gt;
&lt;p&gt;I believe that we stand to gain considerably more than we stand to lose from
this transition.  (Interestingly enough, Wolfgang Bangerth and Timo Heister
came to similar conclusions in section 3.4 their article &lt;a class=&quot;reference external&quot; href=&quot;http://www.math.tamu.edu/~bangerth/publications/2013-software.pdf&quot;&gt;What Makes
Computational Open Source Software Libraries Successful?&lt;/a&gt;)  More to
the point, a few years ago on the yt-dev mailing list we came up with a mission
statement for yt, which now adorns our homepage.  I think we can better serve
that mission statement by enabling broader collaborations within the scientific
software ecosystem.&lt;/p&gt;
&lt;p&gt;This is not motivated by any desire to create a proprietary distribution of yt
-- in fact, exactly the opposite.  I believe that in the current ecosystem of
scientific software, yt will be more sustainable if it is under a permissive
license.  I hope we continue to &lt;a class=&quot;reference external&quot; href=&quot;http://arxiv.org/abs/1301.7064&quot;&gt;scale&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;the-new-license&quot;&gt;
&lt;h3&gt;The New License&lt;/h3&gt;
&lt;p&gt;As of changeset 7a7ca4d (in main yt branch) and 7b180c7 (yt-3.0 branch), yt is
now available under the &lt;a class=&quot;reference external&quot; href=&quot;https://bitbucket.org/yt_analysis/yt/src/7a7ca4d5a1b3747a06ea76b8d090e33413717b06/COPYING.txt&quot;&gt;3-clause BSD license&lt;/a&gt;.
In addition to this, the author lists have been removed from the files; this
was a suggestion from the other developers, to encourage a different
representation of authorship.&lt;/p&gt;
&lt;p&gt;In beginning this process, I consulted with several individuals that I consider
role models in the community -- other long-term, core yt developers but also
Fernando Perez, Anthony Scopatz, Matthew Terry and Katy Huff.
To accomplish the relicensing, we had a public discussion (on yt-dev) of the advantages
and disadvantages of the relicensing.  I'm deeply grateful to Fernando for an
extremely thoughtful email exchange where he described his own motivations for
moving IPython from LGPL to BSD, as well as a set of guidelines and suggestions
for relicensing yt.  The process was inspired by the IPython licensing and
credit system, and I hope we continue to learn from their successes over time.&lt;/p&gt;
&lt;p&gt;To relicense, I personally emailed each individual contributor to yt explaining
the reason, linking to documents describing each license, and asking them to
publicly state their consent to relicense.  Links to each mailing list entry
were posted in a &lt;a class=&quot;reference external&quot; href=&quot;http://goo.gl/3PFnf&quot;&gt;Google Spreadsheet&lt;/a&gt;.  Once these
messages had been collected, we were able to change the license on all of the
header files.&lt;/p&gt;
&lt;p&gt;At some point in the future, we will likely put out a 2.6 release.  This
release will be a long-term stable release, and will be available under the BSD
license linked to above.  But, as of today, checkouts of the code will be
available under that license already.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;future&quot;&gt;
&lt;h3&gt;Future&lt;/h3&gt;
&lt;p&gt;I have come to believe very strongly that as a project we can do more to
support goals of open science, open source, and build a stronger community by
this relicensing, and by rethinking how we fit into an ecosystem of scientific
software.&lt;/p&gt;
&lt;p&gt;Fun stuff is ahead.&lt;/p&gt;
&lt;/div&gt;
</summary>
    <content type="html">&lt;p&gt;Today, I hit the merge button on a relicensing of yt from GPLv3 to the 3-clause
BSD license.  Below is a blog post, largely drawn from an email I sent to
yt-dev several months ago, describing why this process began and what it means
for both users and developers.&lt;/p&gt;
&lt;p&gt;This was an effort we started several months ago, following discussions at the
SciPy 2013 conference.  Nathan Goldbaum, Sam Skillman and I discussed it
somewhat at length, and eventually decided to begin exploring this with the
other key stakeholders of yt.  It wasn't a decision or process that we took
lightly, nor was it particularly seamless, but it was mostly smooth and I think
overall it is going to be a positive change for the community.&lt;/p&gt;
&lt;p&gt;When I originally created yt in the Summer of 2006 (then called Raven) I placed
it under the then-new GPLv3 license.  This license brought with it an ideology
that I support -- free (as in freedom) and open source software, and attempts
to ensure that the spread of software spreads those freedoms as well.  This is
done through terms of licensing; while there are several subtleties to how this
plays out, and the goals of FLOSS and the GPL align very well with my own, at
some point I began to believe that yt would be better suited under a
permissive, non-copyleft license rather than the GPLv3.  As such, through
discussions with the other developers, and through consent from every
contributor to yt over its history, we have relicensed it under the 3-clause
BSD license.&lt;/p&gt;
&lt;div class=&quot;section&quot; id=&quot;why&quot;&gt;
&lt;h3&gt;Why?&lt;/h3&gt;
&lt;p&gt;In the scientific software community, for the most part codes and platforms are
released under a permissive, BSD-like license.  This is not universally true,
but within the scientific python ecosystem (including projects such as AstroPy,
NumPy, IPython and so on), BSD-like licenses are especially prevalent.  These
licenses place no restrictions on redistribution, passing on freedoms to end
users, or making a piece of software closed-source.  A side effect is that if a
piece of software is BSD licensed, it cannot rely on GPL'd software without
itself being subject to those terms.  Specifically, a BSD licensed package that
requires an import of a GPL'd package may then be subject to the GPL -- this is
why it has been termed &amp;quot;viral&amp;quot; in the past.  As examples, many BSD-licensed
packages exist in the scientific software community: VisIt, ParaView, MayaVi,
NumPy, Matplotlib, IPython, Python itself, mpi4py, h5py, SymPy, SciPy, most of
the scikits, scikits-learn, NetworkX and so on.  Collaboration with these
projects is currently one-way because of our license.&lt;/p&gt;
&lt;p&gt;When I initially decided on a license for yt (seven years ago) it seemed
appropriate to use the licensing terms as a mechanism to encourage
contributions upstream.  However, within the current ecosystem, it is clear
that because of the virality of the GPL and the prevailing mindsets of
developers, it is actually an impediment to receiving contributions and
receiving mindshare.  John Hunter described it very clearly in his &amp;quot;&lt;a class=&quot;reference external&quot; href=&quot;http://nipy.sourceforge.net/software/license/johns_bsd_pitch.html#johns-bsd-pitch&quot;&gt;BSD Pitch&lt;/a&gt;&amp;quot;.&lt;/p&gt;
&lt;p&gt;While John focuses on commercial utilization, I believe that within the
scientific python ecosystem the picture can be broadened to include any piece
of software that is under a permissive license.  yt cannot be used or relied
upon as a primary component without that piece of software then becoming
subject to the terms of the GPL.  Additionally, some private and public
institutions are averse to providing code under the GPL, specifically version 3
of the GPL.&lt;/p&gt;
&lt;p&gt;By transitioning to a permissive license, we may be able to receive more
contributions and collaborate more widely.  As a few examples, this could
include more direct collaborations with packages such as &lt;a class=&quot;reference external&quot; href=&quot;http://glueviz.org/&quot;&gt;Glue&lt;/a&gt;, &lt;a class=&quot;reference external&quot; href=&quot;http://ipython.org/&quot;&gt;IPython&lt;/a&gt;, &lt;a class=&quot;reference external&quot; href=&quot;http://visit.llnl.gov/&quot;&gt;VisIt&lt;/a&gt;, &lt;a class=&quot;reference external&quot; href=&quot;http://paraview.org/&quot;&gt;ParaView&lt;/a&gt;, and even
utilization and exposing of yt methods and operations in other,
permissively-licensed packages.  For example, deep integration between
permissively-licensed simulation codes will benefit from this.  Furthermore,
individuals who otherwise could not contribute code under the GPL (due to
employer restrictions) will be able to contribute code under a permissive
license.&lt;/p&gt;
&lt;p&gt;The GPL is designed to prevent turning FLOSS code proprietary.  Changing to a
BSD license does not allow another entity to prevent us from continuing to
develop or make available any yt code.  It simply means that others can utilize
it however they see fit.&lt;/p&gt;
&lt;p&gt;I believe that we stand to gain considerably more than we stand to lose from
this transition.  (Interestingly enough, Wolfgang Bangerth and Timo Heister
came to similar conclusions in section 3.4 their article &lt;a class=&quot;reference external&quot; href=&quot;http://www.math.tamu.edu/~bangerth/publications/2013-software.pdf&quot;&gt;What Makes
Computational Open Source Software Libraries Successful?&lt;/a&gt;)  More to
the point, a few years ago on the yt-dev mailing list we came up with a mission
statement for yt, which now adorns our homepage.  I think we can better serve
that mission statement by enabling broader collaborations within the scientific
software ecosystem.&lt;/p&gt;
&lt;p&gt;This is not motivated by any desire to create a proprietary distribution of yt
-- in fact, exactly the opposite.  I believe that in the current ecosystem of
scientific software, yt will be more sustainable if it is under a permissive
license.  I hope we continue to &lt;a class=&quot;reference external&quot; href=&quot;http://arxiv.org/abs/1301.7064&quot;&gt;scale&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;the-new-license&quot;&gt;
&lt;h3&gt;The New License&lt;/h3&gt;
&lt;p&gt;As of changeset 7a7ca4d (in main yt branch) and 7b180c7 (yt-3.0 branch), yt is
now available under the &lt;a class=&quot;reference external&quot; href=&quot;https://bitbucket.org/yt_analysis/yt/src/7a7ca4d5a1b3747a06ea76b8d090e33413717b06/COPYING.txt&quot;&gt;3-clause BSD license&lt;/a&gt;.
In addition to this, the author lists have been removed from the files; this
was a suggestion from the other developers, to encourage a different
representation of authorship.&lt;/p&gt;
&lt;p&gt;In beginning this process, I consulted with several individuals that I consider
role models in the community -- other long-term, core yt developers but also
Fernando Perez, Anthony Scopatz, Matthew Terry and Katy Huff.
To accomplish the relicensing, we had a public discussion (on yt-dev) of the advantages
and disadvantages of the relicensing.  I'm deeply grateful to Fernando for an
extremely thoughtful email exchange where he described his own motivations for
moving IPython from LGPL to BSD, as well as a set of guidelines and suggestions
for relicensing yt.  The process was inspired by the IPython licensing and
credit system, and I hope we continue to learn from their successes over time.&lt;/p&gt;
&lt;p&gt;To relicense, I personally emailed each individual contributor to yt explaining
the reason, linking to documents describing each license, and asking them to
publicly state their consent to relicense.  Links to each mailing list entry
were posted in a &lt;a class=&quot;reference external&quot; href=&quot;http://goo.gl/3PFnf&quot;&gt;Google Spreadsheet&lt;/a&gt;.  Once these
messages had been collected, we were able to change the license on all of the
header files.&lt;/p&gt;
&lt;p&gt;At some point in the future, we will likely put out a 2.6 release.  This
release will be a long-term stable release, and will be available under the BSD
license linked to above.  But, as of today, checkouts of the code will be
available under that license already.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;future&quot;&gt;
&lt;h3&gt;Future&lt;/h3&gt;
&lt;p&gt;I have come to believe very strongly that as a project we can do more to
support goals of open science, open source, and build a stronger community by
this relicensing, and by rethinking how we fit into an ecosystem of scientific
software.&lt;/p&gt;
&lt;p&gt;Fun stuff is ahead.&lt;/p&gt;
&lt;/div&gt;
</content>
  </entry>
  <entry>
    <title type="text">OBJ File Exporter for Surfaces</title>
    <id>/post/objexporter/</id>
    <updated>2013-03-30T00:50:40Z</updated>
    <published>2013-03-30T00:50:40Z</published>
    <link href="/post/objexporter/" />
    <author>
      <name>jnaiman</name>
      <email>jnaiman@ucolick.org</email>
    </author>
    <summary type="html">&lt;div class=&quot;section&quot; id=&quot;obj-and-mtl-files&quot;&gt;
&lt;h3&gt;OBJ and MTL Files&lt;/h3&gt;
&lt;p&gt;If the ability to maneuver around an isosurface of your 3D simulation in
&lt;a class=&quot;reference external&quot; href=&quot;http://sketchfab.com&quot;&gt;Sketchfab&lt;/a&gt; cost you half a day of work (let's be
honest, 2 days), prepare to be even less productive.  With a new  &lt;a class=&quot;reference external&quot; href=&quot;http://en.wikipedia.org/wiki/Wavefront_.obj_file&quot;&gt;OBJ file&lt;/a&gt; exporter, you can now
upload multiple surfaces of different transparencies in the same file.
The following code snippet produces two files which contain the vertex info
(surfaces.obj) and color/transparency info (surfaces.mtl) for a 3D
galaxy simulation:&lt;/p&gt;
&lt;pre class=&quot;code python literal-block&quot;&gt;
&lt;span class=&quot;keyword namespace&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;name namespace&quot;&gt;yt.mods&lt;/span&gt; &lt;span class=&quot;keyword namespace&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;*&lt;/span&gt;

&lt;span class=&quot;name&quot;&gt;pf&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;load&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;literal string double&quot;&gt;&amp;quot;/data/workshop2012/IsolatedGalaxy/galaxy0030/galaxy0030&amp;quot;&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;rho&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;literal number float&quot;&gt;2e-27&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;literal number float&quot;&gt;1e-27&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;trans&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;literal number float&quot;&gt;1.0&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;literal number float&quot;&gt;0.5&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;filename&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;literal string single&quot;&gt;'./surfaces'&lt;/span&gt;

&lt;span class=&quot;name&quot;&gt;sphere&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;pf&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;h&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;sphere&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;literal string double&quot;&gt;&amp;quot;max&amp;quot;&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;literal number float&quot;&gt;1.0&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;literal string double&quot;&gt;&amp;quot;mpc&amp;quot;&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;r&lt;/span&gt; &lt;span class=&quot;operator word&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;name builtin&quot;&gt;enumerate&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;rho&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;name&quot;&gt;surf&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;pf&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;h&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;surface&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;sphere&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;literal string single&quot;&gt;'Density'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;name&quot;&gt;surf&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;export_obj&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;filename&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;transparency&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;trans&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;color_field&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;literal string single&quot;&gt;'Temperature'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;plot_index&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;The calling sequence is fairly similar to the &lt;tt class=&quot;docutils literal&quot;&gt;export_ply&lt;/tt&gt; function
&lt;a class=&quot;reference external&quot; href=&quot;http://blog.yt-project.org/post/3DSurfacesAndSketchFab.html&quot;&gt;previously used&lt;/a&gt;
to export 3D surfaces.  However, one can now specify a transparency for each
surface of interest, and each surface is enumerated in the OBJ files with &lt;tt class=&quot;docutils literal&quot;&gt;plot_index&lt;/tt&gt;.
This means one could potentially add surfaces to a previously
created file by setting &lt;tt class=&quot;docutils literal&quot;&gt;plot_index&lt;/tt&gt; to the number of previously written
surfaces.&lt;/p&gt;
&lt;p&gt;One tricky thing: the header of the OBJ file points to the MTL file (with
the header command &lt;tt class=&quot;docutils literal&quot;&gt;mtllib&lt;/tt&gt;).  This means if you move one or both of the files
you may have to change the header to reflect their new directory location.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;a-few-more-options&quot;&gt;
&lt;h3&gt;A Few More Options&lt;/h3&gt;
&lt;p&gt;There are a few extra inputs for formatting the surface files you may want to use.&lt;/p&gt;
&lt;p&gt;(1) Setting &lt;tt class=&quot;docutils literal&quot;&gt;dist_fac&lt;/tt&gt; will divide all the vertex coordinates by this factor.
Default will scale the vertices by the physical bounds of your sphere.&lt;/p&gt;
&lt;p&gt;(2) Setting &lt;tt class=&quot;docutils literal&quot;&gt;color_field_max&lt;/tt&gt; and/or &lt;tt class=&quot;docutils literal&quot;&gt;color_field_min&lt;/tt&gt; will scale the colors
of all surfaces between this min and max.  Default is to scale the colors of each
surface to their own min and max values.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;uploading-to-sketchfab&quot;&gt;
&lt;h3&gt;Uploading to SketchFab&lt;/h3&gt;
&lt;p&gt;To upload to &lt;a class=&quot;reference external&quot; href=&quot;http://sketchfab.com&quot;&gt;Sketchfab&lt;/a&gt; one only needs to zip the
OBJ and MTL files together, and then upload via your dashboard prompts in
the usual way.  For example, the above script produces:&lt;/p&gt;
&lt;iframe frameborder=&quot;0&quot; height=&quot;480&quot; width=&quot;854&quot; allowFullScreen
webkitallowfullscreen=&quot;true&quot; mozallowfullscreen=&quot;true&quot;
src=&quot;http://skfb.ly/5k4j2fdcb?autostart=0&amp;transparent=0&amp;autospin=0&amp;controls=1&amp;watermark=1&quot;&gt;
&lt;/iframe&gt;&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;importing-to-meshlab-and-blender&quot;&gt;
&lt;h3&gt;Importing to MeshLab and Blender&lt;/h3&gt;
&lt;p&gt;The new OBJ formatting will produce multi-colored surfaces in both
&lt;a class=&quot;reference external&quot; href=&quot;http://meshlab.sourceforge.net/&quot;&gt;MeshLab&lt;/a&gt; and &lt;a class=&quot;reference external&quot; href=&quot;http://www.blender.org/&quot;&gt;Blender&lt;/a&gt;,
a feature not possible with the
&lt;a class=&quot;reference external&quot; href=&quot;http://blog.yt-project.org/post/3DSurfacesAndSketchFab.html&quot;&gt;previous PLY exporter&lt;/a&gt;.
To see colors in MeshLab go to the &amp;quot;Render&amp;quot; tab and
select &amp;quot;Color -&amp;gt; Per Face&amp;quot;.  Note in both MeshLab and Blender, unlike Sketchfab, you can't see
transparencies until you render.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;one-more-option&quot;&gt;
&lt;h3&gt;...One More Option&lt;/h3&gt;
&lt;p&gt;If you've started poking around the actual code instead of skipping off to
lose a few days running around your own simulations
you may have noticed there are a few more options then those listed above,
specifically, a few related to something called &amp;quot;Emissivity.&amp;quot;  This allows you
to output one more type of variable on your surfaces.  For example:&lt;/p&gt;
&lt;pre class=&quot;code python literal-block&quot;&gt;
&lt;span class=&quot;keyword namespace&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;name namespace&quot;&gt;yt.mods&lt;/span&gt; &lt;span class=&quot;keyword namespace&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;*&lt;/span&gt;

&lt;span class=&quot;name&quot;&gt;pf&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;load&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;literal string double&quot;&gt;&amp;quot;/data/workshop2012/IsolatedGalaxy/galaxy0030/galaxy0030&amp;quot;&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;rho&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;literal number float&quot;&gt;2e-27&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;literal number float&quot;&gt;1e-27&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;trans&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;literal number float&quot;&gt;1.0&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;literal number float&quot;&gt;0.5&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;filename&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;literal string single&quot;&gt;'./surfaces'&lt;/span&gt;

&lt;span class=&quot;keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;name function&quot;&gt;_Emissivity&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;field&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;literal string single&quot;&gt;'Density'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;literal string single&quot;&gt;'Density'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;sqrt&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;literal string single&quot;&gt;'Temperature'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;]))&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;add_field&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;literal string double&quot;&gt;&amp;quot;Emissivity&amp;quot;&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;_Emissivity&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;units&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;literal string double&quot;&gt;r&amp;quot;\rm{g K}/\rm{cm}^{6}&amp;quot;&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;name&quot;&gt;sphere&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;pf&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;h&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;sphere&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;literal string double&quot;&gt;&amp;quot;max&amp;quot;&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;literal number float&quot;&gt;1.0&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;literal string double&quot;&gt;&amp;quot;mpc&amp;quot;&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;r&lt;/span&gt; &lt;span class=&quot;operator word&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;name builtin&quot;&gt;enumerate&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;rho&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;name&quot;&gt;surf&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;pf&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;h&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;surface&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;sphere&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;literal string single&quot;&gt;'Density'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;name&quot;&gt;surf&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;export_obj&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;filename&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;transparency&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;trans&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;],&lt;/span&gt;
                    &lt;span class=&quot;name&quot;&gt;color_field&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;literal string single&quot;&gt;'Temperature'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;emit_field&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;literal string single&quot;&gt;'Emissivity'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt;
                    &lt;span class=&quot;name&quot;&gt;plot_index&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;will output the same OBJ and MTL as in our previous example, but it will scale
an emissivity parameter by our new field.  Technically, this makes our outputs
not really OBJ files at all, but a new sort of hybrid file, however we needn't worry
too much about that for now.&lt;/p&gt;
&lt;p&gt;This parameter is useful if you want to upload your files in Blender and have the
embedded rendering engine do some approximate ray-tracing on your transparencies
and emissivities.   This does take some slight modifications to the OBJ importer
scripts in Blender.  For example, on a Mac, you would modify the file
&amp;quot;/Applications/Blender/blender.app/Contents/MacOS/2.65/scripts/addons/io_scene_obj/import_obj.py&amp;quot;,
in the function &amp;quot;create_materials&amp;quot; with:&lt;/p&gt;
&lt;pre class=&quot;code python literal-block&quot;&gt;
&lt;span class=&quot;comment single&quot;&gt;# ...&lt;/span&gt;

                 &lt;span class=&quot;keyword&quot;&gt;elif&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;line_lower&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;startswith&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;literal string single&quot;&gt;'tr'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;):&lt;/span&gt;  &lt;span class=&quot;comment single&quot;&gt;# translucency&lt;/span&gt;
                     &lt;span class=&quot;name&quot;&gt;context_material&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;translucency&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;float_func&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;line_split&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;literal number integer&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;])&lt;/span&gt;
                 &lt;span class=&quot;keyword&quot;&gt;elif&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;line_lower&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;startswith&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;literal string single&quot;&gt;'tf'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;):&lt;/span&gt;
                     &lt;span class=&quot;comment single&quot;&gt;# rgb, filter color, blender has no support for this.&lt;/span&gt;
                     &lt;span class=&quot;keyword&quot;&gt;pass&lt;/span&gt;
                 &lt;span class=&quot;keyword&quot;&gt;elif&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;line_lower&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;startswith&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;literal string single&quot;&gt;'em'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;):&lt;/span&gt; &lt;span class=&quot;comment single&quot;&gt;# MODIFY: ADD THIS LINE&lt;/span&gt;
                     &lt;span class=&quot;name&quot;&gt;context_material&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;emit&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;float_func&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;line_split&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;literal number integer&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;])&lt;/span&gt; &lt;span class=&quot;comment single&quot;&gt;# MODIFY: THIS LINE TOO&lt;/span&gt;
                 &lt;span class=&quot;keyword&quot;&gt;elif&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;line_lower&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;startswith&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;literal string single&quot;&gt;'illum'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;):&lt;/span&gt;
                     &lt;span class=&quot;name&quot;&gt;illum&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name builtin&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;line_split&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;literal number integer&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;])&lt;/span&gt;

&lt;span class=&quot;comment single&quot;&gt;# ...&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;To use this in Blender, you might create a
&lt;a class=&quot;reference external&quot; href=&quot;http://cgcookie.com/blender/2011/08/26/introduction-to-scripting-with-python-in-blender/&quot;&gt;Blender script&lt;/a&gt;
like the following:&lt;/p&gt;
&lt;pre class=&quot;code python literal-block&quot;&gt;
&lt;span class=&quot;keyword namespace&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;name namespace&quot;&gt;bpy&lt;/span&gt;
&lt;span class=&quot;keyword namespace&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;name namespace&quot;&gt;math&lt;/span&gt; &lt;span class=&quot;keyword namespace&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;*&lt;/span&gt;

&lt;span class=&quot;name&quot;&gt;bpy&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;ops&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;import_scene&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;obj&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;filepath&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;literal string single&quot;&gt;'./surfaces.obj'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;comment single&quot;&gt;# will use new importer&lt;/span&gt;

&lt;span class=&quot;comment single&quot;&gt;# set up lighting = indirect&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;bpy&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;worlds&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;literal string single&quot;&gt;'World'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;light_settings&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;use_indirect_light&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name builtin pseudo&quot;&gt;True&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;bpy&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;worlds&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;literal string single&quot;&gt;'World'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;horizon_color&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;literal number float&quot;&gt;0.0&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;literal number float&quot;&gt;0.0&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;literal number float&quot;&gt;0.0&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;comment single&quot;&gt;# background = black&lt;/span&gt;
&lt;span class=&quot;comment single&quot;&gt;# have to use approximate, not ray tracing for emitting objects ...&lt;/span&gt;
&lt;span class=&quot;comment single&quot;&gt;#   ... for now...&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;bpy&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;worlds&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;literal string single&quot;&gt;'World'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;light_settings&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;gather_method&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;literal string single&quot;&gt;'APPROXIMATE'&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;bpy&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;worlds&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;literal string single&quot;&gt;'World'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;light_settings&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;indirect_factor&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;literal number float&quot;&gt;20.&lt;/span&gt; &lt;span class=&quot;comment single&quot;&gt;# turn up all emiss&lt;/span&gt;

&lt;span class=&quot;comment single&quot;&gt;# set up camera to be on -x axis, facing toward your object&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;scene&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;bpy&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;scenes&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;literal string double&quot;&gt;&amp;quot;Scene&amp;quot;&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;scene&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;camera&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;location&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;literal number float&quot;&gt;0.12&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;literal number float&quot;&gt;0.0&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;literal number float&quot;&gt;0.0&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;comment single&quot;&gt;# location&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;scene&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;camera&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;rotation_euler&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;radians&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;literal number float&quot;&gt;90.&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;literal number float&quot;&gt;0.0&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;radians&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;literal number float&quot;&gt;90.&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;)]&lt;/span&gt; &lt;span class=&quot;comment single&quot;&gt;# face to (0,0,0)&lt;/span&gt;

&lt;span class=&quot;comment single&quot;&gt;# render&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;scene&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;filepath&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;literal string single&quot;&gt;'/Users/jillnaiman/surfaces_blender'&lt;/span&gt; &lt;span class=&quot;comment single&quot;&gt;# needs full path&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;bpy&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;ops&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;write_still&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;name builtin pseudo&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;This above bit of code would produce an image like so:&lt;/p&gt;
&lt;img alt=&quot;/attachments/surfaces_blender.png&quot; src=&quot;/attachments/surfaces_blender.png&quot; /&gt;
&lt;p&gt;Note that the hottest stuff is brightly shining, while the cool stuff is less so
(making the inner isodensity contour barely visible from the outside of the surfaces).&lt;/p&gt;
&lt;p&gt;If the Blender image caught your fancy, you'll be happy to know there is a greater
integration of Blender and yt in the works, so stay tuned!&lt;/p&gt;
&lt;/div&gt;
</summary>
    <content type="html">&lt;div class=&quot;section&quot; id=&quot;obj-and-mtl-files&quot;&gt;
&lt;h3&gt;OBJ and MTL Files&lt;/h3&gt;
&lt;p&gt;If the ability to maneuver around an isosurface of your 3D simulation in
&lt;a class=&quot;reference external&quot; href=&quot;http://sketchfab.com&quot;&gt;Sketchfab&lt;/a&gt; cost you half a day of work (let's be
honest, 2 days), prepare to be even less productive.  With a new  &lt;a class=&quot;reference external&quot; href=&quot;http://en.wikipedia.org/wiki/Wavefront_.obj_file&quot;&gt;OBJ file&lt;/a&gt; exporter, you can now
upload multiple surfaces of different transparencies in the same file.
The following code snippet produces two files which contain the vertex info
(surfaces.obj) and color/transparency info (surfaces.mtl) for a 3D
galaxy simulation:&lt;/p&gt;
&lt;pre class=&quot;code python literal-block&quot;&gt;
&lt;span class=&quot;keyword namespace&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;name namespace&quot;&gt;yt.mods&lt;/span&gt; &lt;span class=&quot;keyword namespace&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;*&lt;/span&gt;

&lt;span class=&quot;name&quot;&gt;pf&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;load&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;literal string double&quot;&gt;&amp;quot;/data/workshop2012/IsolatedGalaxy/galaxy0030/galaxy0030&amp;quot;&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;rho&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;literal number float&quot;&gt;2e-27&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;literal number float&quot;&gt;1e-27&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;trans&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;literal number float&quot;&gt;1.0&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;literal number float&quot;&gt;0.5&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;filename&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;literal string single&quot;&gt;'./surfaces'&lt;/span&gt;

&lt;span class=&quot;name&quot;&gt;sphere&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;pf&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;h&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;sphere&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;literal string double&quot;&gt;&amp;quot;max&amp;quot;&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;literal number float&quot;&gt;1.0&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;literal string double&quot;&gt;&amp;quot;mpc&amp;quot;&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;r&lt;/span&gt; &lt;span class=&quot;operator word&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;name builtin&quot;&gt;enumerate&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;rho&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;name&quot;&gt;surf&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;pf&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;h&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;surface&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;sphere&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;literal string single&quot;&gt;'Density'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;name&quot;&gt;surf&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;export_obj&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;filename&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;transparency&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;trans&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;color_field&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;literal string single&quot;&gt;'Temperature'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;plot_index&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;The calling sequence is fairly similar to the &lt;tt class=&quot;docutils literal&quot;&gt;export_ply&lt;/tt&gt; function
&lt;a class=&quot;reference external&quot; href=&quot;http://blog.yt-project.org/post/3DSurfacesAndSketchFab.html&quot;&gt;previously used&lt;/a&gt;
to export 3D surfaces.  However, one can now specify a transparency for each
surface of interest, and each surface is enumerated in the OBJ files with &lt;tt class=&quot;docutils literal&quot;&gt;plot_index&lt;/tt&gt;.
This means one could potentially add surfaces to a previously
created file by setting &lt;tt class=&quot;docutils literal&quot;&gt;plot_index&lt;/tt&gt; to the number of previously written
surfaces.&lt;/p&gt;
&lt;p&gt;One tricky thing: the header of the OBJ file points to the MTL file (with
the header command &lt;tt class=&quot;docutils literal&quot;&gt;mtllib&lt;/tt&gt;).  This means if you move one or both of the files
you may have to change the header to reflect their new directory location.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;a-few-more-options&quot;&gt;
&lt;h3&gt;A Few More Options&lt;/h3&gt;
&lt;p&gt;There are a few extra inputs for formatting the surface files you may want to use.&lt;/p&gt;
&lt;p&gt;(1) Setting &lt;tt class=&quot;docutils literal&quot;&gt;dist_fac&lt;/tt&gt; will divide all the vertex coordinates by this factor.
Default will scale the vertices by the physical bounds of your sphere.&lt;/p&gt;
&lt;p&gt;(2) Setting &lt;tt class=&quot;docutils literal&quot;&gt;color_field_max&lt;/tt&gt; and/or &lt;tt class=&quot;docutils literal&quot;&gt;color_field_min&lt;/tt&gt; will scale the colors
of all surfaces between this min and max.  Default is to scale the colors of each
surface to their own min and max values.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;uploading-to-sketchfab&quot;&gt;
&lt;h3&gt;Uploading to SketchFab&lt;/h3&gt;
&lt;p&gt;To upload to &lt;a class=&quot;reference external&quot; href=&quot;http://sketchfab.com&quot;&gt;Sketchfab&lt;/a&gt; one only needs to zip the
OBJ and MTL files together, and then upload via your dashboard prompts in
the usual way.  For example, the above script produces:&lt;/p&gt;
&lt;iframe frameborder=&quot;0&quot; height=&quot;480&quot; width=&quot;854&quot; allowFullScreen
webkitallowfullscreen=&quot;true&quot; mozallowfullscreen=&quot;true&quot;
src=&quot;http://skfb.ly/5k4j2fdcb?autostart=0&amp;transparent=0&amp;autospin=0&amp;controls=1&amp;watermark=1&quot;&gt;
&lt;/iframe&gt;&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;importing-to-meshlab-and-blender&quot;&gt;
&lt;h3&gt;Importing to MeshLab and Blender&lt;/h3&gt;
&lt;p&gt;The new OBJ formatting will produce multi-colored surfaces in both
&lt;a class=&quot;reference external&quot; href=&quot;http://meshlab.sourceforge.net/&quot;&gt;MeshLab&lt;/a&gt; and &lt;a class=&quot;reference external&quot; href=&quot;http://www.blender.org/&quot;&gt;Blender&lt;/a&gt;,
a feature not possible with the
&lt;a class=&quot;reference external&quot; href=&quot;http://blog.yt-project.org/post/3DSurfacesAndSketchFab.html&quot;&gt;previous PLY exporter&lt;/a&gt;.
To see colors in MeshLab go to the &amp;quot;Render&amp;quot; tab and
select &amp;quot;Color -&amp;gt; Per Face&amp;quot;.  Note in both MeshLab and Blender, unlike Sketchfab, you can't see
transparencies until you render.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;one-more-option&quot;&gt;
&lt;h3&gt;...One More Option&lt;/h3&gt;
&lt;p&gt;If you've started poking around the actual code instead of skipping off to
lose a few days running around your own simulations
you may have noticed there are a few more options then those listed above,
specifically, a few related to something called &amp;quot;Emissivity.&amp;quot;  This allows you
to output one more type of variable on your surfaces.  For example:&lt;/p&gt;
&lt;pre class=&quot;code python literal-block&quot;&gt;
&lt;span class=&quot;keyword namespace&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;name namespace&quot;&gt;yt.mods&lt;/span&gt; &lt;span class=&quot;keyword namespace&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;*&lt;/span&gt;

&lt;span class=&quot;name&quot;&gt;pf&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;load&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;literal string double&quot;&gt;&amp;quot;/data/workshop2012/IsolatedGalaxy/galaxy0030/galaxy0030&amp;quot;&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;rho&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;literal number float&quot;&gt;2e-27&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;literal number float&quot;&gt;1e-27&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;trans&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;literal number float&quot;&gt;1.0&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;literal number float&quot;&gt;0.5&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;filename&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;literal string single&quot;&gt;'./surfaces'&lt;/span&gt;

&lt;span class=&quot;keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;name function&quot;&gt;_Emissivity&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;field&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;literal string single&quot;&gt;'Density'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;literal string single&quot;&gt;'Density'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;sqrt&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;literal string single&quot;&gt;'Temperature'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;]))&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;add_field&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;literal string double&quot;&gt;&amp;quot;Emissivity&amp;quot;&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;_Emissivity&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;units&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;literal string double&quot;&gt;r&amp;quot;\rm{g K}/\rm{cm}^{6}&amp;quot;&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;name&quot;&gt;sphere&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;pf&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;h&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;sphere&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;literal string double&quot;&gt;&amp;quot;max&amp;quot;&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;literal number float&quot;&gt;1.0&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;literal string double&quot;&gt;&amp;quot;mpc&amp;quot;&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;r&lt;/span&gt; &lt;span class=&quot;operator word&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;name builtin&quot;&gt;enumerate&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;rho&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;name&quot;&gt;surf&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;pf&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;h&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;surface&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;sphere&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;literal string single&quot;&gt;'Density'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;name&quot;&gt;surf&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;export_obj&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;filename&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;transparency&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;trans&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;],&lt;/span&gt;
                    &lt;span class=&quot;name&quot;&gt;color_field&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;literal string single&quot;&gt;'Temperature'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;emit_field&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;literal string single&quot;&gt;'Emissivity'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt;
                    &lt;span class=&quot;name&quot;&gt;plot_index&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;will output the same OBJ and MTL as in our previous example, but it will scale
an emissivity parameter by our new field.  Technically, this makes our outputs
not really OBJ files at all, but a new sort of hybrid file, however we needn't worry
too much about that for now.&lt;/p&gt;
&lt;p&gt;This parameter is useful if you want to upload your files in Blender and have the
embedded rendering engine do some approximate ray-tracing on your transparencies
and emissivities.   This does take some slight modifications to the OBJ importer
scripts in Blender.  For example, on a Mac, you would modify the file
&amp;quot;/Applications/Blender/blender.app/Contents/MacOS/2.65/scripts/addons/io_scene_obj/import_obj.py&amp;quot;,
in the function &amp;quot;create_materials&amp;quot; with:&lt;/p&gt;
&lt;pre class=&quot;code python literal-block&quot;&gt;
&lt;span class=&quot;comment single&quot;&gt;# ...&lt;/span&gt;

                 &lt;span class=&quot;keyword&quot;&gt;elif&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;line_lower&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;startswith&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;literal string single&quot;&gt;'tr'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;):&lt;/span&gt;  &lt;span class=&quot;comment single&quot;&gt;# translucency&lt;/span&gt;
                     &lt;span class=&quot;name&quot;&gt;context_material&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;translucency&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;float_func&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;line_split&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;literal number integer&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;])&lt;/span&gt;
                 &lt;span class=&quot;keyword&quot;&gt;elif&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;line_lower&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;startswith&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;literal string single&quot;&gt;'tf'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;):&lt;/span&gt;
                     &lt;span class=&quot;comment single&quot;&gt;# rgb, filter color, blender has no support for this.&lt;/span&gt;
                     &lt;span class=&quot;keyword&quot;&gt;pass&lt;/span&gt;
                 &lt;span class=&quot;keyword&quot;&gt;elif&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;line_lower&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;startswith&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;literal string single&quot;&gt;'em'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;):&lt;/span&gt; &lt;span class=&quot;comment single&quot;&gt;# MODIFY: ADD THIS LINE&lt;/span&gt;
                     &lt;span class=&quot;name&quot;&gt;context_material&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;emit&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;float_func&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;line_split&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;literal number integer&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;])&lt;/span&gt; &lt;span class=&quot;comment single&quot;&gt;# MODIFY: THIS LINE TOO&lt;/span&gt;
                 &lt;span class=&quot;keyword&quot;&gt;elif&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;line_lower&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;startswith&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;literal string single&quot;&gt;'illum'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;):&lt;/span&gt;
                     &lt;span class=&quot;name&quot;&gt;illum&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name builtin&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;line_split&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;literal number integer&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;])&lt;/span&gt;

&lt;span class=&quot;comment single&quot;&gt;# ...&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;To use this in Blender, you might create a
&lt;a class=&quot;reference external&quot; href=&quot;http://cgcookie.com/blender/2011/08/26/introduction-to-scripting-with-python-in-blender/&quot;&gt;Blender script&lt;/a&gt;
like the following:&lt;/p&gt;
&lt;pre class=&quot;code python literal-block&quot;&gt;
&lt;span class=&quot;keyword namespace&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;name namespace&quot;&gt;bpy&lt;/span&gt;
&lt;span class=&quot;keyword namespace&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;name namespace&quot;&gt;math&lt;/span&gt; &lt;span class=&quot;keyword namespace&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;*&lt;/span&gt;

&lt;span class=&quot;name&quot;&gt;bpy&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;ops&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;import_scene&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;obj&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;filepath&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;literal string single&quot;&gt;'./surfaces.obj'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;comment single&quot;&gt;# will use new importer&lt;/span&gt;

&lt;span class=&quot;comment single&quot;&gt;# set up lighting = indirect&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;bpy&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;worlds&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;literal string single&quot;&gt;'World'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;light_settings&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;use_indirect_light&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name builtin pseudo&quot;&gt;True&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;bpy&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;worlds&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;literal string single&quot;&gt;'World'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;horizon_color&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;literal number float&quot;&gt;0.0&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;literal number float&quot;&gt;0.0&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;literal number float&quot;&gt;0.0&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;comment single&quot;&gt;# background = black&lt;/span&gt;
&lt;span class=&quot;comment single&quot;&gt;# have to use approximate, not ray tracing for emitting objects ...&lt;/span&gt;
&lt;span class=&quot;comment single&quot;&gt;#   ... for now...&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;bpy&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;worlds&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;literal string single&quot;&gt;'World'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;light_settings&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;gather_method&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;literal string single&quot;&gt;'APPROXIMATE'&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;bpy&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;worlds&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;literal string single&quot;&gt;'World'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;light_settings&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;indirect_factor&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;literal number float&quot;&gt;20.&lt;/span&gt; &lt;span class=&quot;comment single&quot;&gt;# turn up all emiss&lt;/span&gt;

&lt;span class=&quot;comment single&quot;&gt;# set up camera to be on -x axis, facing toward your object&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;scene&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;bpy&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;scenes&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;literal string double&quot;&gt;&amp;quot;Scene&amp;quot;&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;scene&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;camera&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;location&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;literal number float&quot;&gt;0.12&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;literal number float&quot;&gt;0.0&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;literal number float&quot;&gt;0.0&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;comment single&quot;&gt;# location&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;scene&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;camera&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;rotation_euler&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;radians&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;literal number float&quot;&gt;90.&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;literal number float&quot;&gt;0.0&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;radians&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;literal number float&quot;&gt;90.&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;)]&lt;/span&gt; &lt;span class=&quot;comment single&quot;&gt;# face to (0,0,0)&lt;/span&gt;

&lt;span class=&quot;comment single&quot;&gt;# render&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;scene&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;filepath&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;literal string single&quot;&gt;'/Users/jillnaiman/surfaces_blender'&lt;/span&gt; &lt;span class=&quot;comment single&quot;&gt;# needs full path&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;bpy&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;ops&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;write_still&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;name builtin pseudo&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;This above bit of code would produce an image like so:&lt;/p&gt;
&lt;img alt=&quot;/attachments/surfaces_blender.png&quot; src=&quot;/attachments/surfaces_blender.png&quot; /&gt;
&lt;p&gt;Note that the hottest stuff is brightly shining, while the cool stuff is less so
(making the inner isodensity contour barely visible from the outside of the surfaces).&lt;/p&gt;
&lt;p&gt;If the Blender image caught your fancy, you'll be happy to know there is a greater
integration of Blender and yt in the works, so stay tuned!&lt;/p&gt;
&lt;/div&gt;
</content>
  </entry>
  <entry>
    <title type="text">The First Development Workshop</title>
    <id>/post/DevelopmentWorkshop2013/</id>
    <updated>2013-03-18T17:11:12Z</updated>
    <published>2013-03-18T17:11:12Z</published>
    <link href="/post/DevelopmentWorkshop2013/" />
    <author>
      <name>Matthew Turk</name>
      <email>matthewturk@gmail.com</email>
    </author>
    <summary type="html">&lt;p&gt;March 6-8, we held a yt-dev workshop at UCSC.  Thanks to everyone who attended,
as well as Joel Primack and &lt;a class=&quot;reference external&quot; href=&quot;http://hipacc.ucsc.edu/&quot;&gt;HIPACC&lt;/a&gt; for sponsoring
us.  This was the &lt;em&gt;first&lt;/em&gt; development-oriented workshop we've ever held, and it
was a gigantic success!  To see a full photo album, visit our
&lt;a class=&quot;reference external&quot; href=&quot;https://plus.google.com/107728486871834552760/posts/BGi1ah4cNMh&quot;&gt;Google Plus Page&lt;/a&gt;.&lt;/p&gt;
&lt;img alt=&quot;/attachments/devworkshop.jpg&quot; class=&quot;align-right&quot; src=&quot;/attachments/devworkshop.jpg&quot; style=&quot;width: 400px; height: 300px;&quot; /&gt;
&lt;p&gt;With local organization by Nathan Goldbaum, Chris Moody and Ji-hoon Kim at
UCSC, over twenty people were able to participate, working on a diverse set of
projects.  The workshop was structured around introducing topics through
lightning talks and then sprinting on those topics during breakout sessions.&lt;/p&gt;
&lt;p&gt;The lightning talks were set up to be one slide (or ten notebook cells, if you
used the IPython notebook!) presenting a concept with ideas for going into the
breakout sessions.  These were isolated ideas -- shovel-ready, with working
guidelines.  We had talks from John ZuHone, Casey Stark, Kacper Kowalik,
Cameron Hummels, Doug Rudd, Britton Smith, Jeff Oishi, Nathan Goldbaum and
Chris Moody.  Following this, we split into a series of breakout groups.&lt;/p&gt;
&lt;p&gt;We also had talks from Joel Primack presenting the AGORA project and from Hari
Krishnan about his work to integrate yt and VisIt.  On the final day, we also
had a show-and-tell, where a member of each working group presented what they
worked on and what they accomplished.&lt;/p&gt;
&lt;div class=&quot;section&quot; id=&quot;grid-data-format&quot;&gt;
&lt;h3&gt;Grid Data Format&lt;/h3&gt;
&lt;p&gt;This breakout group focused on building a portable library in C for reading and
writing data that takes the form of structured, rectilinear grids.  The idea
here is to adhere to the &lt;a class=&quot;reference external&quot; href=&quot;https://bitbucket.org/yt_analysis/grid_data_format&quot;&gt;GDF format&lt;/a&gt;, which specifies a
self-describing HDF5 layout for files.  By developing this portable library,
the group hopes to be able to use yt to &lt;a class=&quot;reference external&quot; href=&quot;http://blog.yt-project.org/post/Simple_Grid_Refinement.html&quot;&gt;make initial conditions&lt;/a&gt;, write them out
in the already-existing GDF writer in yt, and then link simulation codes
against this library to read them back in and run simulations.  It would also
enable directly converting between simulation code outputs.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;units-and-arrays&quot;&gt;
&lt;h3&gt;Units and Arrays&lt;/h3&gt;
&lt;p&gt;This group ambitiously set out the task of incorporating Casey's library
&lt;a class=&quot;reference external&quot; href=&quot;http://caseywstark.com/blog/2012/code-release-dimensionful/&quot;&gt;dimensionful&lt;/a&gt;
into yt.  This library utilizes SymPy for developing a units system that can
convert between known units as well as affiliate those units with array
objects.  The hope here is to eliminate much of the existing unit handling and
field duplication (i.e., CellMass and CellMassMsun) and provide easier methods
for deploying unit conversions.  This work may take some time to integrate into
yt 3.0, but it will be a feature of that codebase eventually.  By the end of
the workshop, this group had a working implementation.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;halo-catalogs&quot;&gt;
&lt;h3&gt;Halo Catalogs&lt;/h3&gt;
&lt;p&gt;The current system for handling halos and halo catalogs in yt is a bit &lt;em&gt;ad
hoc&lt;/em&gt;, where objects are passed around and data held onto for some time.  This
is inefficient and doesn't lend itself well to agile and flexible halo finding.
This working group developed a rough outline of a YTEP that described halo
finding and halo catalogs as a state of &lt;em&gt;flow&lt;/em&gt; -- rather than performing
analysis after the fact, analysis will now be performed during the course of
halo finding.  This will be done by supplying a set of callbacks that will be
executed on each halo in turn.  An ontology for describing halo catalogs was
also developed, which is being fleshed out in a YTEP.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;octree-improvements&quot;&gt;
&lt;h3&gt;Octree Improvements&lt;/h3&gt;
&lt;p&gt;Some representatives of the NMSU-ART code were present at the workshop.  This
working group focused on cleaning up the rough edes of the Octree support in
yt-3.0, as well as applying it to some actual data.  Chris spent quite a bit of
time polishing up star particle IO, fixing rough corners in the octree code,
and testing things.  Kenza gave a show-and-tell talk on the final day showing
how she was able to load up a galaxy formation simulation and plot streamlines,
all in a few lines of code.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;artio&quot;&gt;
&lt;h3&gt;ARTIO&lt;/h3&gt;
&lt;p&gt;For extremely large Octree datasets, it's simply infeasible to load the entire
mesh into memory.  The ARTIO working group worked to develop opaque data chunks
in yt-3.0, so that yt can iterate over chunks, build data objects, perform
processing, and conduct visualization all without needing to know how the data
is laid out on disk or knowing anything about the mesh at all!  This is an
extremely powerful concept, and will hopefully present a number of
opportunities for applying this elsewhere in the future.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;volume-rendering&quot;&gt;
&lt;h3&gt;Volume Rendering&lt;/h3&gt;
&lt;p&gt;The method by which volume renderings are created in yt is a bit clunky right
now.  Many arguments are pushed into the constructor for the Camera object, and
then there's a limited flexibility after that.  This working group built off of
the still-pending YTEP-0010 to build a new system for creating volume
renderings with a stateful Scene, cameras that move, volumes that don't, and so
on.  Cameron, Mark and Will demoed a working implementation of a Scene object
on the final day.  Jill also was able to demo on the final day some initial
integration of yt with Blender -- showing how to script the camera path via
Python, display surfaces extracted with yt, and make movies from them.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;thank-you&quot;&gt;
&lt;h3&gt;Thank you!&lt;/h3&gt;
&lt;p&gt;Thanks to everyone who attended!  It was a great time, and I think we're all
excited to have another one sometime in the future.&lt;/p&gt;
&lt;/div&gt;
</summary>
    <content type="html">&lt;p&gt;March 6-8, we held a yt-dev workshop at UCSC.  Thanks to everyone who attended,
as well as Joel Primack and &lt;a class=&quot;reference external&quot; href=&quot;http://hipacc.ucsc.edu/&quot;&gt;HIPACC&lt;/a&gt; for sponsoring
us.  This was the &lt;em&gt;first&lt;/em&gt; development-oriented workshop we've ever held, and it
was a gigantic success!  To see a full photo album, visit our
&lt;a class=&quot;reference external&quot; href=&quot;https://plus.google.com/107728486871834552760/posts/BGi1ah4cNMh&quot;&gt;Google Plus Page&lt;/a&gt;.&lt;/p&gt;
&lt;img alt=&quot;/attachments/devworkshop.jpg&quot; class=&quot;align-right&quot; src=&quot;/attachments/devworkshop.jpg&quot; style=&quot;width: 400px; height: 300px;&quot; /&gt;
&lt;p&gt;With local organization by Nathan Goldbaum, Chris Moody and Ji-hoon Kim at
UCSC, over twenty people were able to participate, working on a diverse set of
projects.  The workshop was structured around introducing topics through
lightning talks and then sprinting on those topics during breakout sessions.&lt;/p&gt;
&lt;p&gt;The lightning talks were set up to be one slide (or ten notebook cells, if you
used the IPython notebook!) presenting a concept with ideas for going into the
breakout sessions.  These were isolated ideas -- shovel-ready, with working
guidelines.  We had talks from John ZuHone, Casey Stark, Kacper Kowalik,
Cameron Hummels, Doug Rudd, Britton Smith, Jeff Oishi, Nathan Goldbaum and
Chris Moody.  Following this, we split into a series of breakout groups.&lt;/p&gt;
&lt;p&gt;We also had talks from Joel Primack presenting the AGORA project and from Hari
Krishnan about his work to integrate yt and VisIt.  On the final day, we also
had a show-and-tell, where a member of each working group presented what they
worked on and what they accomplished.&lt;/p&gt;
&lt;div class=&quot;section&quot; id=&quot;grid-data-format&quot;&gt;
&lt;h3&gt;Grid Data Format&lt;/h3&gt;
&lt;p&gt;This breakout group focused on building a portable library in C for reading and
writing data that takes the form of structured, rectilinear grids.  The idea
here is to adhere to the &lt;a class=&quot;reference external&quot; href=&quot;https://bitbucket.org/yt_analysis/grid_data_format&quot;&gt;GDF format&lt;/a&gt;, which specifies a
self-describing HDF5 layout for files.  By developing this portable library,
the group hopes to be able to use yt to &lt;a class=&quot;reference external&quot; href=&quot;http://blog.yt-project.org/post/Simple_Grid_Refinement.html&quot;&gt;make initial conditions&lt;/a&gt;, write them out
in the already-existing GDF writer in yt, and then link simulation codes
against this library to read them back in and run simulations.  It would also
enable directly converting between simulation code outputs.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;units-and-arrays&quot;&gt;
&lt;h3&gt;Units and Arrays&lt;/h3&gt;
&lt;p&gt;This group ambitiously set out the task of incorporating Casey's library
&lt;a class=&quot;reference external&quot; href=&quot;http://caseywstark.com/blog/2012/code-release-dimensionful/&quot;&gt;dimensionful&lt;/a&gt;
into yt.  This library utilizes SymPy for developing a units system that can
convert between known units as well as affiliate those units with array
objects.  The hope here is to eliminate much of the existing unit handling and
field duplication (i.e., CellMass and CellMassMsun) and provide easier methods
for deploying unit conversions.  This work may take some time to integrate into
yt 3.0, but it will be a feature of that codebase eventually.  By the end of
the workshop, this group had a working implementation.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;halo-catalogs&quot;&gt;
&lt;h3&gt;Halo Catalogs&lt;/h3&gt;
&lt;p&gt;The current system for handling halos and halo catalogs in yt is a bit &lt;em&gt;ad
hoc&lt;/em&gt;, where objects are passed around and data held onto for some time.  This
is inefficient and doesn't lend itself well to agile and flexible halo finding.
This working group developed a rough outline of a YTEP that described halo
finding and halo catalogs as a state of &lt;em&gt;flow&lt;/em&gt; -- rather than performing
analysis after the fact, analysis will now be performed during the course of
halo finding.  This will be done by supplying a set of callbacks that will be
executed on each halo in turn.  An ontology for describing halo catalogs was
also developed, which is being fleshed out in a YTEP.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;octree-improvements&quot;&gt;
&lt;h3&gt;Octree Improvements&lt;/h3&gt;
&lt;p&gt;Some representatives of the NMSU-ART code were present at the workshop.  This
working group focused on cleaning up the rough edes of the Octree support in
yt-3.0, as well as applying it to some actual data.  Chris spent quite a bit of
time polishing up star particle IO, fixing rough corners in the octree code,
and testing things.  Kenza gave a show-and-tell talk on the final day showing
how she was able to load up a galaxy formation simulation and plot streamlines,
all in a few lines of code.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;artio&quot;&gt;
&lt;h3&gt;ARTIO&lt;/h3&gt;
&lt;p&gt;For extremely large Octree datasets, it's simply infeasible to load the entire
mesh into memory.  The ARTIO working group worked to develop opaque data chunks
in yt-3.0, so that yt can iterate over chunks, build data objects, perform
processing, and conduct visualization all without needing to know how the data
is laid out on disk or knowing anything about the mesh at all!  This is an
extremely powerful concept, and will hopefully present a number of
opportunities for applying this elsewhere in the future.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;volume-rendering&quot;&gt;
&lt;h3&gt;Volume Rendering&lt;/h3&gt;
&lt;p&gt;The method by which volume renderings are created in yt is a bit clunky right
now.  Many arguments are pushed into the constructor for the Camera object, and
then there's a limited flexibility after that.  This working group built off of
the still-pending YTEP-0010 to build a new system for creating volume
renderings with a stateful Scene, cameras that move, volumes that don't, and so
on.  Cameron, Mark and Will demoed a working implementation of a Scene object
on the final day.  Jill also was able to demo on the final day some initial
integration of yt with Blender -- showing how to script the camera path via
Python, display surfaces extracted with yt, and make movies from them.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;thank-you&quot;&gt;
&lt;h3&gt;Thank you!&lt;/h3&gt;
&lt;p&gt;Thanks to everyone who attended!  It was a great time, and I think we're all
excited to have another one sometime in the future.&lt;/p&gt;
&lt;/div&gt;
</content>
  </entry>
  <entry>
    <title type="text">yt 2.5 released!</title>
    <id>/post/yt2.5_released/</id>
    <updated>2013-03-02T04:57:44Z</updated>
    <published>2013-03-02T04:57:44Z</published>
    <link href="/post/yt2.5_released/" />
    <author>
      <name>John ZuHone</name>
      <email>jzuhone@gmail.com</email>
    </author>
    <summary type="html">&lt;!-- author: John ZuHone &lt;jzuhone@gmail.com&gt; --&gt;
&lt;!-- date: 1362200264 --&gt;
&lt;p&gt;We’re proud to announce the release of version 2.5 of the yt Project, &lt;a class=&quot;reference external&quot; href=&quot;http://yt-project.org/&quot;&gt;http://yt-project.org/&lt;/a&gt;. The new version includes many new features, refinements of existing features, and numerous bugfixes.  We encourage all users to upgrade to take advantage of the changes.&lt;/p&gt;
&lt;p&gt;yt is a community-developed analysis and visualization toolkit, primarily directed at astrophysical hydrodynamics simulations.  It provides full support for output from the Enzo, FLASH, Orion, and Nyx codes, with preliminary support for several others.  It provides access to simulation data using an intuitive python interface, can perform many common visualization tasks, and offers a framework for conducting data reductions and analysis of simulation data.&lt;/p&gt;
&lt;p&gt;The most visible changes with the 2.5 release include:&lt;/p&gt;
&lt;blockquote&gt;
&lt;ul class=&quot;simple&quot;&gt;
&lt;li&gt;Testing has been greatly expanded, including unit tests and answer testing.&lt;/li&gt;
&lt;li&gt;The capabilities of the &lt;tt class=&quot;docutils literal&quot;&gt;Stream&lt;/tt&gt; frontend have been expanded. Uniform
grid and AMR-based data can be read into memory, and particle fields can be
initialized.&lt;/li&gt;
&lt;li&gt;The install script now provides for the optional installation of SciPy and the
Rockstar halo finder.&lt;/li&gt;
&lt;li&gt;Surfaces can now be extracted and examined, as well as uploaded to
Sketchfab.com for interactive visualization in a web browser.&lt;/li&gt;
&lt;li&gt;Support for the Athena code has been added.&lt;/li&gt;
&lt;li&gt;Many, many improvements to PlotWindow.&lt;/li&gt;
&lt;li&gt;Coordinate transformations have been sped up and streamlined, as well as
cylindrical and spherical fields.&lt;/li&gt;
&lt;li&gt;Increased support for the IPython notebook.&lt;/li&gt;
&lt;li&gt;Improved support for FLASH particle fields.&lt;/li&gt;
&lt;li&gt;The volume rendering backend has been updated to use an alpha channel, fixing
parallel opaque volume renderings.&lt;/li&gt;
&lt;li&gt;The AMRKDTree has been rewritten, allowing parallelism with other than
power-of-2 MPI processes, arbitrary sets of grids, and splitting of unigrids.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;p&gt;For a complete list of changes in this release, please visit the Changelog (&lt;a class=&quot;reference external&quot; href=&quot;http://yt-project.org/docs/2.5/changelog.html&quot;&gt;http://yt-project.org/docs/2.5/changelog.html&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;Information about the yt project, including installation instructions, can be found on the homepage: &lt;a class=&quot;reference external&quot; href=&quot;http://yt-project.org/&quot;&gt;http://yt-project.org/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Development of yt has been sponsored by the NSF, the DOE, and various universities.  We develop yt in the open and encourage contributions from users who extend and improve the code.  We invite you to get involved with developing and using yt!&lt;/p&gt;
</summary>
    <content type="html">&lt;!-- author: John ZuHone &lt;jzuhone@gmail.com&gt; --&gt;
&lt;!-- date: 1362200264 --&gt;
&lt;p&gt;We’re proud to announce the release of version 2.5 of the yt Project, &lt;a class=&quot;reference external&quot; href=&quot;http://yt-project.org/&quot;&gt;http://yt-project.org/&lt;/a&gt;. The new version includes many new features, refinements of existing features, and numerous bugfixes.  We encourage all users to upgrade to take advantage of the changes.&lt;/p&gt;
&lt;p&gt;yt is a community-developed analysis and visualization toolkit, primarily directed at astrophysical hydrodynamics simulations.  It provides full support for output from the Enzo, FLASH, Orion, and Nyx codes, with preliminary support for several others.  It provides access to simulation data using an intuitive python interface, can perform many common visualization tasks, and offers a framework for conducting data reductions and analysis of simulation data.&lt;/p&gt;
&lt;p&gt;The most visible changes with the 2.5 release include:&lt;/p&gt;
&lt;blockquote&gt;
&lt;ul class=&quot;simple&quot;&gt;
&lt;li&gt;Testing has been greatly expanded, including unit tests and answer testing.&lt;/li&gt;
&lt;li&gt;The capabilities of the &lt;tt class=&quot;docutils literal&quot;&gt;Stream&lt;/tt&gt; frontend have been expanded. Uniform
grid and AMR-based data can be read into memory, and particle fields can be
initialized.&lt;/li&gt;
&lt;li&gt;The install script now provides for the optional installation of SciPy and the
Rockstar halo finder.&lt;/li&gt;
&lt;li&gt;Surfaces can now be extracted and examined, as well as uploaded to
Sketchfab.com for interactive visualization in a web browser.&lt;/li&gt;
&lt;li&gt;Support for the Athena code has been added.&lt;/li&gt;
&lt;li&gt;Many, many improvements to PlotWindow.&lt;/li&gt;
&lt;li&gt;Coordinate transformations have been sped up and streamlined, as well as
cylindrical and spherical fields.&lt;/li&gt;
&lt;li&gt;Increased support for the IPython notebook.&lt;/li&gt;
&lt;li&gt;Improved support for FLASH particle fields.&lt;/li&gt;
&lt;li&gt;The volume rendering backend has been updated to use an alpha channel, fixing
parallel opaque volume renderings.&lt;/li&gt;
&lt;li&gt;The AMRKDTree has been rewritten, allowing parallelism with other than
power-of-2 MPI processes, arbitrary sets of grids, and splitting of unigrids.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;p&gt;For a complete list of changes in this release, please visit the Changelog (&lt;a class=&quot;reference external&quot; href=&quot;http://yt-project.org/docs/2.5/changelog.html&quot;&gt;http://yt-project.org/docs/2.5/changelog.html&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;Information about the yt project, including installation instructions, can be found on the homepage: &lt;a class=&quot;reference external&quot; href=&quot;http://yt-project.org/&quot;&gt;http://yt-project.org/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Development of yt has been sponsored by the NSF, the DOE, and various universities.  We develop yt in the open and encourage contributions from users who extend and improve the code.  We invite you to get involved with developing and using yt!&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title type="text">yt-dev 2013</title>
    <id>/post/yt-dev-2013/</id>
    <updated>2013-01-16T18:42:26Z</updated>
    <published>2013-01-16T18:42:26Z</published>
    <link href="/post/yt-dev-2013/" />
    <author>
      <name>Nathan Goldbaum</name>
      <email>goldbaum@ucolick.org</email>
    </author>
    <summary type="html">&lt;p&gt;We are proud to officially announce the upcoming 2013 yt developer workshop.
This three day event, to be held on the campus of the University of California,
Santa Cruz on March 6th through 8th, will bring together a diverse group of
students, researchers, and developers.&lt;/p&gt;
&lt;p&gt;Up to this point, yt development has proceeded largely over the internet,
leveraging &lt;a class=&quot;reference external&quot; href=&quot;http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org&quot;&gt;e-mail lists&lt;/a&gt;, our &lt;a class=&quot;reference external&quot; href=&quot;https://bitbucket.org/yt_analysis&quot;&gt;online code repository&lt;/a&gt;, and &lt;a class=&quot;reference external&quot; href=&quot;http://yt-project.org/irc.html&quot;&gt;IRC&lt;/a&gt; to track,
discuss, and evaluate changes to the code.  Unfortunately, this model makes it
difficult to jump in to development as a newcomer.  This workshop will not only
allow experienced developers to collaborate in person on new features, but will
also be a means for new developers to learn what yt is about and begin
contributing.  The workshop will include several training sessions, constituting
a primer in distributed version control, test-driven development, and best
practices for scientific programming.&lt;/p&gt;
&lt;p&gt;The workshop will also serve as a venue to plan and execute some of the major
new features we are planning for the upcoming yt 3.0 release, including full
support for outputs of Lagrangian codes like Gadget, Gasoline and AREPO, better
support for oct-based codes like ART and RAMSES, initial conditions generation,
the new Grid Data Format, a new way of handling units and unit conversion,
non-cartesian geometries, and advanced graphical browser widgets inside the
iPython notebook.&lt;/p&gt;
&lt;p&gt;More information and a registration form for the workshop are available on the
&lt;a class=&quot;reference external&quot; href=&quot;http://yt-project.org/workshop2013&quot;&gt;workshop website&lt;/a&gt;. We have limited funding support for hotels and airfare.
Funds will be preferentially distributed to students and the level of individual
support will depend on demand.&lt;/p&gt;
&lt;p&gt;If you have questions or concerns about the workshop, please feel free to
contact the organizers at &lt;a class=&quot;reference external&quot; href=&quot;mailto:workshop2013&amp;#64;yt-project.org&quot;&gt;workshop2013&amp;#64;yt-project.org&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;On behalf of the organizing committee,&lt;/p&gt;
&lt;p&gt;Nathan Goldbaum&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;We are proud to officially announce the upcoming 2013 yt developer workshop.
This three day event, to be held on the campus of the University of California,
Santa Cruz on March 6th through 8th, will bring together a diverse group of
students, researchers, and developers.&lt;/p&gt;
&lt;p&gt;Up to this point, yt development has proceeded largely over the internet,
leveraging &lt;a class=&quot;reference external&quot; href=&quot;http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org&quot;&gt;e-mail lists&lt;/a&gt;, our &lt;a class=&quot;reference external&quot; href=&quot;https://bitbucket.org/yt_analysis&quot;&gt;online code repository&lt;/a&gt;, and &lt;a class=&quot;reference external&quot; href=&quot;http://yt-project.org/irc.html&quot;&gt;IRC&lt;/a&gt; to track,
discuss, and evaluate changes to the code.  Unfortunately, this model makes it
difficult to jump in to development as a newcomer.  This workshop will not only
allow experienced developers to collaborate in person on new features, but will
also be a means for new developers to learn what yt is about and begin
contributing.  The workshop will include several training sessions, constituting
a primer in distributed version control, test-driven development, and best
practices for scientific programming.&lt;/p&gt;
&lt;p&gt;The workshop will also serve as a venue to plan and execute some of the major
new features we are planning for the upcoming yt 3.0 release, including full
support for outputs of Lagrangian codes like Gadget, Gasoline and AREPO, better
support for oct-based codes like ART and RAMSES, initial conditions generation,
the new Grid Data Format, a new way of handling units and unit conversion,
non-cartesian geometries, and advanced graphical browser widgets inside the
iPython notebook.&lt;/p&gt;
&lt;p&gt;More information and a registration form for the workshop are available on the
&lt;a class=&quot;reference external&quot; href=&quot;http://yt-project.org/workshop2013&quot;&gt;workshop website&lt;/a&gt;. We have limited funding support for hotels and airfare.
Funds will be preferentially distributed to students and the level of individual
support will depend on demand.&lt;/p&gt;
&lt;p&gt;If you have questions or concerns about the workshop, please feel free to
contact the organizers at &lt;a class=&quot;reference external&quot; href=&quot;mailto:workshop2013&amp;#64;yt-project.org&quot;&gt;workshop2013&amp;#64;yt-project.org&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;On behalf of the organizing committee,&lt;/p&gt;
&lt;p&gt;Nathan Goldbaum&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title type="text">Particle Generators</title>
    <id>/post/ParticleGenerator/</id>
    <updated>2013-01-04T07:05:00Z</updated>
    <published>2013-01-04T07:05:00Z</published>
    <link href="/post/ParticleGenerator/" />
    <author>
      <name>John ZuHone</name>
      <email>jzuhone@gmail.com</email>
    </author>
    <summary type="html">&lt;!-- date: 1357283100 --&gt;
&lt;p&gt;&lt;a class=&quot;reference external&quot; href=&quot;https://hub.yt-project.org/go/mf0ba2&quot;&gt;Notebook Download&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Generating particle initial conditions is now possible in yt. The
following shows how to generate particle fields from pre-defined
particle lists, lattice distributions, and distributions based on
density fields.&lt;/p&gt;
&lt;p&gt;First, we define a gridded density field where the particle density
field has been &amp;quot;cloud-in-cell&amp;quot; (CIC) interpolated to the grid, and
define a function that assigns a set of particle indices based on a
number of particles and a starting index. This is for a case where we
want to add particles to an already existing set but make sure they have
uniqune indices.&lt;/p&gt;
&lt;p&gt;In[1]:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;yt.mods&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;yt.utilities.particle_generator&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;yt.utilities.initial_conditions&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;ic&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;yt.utilities.flagging_methods&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;fm&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;yt.frontends.stream.api&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;refine_amr&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;yt.utilities.lib&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;CICDeposit_3&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;_pgdensity&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;field&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;blank&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;zeros&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ActiveDimensions&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dtype&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;float32&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;NumberOfParticles&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;blank&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;CICDeposit_3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;particle_position_x&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;astype&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;float64&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
                 &lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;particle_position_y&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;astype&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;float64&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
                 &lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;particle_position_z&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;astype&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;float64&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
                 &lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;particle_gas_density&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;astype&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;float32&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
                 &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;int64&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;NumberOfParticles&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
                 &lt;span class=&quot;n&quot;&gt;blank&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;LeftEdge&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;astype&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;float64&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
                 &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ActiveDimensions&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;astype&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;int32&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
                 &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;float64&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;dx&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]))&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;blank&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;add_field&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;particle_density_cic&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_pgdensity&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
          &lt;span class=&quot;n&quot;&gt;validators&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ValidateGridType&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()],&lt;/span&gt;
          &lt;span class=&quot;n&quot;&gt;display_name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;r&amp;quot;$\mathrm{Particle}\/\mathrm{Density}$&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;add_indices&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;npart&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;start_num&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;arange&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;npart&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;start_num&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Next, we'll set up a uniform grid with some random density data:&lt;/p&gt;
&lt;p&gt;In[2]:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;domain_dims&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;128&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;128&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;128&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;dens&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;0.1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;random&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;random&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;domain_dims&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;fields&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;Density&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dens&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;ug&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;load_uniform_grid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fields&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;domain_dims&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;1.0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;As a first example, we'll generate particle fields from pre-existing
NumPy arrays. First, we define a list of particle field names, and then
assign random positions to the particles in one corner of the grid. We
then call FromListParticleGenerator, which generates the particles.
assign_indices assigns the indices (using numpy.arange by default).
apply_to_stream applies the particle fields to the grid.&lt;/p&gt;
&lt;p&gt;In[3]:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;num_particles1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10000&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;field_list&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;particle_position_x&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;particle_position_y&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
              &lt;span class=&quot;s2&quot;&gt;&amp;quot;particle_position_z&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;particle_gas_density&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;random&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;uniform&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;low&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;high&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;num_particles1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# random positions&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;y&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;random&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;uniform&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;low&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;high&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;num_particles1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# random positions&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;z&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;random&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;uniform&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;low&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;high&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;num_particles1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# random positions&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;pdata&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;particle_position_x&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
         &lt;span class=&quot;s1&quot;&gt;&amp;#39;particle_position_y&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
         &lt;span class=&quot;s1&quot;&gt;&amp;#39;particle_position_z&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;z&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;particles1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;FromListParticleGenerator&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ug&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num_particles1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pdata&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;particles1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;assign_indices&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;particles1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;apply_to_stream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;pre class=&quot;literal-block&quot;&gt;
yt : [INFO     ] 2013-01-01 21:24:32,484 Adding Density to list of fields
yt : [INFO     ] 2013-01-01 21:24:32,486 Adding particle_position_z to list of fields
yt : [INFO     ] 2013-01-01 21:24:32,487 Adding particle_index to list of fields
yt : [INFO     ] 2013-01-01 21:24:32,487 Adding particle_position_x to list of fields
yt : [INFO     ] 2013-01-01 21:24:32,488 Adding particle_position_y to list of fields
&lt;/pre&gt;
&lt;p&gt;Now that the particles are part of the parameter file, they may be
manipulated and plotted:&lt;/p&gt;
&lt;p&gt;In[4]:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;slc&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;SlicePlot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ug&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;Density&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;center&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ug&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;domain_center&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;slc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;set_cmap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;Density&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;spring&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;slc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;annotate_particles&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;p_size&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;10.0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# Display all particles within a thick slab 0.2 times the domain width&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;slc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;img alt=&quot;/attachments/ParticleGenerator_files/ParticleGenerator_ipynb_fig_00.png&quot; src=&quot;/attachments/ParticleGenerator_files/ParticleGenerator_ipynb_fig_00.png&quot; /&gt;
&lt;p&gt;Now let's try adding a particle distribution in a lattice-shaped spatial
arrangement. Let's choose ten particles on a side, and place them in a
small region away from the random particles. We'll use the special
add_indices function we defined earlier to assign indices that are all
different from the ones the already existing particles have.&lt;/p&gt;
&lt;p&gt;In[5]:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pdims&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# number of particles on a side in each dimension&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;ple&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# left edge of particle positions&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;pre&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.9&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.9&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.9&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# right edge of particle positions&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;particles2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;LatticeParticleGenerator&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ug&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pdims&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ple&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pre&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;field_list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;particles2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;assign_indices&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;add_indices&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;npart&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;product&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pdims&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
                          &lt;span class=&quot;n&quot;&gt;start_num&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;num_particles1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;particles2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;apply_to_stream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;pre class=&quot;literal-block&quot;&gt;
yt : [INFO     ] 2013-01-01 21:24:33,957 Adding particle_gas_density to list of fields
&lt;/pre&gt;
&lt;p&gt;We now have both sets of particles:&lt;/p&gt;
&lt;p&gt;In[6]:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;slc&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;SlicePlot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ug&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;Density&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;center&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ug&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;domain_center&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;slc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;set_cmap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;Density&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;spring&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;slc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;annotate_particles&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;p_size&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;10.0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;slc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;img alt=&quot;/attachments/ParticleGenerator_files/ParticleGenerator_ipynb_fig_01.png&quot; src=&quot;/attachments/ParticleGenerator_files/ParticleGenerator_ipynb_fig_01.png&quot; /&gt;
&lt;p&gt;And by sorting all of the indices we can check that all of them are
unique, as advertised:&lt;/p&gt;
&lt;p&gt;In[7]:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dd&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ug&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;h&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;all_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;indices&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sort&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;int32&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;particle_index&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]))&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;All indices unique = &amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;all&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;unique&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;indices&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;indices&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;pre class=&quot;literal-block&quot;&gt;
All indices unique =  True
&lt;/pre&gt;
&lt;p&gt;Now let's get fancy. We will use the initial conditions capabilities of
yt to apply a spherically symmetric density distribution based on the
&amp;quot;beta-model&amp;quot; functional form, and set up a refinement method based on
overdensity. Then, we will call refine_amr to apply this density
distribution and refine the grid based on the overdensity over some
value.&lt;/p&gt;
&lt;p&gt;In[8]:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fo&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ic&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;BetaModelSphere&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;1.0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,[&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;Density&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:(&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;10.0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)})]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;rc&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fm&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;flagging_method_registry&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;overdensity&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;](&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;4.0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;pf&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;refine_amr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ug&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fo&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now, we have an interesting density field to serve as a distribution
function for particle positions. What we do next is define a spherical
region over which particle positions will be generated based on the
local grid density. We also will map the grid density to a particle
density field using cloud-in-cell interpolation. Finally, when we apply
these particles, we will set the optional argument clobber=True, which
will remove the particles we already created.&lt;/p&gt;
&lt;p&gt;In[9]:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;num_particles3&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;100000&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;map_dict&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;Density&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;particle_gas_density&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# key is grid field, value is particle field&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;sphere&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;h&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sphere&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;domain_center&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;unitary&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;particles3&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;WithDensityParticleGenerator&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sphere&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num_particles3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
                                          &lt;span class=&quot;n&quot;&gt;field_list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;particles3&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;assign_indices&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;particles3&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;map_grid_fields_to_particles&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;map_dict&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# Map density fields to particle fields&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;particles3&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;apply_to_stream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;clobber&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# Get rid of all pre-existing particles&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now we'll plot up both the grid density field and the
&amp;quot;particle_density_cic&amp;quot; field (defined at the top of the script), which
is mapped from the particles onto the grid. We also overplot the
particle positions. These should roughly correspond to the non-zero
values of &amp;quot;particle_density_cic&amp;quot;, but there will be some discrepancies
due to the fact that they are taken from a thick slab and only a slice
of the grid-based field is shown.&lt;/p&gt;
&lt;p&gt;In[10]:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;slc&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;SlicePlot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;Density&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;particle_density_cic&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;center&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;domain_center&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;slc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;set_log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;Density&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;slc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;set_log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;particle_density_cic&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;slc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;set_cmap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;all&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;spring&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;slc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;annotate_grids&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;slc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;annotate_particles&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.01&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;p_size&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;slc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;img alt=&quot;/attachments/ParticleGenerator_files/ParticleGenerator_ipynb_fig_02.png&quot; src=&quot;/attachments/ParticleGenerator_files/ParticleGenerator_ipynb_fig_02.png&quot; /&gt;
&lt;img alt=&quot;/attachments/ParticleGenerator_files/ParticleGenerator_ipynb_fig_03.png&quot; src=&quot;/attachments/ParticleGenerator_files/ParticleGenerator_ipynb_fig_03.png&quot; /&gt;
</summary>
    <content type="html">&lt;!-- date: 1357283100 --&gt;
&lt;p&gt;&lt;a class=&quot;reference external&quot; href=&quot;https://hub.yt-project.org/go/mf0ba2&quot;&gt;Notebook Download&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Generating particle initial conditions is now possible in yt. The
following shows how to generate particle fields from pre-defined
particle lists, lattice distributions, and distributions based on
density fields.&lt;/p&gt;
&lt;p&gt;First, we define a gridded density field where the particle density
field has been &amp;quot;cloud-in-cell&amp;quot; (CIC) interpolated to the grid, and
define a function that assigns a set of particle indices based on a
number of particles and a starting index. This is for a case where we
want to add particles to an already existing set but make sure they have
uniqune indices.&lt;/p&gt;
&lt;p&gt;In[1]:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;yt.mods&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;yt.utilities.particle_generator&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;yt.utilities.initial_conditions&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;ic&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;yt.utilities.flagging_methods&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;fm&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;yt.frontends.stream.api&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;refine_amr&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;yt.utilities.lib&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;CICDeposit_3&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;_pgdensity&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;field&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;blank&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;zeros&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ActiveDimensions&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dtype&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;float32&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;NumberOfParticles&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;blank&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;CICDeposit_3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;particle_position_x&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;astype&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;float64&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
                 &lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;particle_position_y&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;astype&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;float64&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
                 &lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;particle_position_z&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;astype&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;float64&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
                 &lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;particle_gas_density&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;astype&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;float32&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
                 &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;int64&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;NumberOfParticles&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
                 &lt;span class=&quot;n&quot;&gt;blank&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;LeftEdge&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;astype&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;float64&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
                 &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ActiveDimensions&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;astype&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;int32&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
                 &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;float64&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;dx&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]))&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;blank&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;add_field&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;particle_density_cic&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_pgdensity&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
          &lt;span class=&quot;n&quot;&gt;validators&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ValidateGridType&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()],&lt;/span&gt;
          &lt;span class=&quot;n&quot;&gt;display_name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;r&amp;quot;$\mathrm{Particle}\/\mathrm{Density}$&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;add_indices&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;npart&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;start_num&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;arange&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;npart&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;start_num&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Next, we'll set up a uniform grid with some random density data:&lt;/p&gt;
&lt;p&gt;In[2]:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;domain_dims&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;128&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;128&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;128&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;dens&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;0.1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;random&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;random&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;domain_dims&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;fields&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;Density&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dens&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;ug&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;load_uniform_grid&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fields&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;domain_dims&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;1.0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;As a first example, we'll generate particle fields from pre-existing
NumPy arrays. First, we define a list of particle field names, and then
assign random positions to the particles in one corner of the grid. We
then call FromListParticleGenerator, which generates the particles.
assign_indices assigns the indices (using numpy.arange by default).
apply_to_stream applies the particle fields to the grid.&lt;/p&gt;
&lt;p&gt;In[3]:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;num_particles1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10000&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;field_list&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;particle_position_x&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;particle_position_y&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
              &lt;span class=&quot;s2&quot;&gt;&amp;quot;particle_position_z&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;particle_gas_density&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;random&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;uniform&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;low&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;high&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;num_particles1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# random positions&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;y&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;random&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;uniform&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;low&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;high&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;num_particles1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# random positions&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;z&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;random&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;uniform&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;low&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;high&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;num_particles1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# random positions&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;pdata&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;particle_position_x&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
         &lt;span class=&quot;s1&quot;&gt;&amp;#39;particle_position_y&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
         &lt;span class=&quot;s1&quot;&gt;&amp;#39;particle_position_z&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;z&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;particles1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;FromListParticleGenerator&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ug&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num_particles1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pdata&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;particles1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;assign_indices&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;particles1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;apply_to_stream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;pre class=&quot;literal-block&quot;&gt;
yt : [INFO     ] 2013-01-01 21:24:32,484 Adding Density to list of fields
yt : [INFO     ] 2013-01-01 21:24:32,486 Adding particle_position_z to list of fields
yt : [INFO     ] 2013-01-01 21:24:32,487 Adding particle_index to list of fields
yt : [INFO     ] 2013-01-01 21:24:32,487 Adding particle_position_x to list of fields
yt : [INFO     ] 2013-01-01 21:24:32,488 Adding particle_position_y to list of fields
&lt;/pre&gt;
&lt;p&gt;Now that the particles are part of the parameter file, they may be
manipulated and plotted:&lt;/p&gt;
&lt;p&gt;In[4]:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;slc&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;SlicePlot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ug&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;Density&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;center&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ug&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;domain_center&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;slc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;set_cmap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;Density&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;spring&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;slc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;annotate_particles&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;p_size&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;10.0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# Display all particles within a thick slab 0.2 times the domain width&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;slc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;img alt=&quot;/attachments/ParticleGenerator_files/ParticleGenerator_ipynb_fig_00.png&quot; src=&quot;/attachments/ParticleGenerator_files/ParticleGenerator_ipynb_fig_00.png&quot; /&gt;
&lt;p&gt;Now let's try adding a particle distribution in a lattice-shaped spatial
arrangement. Let's choose ten particles on a side, and place them in a
small region away from the random particles. We'll use the special
add_indices function we defined earlier to assign indices that are all
different from the ones the already existing particles have.&lt;/p&gt;
&lt;p&gt;In[5]:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pdims&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# number of particles on a side in each dimension&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;ple&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# left edge of particle positions&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;pre&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.9&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.9&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.9&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# right edge of particle positions&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;particles2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;LatticeParticleGenerator&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ug&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pdims&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ple&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pre&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;field_list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;particles2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;assign_indices&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;add_indices&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;npart&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;product&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pdims&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
                          &lt;span class=&quot;n&quot;&gt;start_num&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;num_particles1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;particles2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;apply_to_stream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;pre class=&quot;literal-block&quot;&gt;
yt : [INFO     ] 2013-01-01 21:24:33,957 Adding particle_gas_density to list of fields
&lt;/pre&gt;
&lt;p&gt;We now have both sets of particles:&lt;/p&gt;
&lt;p&gt;In[6]:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;slc&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;SlicePlot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ug&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;Density&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;center&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ug&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;domain_center&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;slc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;set_cmap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;Density&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;spring&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;slc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;annotate_particles&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;p_size&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;10.0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;slc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;img alt=&quot;/attachments/ParticleGenerator_files/ParticleGenerator_ipynb_fig_01.png&quot; src=&quot;/attachments/ParticleGenerator_files/ParticleGenerator_ipynb_fig_01.png&quot; /&gt;
&lt;p&gt;And by sorting all of the indices we can check that all of them are
unique, as advertised:&lt;/p&gt;
&lt;p&gt;In[7]:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dd&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ug&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;h&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;all_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;indices&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sort&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;int32&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;particle_index&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]))&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;All indices unique = &amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;all&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;unique&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;indices&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;indices&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;pre class=&quot;literal-block&quot;&gt;
All indices unique =  True
&lt;/pre&gt;
&lt;p&gt;Now let's get fancy. We will use the initial conditions capabilities of
yt to apply a spherically symmetric density distribution based on the
&amp;quot;beta-model&amp;quot; functional form, and set up a refinement method based on
overdensity. Then, we will call refine_amr to apply this density
distribution and refine the grid based on the overdensity over some
value.&lt;/p&gt;
&lt;p&gt;In[8]:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fo&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ic&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;BetaModelSphere&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;1.0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,[&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;Density&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:(&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;10.0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)})]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;rc&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fm&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;flagging_method_registry&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;overdensity&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;](&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;4.0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;pf&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;refine_amr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ug&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fo&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now, we have an interesting density field to serve as a distribution
function for particle positions. What we do next is define a spherical
region over which particle positions will be generated based on the
local grid density. We also will map the grid density to a particle
density field using cloud-in-cell interpolation. Finally, when we apply
these particles, we will set the optional argument clobber=True, which
will remove the particles we already created.&lt;/p&gt;
&lt;p&gt;In[9]:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;num_particles3&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;100000&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;map_dict&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;Density&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;particle_gas_density&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# key is grid field, value is particle field&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;sphere&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;h&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sphere&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;domain_center&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;unitary&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;particles3&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;WithDensityParticleGenerator&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sphere&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num_particles3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
                                          &lt;span class=&quot;n&quot;&gt;field_list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;particles3&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;assign_indices&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;particles3&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;map_grid_fields_to_particles&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;map_dict&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# Map density fields to particle fields&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;particles3&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;apply_to_stream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;clobber&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# Get rid of all pre-existing particles&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now we'll plot up both the grid density field and the
&amp;quot;particle_density_cic&amp;quot; field (defined at the top of the script), which
is mapped from the particles onto the grid. We also overplot the
particle positions. These should roughly correspond to the non-zero
values of &amp;quot;particle_density_cic&amp;quot;, but there will be some discrepancies
due to the fact that they are taken from a thick slab and only a slice
of the grid-based field is shown.&lt;/p&gt;
&lt;p&gt;In[10]:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;slc&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;SlicePlot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;Density&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;particle_density_cic&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;center&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;domain_center&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;slc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;set_log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;Density&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;slc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;set_log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;particle_density_cic&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;slc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;set_cmap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;all&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;spring&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;slc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;annotate_grids&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;slc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;annotate_particles&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.01&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;p_size&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;slc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;img alt=&quot;/attachments/ParticleGenerator_files/ParticleGenerator_ipynb_fig_02.png&quot; src=&quot;/attachments/ParticleGenerator_files/ParticleGenerator_ipynb_fig_02.png&quot; /&gt;
&lt;img alt=&quot;/attachments/ParticleGenerator_files/ParticleGenerator_ipynb_fig_03.png&quot; src=&quot;/attachments/ParticleGenerator_files/ParticleGenerator_ipynb_fig_03.png&quot; /&gt;
</content>
  </entry>
  <entry>
    <title type="text">2012 In Review</title>
    <id>/post/2012InReview/</id>
    <updated>2012-12-31T23:21:30Z</updated>
    <published>2012-12-31T23:21:30Z</published>
    <link href="/post/2012InReview/" />
    <author>
      <name>Matthew Turk</name>
      <email>matthewturk@gmail.com</email>
    </author>
    <summary type="html">&lt;p&gt;2012 was an amazing year for yt.  Whether measured by improvements to the code
or community activity, it has been the busiest and most productive yet.&lt;/p&gt;
&lt;p&gt;Here are a few stats:&lt;/p&gt;
&lt;blockquote&gt;
&lt;ul class=&quot;simple&quot;&gt;
&lt;li&gt;We held the first ever &lt;a class=&quot;reference external&quot; href=&quot;http://yt-project.org/workshop2012/&quot;&gt;yt workshop&lt;/a&gt;
at the FLASH center in Chicago in January.  Plans for a development-focused
workshop have already begun in earnest for March of 2013.&lt;/li&gt;
&lt;li&gt;2221 changesets were added to the code base -- out of a total 7369, or
slightly over 30%!&lt;/li&gt;
&lt;li&gt;One of the most exciting things that happened within the yt community this
year has been the growth of the developer community.  Many people who
previously used yt, or participated on the mailing list, have transitioned
into being very active developers of yt as well.&lt;ul&gt;
&lt;li&gt;In 2011, Nathan Goldbaum had contributed one changeset.  In 2012, he was
the number two contributor, with 322, ranging from the PlotWindow to field
names and fixes for detailed aspects of the FLASH frontend.&lt;/li&gt;
&lt;li&gt;This year Kacper Kowalik began to contribute strongly in many areas,
including the grid data format, arbitrary data loading, and improving the
overall health of the code.&lt;/li&gt;
&lt;li&gt;Chris Moody contributed substantially to the (NMSU) ART frontend and
support for the Rockstar halo finder, over the course of 121 changesets in
2012.&lt;/li&gt;
&lt;li&gt;Andrew Myers expanded support for particles in Orion and contributed many
changes for Chombo and Boxlib codes.&lt;/li&gt;
&lt;li&gt;In 2012, John ZuHone contributed 106 changesets, fixing aspects of the
FLASH and Athena frontends and adding substantial support for creating
particle datasets in memory and expanding the generation of initial
conditions.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;With a focus on enabling easier contributions from members of the community,
we've also had first-time contributions from many people.&lt;ul&gt;
&lt;li&gt;Brian Crosby&lt;/li&gt;
&lt;li&gt;Andrew Cunningham&lt;/li&gt;
&lt;li&gt;Markus Haider&lt;/li&gt;
&lt;li&gt;Christian Karch - a constant cheerful presence in IRC who has helped out
with volume rendering and FLASH frontend improvements.&lt;/li&gt;
&lt;li&gt;Yuan Li&lt;/li&gt;
&lt;li&gt;Joshua Moloney&lt;/li&gt;
&lt;li&gt;Thomas Robitaille&lt;/li&gt;
&lt;li&gt;Anna Rosen&lt;/li&gt;
&lt;li&gt;Anthony Scopatz - who has helped us start a large-scale testing initative,
add support for cylindrical coordinates, and transition from using &lt;tt class=&quot;docutils literal&quot;&gt;na&lt;/tt&gt;
for NumPy to &lt;tt class=&quot;docutils literal&quot;&gt;np&lt;/tt&gt;!&lt;/li&gt;
&lt;li&gt;Elizabeth Tasker&lt;/li&gt;
&lt;li&gt;Stephanie Tonnesen - whose help keeping Athena support up to date and
functional has been incredibly helpful!&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Version 2.4 of yt was released, which included threaded volume rendering,
the Plot Window, a totally rewritten GUI, and a bunch of other improvements.&lt;/li&gt;
&lt;li&gt;The &lt;a class=&quot;reference external&quot; href=&quot;https://hub.yt-project.org/&quot;&gt;yt Hub&lt;/a&gt; was re-launched with data
exploration widgets and an IPython Notebook viewer.&lt;/li&gt;
&lt;li&gt;The &lt;a class=&quot;reference external&quot; href=&quot;http://yt-project.org/docs/2.4&quot;&gt;documentation for yt&lt;/a&gt; was streamlined
and improved, with some awesome &lt;a class=&quot;reference external&quot; href=&quot;http://yt-project.org/docs/2.4/cookbook/index.html&quot;&gt;cookbook recipes&lt;/a&gt; and improvements.  We
also now have a constantly refreshed
&lt;a class=&quot;reference external&quot; href=&quot;https://yt.readthedocs.org/en/latest/&quot;&gt;build&lt;/a&gt; of the documentation at
&lt;a class=&quot;reference external&quot; href=&quot;http://readthedocs.org&quot;&gt;ReadTheDocs&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Development of yt 3.0 really took off, with people from several communities
picking it up and contributing changes.&lt;/li&gt;
&lt;li&gt;yt gained the ability to create data totally in memory, and then write it to
disk!&lt;/li&gt;
&lt;li&gt;The yt community grew and was more active than ever, providing assistance,
ideas, sharing suggestions and scripts, and keeping a congenial, friendly
attitude.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;p&gt;Thanks for everything, and here's to making 2013 even better!&lt;/p&gt;
</summary>
    <content type="html">&lt;p&gt;2012 was an amazing year for yt.  Whether measured by improvements to the code
or community activity, it has been the busiest and most productive yet.&lt;/p&gt;
&lt;p&gt;Here are a few stats:&lt;/p&gt;
&lt;blockquote&gt;
&lt;ul class=&quot;simple&quot;&gt;
&lt;li&gt;We held the first ever &lt;a class=&quot;reference external&quot; href=&quot;http://yt-project.org/workshop2012/&quot;&gt;yt workshop&lt;/a&gt;
at the FLASH center in Chicago in January.  Plans for a development-focused
workshop have already begun in earnest for March of 2013.&lt;/li&gt;
&lt;li&gt;2221 changesets were added to the code base -- out of a total 7369, or
slightly over 30%!&lt;/li&gt;
&lt;li&gt;One of the most exciting things that happened within the yt community this
year has been the growth of the developer community.  Many people who
previously used yt, or participated on the mailing list, have transitioned
into being very active developers of yt as well.&lt;ul&gt;
&lt;li&gt;In 2011, Nathan Goldbaum had contributed one changeset.  In 2012, he was
the number two contributor, with 322, ranging from the PlotWindow to field
names and fixes for detailed aspects of the FLASH frontend.&lt;/li&gt;
&lt;li&gt;This year Kacper Kowalik began to contribute strongly in many areas,
including the grid data format, arbitrary data loading, and improving the
overall health of the code.&lt;/li&gt;
&lt;li&gt;Chris Moody contributed substantially to the (NMSU) ART frontend and
support for the Rockstar halo finder, over the course of 121 changesets in
2012.&lt;/li&gt;
&lt;li&gt;Andrew Myers expanded support for particles in Orion and contributed many
changes for Chombo and Boxlib codes.&lt;/li&gt;
&lt;li&gt;In 2012, John ZuHone contributed 106 changesets, fixing aspects of the
FLASH and Athena frontends and adding substantial support for creating
particle datasets in memory and expanding the generation of initial
conditions.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;With a focus on enabling easier contributions from members of the community,
we've also had first-time contributions from many people.&lt;ul&gt;
&lt;li&gt;Brian Crosby&lt;/li&gt;
&lt;li&gt;Andrew Cunningham&lt;/li&gt;
&lt;li&gt;Markus Haider&lt;/li&gt;
&lt;li&gt;Christian Karch - a constant cheerful presence in IRC who has helped out
with volume rendering and FLASH frontend improvements.&lt;/li&gt;
&lt;li&gt;Yuan Li&lt;/li&gt;
&lt;li&gt;Joshua Moloney&lt;/li&gt;
&lt;li&gt;Thomas Robitaille&lt;/li&gt;
&lt;li&gt;Anna Rosen&lt;/li&gt;
&lt;li&gt;Anthony Scopatz - who has helped us start a large-scale testing initative,
add support for cylindrical coordinates, and transition from using &lt;tt class=&quot;docutils literal&quot;&gt;na&lt;/tt&gt;
for NumPy to &lt;tt class=&quot;docutils literal&quot;&gt;np&lt;/tt&gt;!&lt;/li&gt;
&lt;li&gt;Elizabeth Tasker&lt;/li&gt;
&lt;li&gt;Stephanie Tonnesen - whose help keeping Athena support up to date and
functional has been incredibly helpful!&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Version 2.4 of yt was released, which included threaded volume rendering,
the Plot Window, a totally rewritten GUI, and a bunch of other improvements.&lt;/li&gt;
&lt;li&gt;The &lt;a class=&quot;reference external&quot; href=&quot;https://hub.yt-project.org/&quot;&gt;yt Hub&lt;/a&gt; was re-launched with data
exploration widgets and an IPython Notebook viewer.&lt;/li&gt;
&lt;li&gt;The &lt;a class=&quot;reference external&quot; href=&quot;http://yt-project.org/docs/2.4&quot;&gt;documentation for yt&lt;/a&gt; was streamlined
and improved, with some awesome &lt;a class=&quot;reference external&quot; href=&quot;http://yt-project.org/docs/2.4/cookbook/index.html&quot;&gt;cookbook recipes&lt;/a&gt; and improvements.  We
also now have a constantly refreshed
&lt;a class=&quot;reference external&quot; href=&quot;https://yt.readthedocs.org/en/latest/&quot;&gt;build&lt;/a&gt; of the documentation at
&lt;a class=&quot;reference external&quot; href=&quot;http://readthedocs.org&quot;&gt;ReadTheDocs&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Development of yt 3.0 really took off, with people from several communities
picking it up and contributing changes.&lt;/li&gt;
&lt;li&gt;yt gained the ability to create data totally in memory, and then write it to
disk!&lt;/li&gt;
&lt;li&gt;The yt community grew and was more active than ever, providing assistance,
ideas, sharing suggestions and scripts, and keeping a congenial, friendly
attitude.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;p&gt;Thanks for everything, and here's to making 2013 even better!&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title type="text">3D Surfaces and Sketchfab</title>
    <id>/post/3DSurfacesAndSketchFab/</id>
    <updated>2012-12-05T15:24:42Z</updated>
    <published>2012-12-05T15:24:42Z</published>
    <link href="/post/3DSurfacesAndSketchFab/" />
    <author>
      <name>Matthew Turk</name>
      <email>matthewturk@gmail.com</email>
    </author>
    <summary type="html">&lt;div class=&quot;section&quot; id=&quot;surfaces&quot;&gt;
&lt;h3&gt;Surfaces&lt;/h3&gt;
&lt;p&gt;For a while now, yt has had the ability to extract isosurfaces from volumetric
data using a &lt;a class=&quot;reference external&quot; href=&quot;http://en.wikipedia.org/wiki/Marching_cubes&quot;&gt;marching cubes&lt;/a&gt;
algorithm.  The surfaces could be exported in &lt;a class=&quot;reference external&quot; href=&quot;http://en.wikipedia.org/wiki/Wavefront_.obj_file&quot;&gt;OBJ format&lt;/a&gt;, values could be samples
at the center of each face of the surface, and flux of a given field could be
calculated over the surface.  This means you could, for instance, extract an
isocontour in density and calculate the mass flux over that isocontour.  It
also means you could export a surface from yt and view it in something like
&lt;a class=&quot;reference external&quot; href=&quot;http://www.blender.org/&quot;&gt;Blender&lt;/a&gt;, &lt;a class=&quot;reference external&quot; href=&quot;http://meshlab.sourceforge.net/&quot;&gt;MeshLab&lt;/a&gt;, or even on your Android or iOS device in
&lt;a class=&quot;reference external&quot; href=&quot;http://www.meshpad.org/&quot;&gt;MeshPad&lt;/a&gt; or &lt;a class=&quot;reference external&quot; href=&quot;https://play.google.com/store/apps/details?id=it.isticnr.meshlab&amp;amp;hl=en&quot;&gt;MeshLab Android&lt;/a&gt;.
One important caveat with marching cubes is that with adaptive mesh refinement
data, you &lt;em&gt;will&lt;/em&gt; see cracks across refinement boundaries unless a
&amp;quot;crack-fixing&amp;quot; step is applied to match up these boundaries.  yt does not
perform such an operation, and so there will be seams visible in 3D views of
your isosurfaces.&lt;/p&gt;
&lt;p&gt;The methods to do so were methods on data objects -- &lt;tt class=&quot;docutils literal&quot;&gt;extract_isocontours&lt;/tt&gt;,
&lt;tt class=&quot;docutils literal&quot;&gt;calculate_isocontour_flux&lt;/tt&gt; -- which returned just numbers or values.
However, recently, I've created a new object called &lt;tt class=&quot;docutils literal&quot;&gt;AMRSurface&lt;/tt&gt; that makes
this process much easier.  You can create one of these objects by specifying a
source data object and a field over which to identify a surface at a given
value.  For example:&lt;/p&gt;
&lt;pre class=&quot;code python literal-block&quot;&gt;
&lt;span class=&quot;keyword namespace&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;name namespace&quot;&gt;yt.mods&lt;/span&gt; &lt;span class=&quot;keyword namespace&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;*&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;pf&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;load&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;literal string double&quot;&gt;&amp;quot;/data/workshop2012/IsolatedGalaxy/galaxy0030/galaxy0030&amp;quot;&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;sphere&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;pf&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;h&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;sphere&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;literal string double&quot;&gt;&amp;quot;max&amp;quot;&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;literal number float&quot;&gt;1.0&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;literal string double&quot;&gt;&amp;quot;mpc&amp;quot;&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;surface&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;pf&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;h&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;surface&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;sphere&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;literal string double&quot;&gt;&amp;quot;Density&amp;quot;&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;literal number float&quot;&gt;1e-27&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;This object, &lt;tt class=&quot;docutils literal&quot;&gt;surface&lt;/tt&gt;, can now be queried for values on the surface.  For
instance:&lt;/p&gt;
&lt;pre class=&quot;code python literal-block&quot;&gt;
&lt;span class=&quot;keyword&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;surface&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;literal string double&quot;&gt;&amp;quot;Temperature&amp;quot;&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;min&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;surface&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;literal string double&quot;&gt;&amp;quot;Temperature&amp;quot;&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;max&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;()&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;will return the values 11850.7476943 and 13641.0663899.  These values are
interpolated to the face centers of every triangle that constitutes a portion
of the surface.  Note that reading a new field requires re-calculating the
entire surface, so it's not the fastest operation.  You can get the vertices of
the triangle by looking at the property &lt;tt class=&quot;docutils literal&quot;&gt;.vertices&lt;/tt&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;exporting-to-a-file&quot;&gt;
&lt;h3&gt;Exporting to a File&lt;/h3&gt;
&lt;p&gt;If you want to export this to a &lt;a class=&quot;reference external&quot; href=&quot;http://en.wikipedia.org/wiki/PLY_(file_format)&quot;&gt;PLY file&lt;/a&gt; you can call the routine
&lt;tt class=&quot;docutils literal&quot;&gt;export_ply&lt;/tt&gt;, which will write to a file and optionally sample a field at
every face or vertex, outputting a color value to the file as well.  This file
can then be viewed in MeshLab, Blender or on the website &lt;a class=&quot;reference external&quot; href=&quot;Sketchfab.com&quot;&gt;Sketchfab.com&lt;/a&gt;.  But if you want to view it on Sketchfab, there's an even
easier way!&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;exporting-to-sketchfab&quot;&gt;
&lt;h3&gt;Exporting to Sketchfab&lt;/h3&gt;
&lt;p&gt;&lt;a class=&quot;reference external&quot; href=&quot;http://sketchfab.com&quot;&gt;Sketchfab&lt;/a&gt; is a website that uses WebGL, a relatively
new technology for displaying 3D graphics in any browser.  It's very fast and
typically requires no plugins.  Plus, it means that you can share data with
anyone and they can view it immersively without having to download the data or
any software packages!  Sketchfab provides a free tier for up to 10 models, and
these models can be embedded in websites.&lt;/p&gt;
&lt;p&gt;There are lots of reasons to want to export to Sketchfab.  For instance, if
you're looking at a galaxy formation simulation and you publish a paper, you
can include a link to the model in that paper (or in the arXiv listing) so that
people can explore and see what the data looks like.  You can also embed a
model in a website with other supplemental data, or you can use Sketchfab to
discuss morphological properties of a dataset with collaborators.  It's also
just plain cool.&lt;/p&gt;
&lt;p&gt;The &lt;tt class=&quot;docutils literal&quot;&gt;AMRSurface&lt;/tt&gt; object includes a method to upload directly to Sketchfab,
but it requires that you get an API key first.  You can get this API key by
creating an account and then going to your &amp;quot;dashboard,&amp;quot; where it will be listed
on the right hand side.  Once you've obtained it, put it into your
&lt;tt class=&quot;docutils literal&quot;&gt;&lt;span class=&quot;pre&quot;&gt;~/.yt/config&lt;/span&gt;&lt;/tt&gt; file under the heading &lt;tt class=&quot;docutils literal&quot;&gt;[yt]&lt;/tt&gt; as the variable
&lt;tt class=&quot;docutils literal&quot;&gt;sketchfab_api_key&lt;/tt&gt;.  If you don't want to do this, you can also supply it as
an argument to the function &lt;tt class=&quot;docutils literal&quot;&gt;export_sketchfab&lt;/tt&gt;.&lt;/p&gt;
&lt;p&gt;Now you can run a script like this:&lt;/p&gt;
&lt;pre class=&quot;code python literal-block&quot;&gt;
&lt;span class=&quot;keyword namespace&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;name namespace&quot;&gt;yt.mods&lt;/span&gt; &lt;span class=&quot;keyword namespace&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;*&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;pf&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;load&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;literal string double&quot;&gt;&amp;quot;redshift0058&amp;quot;&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;dd&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;pf&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;h&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;sphere&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;literal string double&quot;&gt;&amp;quot;max&amp;quot;&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;literal number integer&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;literal string double&quot;&gt;&amp;quot;kpc&amp;quot;&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;rho&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;literal number float&quot;&gt;5e-27&lt;/span&gt;

&lt;span class=&quot;name&quot;&gt;bounds&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;punctuation&quot;&gt;[(&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;dd&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;center&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;literal number float&quot;&gt;100.0&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;pf&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;literal string single&quot;&gt;'kpc'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;],&lt;/span&gt;
           &lt;span class=&quot;name&quot;&gt;dd&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;center&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;literal number float&quot;&gt;100.0&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;pf&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;literal string single&quot;&gt;'kpc'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;])&lt;/span&gt; &lt;span class=&quot;keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;operator word&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;name builtin&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;literal number integer&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;)]&lt;/span&gt;

&lt;span class=&quot;name&quot;&gt;surf&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;pf&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;h&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;surface&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;dd&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;literal string double&quot;&gt;&amp;quot;Density&amp;quot;&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;rho&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;name&quot;&gt;upload_id&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;surf&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;export_sketchfab&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;name&quot;&gt;title&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;literal string double&quot;&gt;&amp;quot;RD0058 - 5e-27&amp;quot;&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;name&quot;&gt;description&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;literal string double&quot;&gt;&amp;quot;Extraction of Density (colored by Temperature) at 5e-27 &amp;quot;&lt;/span&gt; \
                &lt;span class=&quot;operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;literal string double&quot;&gt;&amp;quot;g/cc from a galaxy formation simulation by Ryan Joung.&amp;quot;&lt;/span&gt;
    &lt;span class=&quot;name&quot;&gt;color_field&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;literal string double&quot;&gt;&amp;quot;Temperature&amp;quot;&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;name&quot;&gt;color_map&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;literal string double&quot;&gt;&amp;quot;hot&amp;quot;&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;name&quot;&gt;color_log&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name builtin pseudo&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;name&quot;&gt;bounds&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;bounds&lt;/span&gt;
&lt;span class=&quot;punctuation&quot;&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;and yt will extract a surface, convert to a format that Sketchfab.com
understands (PLY, in a zip file) and then upload it using your API key.  For
this demo, I've used data kindly provided by Ryan Joung from a simulation of
galaxy formation.  Here's what my newly-uploaded model looks like, using the
embed code from Sketchfab:&lt;/p&gt;
&lt;iframe frameborder=&quot;0&quot; height=&quot;480&quot; width=&quot;854&quot; allowFullScreen
webkitallowfullscreen=&quot;true&quot; mozallowfullscreen=&quot;true&quot;
src=&quot;http://skfb.ly/l4jh2edcba?autostart=0&amp;transparent=0&amp;autospin=0&amp;controls=1&amp;watermark=1&quot;&gt;&lt;/iframe&gt;&lt;p&gt;As a note, Sketchfab has a maximum model size of 50MB for the free account.
50MB is pretty hefty, though, so it shouldn't be a problem for most needs.
We're working on a way to optionally upload links to the Sketchfab models on
the &lt;a class=&quot;reference external&quot; href=&quot;https://hub.yt-project.org/&quot;&gt;yt Hub&lt;/a&gt;, but for now, if you want to share
a cool model we'd love to see it!&lt;/p&gt;
&lt;p&gt;Thanks to Sketchfab for such a cool service, and for helping us out along the
way with their API.&lt;/p&gt;
&lt;/div&gt;
</summary>
    <content type="html">&lt;div class=&quot;section&quot; id=&quot;surfaces&quot;&gt;
&lt;h3&gt;Surfaces&lt;/h3&gt;
&lt;p&gt;For a while now, yt has had the ability to extract isosurfaces from volumetric
data using a &lt;a class=&quot;reference external&quot; href=&quot;http://en.wikipedia.org/wiki/Marching_cubes&quot;&gt;marching cubes&lt;/a&gt;
algorithm.  The surfaces could be exported in &lt;a class=&quot;reference external&quot; href=&quot;http://en.wikipedia.org/wiki/Wavefront_.obj_file&quot;&gt;OBJ format&lt;/a&gt;, values could be samples
at the center of each face of the surface, and flux of a given field could be
calculated over the surface.  This means you could, for instance, extract an
isocontour in density and calculate the mass flux over that isocontour.  It
also means you could export a surface from yt and view it in something like
&lt;a class=&quot;reference external&quot; href=&quot;http://www.blender.org/&quot;&gt;Blender&lt;/a&gt;, &lt;a class=&quot;reference external&quot; href=&quot;http://meshlab.sourceforge.net/&quot;&gt;MeshLab&lt;/a&gt;, or even on your Android or iOS device in
&lt;a class=&quot;reference external&quot; href=&quot;http://www.meshpad.org/&quot;&gt;MeshPad&lt;/a&gt; or &lt;a class=&quot;reference external&quot; href=&quot;https://play.google.com/store/apps/details?id=it.isticnr.meshlab&amp;amp;hl=en&quot;&gt;MeshLab Android&lt;/a&gt;.
One important caveat with marching cubes is that with adaptive mesh refinement
data, you &lt;em&gt;will&lt;/em&gt; see cracks across refinement boundaries unless a
&amp;quot;crack-fixing&amp;quot; step is applied to match up these boundaries.  yt does not
perform such an operation, and so there will be seams visible in 3D views of
your isosurfaces.&lt;/p&gt;
&lt;p&gt;The methods to do so were methods on data objects -- &lt;tt class=&quot;docutils literal&quot;&gt;extract_isocontours&lt;/tt&gt;,
&lt;tt class=&quot;docutils literal&quot;&gt;calculate_isocontour_flux&lt;/tt&gt; -- which returned just numbers or values.
However, recently, I've created a new object called &lt;tt class=&quot;docutils literal&quot;&gt;AMRSurface&lt;/tt&gt; that makes
this process much easier.  You can create one of these objects by specifying a
source data object and a field over which to identify a surface at a given
value.  For example:&lt;/p&gt;
&lt;pre class=&quot;code python literal-block&quot;&gt;
&lt;span class=&quot;keyword namespace&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;name namespace&quot;&gt;yt.mods&lt;/span&gt; &lt;span class=&quot;keyword namespace&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;*&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;pf&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;load&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;literal string double&quot;&gt;&amp;quot;/data/workshop2012/IsolatedGalaxy/galaxy0030/galaxy0030&amp;quot;&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;sphere&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;pf&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;h&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;sphere&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;literal string double&quot;&gt;&amp;quot;max&amp;quot;&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;literal number float&quot;&gt;1.0&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;literal string double&quot;&gt;&amp;quot;mpc&amp;quot;&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;surface&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;pf&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;h&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;surface&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;sphere&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;literal string double&quot;&gt;&amp;quot;Density&amp;quot;&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;literal number float&quot;&gt;1e-27&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;This object, &lt;tt class=&quot;docutils literal&quot;&gt;surface&lt;/tt&gt;, can now be queried for values on the surface.  For
instance:&lt;/p&gt;
&lt;pre class=&quot;code python literal-block&quot;&gt;
&lt;span class=&quot;keyword&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;surface&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;literal string double&quot;&gt;&amp;quot;Temperature&amp;quot;&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;min&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;surface&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;literal string double&quot;&gt;&amp;quot;Temperature&amp;quot;&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;max&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;()&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;will return the values 11850.7476943 and 13641.0663899.  These values are
interpolated to the face centers of every triangle that constitutes a portion
of the surface.  Note that reading a new field requires re-calculating the
entire surface, so it's not the fastest operation.  You can get the vertices of
the triangle by looking at the property &lt;tt class=&quot;docutils literal&quot;&gt;.vertices&lt;/tt&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;exporting-to-a-file&quot;&gt;
&lt;h3&gt;Exporting to a File&lt;/h3&gt;
&lt;p&gt;If you want to export this to a &lt;a class=&quot;reference external&quot; href=&quot;http://en.wikipedia.org/wiki/PLY_(file_format)&quot;&gt;PLY file&lt;/a&gt; you can call the routine
&lt;tt class=&quot;docutils literal&quot;&gt;export_ply&lt;/tt&gt;, which will write to a file and optionally sample a field at
every face or vertex, outputting a color value to the file as well.  This file
can then be viewed in MeshLab, Blender or on the website &lt;a class=&quot;reference external&quot; href=&quot;Sketchfab.com&quot;&gt;Sketchfab.com&lt;/a&gt;.  But if you want to view it on Sketchfab, there's an even
easier way!&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;exporting-to-sketchfab&quot;&gt;
&lt;h3&gt;Exporting to Sketchfab&lt;/h3&gt;
&lt;p&gt;&lt;a class=&quot;reference external&quot; href=&quot;http://sketchfab.com&quot;&gt;Sketchfab&lt;/a&gt; is a website that uses WebGL, a relatively
new technology for displaying 3D graphics in any browser.  It's very fast and
typically requires no plugins.  Plus, it means that you can share data with
anyone and they can view it immersively without having to download the data or
any software packages!  Sketchfab provides a free tier for up to 10 models, and
these models can be embedded in websites.&lt;/p&gt;
&lt;p&gt;There are lots of reasons to want to export to Sketchfab.  For instance, if
you're looking at a galaxy formation simulation and you publish a paper, you
can include a link to the model in that paper (or in the arXiv listing) so that
people can explore and see what the data looks like.  You can also embed a
model in a website with other supplemental data, or you can use Sketchfab to
discuss morphological properties of a dataset with collaborators.  It's also
just plain cool.&lt;/p&gt;
&lt;p&gt;The &lt;tt class=&quot;docutils literal&quot;&gt;AMRSurface&lt;/tt&gt; object includes a method to upload directly to Sketchfab,
but it requires that you get an API key first.  You can get this API key by
creating an account and then going to your &amp;quot;dashboard,&amp;quot; where it will be listed
on the right hand side.  Once you've obtained it, put it into your
&lt;tt class=&quot;docutils literal&quot;&gt;&lt;span class=&quot;pre&quot;&gt;~/.yt/config&lt;/span&gt;&lt;/tt&gt; file under the heading &lt;tt class=&quot;docutils literal&quot;&gt;[yt]&lt;/tt&gt; as the variable
&lt;tt class=&quot;docutils literal&quot;&gt;sketchfab_api_key&lt;/tt&gt;.  If you don't want to do this, you can also supply it as
an argument to the function &lt;tt class=&quot;docutils literal&quot;&gt;export_sketchfab&lt;/tt&gt;.&lt;/p&gt;
&lt;p&gt;Now you can run a script like this:&lt;/p&gt;
&lt;pre class=&quot;code python literal-block&quot;&gt;
&lt;span class=&quot;keyword namespace&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;name namespace&quot;&gt;yt.mods&lt;/span&gt; &lt;span class=&quot;keyword namespace&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;*&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;pf&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;load&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;literal string double&quot;&gt;&amp;quot;redshift0058&amp;quot;&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;dd&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;pf&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;h&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;sphere&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;literal string double&quot;&gt;&amp;quot;max&amp;quot;&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;literal number integer&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;literal string double&quot;&gt;&amp;quot;kpc&amp;quot;&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;name&quot;&gt;rho&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;literal number float&quot;&gt;5e-27&lt;/span&gt;

&lt;span class=&quot;name&quot;&gt;bounds&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;punctuation&quot;&gt;[(&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;dd&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;center&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;literal number float&quot;&gt;100.0&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;pf&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;literal string single&quot;&gt;'kpc'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;],&lt;/span&gt;
           &lt;span class=&quot;name&quot;&gt;dd&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;center&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;literal number float&quot;&gt;100.0&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;pf&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;literal string single&quot;&gt;'kpc'&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;])&lt;/span&gt; &lt;span class=&quot;keyword&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;operator word&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;name builtin&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;literal number integer&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;)]&lt;/span&gt;

&lt;span class=&quot;name&quot;&gt;surf&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;pf&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;h&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;surface&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;dd&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;literal string double&quot;&gt;&amp;quot;Density&amp;quot;&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;rho&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;name&quot;&gt;upload_id&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;surf&lt;/span&gt;&lt;span class=&quot;operator&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;name&quot;&gt;export_sketchfab&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;name&quot;&gt;title&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;literal string double&quot;&gt;&amp;quot;RD0058 - 5e-27&amp;quot;&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;name&quot;&gt;description&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;literal string double&quot;&gt;&amp;quot;Extraction of Density (colored by Temperature) at 5e-27 &amp;quot;&lt;/span&gt; \
                &lt;span class=&quot;operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;literal string double&quot;&gt;&amp;quot;g/cc from a galaxy formation simulation by Ryan Joung.&amp;quot;&lt;/span&gt;
    &lt;span class=&quot;name&quot;&gt;color_field&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;literal string double&quot;&gt;&amp;quot;Temperature&amp;quot;&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;name&quot;&gt;color_map&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;literal string double&quot;&gt;&amp;quot;hot&amp;quot;&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;name&quot;&gt;color_log&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name builtin pseudo&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;name&quot;&gt;bounds&lt;/span&gt; &lt;span class=&quot;operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;name&quot;&gt;bounds&lt;/span&gt;
&lt;span class=&quot;punctuation&quot;&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;and yt will extract a surface, convert to a format that Sketchfab.com
understands (PLY, in a zip file) and then upload it using your API key.  For
this demo, I've used data kindly provided by Ryan Joung from a simulation of
galaxy formation.  Here's what my newly-uploaded model looks like, using the
embed code from Sketchfab:&lt;/p&gt;
&lt;iframe frameborder=&quot;0&quot; height=&quot;480&quot; width=&quot;854&quot; allowFullScreen
webkitallowfullscreen=&quot;true&quot; mozallowfullscreen=&quot;true&quot;
src=&quot;http://skfb.ly/l4jh2edcba?autostart=0&amp;transparent=0&amp;autospin=0&amp;controls=1&amp;watermark=1&quot;&gt;&lt;/iframe&gt;&lt;p&gt;As a note, Sketchfab has a maximum model size of 50MB for the free account.
50MB is pretty hefty, though, so it shouldn't be a problem for most needs.
We're working on a way to optionally upload links to the Sketchfab models on
the &lt;a class=&quot;reference external&quot; href=&quot;https://hub.yt-project.org/&quot;&gt;yt Hub&lt;/a&gt;, but for now, if you want to share
a cool model we'd love to see it!&lt;/p&gt;
&lt;p&gt;Thanks to Sketchfab for such a cool service, and for helping us out along the
way with their API.&lt;/p&gt;
&lt;/div&gt;
</content>
  </entry>
</feed>
