Skip to content

Instantly share code, notes, and snippets.

Created June 18, 2015 17:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/7ec291a0dece212110f1 to your computer and use it in GitHub Desktop.
Save anonymous/7ec291a0dece212110f1 to your computer and use it in GitHub Desktop.
{"nbformat_minor": 0, "cells": [{"execution_count": 1, "cell_type": "code", "source": "#import the modules you need\nimport numpy as np\nfrom IPython.display import Image\nprint \"Let's run some numbers on palm oil!\"", "outputs": [{"output_type": "stream", "name": "stdout", "text": "Let's run some numbers on palm oil!\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"execution_count": 2, "cell_type": "code", "source": "Image(url = 'https://upload.wikimedia.org/wikipedia/commons/8/8d/Oilpalm_malaysia.jpg', width=227, height=170)", "outputs": [{"execution_count": 2, "output_type": "execute_result", "data": {"text/plain": "<IPython.core.display.Image object>", "text/html": "<img src=\"https://upload.wikimedia.org/wikipedia/commons/8/8d/Oilpalm_malaysia.jpg\" width=\"227\" height=\"170\"/>"}, "metadata": {}}], "metadata": {"collapsed": false, "trusted": true}}, {"execution_count": 3, "cell_type": "code", "source": "willing = .15; # percent increase you're willing to pay\nprice = 7.995; # price for 1 L palm oil on amazon.com\nnL = 0.473176 # how many liters you buy (16 fluid oz = 0.473176 L)", "outputs": [], "metadata": {"collapsed": true, "trusted": true}}, {"execution_count": 4, "cell_type": "code", "source": "# Unit conversions\ntph = 3.5 # tonnes oil per hectare. source: WWF%20Profitability%20and%20Sustainability%20in%20Palm%20Oil%20Production%202012.pdf\nkgpt = 1000 # kg per tonne \nhapm2 = 10000 # 1 hectare = 100000 square meters\nrhop = 890 # density of palm oil, kg/m^3 source:http://www.chempro.in/palmoilproperties.htm\nm3ph = tph*kgpt/rhop # m^3 per hectare\nLph = m3ph/.001 # L per ha (1 L = .001 m^3)\ninpm = 39.3701 # meters per inch\n\n# Numbers from PNAS paper\nAt = 32000. # total hectacres\nAc = 5000. # conserved hectares\nngibbon = 1337. # gibbons in conserved area\nnpangolin = 31. # pangolins ''\nnlmacaque = 1457 # macaques ''\n\n# computations\nLt = Lph*(At-Ac); # total liters per plantation\n\nmyfrac = nL/Lt; # fraction of liters produced you buy\nmyland = myfrac*Ac; # fraction of land you contribute\nm = myland*hapm2\n", "outputs": [], "metadata": {"collapsed": false, "trusted": true}}, {"execution_count": 5, "cell_type": "code", "source": "s = \"/ /\"\nprint \"Estimated prodcution is %.1f liters palm oil per hectare per year\"%Lph\nprint \"Plantation with %d acres, of which %d conserved, produces %.1f liters\\n\"%(At,Ac, Lt)\n\nprint \"My price increase of %.0f%% on %.2f liters at $%.2f per liter is %.2f\" %(willing*100,nL, price, price*willing)\nprint \"My extra $%.2f contributes to %.6f acres conserved\"%(price*willing, myland)\n\nprint \"That's %f square meteres: e.g. %f in by %f in\\n\" %(m, np.sqrt(m)*inpm, np.sqrt(m)*inpm)\n\nprint \"On average, this sqaure is home to: \\n\" \nprint \"<-------------- %.0f in -------------->\"%(np.sqrt(m)*inpm)\n#print \"-----------------------------------\"\nprint \"//////////////////////////////////// ^\"\ns = \"/ / |\"\nfor i in range(3): print s\nprint \"/ %.7f gibbons / |\"%((myfrac*ngibbon))\nprint \"/ %.7f pangolins / %.0f in \"%((myfrac*npangolin), np.sqrt(m)*inpm)\nprint \"/ %.7f long-tailed macaques / |\"%((myfrac*nlmacaque))\nfor i in range(3): print s\nprint \"//////////////////////////////////// v\"\nprint \"Here's what a pangolin looks like:\"", "outputs": [{"output_type": "stream", "name": "stdout", "text": "Estimated prodcution is 3932.6 liters palm oil per hectare per year\nPlantation with 32000 acres, of which 5000 conserved, produces 106179775.3 liters\n\nMy price increase of 15% on 0.47 liters at $8.00 per liter is 1.20\nMy extra $1.20 contributes to 0.000022 acres conserved\nThat's 0.222818 square meteres: e.g. 18.584119 in by 18.584119 in\n\nOn average, this sqaure is home to: \n\n<-------------- 19 in -------------->\n//////////////////////////////////// ^\n/ / |\n/ / |\n/ / |\n/ 0.0000060 gibbons / |\n/ 0.0000001 pangolins / 19 in \n/ 0.0000065 long-tailed macaques / |\n/ / |\n/ / |\n/ / |\n//////////////////////////////////// v\nHere's what a pangolin looks like:\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"execution_count": 6, "cell_type": "code", "source": "from IPython.display import Image\nImage(url = 'https://upload.wikimedia.org/wikipedia/commons/f/fe/Tree_Pangolin.JPG', width=400, height=300)", "outputs": [{"execution_count": 6, "output_type": "execute_result", "data": {"text/plain": "<IPython.core.display.Image object>", "text/html": "<img src=\"https://upload.wikimedia.org/wikipedia/commons/f/fe/Tree_Pangolin.JPG\" width=\"400\" height=\"300\"/>"}, "metadata": {}}], "metadata": {"collapsed": false, "trusted": true}}], "nbformat": 4, "metadata": {"kernelspec": {"display_name": "Python 2", "name": "python2", "language": "python"}, "language_info": {"mimetype": "text/x-python", "nbconvert_exporter": "python", "version": "2.7.9", "name": "python", "file_extension": ".py", "pygments_lexer": "ipython2", "codemirror_mode": {"version": 2, "name": "ipython"}}}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment