{ "info": { "author": "Laurent Faucheux", "author_email": "laurent.faucheux@hotmail.fr", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "Intended Audience :: Science/Research", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Topic :: Scientific/Engineering" ], "description": "# PyLUCCBA\r\n\r\n
\r\n A Land-Use-Change Cost-Benefit-Analysis calculator coded in Python.\r\n
\r\n\r\n*This package offers a compilation of environmental and economic data to generate environment-related net present values of any biofuel project with impacts to the environment (GHG emissions or sequestrations). It is coded in Python (compatible with both versions: 2 and 3). Python is a cross platform and a comprehensive extensible and editable language with a large community of users. The structure of the package is simple with accessible input data to which it is possible to add or suppress one\u2019s own trajectories (of prices, carbon stocks, etc).*\r\n\r\n*NB: In the following description we use the expression project's Net Present Value (NPV) multiple times. Note that this use is abusive since it actually refers to the environmental component of projects. For more details, see [Dupoux (In press)](https://github.com/lfaucheux/PyLUCCBA/raw/master/Dupoux_inpress.pdf)*\r\n\r\n
\r\n\r\n- [Code coverage](#code-coverage)\r\n- [Installation](#installation)\r\n- [Example usage](#example-usage)\r\n - [A note on the carbon profitability payback period](#a-note-on-the-carbon-profitability-payback-period)\r\n - [A note on the compensatory rate](#a-note-on-the-compensatory-rate)\r\n- [Invoking documentation](#invoking-documentation)\r\n- [Data](#data)\r\n- [Data customization/addition](#data-customizationaddition)\r\n- [Format of results](#format-of-results)\r\n- [Paper's results replication](#papers-results-replication)\r\n- [References](#references)\r\n\r\n
\r\n\r\n## Code coverage\r\n\r\n| Module | statements | missing | excluded | coverage |\r\n| -------- | ---------- | ------- | -------- | -------- |\r\n| core.py | 880 | 26 | 0 | 97% |\r\n| tools.py | 308 | 60 | 0 | 81% |\r\n| Total | 1188 | 86 | 0 | 93% |\r\n\r\n
\r\n\r\n## Installation\r\n\r\nFirst, you need Python installed, either [Python2.7.+](https://www.python.org/downloads/) or [Python3.+](https://www.python.org/downloads/). Either versions are good for our purpose. Then, we are going to use a package management system to install [PyLUCCBA](https://github.com/lfaucheux/PyLUCCBA), namely [pip](https://en.wikipedia.org/wiki/Pip_(package_manager)), _already installed if you are using Python 2 >=2.7.9 or Python 3 >=3.4_. Open a session in your OS [shell](https://en.wikipedia.org/wiki/Shell_(computing)) prompt and type\r\n\r\n pip install pyluccba\r\n\r\nOr using a non-python-builtin approach, namely [git](https://git-scm.com/downloads),\r\n\r\n git clone git://github.com/lfaucheux/PyLUCCBA.git\r\n cd PyLUCCBA\r\n python setup.py install \r\n\r\n\r\n
\r\n\r\n## Example usage\r\n\r\n*The example that follows is done with the idea of showing how to go beyond the replication of the results presented in [Dupoux (In press)](https://github.com/lfaucheux/PyLUCCBA/raw/master/Dupoux_inpress.pdf) via the Python Shell*.\r\n\r\nLet's first import the module `PyLUCCBA`\r\n\r\n >>> import PyLUCCBA as cc\r\n\r\nThe alias of `PyLUCCBA`, namely `cc`, actually contains many objects definitions, such as that of the calculator that we are going to use in examples. The name of the calculator is `CBACalculator`.\r\n\r\nBut before using the calculator as such, let's define (and introduce) the set of parameters that we are going to use to configure `CBACalculator`. As can be expected when performing a cost benefit analysis, these parameters are related to: *(i)* the horizon of the project, *(ii)* the discount rate that we want to use in our calculations, *(iii)* the scenarized price trajectory of carbon dioxide (CO2), *(iv)* the scenarized trajectory of quantities of bio-ethanol to produce annually and *(...)* so on. Let's introduce them all in practice:\r\n\r\n >>> cba = cc.CBACalculator(\r\n run_name = 'Example-1',\r\n country = 'france',\r\n project_first_year = 2020,\r\n project_horizon = 20,\r\n discount_rate = .03,\r\n co2_prices_scenario = 'SPC2009',\r\n output_flows_scenario = 'O',\r\n initial_landuse = 'improved grassland',\r\n final_landuse = 'wheat',\r\n input_flows_scenario = 'IFP',\r\n T_so = 20,\r\n T_vg_diff = 1,\r\n T_vg_unif = 20,\r\n polat_repeated_pattern = True,\r\n final_currency = 'EUR',\r\n change_rates = {'EUR':{'USD/EUR':1.14}}, # https://www.google.fr/#q=EUR+USD\r\n return_charts = True,\r\n save_charts = True,\r\n from_local_data = False,\r\n )\r\n\r\nThe following table enumerates all parameters that can be used to create an instance of `CBACalculator`.\r\n\r\n Parameter's name | Description\r\n ------------------------ | -------\r\n `run_name` | name of the folder that will contain the generated results and charts, *e.g.* `'Example-1'`.\r\n `country` | name of the country under study. Only *one* possible choice currently: `France`.\r\n `project_first_year` | first year of the project.\r\n `project_horizon` | duration of the biofuel production project (years).\r\n `discount_rate` | rate involved in the calculations of net present values. Set to `0.` by default.\r\n `co2_prices_scenario` | name of the trajectory of CO2 prices. The current choices are `'A'`, `'B'`, `'C'`, `'DEBUG'`, `'O'`, `'OECD2018'`, `'SPC2009'`, `'SPC2019'`, `'WEO2015-450S'`, `'WEO2015-CPS'`, `'WEO2018-CPS'`, `'WEO2015-NPS'`, `'WEO2018-NPS'` or `'WEO2018-SDS'`.\r\n `output` | name of the produced biofuel. Set to `'eth'` by default. Only *one* possible choice currently: `'eth'`. ***NB***: `'eth'` actually stands for **bio**ethanol.\r\n `black_output` | name of the counterfactual produced output. Serves as the reference according to which the production of bioethanol (`'eth'`) is considered (or not) as pro-environmental. Set to `'oil'` by default. Only *one* possible choice currently: `'oil'`. ***NB***: `'oil'` actually stands for gasoline.\r\n `output_flows_scenario` | name of the trajectory of annually produced quantities of biofuel. The current choices are `'DEBUG'` or `'O'`.\r\n `initial_landuse` | use of the land *before* land conversion. The current choices are `'forestland30'`, `'improved grassland'`, `'annual cropland'` or `'degraded grassland'`.\r\n `final_landuse` | use of the land *after* land conversion. The current choices are `'miscanthus'`, `'sugarbeet'` or `'wheat'`.\r\n `input_flows_scenario` | name of the trajectory of input-to-ouput yields. The current choices depend on the value set for `final_landuse`. If `final_landuse` is set to `'miscanthus'`, the possibilities are `'DEBUG'` and `'DOE'`. If `final_landuse` is set to `'wheat'` or `'sugarbeet'`, the possibilities are `'IFP'` and `'DEBUG'`.\r\n `T_so` | period over which soil carbon emissions due to LUC are considered.\r\n `T_vg_diff` | period over which vegetation carbon emissions due to LUC are considered in the differentiated annualization approach.\r\n `T_vg_unif` | period over which vegetation carbon emissions due to LUC are considered in the uniform annualization approach.\r\n `polat_repeated_pattern` | if `True`, retro/extra-polation pattern is repeated before/after the first/last mentioned value. Otherwise, it is maintained constant.\r\n `final_currency` | currency used to conduct the study and express the results. The current choices are `'EUR'` or `'USD'`. Set to `'EUR'` by default.\r\n `change_rates` | `final_currency`-dependent exchange rate to consider in calculations, *e.g.* `{'EUR':{'USD/EUR':1.14,}}` *(or `{'EUR':{'EUR/USD':0.8772,}}` since the tool ensures dimensional homogeneity)*.\r\n `return_charts` | if `True`, charts are returned (for interactive use, e.g. hovering). Set to `True` by default.\r\n `save_charts` | if `True`, charts are saved on the disk. Set to `True` by default.\r\n `from_local_data` | if `True`, scenarized trajectories (*e.g.* of CO2 prices, of output flows quantities, of yields) are read from the 'resources' folder that is located next to the working script. If `False`, those are read from the 'resources' folder natively contained in the package directory. Set to `False` by default.\r\n\r\nOnce we have our instance of `CBACalculator` in hand, *i.e.* `cba`, we may wonder what are the scenarized trajectories over which we are about to conduct our study, *e.g.* of CO2 prices, produced quantities of biofuel, etc. In this case, we can simply type:\r\n\r\n >>> cba.chart_of_output_flows_traj.show()\r\n\r\n

\r\n\r\nAs it reads in the above chart, we are about to work with a constant level of production over the project horizon. Note the absence of flow in 2020: this illustrates the need for waiting one year before having enough wheat to produce biofuel.\r\n\r\nWe may then wonder what is the counterfactual trajectory in terms of gasoline \u2013 targeting the same [energy efficiency](https://en.wikipedia.org/wiki/Energy_conversion_efficiency) (in joule) as conversion basis: \r\n\r\n >>> cba.chart_of_black_output_flows_traj.show()\r\n\r\n

\r\n\r\nNow, let's see which trajectory of CO2 prices is behind the name `'SPC2009'` \u2013 which stands for [Quinet (2009)](http://www.ladocumentationfrancaise.fr/var/storage/rapports-publics/094000195.pdf)'s shadow price of carbon:\r\n\r\n >>> cba.chart_of_co2_prices_traj.show()\r\n\r\n

\r\n\r\nWe may also wonder which quantities trajectory of wheat is implied by that of biofuel on the one hand, and by the value we set for the parameter `input_flows_scenario`, that is `'IFP'` , on the other hand \u2013 where *I.F.P* stands for *Institut Fran\u00e7ais du P\u00e9trole \u00e9nergies nouvelles* \u2013 which made a report in [2013](https://github.com/lfaucheux/PyLUCCBA/blob/master/PyLUCCBA/resources/yields/Input/Input.txt) in which it reads that, with 1 tonne of wheat, one can produce [0.2844](https://github.com/lfaucheux/PyLUCCBA/blob/master/PyLUCCBA/resources/yields/Input/WHEAT_yields_FR.csv) tonnes of bioethanol. Let's vizualize that:\r\n\r\n >>> cba.chart_of_input_flows_traj.show()\r\n\r\n

\r\n\r\nNote the absence of input flow in 2040: as explained previously, this illustrates the time delay that exists between the cultivation of wheat and its processing into bioethanol, *e.g.* wheat cultivated in 2039 is used for the production of bioethanol planned in 2040.\r\n\r\nThe land use change from `initial_landuse='improved grassland'` to `final_landuse='wheat'` has effects in terms of CO2 emissions. These emissions clearly do not exhibit the same profile depending on how we choose to consider them over the project horizon. First, regarding soil CO2 emissions:\r\n\r\n >>> cba.carbon_and_co2_flows_traj_annualizer.so_emitting\r\n True\r\n >>> cba.chart_of_soco2_unif_flows_traj.show()\r\n >>> cba.chart_of_soco2_diff_flows_traj.show()\r\n ---- a_parameter_which_solves_soc_chosen_CRF_constrained sol=[0.52418009]\r\n ---- [***]The solution converged.[0.000000e+00][***]\r\n\r\n

\r\n\r\nOf course, the comparison makes sense since the total emitted stocks are identical:\r\n\r\n >>> import numpy as np\r\n >>> np.sum(cba.soco2_unif_flows_traj)\r\n -10.90041830757967 # tonnes\r\n >>> np.sum(cba.soco2_diff_flows_traj)\r\n -10.90041830757967 # tonnes\r\n\r\nOn the side of vegetation-related emissions, converting grassland into wheat field generates a loss of carbon since the latter is harvested annually while the former sequestrates carbon on a pertpetual basis. Here again, emissions' profiles are clearly different under differentiated or uniform annualization approach, see \r\n\r\n >>> cba.carbon_and_co2_flows_traj_annualizer.vg_emitting\r\n True\r\n >>> cba.chart_of_vgco2_unif_flows_traj.show()\r\n >>> np.sum(cba.vgco2_unif_flows_traj)\r\n -7.130970463238133 # tonnes\r\n >>> cba.chart_of_vgco2_diff_flows_traj.show()\r\n ---- a_parameter_which_solves_vgc_chosen_CRF_constrained sol=[0.02458071]\r\n ---- [***]The solution converged.[0.000000e+00][***]\r\n >>> np.sum(cba.vgco2_diff_flows_traj)\r\n -7.130970463238132 # tonnes\r\n\r\n

\r\n\r\nIndependently of how we annualize the LUC-related CO2 emissions, the cultivation and the processing of wheat generate emissions annually as well. See\r\n\r\n >>> cba.chart_of_cult_input_co2eq_flows_traj.show()\r\n >>> cba.chart_of_proc_input_co2eq_flows_traj.show()\r\n\r\n

\r\n\r\nOnce again, the two above charts unambiguously illustrate the time delay that exists between the cultivation of wheat and its processing into bioethanol, *i.e.* wheat cultivated in year *t-1* is used for the production of bioethanol planned in year *t*. Also, note that these cultivation- and processing-related emissions are in *CO2eq* since *CH4* and *N2O* flows are considered as well, using their relative global warming potentials \u2013 relatively to that of CO2 \u2013 as a basis of conversion. See calculation details at [PyGWP](https://github.com/lfaucheux/PyGWP). \r\n\r\nFinally, under the two types of annualization approach, the total emissions following a change in land use from improved grassland into wheat field are:\r\n\r\n >>> cba.chart_of_total_unif_co2_flows_traj.show()\r\n >>> cba.chart_of_total_diff_co2_flows_traj.show()\r\n\r\n

\r\n\r\nwhich, when monetized with a non-zero discount rate and compared in terms of absolute deviations from gasoline's valorized CO2 flows, lead to sensitivly different profiles for the values of the environmental component of the project, see rather\r\n\r\n >>> cba.chart_of_NPV_total_unif_minus_black_output_co2_flows_trajs.show()\r\n >>> cba.chart_of_NPV_total_diff_minus_black_output_co2_flows_trajs.show()\r\n\r\n

\r\n\r\nNote the slope-breaks that occur during the last year. This is due to the fact that cultivation and its associated emission flows generally \u2013 depending on the type of final land use \u2013 finish one year before the end of the project, which structurally increases projects' NPVs.\r\n\r\n### A note on the carbon profitability payback period\r\n\r\nActually, it looks like extending the horizon of the project may be a good idea to see whether one of the two NPVs' profiles \u2013 shown above \u2013 exhibit positive values over the long run. Put differently, let's vizualize *when* the project exhibits positive NPV under each annualization approach.\r\n\r\n\u2022\t*NB1: the project horizon must be long enough for such a payback period to exist. Hence the extension from 20 to 50 years configured below.*\r\n\r\n\u2022\t*NB2: given that cultivation and its associated flows of emission generally \u2013 depending on the type of final land use \u2013 stop before the end of the project, the last year of the project is structurally more environment-friendly, which increases projects' NPVs (see the jump in the charts above), in some cases to such an extent that the last year actually becomes the payback period, hence the NB1*.\r\n\r\n >>> cba._clear_caches() # we clear the cache of our instance since we are going to change a calculation parameter.\r\n GlobalWarmingPotential # the tool enumerates objects whose cache have been cleaned.\r\n OutputFlows\r\n CarbonAndCo2FlowsAnnualizer\r\n LandSurfaceFlows\r\n Co2Prices\r\n CBACalculator\r\n >>> cba.project_horizon = 50 # we set a long project horizon\r\n >>> cba.chart_of_NPV_total_unif_minus_black_output_co2_flows_trajs.show()\r\n >>> cba.chart_of_NPV_total_diff_minus_black_output_co2_flows_trajs.show()\r\n ---- a_parameter_which_solves_soc_chosen_CRF_constrained sol=[0.52418009]\r\n ---- [***]The solution converged.[0.000000e+00][***]\r\n ---- a_parameter_which_solves_vgc_chosen_CRF_constrained sol=[0.02458071]\r\n ---- [***]The solution converged.[0.000000e+00][***]\r\n\r\n

\r\n\r\nRather than vizualizing the NPVs' profiles, we may use a precise way to know *when* a project becomes *environmentally* profitable \u2013 referred to as *Carbon Profitability Payback Period* in [Dupoux (In press)](https://github.com/lfaucheux/PyLUCCBA/raw/master/Dupoux_inpress.pdf) \u2013 for each type of annualization approach.\r\n\r\n >>> cba.unif_payback_period\r\n 41 # years\r\n >>> cba.diff_payback_period\r\n 35 # years\r\n\r\nLet's be precautious and go back to the project's settings of interest for the rest of the example.\r\n\r\n >>> cba._clear_caches()\r\n GlobalWarmingPotential\r\n OutputFlows\r\n CarbonAndCo2FlowsAnnualizer\r\n LandSurfaceFlows\r\n Co2Prices\r\n CBACalculator\r\n >>> cba.project_horizon = 20 # let's go back to our initial settings !\r\n\r\n### A note on the compensatory rate\r\n\r\nWe may wonder under which discount rate the two approaches of annualization \u2013 uniform *versus* differentiated \u2013 would lead to the same NPV over the project horizon. To do so, we have to use another object that is defined in `PyLUCCBA`, namely `CBAParametersEndogenizer`. Let's continue our example and instantiate it:\r\n\r\n >>> gen = cc.CBAParametersEndogenizer(CBACalculator_instance = cba)\r\n\r\nWith `gen` in hand, we can now determine which discount rate equalizes our two NPVs, as follows:\r\n\r\n >>> cba_eq = gen.endo_disc_rate_which_eqs_NPV_total_unif_co2_flows_traj_to_NPV_total_diff_co2_flows_traj\r\n ---- a_parameter_which_solves_soc_chosen_CRF_constrained sol=[0.52418009]\r\n ---- [***]The solution converged.[0.000000e+00][***]\r\n ---- a_parameter_which_solves_vgc_chosen_CRF_constrained sol=[0.02458071]\r\n ---- [***]The solution converged.[0.000000e+00][***]\r\n ---- disc rate equating unif- and diff-based NPVs sol=[0.05420086]\r\n ---- [***]The solution converged.[4.440892e-16][***]\r\n\r\nNote that `cba_eq` is the `disc_rate`-balanced counterpart of `cba`. It reads above that, \"so configured\", our project would have identical NPVs under the uniform and differentiated annualization approaches for a discount rate of 5.42%.\r\n\r\nAt anytime, we can have a quick look at what is meant exactly by \"so configured\", typing\r\n\r\n >>> print(cba_eq.summary_args)\r\n **************************************************************************************\r\n run_name : Example-1\r\n output : ETH\r\n black_output : OIL\r\n initial_landuse : IMPROVED GRASSLAND\r\n final_landuse/input : WHEAT\r\n country : FRANCE\r\n project_horizon : 21 # because of the time delay between cultivation and processing, taken at t0 - 1.\r\n T_so : 20\r\n T_vg_diff : 1\r\n T_vg_unif : 20\r\n project_first_year : 2020\r\n polat_repeated_pattern : True\r\n co2_prices_scenario : SPC2009\r\n discount_rate : [0.05420086] # our endogenized compensatory rate\r\n diff_payback_period : []\r\n unif_payback_period : []\r\n final_currency : EUR\r\n change_rates : {'USD/EUR': 1.14}\r\n output_flows_scenario : O\r\n input_flows_scenario : IFP\r\n message : _ENDOGENIZER finally says sol=0.0542008612895724 \r\n obj(sol)=[4.4408921e-16]\r\n\r\n
\r\n\r\n## Invoking documentation\r\n\r\nYou should abuse of the python-builtin function [`help`](https://www.programiz.com/python-programming/methods/built-in/help) on any object defined in PyLUCCBA, as well as on any instantiated object, *e.g.*\r\n\r\n >>> import PyLUCCBA as cc\r\n >>> help(cc.CBAParametersEndogenizer)\r\n Help on CBAParametersEndogenizer in module PyLUCCBA.core object:\r\n\r\n class CBAParametersEndogenizer(builtins.object)\r\n | Class object designed to handle a CBACalculator instances and to\r\n | endogenize some of its parameter.\r\n | \r\n | Methods defined here:\r\n | \r\n | __init__(self, CBACalculator_instance)\r\n | Initialize self. See help(type(self)) for accurate signature.\r\n | \r\n | ----------------------------------------------------------------------\r\n | Data descriptors defined here:\r\n | \r\n | OBJECTIVE_NPV_total_unif_co2_flows_traj_VS_NPV_total_diff_co2_flows_traj\r\n | Method which computes the objective of the discount rate\r\n | endogenizing process.\r\n | \r\n | Testing/Example\r\n | ---------------\r\n | >>> _dr_ = 0.03847487575799428 ## the solution\r\n | >>> cba = CBACalculator._testing_instancer(\r\n | ... dr = _dr_, \r\n | ... sc = 'WEO2015-CPS',\r\n | ... )\r\n | >>> CBAParametersEndogenizer(\r\n | ... CBACalculator_instance = cba\r\n | ... ).OBJECTIVE_NPV_total_unif_co2_flows_traj_VS_NPV_total_diff_co2_flows_traj\r\n | ---- a_parameter_which_solves_soc_chosen_CRF_constrained sol=[0.52418009]\r\n | ---- [***]The solution converged.[0.000000e+00][***]\r\n | ---- a_parameter_which_solves_vgc_chosen_CRF_constrained sol=[0.02458071]\r\n | ---- [***]The solution converged.[0.000000e+00][***]\r\n | array([2.22044605e-16])\r\n | \r\n | __dict__\r\n | dictionary for instance variables (if defined)\r\n | \r\n | __weakref__\r\n | list of weak references to the object (if defined)\r\n | \r\n | endo_disc_rate_which_eqs_NPV_total_unif_co2_flows_traj_to_NPV_total_diff_co2_flows_traj\r\n | Returns a CBACalculator instance configured with the discount rate\r\n | which equates NPV_total_unif_co2_flows_traj TO NPV_total_diff_co2_flows_traj.\r\n | \r\n | Testing/Example\r\n | ---------------\r\n | >>> cba = CBACalculator._testing_instancer(\r\n | ... sc = 'WEO2015-CPS',\r\n | ... )\r\n | >>> o = CBAParametersEndogenizer(\r\n | ... CBACalculator_instance = cba\r\n | ... )\r\n | >>> o.endo_disc_rate_which_eqs_NPV_total_unif_co2_flows_traj_to_NPV_total_diff_co2_flows_traj.discount_rate[0]\r\n | ---- a_parameter_which_solves_soc_chosen_CRF_constrained sol=[0.52418009]\r\n | ---- [***]The solution converged.[0.000000e+00][***]\r\n | ---- a_parameter_which_solves_vgc_chosen_CRF_constrained sol=[0.02458071]\r\n | ---- [***]The solution converged.[0.000000e+00][***]\r\n | ---- disc rate equating unif- and diff-based NPVs sol=[0.03847488]\r\n | ---- [***]The solution converged.[2.220446e-16][***]\r\n | 0.038474875757994256\r\n\r\n\r\nI invite you to test the function `help` on any of the following objects: `cc.BlackOutputAndSubstitutesSpecificities`, `cc.CBACalculator`, `cc.CBAParametersEndogenizer`, `cc.CarbonAndCo2FlowsAnnualizer`, `cc.Co2Prices`, `cc.GlobalWarmingPotential`, `cc.InputFlows`, `cc.LandSurfaceFlows`, `cc.OutputFlows`, `cc.VGCAndSOCDeltas`, `cc.VegetationsAndSoilSpecificities`.\r\n\r\n\r\n
\r\n\r\n## Data\r\n\r\nData are stored in the [resources](https://github.com/lfaucheux/PyLUCCBA/tree/master/PyLUCCBA/resources) folder, composed of the following subfolders:\r\n\r\n\u2022\tThe [__meta__](https://github.com/lfaucheux/PyLUCCBA/tree/master/PyLUCCBA/resources/__meta__) folder, which includes [BioGrace Excel tool - version 4c.xls](https://github.com/lfaucheux/PyLUCCBA/raw/master/PyLUCCBA/resources/__meta__/BioGrace%20Excel%20tool%20-%20version%204c.xls) and [Data_CarbonStocks_Emissions.xlsx](https://github.com/lfaucheux/PyLUCCBA/raw/master/PyLUCCBA/resources/__meta__/Data_CarbonStocks_Emissions.xlsx), in which you can see all the calculations of carbon stocks for each type of land use.\r\n\r\n\u2022\tThe [dluc](https://github.com/lfaucheux/PyLUCCBA/tree/master/PyLUCCBA/resources/dluc) folder, which includes three datafiles, namely *(i) [cs_changes_fr.csv](https://raw.githubusercontent.com/lfaucheux/PyLUCCBA/master/PyLUCCBA/resources/dluc/cs_changes_fr.csv)* relating to the carbon stock associated with specific types of land use, *(ii) [so_ghgs_shares_fr.csv](https://raw.githubusercontent.com/lfaucheux/PyLUCCBA/master/PyLUCCBA/resources/dluc/so_ghgs_shares_fr.csv)* relating to the share of soil carbon that translate to actual emissions/sequestrations and *(iii) [vg_ghgs_shares_fr.csv](https://raw.githubusercontent.com/lfaucheux/PyLUCCBA/master/PyLUCCBA/resources/dluc/vg_ghgs_shares_fr.csv)* relating to the share of vegetation carbon that translate to actual emissions/sequestrations. Each of these csv files possesses a txt counterpart with the same name, which provides mandatory information regarding, e.g., the unit of measurement of data.\r\n\r\n\u2022\tThe [externality](https://github.com/lfaucheux/PyLUCCBA/tree/master/PyLUCCBA/resources/externality) folder, which includes three datafiles, namely *(i) [co2_prices_fr.csv](https://raw.githubusercontent.com/lfaucheux/PyLUCCBA/master/PyLUCCBA/resources/externality/co2_prices_fr.csv)* relating to the CO2 price-trajectory scenarios, *(ii) [cult_ghgs_fr.csv](https://raw.githubusercontent.com/lfaucheux/PyLUCCBA/master/PyLUCCBA/resources/externality/cult_ghgs_fr.csv)* relating to the quantity of GHG emissions associated with the cultivation of land and *(iii) [proc_ghgs_fr.csv](https://raw.githubusercontent.com/lfaucheux/PyLUCCBA/master/PyLUCCBA/resources/externality/proc_ghgs_fr.csv)* relating to the processing of energy crop to biofuel. Each of these csv files possesses a txt counterpart that has the same name, which provides mandatory information regarding, e.g., the unit of measurement of data.\r\n\r\n\u2022\tThe [input](https://github.com/lfaucheux/PyLUCCBA/tree/master/PyLUCCBA/resources/input) folder, which includes four datafiles, namely *(i) [haeth_yields_fr.csv](https://raw.githubusercontent.com/lfaucheux/PyLUCCBA/master/PyLUCCBA/resources/input/haeth_yields_fr.csv)* relating to the number of tonnes of ethanol per hectare over time and *(ii) [miscanthus_yields_fr.csv](https://raw.githubusercontent.com/lfaucheux/PyLUCCBA/master/PyLUCCBA/resources/input/miscanthus_yields_fr.csv)*, *[sugarbeet_yields_fr.csv](https://raw.githubusercontent.com/lfaucheux/PyLUCCBA/master/PyLUCCBA/resources/input/sugarbeet_yields_fr.csv)* and *[wheat_yields_fr.csv](https://raw.githubusercontent.com/lfaucheux/PyLUCCBA/master/PyLUCCBA/resources/input/wheat_yields_fr.csv)* relating to the number of tonnes of feedstock necessary to produce one tonne of biofuel. As before, almost each of these csv files has a txt counterpart that provides mandatory information on data. In the case of datafiles with no txt counterpart, the tool searches for information in a txt file with the same name as the parent folder's, i.e. *input.txt* in this case.\r\n\r\n\u2022\tThe [output](https://github.com/lfaucheux/PyLUCCBA/tree/master/PyLUCCBA/resources/output) folder, which includes three datafiles, namely *(i) [eth_yields_fr.csv](https://raw.githubusercontent.com/lfaucheux/PyLUCCBA/master/PyLUCCBA/resources/output/eth_yields_fr.csv)* that tautologically states that one tonne of biofuel is produced per tonne of output, *(ii) [cult_to_proc_delays_fr.csv](https://raw.githubusercontent.com/lfaucheux/PyLUCCBA/master/PyLUCCBA/resources/output/cult_to_proc_delays_fr.csv)* relating to the time delay required between cultivation and processing of feedstock and *(iii) [subs_intensities_fr.csv](https://raw.githubusercontent.com/lfaucheux/PyLUCCBA/master/PyLUCCBA/resources/output/subs_intensities_fr.csv)* relating to the amount of energy and emissions associated with bioethanol and oil. Once again, each of these csv files has a txt counterpart that provides mandatory information on data. \r\n\r\n*NB1*: all files with a name containing either *\"_yields\"* or *\"_prices\"* consist of temporal trajectories. These trajectories can be sparse. Indeed, when sparse trajectories with more than one point are provided, say, CO2 prices such as in the scenario *WEO2015-CPS* \u2013 see [co2_prices_fr.csv](https://github.com/lfaucheux/PyLUCCBA/blob/master/PyLUCCBA/resources/externality/co2_prices_fr.csv) \u2013, the tool automatically retro/inter/extrapolates the values for each year in an exponential way. When both retro- and extrapolation are possible, retropolation is chosen by using the next period's rate of growth. Then, if the parameter `polat_repeated_pattern` is set to `True`, extrapolation is performed by repeating the entire anterior pattern of growth rates from the last known value. If the parameter is set to `False`, the last known value is kept constant over the project horizon. In the case of sparse trajectories that contain only one value \u2013 see *e.g.* [wheat_yields_fr.csv](https://github.com/lfaucheux/PyLUCCBA/blob/master/PyLUCCBA/resources/input/wheat_yields_fr.csv) \u2013, the trajectory is assumed to be flat over the project horizon.\r\n\r\n*NB2*: all files with a name containing either *\"_yields\"* or *\"_prices\"* must possess a txt file counterpart providing information on their unit of measurement. Indeed, they are read and interpreted with the intention of ensuring the dimensional homogenity of calculations. For example, if, say, *tonne/ha* is required for calculation and that the unit of measurement is *ha/tonne*, the numerical inverse is computed prior to core-calculations.\r\n\r\n\r\n
\r\n\r\n## Data customization/addition\r\n\r\nYou may want to add your own scenarii regarding, e.g., how the price of CO2 evolves over time, the trajectory of output flows produced annually, the quantity of input that is required to produce 1 tonne of output, etc...\r\nThe easiest way of working with custom data is to imitate the package-native data contained in the [*resources*](https://github.com/lfaucheux/PyLUCCBA/tree/master/PyLUCCBA/resources) folder. Let's start with a local copy of this folder:\r\n\r\n >>> import PyLUCCBA as cc\r\n >>> cc.folder_copier(name='resources')\r\n 'resources' folder copied to C:\\path\\to\\folder\r\n\r\nNow, to explore the data, go to `C:\\path\\to\\folder`, where you will see a folder named *resources* that is the exact copy of the data used in [Dupoux (In press)](https://github.com/lfaucheux/PyLUCCBA/raw/master/Dupoux_inpress.pdf).\r\n\r\n#### Adding new data\r\n\r\nTo add new data, e.g. a scenario of CO2 prices, go to the folder *resources\\externality* of your local copy. There, you will find two files, namely [co2_prices_fr.csv](https://raw.githubusercontent.com/lfaucheux/PyLUCCBA/master/PyLUCCBA/resources/externality/co2_prices_fr.csv) and [co2_prices_fr.txt](https://raw.githubusercontent.com/lfaucheux/PyLUCCBA/master/PyLUCCBA/resources/externality/co2_prices_fr.txt). First, open the csv file, add a scenario's name [in the first line](https://github.com/lfaucheux/PyLUCCBA/blob/master/PyLUCCBA/resources/externality/co2_prices_fr.csv#L1), *e.g.* `customPricesScenario`, and prices in the just-named column. Remember that your newly-added trajectory can be sparse and that the tool will retro/intra/extrapolate missing prices. Second, open the txt file and add two lines related to `customPricesScenario`, as shown below:\r\n\r\n customPricesScenario:unit:EUR/tonne\r\n customPricesScenario:yrb:none\r\n\r\nThe first line specifies the currency in which prices are expressed. Note that the tool is actually not capable of dealing with other mass-units than `tonne`, so stick to it. The second line is not mandatory. It only allows you to simplify the potential future improvements of the tool. Finally, to imply the just-added trajectory of prices in your calculations, simply instantiate `CBACalculator` with `'customPricesScenario'`, *i.e.*\r\n\r\n >>> cba = cc.CBACalculator(\r\n # ...\r\n co2_prices_scenario = 'customPricesScenario', # not case sensitive\r\n from_local_data = True, # [!!!]\r\n # ...\r\n )\r\n\r\nNote that to add a new trajectory of annual output flows or one of yields, the approach is exactly the same as that described for CO2 prices. Simply enrich/modify your local copy.\r\n\r\n
\r\n\r\n## Format of results\r\n\r\n The generated results consist of three .xlsx files, namely [\\_quantities.xlsx](https://github.com/lfaucheux/PyLUCCBA/raw/master/PyLUCCBA/examples/Example-1/_quantities.xlsx), [\\_values.xlsx](https://github.com/lfaucheux/PyLUCCBA/raw/master/PyLUCCBA/examples/Example-1/_values.xlsx) and [\\_NPVs.xlsx](https://github.com/lfaucheux/PyLUCCBA/raw/master/PyLUCCBA/examples/Example-1/_NPVs.xlsx) all three located in a folder that is named (by default) according to the arguments involved in the computation:\r\n\r\n\u2022\t[\\_quantities.xlsx](https://github.com/lfaucheux/PyLUCCBA/raw/master/PyLUCCBA/examples/Example-1/_quantities.xlsx) displays the quantities associated to each flow, among which, emissions from the process of production, emissions from the cultivation of the feedstock, land use change impact from soil, land use change impact from biomass, etc.\r\n\r\n\u2022\t[\\_values.xlsx](https://github.com/lfaucheux/PyLUCCBA/raw/master/PyLUCCBA/examples/Example-1/_values.xlsx) displays the monetary value of the different types of flows from both bioethanol and gasoline (\u201cblack\u201d) depending of the carbon price scenario that is chosen.\r\n\r\n\u2022\t[\\_NPVs.xlsx](https://github.com/lfaucheux/PyLUCCBA/raw/master/PyLUCCBA/examples/Example-1/_NPVs.xlsx) displays the net present values for both the uniform and the differentiated annualizations for the different types of flow again.\r\n\r\nNote that each column has a title that is very verbose \u2013 so as to make things as explicit as possible \u2013 regarding what is calculated. When the prefix **ut_** appears in the title it means that it is calculated for one unit tonne of biofuel. When the prefix **um_** appears in the title, it means that it is calculated for one unit megajoule of biofuel. When nothing is specified, it takes into account the total quantity of biofuel produced.\r\n\r\n
\r\n\r\n## Paper's results replication\r\n\r\nAll the results presented in [Dupoux (In press)](https://github.com/lfaucheux/PyLUCCBA/raw/master/Dupoux_inpress.pdf) can easily be reproduced. To replicate a specific result, one has to `import` the associated script. Its importation will run the code that is required to generate the results. The table that follows makes the association between the python `import`-commands and the cases presented in the paper.\r\n\r\n Paper's section and page | Python command | Invoked script\r\n ------------------------ | ------------------------------------------------------------------ | -------------------\r\n Subsection 3.2 page 12 | `from PyLUCCBA.examples import study_Grassland_DiscountingEffect` | [*study_Grassland_DiscountingEffect.py*](https://raw.githubusercontent.com/lfaucheux/PyLUCCBA/master/PyLUCCBA/examples/study_Grassland_DiscountingEffect.py)\r\n Subsection 3.2 page 13 | `from PyLUCCBA.examples import study_Grassland_CarbonPriceEffect` | [*study_Grassland_CarbonPriceEffect.py*](https://raw.githubusercontent.com/lfaucheux/PyLUCCBA/master/PyLUCCBA/examples/study_Grassland_CarbonPriceEffect.py)\r\n Subsection 3.2 page 14 | `from PyLUCCBA.examples import study_Grassland_CombinedEffect` | [*study_Grassland_CombinedEffect.py*](https://raw.githubusercontent.com/lfaucheux/PyLUCCBA/master/PyLUCCBA/examples/study_Grassland_CombinedEffect.py)\r\n Subsection 4.1 page 14 | `from PyLUCCBA.examples import study_Grassland_CompensatoryRate` | [*study_Grassland_CompensatoryRate.py*](https://raw.githubusercontent.com/lfaucheux/PyLUCCBA/master/PyLUCCBA/examples/study_Grassland_CompensatoryRate.py)\r\n Subsection 4.2 page 15 | `from PyLUCCBA.examples import study_Grassland_PaybackPeriod` | [*study_Grassland_PaybackPeriod.py*](https://raw.githubusercontent.com/lfaucheux/PyLUCCBA/master/PyLUCCBA/examples/study_Grassland_PaybackPeriod.py)\r\n\r\n\r\nIn case you want to modify those scripts instead of simply invoking them, you can first copy them to your working directory, typing\r\n\r\n >>> import PyLUCCBA as cc\r\n >>> cc.folder_copier(name='examples')\r\n 'examples' folder copied to C:\\path\\to\\folder\r\n\r\nSecond, go to `C:\\path\\to\\folder`, where you will see a folder named `examples` that contains the exact copies of the scripts enumerated in the above table. To edit one of those scripts, say, [*study_Grassland_CompensatoryRate.py*](https://raw.githubusercontent.com/lfaucheux/PyLUCCBA/master/PyLUCCBA/examples/study_Grassland_CompensatoryRate.py), right-click it and select option *Edit with [IDLE](http://anh.cs.luc.edu/python/hands-on/3.1/handsonHtml/idle.html#windows-in-idle)*. Modify anything you want. To execute the script, type **F5**.\r\n\r\n
\r\n\r\n## References\r\n\r\nHoefnagels, R., E. Smeets, and A. Faaij (2010). \u201c[Greenhouse gas footprints of different biofuel production systems](https://www.sciencedirect.com/science/article/pii/S1364032110000535)\u201d. _Renewable and Sustainable Energy Reviews_ 14.7, pp. 1661\u20131694.\r\n\r\nIEA (2015). _World Energy Outlook 2015_. Tech. rep. International Energy Agency.\r\n\r\nIPCC (2006). \u201cVolume 4: Agriculture, Forestry and Other Land Use\u201d. _IPCC guidelines for national greenhouse gas inventories 4_.\r\n\r\nPoeplau, C., A. Don, L. Vesterdal, J. Leifeld, B. VanWesemael, J. Schumacher, and A. Gensior (2011). \u201c[Temporal dynamics of soil organic carbon after land-use change in the temperate zone - carbon response functions as a model approach](https://www.researchgate.net/publication/242081920_Temporal_dynamics_of_soil_organic_carbon_after_land-use_change_in_the_temperate_zone-Carbon_response_functions_as_a_model_approach)\u201d. _Global Change Biology_ 17.7, pp. 2415\u20132427.\r\n\r\nThe European Commission (2010). \u201c[Commission decision of 10 June 2010 on guidelines for the calculation of land carbon stocks for the purpose of Annex V to Directive 2009/28/EC](https://www.emissions-euets.com/component/content/article/261-commission-decision-of-10-june-2010-on-guidelines-for-the-calculation-of-land-carbon-stocks-for-the-purpose-of-annex-v-to-directive-200928ec)\u201d. _Official Journal of The European Union_ 2010/335/E.\r\n\r\nDupoux, M. \u201c[The land use change time-accounting failure](https://github.com/lfaucheux/PyLUCCBA/raw/master/Dupoux_inpress.pdf)\u201d (in press).\r\n\r\n\r\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "https://github.com/lfaucheux/PyLUCCBA/archive/0.9.23.tar.gz", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/lfaucheux/PyLUCCBA", "keywords": "land use change,cost benefit analysis,environmental economics", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "PyLUCCBA", "package_url": "https://pypi.org/project/PyLUCCBA/", "platform": "", "project_url": "https://pypi.org/project/PyLUCCBA/", "project_urls": { "Download": "https://github.com/lfaucheux/PyLUCCBA/archive/0.9.23.tar.gz", "Homepage": "https://github.com/lfaucheux/PyLUCCBA" }, "release_url": "https://pypi.org/project/PyLUCCBA/0.9.23/", "requires_dist": [ "numpy (>=1.14.0)", "scipy (>=1.0.0)", "openpyxl (>=2.5.5)", "matplotlib (>=1.4.3)" ], "requires_python": "", "summary": "A Land-Use-Change Cost-Benefit-Analysis calculator coded in Python27&3, PyLUCCBA.", "version": "0.9.23" }, "last_serial": 5022523, "releases": { "0.1.33": [ { "comment_text": "", "digests": { "md5": "53381ad523f69823fc2c898e39624cfb", "sha256": "1aedb2fbb63ccf6c122fefa739cf1a0dac06b9e3b299e30e4ee99ae91e419207" }, "downloads": -1, "filename": "PyLUCCBA-0.1.33.tar.gz", "has_sig": false, "md5_digest": "53381ad523f69823fc2c898e39624cfb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6369949, "upload_time": "2018-09-02T15:39:35", "url": "https://files.pythonhosted.org/packages/fa/64/277fcb40b7ce77bafb724db0925eff26609944f1278fd8a421ea12854b79/PyLUCCBA-0.1.33.tar.gz" } ], "0.1.38": [ { "comment_text": "", "digests": { "md5": "58e7874fe5af43b33fe9b8b5e3f19b11", "sha256": "e825da6c1270c3bf4c9517ad750e0644db9a41caa689406869e34e7d61098e5a" }, "downloads": -1, "filename": "PyLUCCBA-0.1.38.tar.gz", "has_sig": false, "md5_digest": "58e7874fe5af43b33fe9b8b5e3f19b11", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8887881, "upload_time": "2018-09-04T15:41:57", "url": "https://files.pythonhosted.org/packages/8b/cb/aed8352245e838fff159f7b86bcb0c672a40aa0080483991f00153df6377/PyLUCCBA-0.1.38.tar.gz" } ], "0.9.0": [ { "comment_text": "", "digests": { "md5": "d2796b387772aef48209ce483b5d15d2", "sha256": "24192dabc303bf5e0d1b68dd3e7f7187bde2a76d6a1358dd367feae637203f52" }, "downloads": -1, "filename": "PyLUCCBA-0.9.0.tar.gz", "has_sig": false, "md5_digest": "d2796b387772aef48209ce483b5d15d2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8528760, "upload_time": "2019-03-19T16:46:10", "url": "https://files.pythonhosted.org/packages/51/af/4db03165ddd5cee4c418ce7a2db30f2219d94fe556e53f71e5820b74e818/PyLUCCBA-0.9.0.tar.gz" } ], "0.9.13": [ { "comment_text": "", "digests": { "md5": "f8fcecc283e321c72c860d96a2936029", "sha256": "391d94d164ca2460b4935b31f7d41e5c3c5fb8603ec5277f516a1fb8e91f48df" }, "downloads": -1, "filename": "PyLUCCBA-0.9.13-py2-none-any.whl", "has_sig": false, "md5_digest": "f8fcecc283e321c72c860d96a2936029", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 8771680, "upload_time": "2019-03-24T10:54:59", "url": "https://files.pythonhosted.org/packages/8d/40/dc0d49bfb7ca742f69a13cabe3cfee43ef9d6f923d9fd822afd9fd57cdc2/PyLUCCBA-0.9.13-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "baebf59bd4e54d00e7ee88d4538fef38", "sha256": "f22cd5b8a1ddb749274463b9a200efbaf98d5d9721f10de8abff71d7bec98b5f" }, "downloads": -1, "filename": "PyLUCCBA-0.9.13.tar.gz", "has_sig": false, "md5_digest": "baebf59bd4e54d00e7ee88d4538fef38", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8531478, "upload_time": "2019-03-24T10:55:08", "url": "https://files.pythonhosted.org/packages/ea/e0/5cfc5f1ee6ad38b6545f9d1f9af7cf2a27054f9032624cf58a2483179913/PyLUCCBA-0.9.13.tar.gz" } ], "0.9.23": [ { "comment_text": "", "digests": { "md5": "c6446c1d6a8c6676eb5693eda9b0506c", "sha256": "3acb9a1497e95ec647d5d1db4b451bf91cd719481fa72d700a6c13d4e26e07c9" }, "downloads": -1, "filename": "PyLUCCBA-0.9.23-py2-none-any.whl", "has_sig": false, "md5_digest": "c6446c1d6a8c6676eb5693eda9b0506c", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 8776161, "upload_time": "2019-04-01T14:36:50", "url": "https://files.pythonhosted.org/packages/ce/1a/f290215487ab5ef9e79a021f80a7eec3bb002c53a2e3474ca5f682d5c2de/PyLUCCBA-0.9.23-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9953d0436eb4e9875757065b6de27579", "sha256": "5301cde4cc01e4bfaac6db4f8d99d4b159aab29ae65266a19b8a8b9d83452245" }, "downloads": -1, "filename": "PyLUCCBA-0.9.23.tar.gz", "has_sig": false, "md5_digest": "9953d0436eb4e9875757065b6de27579", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8532560, "upload_time": "2019-04-01T14:37:47", "url": "https://files.pythonhosted.org/packages/4f/e6/7946249e9eddb869f50be09413e331d7317b34929a3afd24744896c85373/PyLUCCBA-0.9.23.tar.gz" } ], "0.9.3": [ { "comment_text": "", "digests": { "md5": "ecdbdd8cbeed297b0debc36375d6b009", "sha256": "62cfa755d14767db482a551a228f1b48cc5eaa57f76c5a4e28178bd980c03370" }, "downloads": -1, "filename": "PyLUCCBA-0.9.3.tar.gz", "has_sig": false, "md5_digest": "ecdbdd8cbeed297b0debc36375d6b009", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8531165, "upload_time": "2019-03-20T11:09:32", "url": "https://files.pythonhosted.org/packages/7e/b7/7ebd1d53575eb8256f30154c52b6b24cb8c929308646fff30a145cde00a0/PyLUCCBA-0.9.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c6446c1d6a8c6676eb5693eda9b0506c", "sha256": "3acb9a1497e95ec647d5d1db4b451bf91cd719481fa72d700a6c13d4e26e07c9" }, "downloads": -1, "filename": "PyLUCCBA-0.9.23-py2-none-any.whl", "has_sig": false, "md5_digest": "c6446c1d6a8c6676eb5693eda9b0506c", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 8776161, "upload_time": "2019-04-01T14:36:50", "url": "https://files.pythonhosted.org/packages/ce/1a/f290215487ab5ef9e79a021f80a7eec3bb002c53a2e3474ca5f682d5c2de/PyLUCCBA-0.9.23-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9953d0436eb4e9875757065b6de27579", "sha256": "5301cde4cc01e4bfaac6db4f8d99d4b159aab29ae65266a19b8a8b9d83452245" }, "downloads": -1, "filename": "PyLUCCBA-0.9.23.tar.gz", "has_sig": false, "md5_digest": "9953d0436eb4e9875757065b6de27579", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8532560, "upload_time": "2019-04-01T14:37:47", "url": "https://files.pythonhosted.org/packages/4f/e6/7946249e9eddb869f50be09413e331d7317b34929a3afd24744896c85373/PyLUCCBA-0.9.23.tar.gz" } ] }