Skip to content

Commit

Permalink
Deploying to gh-pages from @ 44397a1 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
jdebacker committed Sep 19, 2024
1 parent b5a83cf commit d0457bc
Show file tree
Hide file tree
Showing 37 changed files with 678 additions and 256 deletions.
2 changes: 1 addition & 1 deletion _modules/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<link rel="stylesheet" type="text/css" href="../_static/copybutton.css?v=76b2166b" />
<link rel="stylesheet" type="text/css" href="../_static/mystnb.4510f1fc1dee50b3e5859aac5469c37c29e427902b24a333a5f9fcb2f0b3ac41.css" />
<link rel="stylesheet" type="text/css" href="../_static/sphinx-thebe.css?v=4fa983c6" />
<link rel="stylesheet" type="text/css" href="../_static/sphinx-design.min.css?v=87e54e7c" />
<link rel="stylesheet" type="text/css" href="../_static/sphinx-design.min.css?v=95c83b7e" />

<!-- Pre-loaded scripts that we'll load fully later -->
<link rel="preload" as="script" href="../_static/scripts/bootstrap.js?digest=dfe6caa3a7d634c4db9b" />
Expand Down
18 changes: 7 additions & 11 deletions _modules/ogzaf/calibrate.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<link rel="stylesheet" type="text/css" href="../../_static/copybutton.css?v=76b2166b" />
<link rel="stylesheet" type="text/css" href="../../_static/mystnb.4510f1fc1dee50b3e5859aac5469c37c29e427902b24a333a5f9fcb2f0b3ac41.css" />
<link rel="stylesheet" type="text/css" href="../../_static/sphinx-thebe.css?v=4fa983c6" />
<link rel="stylesheet" type="text/css" href="../../_static/sphinx-design.min.css?v=87e54e7c" />
<link rel="stylesheet" type="text/css" href="../../_static/sphinx-design.min.css?v=95c83b7e" />

<!-- Pre-loaded scripts that we'll load fully later -->
<link rel="preload" as="script" href="../../_static/scripts/bootstrap.js?digest=dfe6caa3a7d634c4db9b" />
Expand Down Expand Up @@ -366,6 +366,7 @@ <h1>Source code for ogzaf.calibrate</h1><div class="highlight"><pre>
<span class="kn">from</span> <span class="nn">ogzaf</span> <span class="kn">import</span> <span class="n">input_output</span> <span class="k">as</span> <span class="n">io</span>
<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
<span class="kn">import</span> <span class="nn">datetime</span>
<span class="kn">from</span> <span class="nn">ogcore</span> <span class="kn">import</span> <span class="n">demographics</span>


Expand All @@ -377,8 +378,8 @@ <h1>Source code for ogzaf.calibrate</h1><div class="highlight"><pre>
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span>
<span class="bp">self</span><span class="p">,</span>
<span class="n">p</span><span class="p">,</span>
<span class="n">estimate_tax_functions</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
<span class="n">estimate_chi_n</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
<span class="n">macro_data_start_year</span><span class="o">=</span><span class="n">datetime</span><span class="o">.</span><span class="n">datetime</span><span class="p">(</span><span class="mi">1947</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span>
<span class="n">macro_data_end_year</span><span class="o">=</span><span class="n">datetime</span><span class="o">.</span><span class="n">date</span><span class="o">.</span><span class="n">today</span><span class="p">(),</span>
<span class="n">demographic_data_path</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
<span class="n">output_path</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
<span class="p">):</span>
Expand All @@ -387,9 +388,6 @@ <h1>Source code for ogzaf.calibrate</h1><div class="highlight"><pre>

<span class="sd"> Args:</span>
<span class="sd"> p (OG-Core Specifications object): model parameters</span>
<span class="sd"> estimate_tax_functions (bool): whether to estimate tax</span>
<span class="sd"> function parameters</span>
<span class="sd"> estimate_chi_n (bool): whether to estimate chi_n</span>
<span class="sd"> demographic_data_path (str): path to save demographic data</span>
<span class="sd"> output_path (str): path to save output to</span>

Expand All @@ -401,11 +399,11 @@ <h1>Source code for ogzaf.calibrate</h1><div class="highlight"><pre>
<span class="k">if</span> <span class="n">output_path</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="n">output_path</span><span class="p">):</span>
<span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span><span class="n">output_path</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">estimate_tax_functions</span> <span class="o">=</span> <span class="n">estimate_tax_functions</span>
<span class="bp">self</span><span class="o">.</span><span class="n">estimate_chi_n</span> <span class="o">=</span> <span class="n">estimate_chi_n</span>

