<h2>Generate the example file<a class="headerlink" href="#generate-the-example-file" title="Permalink to this headline">¶</a></h2>
<p>To run the examples of this section, you must first move to the <tt class="docutils literal"><span class="pre">~/pnbody_examples</span></tt> directory.
If the latter does not exists, you can first create it with:</p>
<p>This will create the N-body file <tt class="docutils literal"><span class="pre">snapd.dat</span></tt>.
This file contains a rotating disk of radius 30, with a small plummer sphere centered on (15,15,10).</p>
</div>
<div class="section" id="the-display-method">
<h2>The display method<a class="headerlink" href="#the-display-method" title="Permalink to this headline">¶</a></h2>
<p>Any model may be displayed simply using the method <a class="reference internal" href="MainModule.html#pNbody.main.NbodyDefault.display" title="pNbody.main.NbodyDefault.display"><tt class="xref py py-func docutils literal"><span class="pre">NbodyDefault.display()</span></tt></a>.
This method takes several parameters that will be described in detail below.
For our first example, we simply use the <tt class="docutils literal"><span class="pre">size</span></tt> parameter, which set the size of
<h2>Set the observer position<a class="headerlink" href="#set-the-observer-position" title="Permalink to this headline">¶</a></h2>
<p>When creating an image from a model, one has to choose the observer position, the look at
point and the orientation of the head. The user has tree possibilities to define these parameters :</p>
<blockquote>
<div><ol class="arabic simple">
<li>Define manually the observer matrix <tt class="docutils literal"><span class="pre">obs</span></tt>. <tt class="docutils literal"><span class="pre">obs</span></tt> is a 4x3 array matrix. Meaning of the four vectors composing this matrix is given in the following table :</li>
</ol>
<table border="1" class="docutils">
<colgroup>
<col width="7%" />
<col width="93%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">obs</th>
<th class="head">Meaning</th>
</tr>
</thead>
<tbody valign="top">
<tr><td>obs[0]</td>
<td>position of the observer</td>
</tr>
<tr><td>obs[1]</td>
<td>position of the look at point (with respect to the position of the observer)</td>
</tr>
<tr><td>obs[2]</td>
<td>position of the head (with respect to the position of the observer)</td>
</tr>
<tr><td>obs[3]</td>
<td>position of the arm (with respect to the position of the observer)</td>
</tr>
</tbody>
</table>
<blockquote>
<div>If <tt class="docutils literal"><span class="pre">obs</span></tt> is defined, it is used in priority.</div></blockquote>
<ol class="arabic simple" start="2">
<li>Using the parameters <tt class="docutils literal"><span class="pre">xp</span></tt>, <tt class="docutils literal"><span class="pre">x0</span></tt> and <tt class="docutils literal"><span class="pre">alpha</span></tt>, where <tt class="docutils literal"><span class="pre">x0</span></tt> is the observer position, <tt class="docutils literal"><span class="pre">xp</span></tt> is
the <em>look at point</em> and <tt class="docutils literal"><span class="pre">alpha</span></tt> the angle between the head and the z axis.</li>
<li>Using the parameters <tt class="docutils literal"><span class="pre">view</span></tt> and <tt class="docutils literal"><span class="pre">r_obs</span></tt>. This simpler method is used if <tt class="docutils literal"><span class="pre">obs</span></tt>, <tt class="docutils literal"><span class="pre">xp</span></tt> and <tt class="docutils literal"><span class="pre">x0</span></tt> are set to <tt class="xref docutils literal"><span class="pre">None</span></tt>.
The parameter <tt class="docutils literal"><span class="pre">view</span></tt> can be equal to <em>xy</em>, <em>xz</em> or <em>yz</em>, the projection
being parallel to one of the main axis. <tt class="docutils literal"><span class="pre">r_obs</span></tt> gives the distance between the observer and the <em>look at point</em>.</li>
</ol>
</div></blockquote>
<div class="section" id="example">
<h3>Example:<a class="headerlink" href="#example" title="Permalink to this headline">¶</a></h3>
<p>To see the disk face-on, projecting it along the z axis:</p>
<span class="pre">the</span> <span class="pre">parameter</span> <span class="pre">``clip</span></tt> containing a tuple. The left, right, bottom and top clipping planes are given by the parameter <tt class="docutils literal"><span class="pre">size</span></tt>.
If <tt class="docutils literal"><span class="pre">cut</span></tt> is set to ‘yes’, particles outside the box defined by the 6 planes are not displayed.</p>
<div class="section" id="id1">
<h3>Example:<a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h3>
<p>The field of view is determined using <tt class="docutils literal"><span class="pre">clip</span></tt> and <tt class="docutils literal"><span class="pre">size</span></tt>.</p>
<p>If <tt class="docutils literal"><span class="pre">cut</span></tt> is set to <tt class="docutils literal"><span class="pre">yes</span></tt>, only particles inside the clip planes are displayed:</p>
<h2>Stero mode<a class="headerlink" href="#stero-mode" title="Permalink to this headline">¶</a></h2>
<p>In order to create stereo images, you can specify the <tt class="docutils literal"><span class="pre">eye</span></tt> you are looking with (‘right’,’left’).
When exposition the model using the method <a class="reference internal" href="MainModule.html#pNbody.main.NbodyDefault.expose" title="pNbody.main.NbodyDefault.expose"><tt class="xref py py-func docutils literal"><span class="pre">NbodyDefault.expose()</span></tt></a>, the observer will be rotate around
an axis parallel to its head, with a center rotation in the direction of the <em>look at point</em>, at a distance
<tt class="docutils literal"><span class="pre">foc</span></tt> of the eye. The angle of the rotation is such as to move the observer of a distance <tt class="docutils literal"><span class="pre">dist_eye</span></tt>/2.</p>
<div class="section" id="id2">
<h3>Example:<a class="headerlink" href="#id2" title="Permalink to this headline">¶</a></h3>
<p>Left and right images may be obtained respectively with:</p>
<h2>Shape of the final image<a class="headerlink" href="#shape-of-the-final-image" title="Permalink to this headline">¶</a></h2>
<p>The shape in pixel of the final image is set by the tuple <tt class="docutils literal"><span class="pre">shape</span></tt>.</p>
</div>
<div class="section" id="display-space">
<h2>Display space<a class="headerlink" href="#display-space" title="Permalink to this headline">¶</a></h2>
<p>The <tt class="docutils literal"><span class="pre">space</span></tt> parameter may be either <tt class="docutils literal"><span class="pre">pos</span></tt> (default) or <tt class="docutils literal"><span class="pre">vel</span></tt>.
In the second case, the model is displayed in velocity space, this simply means
that the positions are replaced by the velocities.</p>
<div class="section" id="id3">
<h3>Example:<a class="headerlink" href="#id3" title="Permalink to this headline">¶</a></h3>
<p>We clearly see the ofset of (0.5,0,0) in velocity of the sphere.</p>
</div>
</div>
<div class="section" id="display-mode">
<h2>Display mode<a class="headerlink" href="#display-mode" title="Permalink to this headline">¶</a></h2>
<p>The <tt class="docutils literal"><span class="pre">mode</span></tt> parameter is very important. It tells the method <a class="reference internal" href="MainModule.html#pNbody.main.NbodyDefault.display" title="pNbody.main.NbodyDefault.display"><tt class="xref py py-func docutils literal"><span class="pre">NbodyDefault.display()</span></tt></a> which
physical quantities must be displayed. By default, it value is <tt class="docutils literal"><span class="pre">m</span></tt>, meaning the mass. When used,
a projected mass map (surface density) is returned.</p>
<p>The value of <tt class="docutils literal"><span class="pre">mode</span></tt> parameter may be set to:</p>
<ol class="arabic simple">
<li>a value from the following list. In this case, the value does not dependends on the observer position :</li>
<p>Note that we have used a linear scale here.</p>
</div>
</div>
<div class="section" id="rendering">
<h2>Rendering<a class="headerlink" href="#rendering" title="Permalink to this headline">¶</a></h2>
<p>The parameter <tt class="docutils literal"><span class="pre">rendering</span></tt> is by default set to <tt class="docutils literal"><span class="pre">map</span></tt>. This means that particles are projected on a grid (2d histrogram).
However, in some circumstances, it may be usefull to display simple objects, like a cube or a sphere, determined
by a small number of points. The object is obtained by linking all points with segments. This is done by setting
the parameter <tt class="docutils literal"><span class="pre">rendering</span></tt> to one of the following value:</p>
<blockquote>
<div><table border="1" class="docutils">
<colgroup>
<col width="13%" />
<col width="23%" />
<col width="65%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">Value</th>
<th class="head">Call</th>
<th class="head">Meaning</th>
</tr>
</thead>
<tbody valign="top">
<tr><td>lines</td>
<td>draw_lines</td>
<td>draw a continuous line linking all points</td>
<h2>Set color range<a class="headerlink" href="#set-color-range" title="Permalink to this headline">¶</a></h2>
<p>Once a mapping has been performed, it return a matrix containing physical values.
The latter must be transformed into an image coded by 256 colors, i.e, a matrix containing
integers between 0 and 255. The transformation from the initial matrix and the integer matrix
is determined using four parameters:</p>
<blockquote>
<div><table border="1" class="docutils">
<colgroup>
<col width="15%" />
<col width="85%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">Parameter</th>
<th class="head">Meaning</th>
</tr>
</thead>
<tbody valign="top">
<tr><td>scale</td>
<td>the scaling ‘lin’ or ‘log’</td>
</tr>
<tr><td>cd</td>
<td>if scale=’lin’, this gives the position of the elbow</td>
</tr>
<tr><td>mn</td>
<td>the minimum physical value</td>
</tr>
<tr><td>mx</td>
<td>the maximum physical value</td>
</tr>
</tbody>
</table>
</div></blockquote>
<p>In more details, if <img class="math" src="../_images/math/57c1ae3e3c98703798989a456983e0466caf3221.png" alt="M_p"/> is the physical matrix and <img class="math" src="../_images/math/50496bd204bbf34e209ecabe0729f4937fe69a1d.png" alt="M_i"/> the
<p>If <a href="#id9"><span class="problematic" id="id10">``</span></a>mn``=0 or <a href="#id11"><span class="problematic" id="id12">``</span></a>mx``=0, or <a href="#id13"><span class="problematic" id="id14">``</span></a>cd``=0, these parameters are set automatically.</p>
<div class="section" id="id15">
<h3>Examples:<a class="headerlink" href="#id15" title="Permalink to this headline">¶</a></h3>
<p>To cut the velocities at a values of -0.3 and 0.3 in the velocity map example:</p>
<h2>Set filters<a class="headerlink" href="#set-filters" title="Permalink to this headline">¶</a></h2>
<p>Its possible to apply filter on the physical matrix, before converting it into an integer matrix.
To set a filter, you must specify the <tt class="docutils literal"><span class="pre">filter_name</span></tt> parameter and the <tt class="docutils literal"><span class="pre">filter_options</span></tt> parameter:
The actual filters are :</p>
<blockquote>
<div><table border="1" class="docutils">
<colgroup>
<col width="19%" />
<col width="81%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">Filter name</th>
<th class="head">filter opts</th>
</tr>
</thead>
<tbody valign="top">
<tr><td>convol</td>
<td>[nx,ny,sx,xy]</td>
</tr>
<tr><td>convolve</td>
<td>[nx,ny,sx,xy]</td>
</tr>
<tr><td>boxcar</td>
<td>[nx,ny,sx,xy]</td>
</tr>
<tr><td>gaussian</td>
<td>[sigma]</td>
</tr>
<tr><td>uniform</td>
<td>[sigma]</td>
</tr>
</tbody>
</table>
</div></blockquote>
<div class="section" id="id16">
<h3>Examples:<a class="headerlink" href="#id16" title="Permalink to this headline">¶</a></h3>