Skip to content

Commit

Permalink
Deploying to gh-pages from @ 0c436fd πŸš€
Browse files Browse the repository at this point in the history
  • Loading branch information
ghislainv committed Jun 6, 2024
1 parent ba80ed5 commit a227a88
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions _modules/riskmapjnr/defrate_per_cat.html
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,7 @@ <h1>Source code for riskmapjnr.defrate_per_cat</h1><div class="highlight"><pre>
<span class="n">cat</span> <span class="o">=</span> <span class="p">[</span><span class="n">c</span> <span class="o">+</span> <span class="mi">1</span> <span class="k">for</span> <span class="n">c</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">n_cat</span><span class="p">)]</span>

<span class="c1"># Create a table to save the results</span>
<span class="n">data</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;cat&quot;</span><span class="p">:</span> <span class="n">cat</span><span class="p">,</span> <span class="s2">&quot;nfor&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="s2">&quot;ndefor&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
<span class="s2">&quot;rate_obs&quot;</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span> <span class="s2">&quot;rate_mod&quot;</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">}</span>
<span class="n">data</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;cat&quot;</span><span class="p">:</span> <span class="n">cat</span><span class="p">,</span> <span class="s2">&quot;nfor&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="s2">&quot;ndefor&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">}</span>
<span class="n">df</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>

<span class="c1"># Loop on blocks of data</span>
Expand Down Expand Up @@ -228,6 +227,9 @@ <h1>Source code for riskmapjnr.defrate_per_cat</h1><div class="highlight"><pre>
<span class="n">cat_defor</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">Categorical</span><span class="p">(</span><span class="n">data_defor</span><span class="o">.</span><span class="n">flatten</span><span class="p">(),</span> <span class="n">categories</span><span class="o">=</span><span class="n">cat</span><span class="p">)</span>
<span class="n">df</span><span class="p">[</span><span class="s2">&quot;ndefor&quot;</span><span class="p">]</span> <span class="o">+=</span> <span class="n">cat_defor</span><span class="o">.</span><span class="n">value_counts</span><span class="p">()</span><span class="o">.</span><span class="n">values</span>

<span class="c1"># Time interval</span>
<span class="n">df</span><span class="p">[</span><span class="s2">&quot;time_interval&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">time_interval</span>

<span class="c1"># Annual deforestation rates per category</span>
<span class="n">df</span><span class="p">[</span><span class="s2">&quot;rate_obs&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">-</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">df</span><span class="p">[</span><span class="s2">&quot;ndefor&quot;</span><span class="p">]</span> <span class="o">/</span> <span class="n">df</span><span class="p">[</span><span class="s2">&quot;nfor&quot;</span><span class="p">])</span> <span class="o">**</span> <span class="p">(</span><span class="mi">1</span> <span class="o">/</span> <span class="n">time_interval</span><span class="p">)</span>

Expand All @@ -245,9 +247,6 @@ <h1>Source code for riskmapjnr.defrate_per_cat</h1><div class="highlight"><pre>
<span class="c1"># Absolute deforestation probability</span>
<span class="n">df</span><span class="p">[</span><span class="s2">&quot;rate_abs&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">df</span><span class="p">[</span><span class="s2">&quot;rate_mod&quot;</span><span class="p">]</span> <span class="o">*</span> <span class="n">correction_factor</span>

<span class="c1"># Time interval</span>
<span class="n">df</span><span class="p">[</span><span class="s2">&quot;time_interval&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">time_interval</span>

<span class="c1"># Pixel area</span>
<span class="n">pixel_area</span> <span class="o">=</span> <span class="n">xres</span> <span class="o">*</span> <span class="n">yres</span> <span class="o">/</span> <span class="mi">10000</span>
<span class="n">df</span><span class="p">[</span><span class="s2">&quot;pixel_area&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">pixel_area</span>
Expand Down

0 comments on commit a227a88

Please sign in to comment.