<span class="c1"># Macro estimation</span>
<span class="bp">self</span><span class="o">.</span><span class="n">macro_params</span> <span class="o">=</span> <span class="n">macro_params</span><span class="o">.</span><span class="n">get_macro_params</span><span class="p">()</span>
<span class="bp">self</span><span class="o">.</span><span class="n">macro_params</span> <span class="o">=</span> <span class="n">macro_params</span><span class="o">.</span><span class="n">get_macro_params</span><span class="p">(</span>
<span class="n">macro_data_start_year</span><span class="p">,</span> <span class="n">macro_data_end_year</span>
<span class="p">)</span>

<span class="c1"># io matrix and alpha_c</span>
<span class="k">if</span> <span class="n">p</span><span class="o">.</span><span class="n">I</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span> <span class="c1"># no need if just one consumption good</span>
Expand Down Expand Up @@ -462,8 +460,6 @@ <h1>Source code for ogzaf.calibrate</h1><div class="highlight"><pre>
<span class="c1"># method to return all newly calibrated parameters in a dictionary</span>
<span class="k">def</span> <span class="nf">get_dict</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="nb">dict</span> <span class="o">=</span> <span class="p">{}</span>
<span class="c1"># if self.estimate_chi_n:</span>
<span class="c1"># dict[&quot;chi_n&quot;] = self.chi_n</span>
<span class="nb">dict</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">macro_params</span><span class="p">)</span>
<span class="nb">dict</span><span class="p">[</span><span class="s2">&quot;e&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">e</span>
<span class="nb">dict</span><span class="p">[</span><span class="s2">&quot;alpha_c&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">alpha_c</span>
Expand Down
4 changes: 2 additions & 2 deletions _modules/ogzaf/income.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<link rel="stylesheet" type="text/css" href="../../_static/copybutton.css?v=76b2166b" />
<link rel="stylesheet" type="text/css" href="../../_static/mystnb.4510f1fc1dee50b3e5859aac5469c37c29e427902b24a333a5f9fcb2f0b3ac41.css" />
<link rel="stylesheet" type="text/css" href="../../_static/sphinx-thebe.css?v=4fa983c6" />
<link rel="stylesheet" type="text/css" href="../../_static/sphinx-design.min.css?v=87e54e7c" />
<link rel="stylesheet" type="text/css" href="../../_static/sphinx-design.min.css?v=95c83b7e" />

<!-- Pre-loaded scripts that we'll load fully later -->
<link rel="preload" as="script" href="../../_static/scripts/bootstrap.js?digest=dfe6caa3a7d634c4db9b" />
Expand Down Expand Up @@ -694,7 +694,7 @@ <h1>Source code for ogzaf.income</h1><div class="highlight"><pre>
<div class="viewcode-block" id="get_e_orig">
<a class="viewcode-back" href="../../content/api/income.html#ogzaf.income.get_e_orig">[docs]</a>
<span class="k">def</span> <span class="nf">get_e_orig</span><span class="p">(</span><span class="n">age_wgts</span><span class="p">,</span> <span class="n">abil_wgts</span><span class="p">,</span> <span class="n">plot_path</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="w"> </span><span class="sa">r</span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> This function generates the 80 x 7 matrix of lifetime earnings</span>
<span class="sd"> ability profiles, corresponding to annual ages from 21 to 100 and to</span>
<span class="sd"> paths based on income percentiles 0-25, 25-50, 50-70, 70-80, 80-90,</span>
Expand Down
43 changes: 35 additions & 8 deletions _modules/ogzaf/input_output.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<link rel="stylesheet" type="text/css" href="../../_static/copybutton.css?v=76b2166b" />
<link rel="stylesheet" type="text/css" href="../../_static/mystnb.4510f1fc1dee50b3e5859aac5469c37c29e427902b24a333a5f9fcb2f0b3ac41.css" />
<link rel="stylesheet" type="text/css" href="../../_static/sphinx-thebe.css?v=4fa983c6" />
<link rel="stylesheet" type="text/css" href="../../_static/sphinx-design.min.css?v=87e54e7c" />
<link rel="stylesheet" type="text/css" href="../../_static/sphinx-design.min.css?v=95c83b7e" />

<!-- Pre-loaded scripts that we'll load fully later -->
<link rel="preload" as="script" href="../../_static/scripts/bootstrap.js?digest=dfe6caa3a7d634c4db9b" />
Expand Down Expand Up @@ -364,6 +364,7 @@ <h1></h1>
<h1>Source code for ogzaf.input_output</h1><div class="highlight"><pre>
<span></span><span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span>
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
<span class="kn">from</span> <span class="nn">ogzaf.utils</span> <span class="kn">import</span> <span class="n">is_connected</span>
<span class="kn">from</span> <span class="nn">ogzaf.constants</span> <span class="kn">import</span> <span class="n">CONS_DICT</span><span class="p">,</span> <span class="n">PROD_DICT</span>

<span class="sd">&quot;&quot;&quot;</span>
Expand All @@ -372,13 +373,39 @@ <h1>Source code for ogzaf.input_output</h1><div class="highlight"><pre>
<span class="c1"># Read in SAM file</span>
<span class="n">storage_options</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;User-Agent&quot;</span><span class="p">:</span> <span class="s2">&quot;Mozilla/5.0&quot;</span><span class="p">}</span>
<span class="n">SAM_path</span> <span class="o">=</span> <span class="s2">&quot;https://www.wider.unu.edu/sites/default/files/Data/SASAM-2015-Data-Resource.xlsx&quot;</span>
<span class="n">SAM</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">read_excel</span><span class="p">(</span>
<span class="n">SAM_path</span><span class="p">,</span>
<span class="n">sheet_name</span><span class="o">=</span><span class="s2">&quot;Micro SAM 2015&quot;</span><span class="p">,</span>
<span class="n">skiprows</span><span class="o">=</span><span class="mi">6</span><span class="p">,</span>
<span class="n">index_col</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span>
<span class="n">storage_options</span><span class="o">=</span><span class="n">storage_options</span><span class="p">,</span>
<span class="p">)</span>
<span class="n">SAM_path_alt</span> <span class="o">=</span> <span class="s2">&quot;https://raw.githubusercontent.com/EAPD-DRB/SAM-files/main/Data/ZAF/SASAM-2015-Data-Resource.xlsx&quot;</span>

<span class="k">if</span> <span class="n">is_connected</span><span class="p">():</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">SAM</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">read_excel</span><span class="p">(</span>
<span class="n">SAM_path</span><span class="p">,</span>
<span class="n">sheet_name</span><span class="o">=</span><span class="s2">&quot;Micro SAM 2015&quot;</span><span class="p">,</span>
<span class="n">skiprows</span><span class="o">=</span><span class="mi">6</span><span class="p">,</span>
<span class="n">index_col</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span>
<span class="n">storage_options</span><span class="o">=</span><span class="n">storage_options</span><span class="p">,</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Successfully read SAM from WIDER.&quot;</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Failed to read from WIDER: </span><span class="si">{</span><span class="n">e</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>
<span class="k">try</span><span class="p">:</span>
<span class="c1"># Attempt to read from the GitHub repository</span>
<span class="n">SAM</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">read_excel</span><span class="p">(</span>
<span class="n">SAM_path_alt</span><span class="p">,</span>
<span class="n">sheet_name</span><span class="o">=</span><span class="s2">&quot;Micro SAM 2015&quot;</span><span class="p">,</span>
<span class="n">skiprows</span><span class="o">=</span><span class="mi">6</span><span class="p">,</span>
<span class="n">index_col</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span>
<span class="n">storage_options</span><span class="o">=</span><span class="n">storage_options</span><span class="p">,</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Successfully read SAM from GitHub repository.&quot;</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Failed to read from the GitHub repository: </span><span class="si">{</span><span class="n">e</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>
<span class="n">SAM</span> <span class="o">=</span> <span class="kc">None</span>
<span class="c1"># If both attempts fail, SAM will be None</span>
<span class="k">if</span> <span class="n">SAM</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Failed to read SAM from both sources.&quot;</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">SAM</span> <span class="o">=</span> <span class="kc">None</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;No internet connection. SAM cannot be read.&quot;</span><span class="p">)</span>


<div class="viewcode-block" id="get_alpha_c">
Expand Down
Loading

0 comments on commit d0457bc

Please sign in to comment.