

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>Tutorial - Basic Usage &mdash; PsrPopPy 1 documentation</title>
    
    <link rel="stylesheet" href="_static/default.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '',
        VERSION:     '1',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="top" title="PsrPopPy 1 documentation" href="index.html" />
    <link rel="next" title="Module-level Documentation" href="module-level-docs.html" />
    <link rel="prev" title="Documentation for the command-line scripts" href="cmd-line-docs.html" /> 
  </head>
  <body>

<div style="background-color: white; text-align: left; padding: 10px 10px 15px 15px">
<a href="index.html"><img src="_static/logo2.png" border="0" alt="py4sci"/></a>
</div>

    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="module-level-docs.html" title="Module-level Documentation"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="cmd-line-docs.html" title="Documentation for the command-line scripts"
             accesskey="P">previous</a> |</li>
        <li><a href="index.html">home</a>|&nbsp;</li>
        <li><a href="search.html">search</a>|&nbsp;</li>
 
      </ul>
    </div>

      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h3><a href="index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Tutorial - Basic Usage</a><ul>
<li><a class="reference internal" href="#generate-population-model">Generate Population Model</a></li>
<li><a class="reference internal" href="#simulate-a-pulsar-survey">Simulate a Pulsar Survey</a></li>
<li><a class="reference internal" href="#visualising-a-pulsar-model">Visualising a Pulsar Model</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="cmd-line-docs.html"
                        title="previous chapter">Documentation for the command-line scripts</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="module-level-docs.html"
                        title="next chapter">Module-level Documentation</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="_sources/tutorial-basic.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="tutorial-basic-usage">
<span id="tutorial-basic"></span><h1>Tutorial - Basic Usage<a class="headerlink" href="#tutorial-basic-usage" title="Permalink to this headline">¶</a></h1>
<p>This page will outline a very simple pipeline for basic population
simulations with PsrPopPy.</p>
<div class="section" id="generate-population-model">
<span id="generate-population"></span><h2>Generate Population Model<a class="headerlink" href="#generate-population-model" title="Permalink to this headline">¶</a></h2>
<p>Population models are generated using the <tt class="docutils literal"><span class="pre">populate.py</span></tt> script. A common
use would be to generate a population of normal pulsars using the Parkes
Multibeam Pulsar Survey as a basis. This survey detected 1038 pulsars (at
last count). Using default radial distribution, period and luminosity models,
we can generate such a population using the command:</p>
<div class="highlight-python"><pre>python populate.py -n 1038 -surveys PMSURV</pre>
</div>
<p>This will then run for a few minutes, until the model PMSURV survey
has detected 1038 pulsars. The file <tt class="docutils literal"><span class="pre">populate.model</span></tt> will be produced
by default, which is a <a class="reference external" href="http://docs.python.org/library/pickle.html">pickled</a>
population object.</p>
<p>If, instead, you wanted to use the Lyne &amp; Manchester (1998) electron
distribution, and for whatever reason wanted to store the output in the
file <tt class="docutils literal"><span class="pre">pop_lm98.model</span></tt>, then we could run:</p>
<div class="highlight-python"><pre>python populate.py -n 1038 -surveys PMSURV -dm lm98 -o pop_lm98.model</pre>
</div>
<p>A different output file will then be produced, where the population uses
the new simulation parameters.</p>
</div>
<div class="section" id="simulate-a-pulsar-survey">
<span id="simulate-survey"></span><h2>Simulate a Pulsar Survey<a class="headerlink" href="#simulate-a-pulsar-survey" title="Permalink to this headline">¶</a></h2>
<p>Once you&#8217;ve generated a pulsar population model, the <tt class="docutils literal"><span class="pre">dosurvey.py</span></tt> script
can be used to run the model through a past, present or future, pulsar
survey (as specified in files in the <tt class="docutils literal"><span class="pre">survey</span></tt> directory &#8212; see
<em class="xref std std-ref">_model-survey-files</em>).</p>
<p>For example, say we want to take the population model we just created,
<tt class="docutils literal"><span class="pre">pop_lm98.model</span></tt>, and estimate from this how many pulsars would be detected
in a putative LOFAR pulsar survey. This can be simply done using:</p>
<div class="highlight-python"><pre>python dosurvey.py -f pop_lm98.model -surveys LOFAR</pre>
</div>
<p>Which will print out the results of the survey, and write a results file called
<tt class="docutils literal"><span class="pre">LOFAR.results</span></tt>, which again is in the Pickle format. To write an ascii
summary file, and an ascii file containing the parameters of all detected pulsars,
simply add some extra flags:</p>
<div class="highlight-python"><pre>python dosurvey.py -f pop_lm98.model -surveys LOFAR --asc --summary</pre>
</div>
<p>Note that multiple model surveys may be run at once. To do so, just list
as many as required after the <tt class="docutils literal"><span class="pre">-surveys</span></tt> flag. The results file can also
be turned off:</p>
<div class="highlight-python"><pre>python dosurvey.py -f pop_lm98.model -surveys LOFAR GMRT GBNCC --noresults</pre>
</div>
</div>
<div class="section" id="visualising-a-pulsar-model">
<span id="visualise-model"></span><h2>Visualising a Pulsar Model<a class="headerlink" href="#visualising-a-pulsar-model" title="Permalink to this headline">¶</a></h2>
<p>There are two ways to visualise the populations generated by either
<tt class="docutils literal"><span class="pre">populate.py</span></tt> (<tt class="docutils literal"><span class="pre">.model</span></tt>) or <tt class="docutils literal"><span class="pre">dosurvey.py</span></tt> (<tt class="docutils literal"><span class="pre">.results</span></tt>). To plot
basic histograms of various parameters, use the <tt class="docutils literal"><span class="pre">view.py</span></tt> script:</p>
<div class="highlight-python"><pre>python view.py -f &lt;model&gt; -p &lt;parameter&gt;</pre>
</div>
<p>Here <tt class="docutils literal"><span class="pre">&lt;parameter&gt;</span></tt> could be <tt class="docutils literal"><span class="pre">period</span></tt>, <tt class="docutils literal"><span class="pre">dm</span></tt>, or several other options,
as outlined in <em class="xref std std-ref">_view_docs</em>. Assuming the <a class="reference external" href="http://matplotlib.org/">Matplotlib</a>
package is installed, this will generate a histogram which can then be
saved or printed as necessary.</p>
<p>To create a histogram of the logarithm of the selected parameter, use:</p>
<div class="highlight-python"><pre>python view.py -f &lt;model&gt; -p &lt;parameter&gt; --logx</pre>
</div>
<p>For more detailed information, sometimes it may be useful to plot two parameters
against one another. For this, use <tt class="docutils literal"><span class="pre">visualize.py</span></tt>:</p>
<div class="highlight-python"><pre>python visualize.py -f &lt;model&gt;</pre>
</div>
<p>This will open a window with some radio buttons on the left-hand-side. Select a
parameter for the x-axis, one for the y-axis, and select whether you want to
plot the logarithms of these parameters (see screenshot below).</p>
<img alt="_images/visualize_screenshot2.png" src="_images/visualize_screenshot2.png" />
</div>
</div>


          </div>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="module-level-docs.html" title="Module-level Documentation"
             >next</a> |</li>
        <li class="right" >
          <a href="cmd-line-docs.html" title="Documentation for the command-line scripts"
             >previous</a> |</li>
        <li><a href="index.html">home</a>|&nbsp;</li>
        <li><a href="search.html">search</a>|&nbsp;</li>
 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2012, S Bates.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
    </div>
  </body>
</html>