Skip to content

Commit

Permalink
updated ipynb
Browse files Browse the repository at this point in the history
  • Loading branch information
eltrompetero committed Apr 1, 2021
1 parent c32302b commit 39991dd
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 63 deletions.
39 changes: 12 additions & 27 deletions plotting (pnas).html
Original file line number Diff line number Diff line change
Expand Up @@ -16361,7 +16361,7 @@
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[82]:</div>
<div class="prompt input_prompt">In&nbsp;[1]:</div>
<div class="inner_cell">
<div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="o">%</span><span class="k">pylab</span> inline
Expand All @@ -16386,19 +16386,6 @@
</div>
</div>

<div class="output_area">

<div class="prompt"></div>


<div class="output_subarea output_stream output_stderr output_text">
<pre>/home/eddie/anaconda3/envs/forests/lib/python3.8/site-packages/IPython/core/magics/pylab.py:159: UserWarning: pylab import has clobbered these variables: [&#39;imread&#39;]
`%matplotlib` prevents importing * from pylab and numpy
warn(&#34;pylab import has clobbered these variables: %s&#34; % clobbered +
</pre>
</div>
</div>

</div>
</div>

Expand All @@ -16421,19 +16408,18 @@
<div class="prompt input_prompt">In&nbsp;[84]:</div>
<div class="inner_cell">
<div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="c1"># import necessary Python modules</span>
<span class="kn">from</span> <span class="nn">pyutils</span> <span class="kn">import</span> <span class="o">*</span>
<span class="kn">from</span> <span class="nn">statsmodels.distributions</span> <span class="kn">import</span> <span class="n">ECDF</span>
<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">from</span> <span class="nn">misc.plot</span> <span class="kn">import</span> <span class="n">colorcycle</span>
<span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span>
<div class=" highlight hl-ipython3"><pre><span></span><span class="c1"># import necessary standard Python modules</span>
<span class="kn">from</span> <span class="nn">matplotlib.patches</span> <span class="kn">import</span> <span class="n">Circle</span>
<span class="kn">from</span> <span class="nn">matplotlib.collections</span> <span class="kn">import</span> <span class="n">PatchCollection</span>
<span class="kn">from</span> <span class="nn">matplotlib.gridspec</span> <span class="kn">import</span> <span class="n">GridSpec</span><span class="p">,</span> <span class="n">GridSpecFromSubplotSpec</span>
<span class="kn">from</span> <span class="nn">matplotlib.offsetbox</span> <span class="kn">import</span> <span class="n">OffsetImage</span><span class="p">,</span> <span class="n">AnnotationBbox</span>
<span class="kn">from</span> <span class="nn">matplotlib.image</span> <span class="kn">import</span> <span class="n">imread</span>
<span class="kn">from</span> <span class="nn">mpl_toolkits.axes_grid1.inset_locator</span> <span class="kn">import</span> <span class="n">inset_axes</span>

<span class="c1"># import custom Python modules</span>
<span class="kn">from</span> <span class="nn">misc.plot</span> <span class="kn">import</span> <span class="n">colorcycle</span> <span class="c1"># see installation instructions</span>
<span class="kn">from</span> <span class="nn">pyutils</span> <span class="kn">import</span> <span class="o">*</span>

<span class="c1"># set image save path</span>
<span class="n">imgdr</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">expanduser</span><span class="p">(</span><span class="s1">&#39;~&#39;</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;/Dropbox/Research/forests/writing/20201130_pnas&#39;</span>
<span class="k">assert</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isdir</span><span class="p">(</span><span class="n">imgdr</span><span class="p">),</span> <span class="s2">&quot;Directory in which to save images does not exist.&quot;</span>
Expand All @@ -16456,9 +16442,7 @@ <h1 id="Figure-2">Figure 2<a class="anchor-link" href="#Figure-2">&#182;</a></h1
<div class="prompt input_prompt">In&nbsp;[85]:</div>
<div class="inner_cell">
<div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="c1"># is the disagreement from the fact that the &quot;core&quot; of the tree is less likely to have competitors</span>
<span class="c1"># such that you actually don&#39;t compete with all of you&#39;re area?</span>
<span class="n">load_pickle</span><span class="p">(</span><span class="s1">&#39;cache/biomass_scaling_w_compet_nu=2.5.p.bak&#39;</span><span class="p">)</span>
<div class=" highlight hl-ipython3"><pre><span></span><span class="n">load_pickle</span><span class="p">(</span><span class="s1">&#39;cache/biomass_scaling_w_compet_nu=2.5.p.bak&#39;</span><span class="p">)</span>

<span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">nk</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
<span class="n">nk</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">concatenate</span><span class="p">([</span><span class="n">i</span><span class="p">[</span><span class="o">-</span><span class="mi">1000</span><span class="p">:,:,</span><span class="kc">None</span><span class="p">]</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">nk</span><span class="p">[</span><span class="n">k</span><span class="p">]],</span> <span class="n">axis</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span><span class="o">.</span><span class="n">mean</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
Expand Down Expand Up @@ -16801,7 +16785,6 @@ <h1 id="Figure-4">Figure 4<a class="anchor-link" href="#Figure-4">&#182;</a></h1
<div class=" highlight hl-ipython3"><pre><span></span><span class="n">fig</span><span class="p">,</span> <span class="n">ax</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplots</span><span class="p">(</span><span class="n">figsize</span><span class="o">=</span><span class="p">(</span><span class="mi">8</span><span class="p">,</span><span class="mi">2</span><span class="p">))</span>

<span class="n">coeff</span> <span class="o">=</span> <span class="n">logspace</span><span class="p">(</span><span class="o">-</span><span class="mi">4</span><span class="p">,</span><span class="mf">1.1</span><span class="p">,</span><span class="mi">10</span><span class="p">)</span>
<span class="c1"># coeff = linspace(1e-3,1,1000)</span>
<span class="n">delta</span> <span class="o">=</span> <span class="mf">1.8</span> <span class="o">-</span> <span class="mi">4</span><span class="o">/</span><span class="mi">3</span>

<span class="n">ax</span><span class="o">.</span><span class="n">loglog</span><span class="p">(</span><span class="n">coeff</span><span class="p">,</span> <span class="n">coeff</span><span class="o">**</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="o">/</span><span class="p">(</span><span class="n">delta</span><span class="o">+</span><span class="mi">2</span><span class="o">/</span><span class="mi">3</span><span class="p">)),</span> <span class="s1">&#39;-&#39;</span><span class="p">)</span>
Expand Down Expand Up @@ -17059,10 +17042,11 @@ <h4 id="Puerto-Rico-rainfall">Puerto Rico rainfall<a class="anchor-link" href="#
<span class="n">na</span> <span class="o">=</span> <span class="n">na</span> <span class="o">/</span> <span class="n">na</span><span class="o">.</span><span class="n">sum</span><span class="p">()</span>
<span class="n">nb</span> <span class="o">=</span> <span class="n">nb</span> <span class="o">/</span> <span class="n">nb</span><span class="o">.</span><span class="n">sum</span><span class="p">()</span>

<span class="c1"># data</span>
<span class="n">ax</span><span class="o">.</span><span class="n">loglog</span><span class="p">(</span><span class="n">xa</span><span class="p">,</span> <span class="n">na</span><span class="p">,</span> <span class="s1">&#39;.&#39;</span><span class="p">,</span> <span class="n">c</span><span class="o">=</span><span class="s1">&#39;C0&#39;</span><span class="p">)</span>
<span class="n">ax</span><span class="o">.</span><span class="n">loglog</span><span class="p">(</span><span class="n">xb</span><span class="p">,</span> <span class="n">nb</span><span class="p">,</span> <span class="s1">&#39;.&#39;</span><span class="p">,</span> <span class="n">c</span><span class="o">=</span><span class="s1">&#39;C1&#39;</span><span class="p">)</span>

<span class="c1"># power law</span>
<span class="c1"># power law comparison</span>
<span class="n">x</span> <span class="o">=</span> <span class="n">array</span><span class="p">([</span><span class="mi">8</span><span class="p">,</span> <span class="n">xb</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]])</span>
<span class="n">ax</span><span class="o">.</span><span class="n">loglog</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="mi">15</span> <span class="o">*</span> <span class="n">x</span><span class="o">**-</span><span class="mf">2.6</span><span class="p">,</span> <span class="s1">&#39;k-&#39;</span><span class="p">)</span>

Expand Down Expand Up @@ -17456,7 +17440,7 @@ <h4 id="Canopy-simulation-example">Canopy simulation example<a class="anchor-lin
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h4 id="Non-power-law-growth-tail">Non-power-law growth tail<a class="anchor-link" href="#Non-power-law-growth-tail">&#182;</a></h4>
<h4 id="Non-power-law-growth-(logistic)-example">Non-power-law growth (logistic) example<a class="anchor-link" href="#Non-power-law-growth-(logistic)-example">&#182;</a></h4>
</div>
</div>
</div>
Expand Down Expand Up @@ -17533,8 +17517,9 @@ <h4 id="Automaton-simulation-of-asymmetric-competition">Automaton simulation of
<div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="n">load_pickle</span><span class="p">(</span><span class="s1">&#39;cache/automaton_oscillation_example.p&#39;</span><span class="p">)</span>

<span class="c1"># average across forests</span>
<span class="c1"># average across forests (this averages out random fluctuations)</span>
<span class="c1"># thisnk = concatenate([i[:,:,None] for i in nk], axis=2).mean(2)</span>
<span class="c1"># show a single forest</span>
<span class="n">thisnk</span> <span class="o">=</span> <span class="n">nk</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>

<span class="n">fig</span><span class="p">,</span> <span class="n">ax</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplots</span><span class="p">(</span><span class="n">figsize</span><span class="o">=</span><span class="p">(</span><span class="mi">6</span><span class="p">,</span><span class="mi">9</span><span class="p">),</span> <span class="n">nrows</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span>
Expand Down
86 changes: 50 additions & 36 deletions plotting (pnas).ipynb

Large diffs are not rendered by default.

0 comments on commit 39991dd

Please sign in to comment.