Giter Site home page Giter Site logo

natenjuguna / otm-ecoservice Goto Github PK

View Code? Open in Web Editor NEW

This project forked from opentreemap/otm-ecoservice

0.0 0.0 0.0 835 KB

REST services providing eco benefit calculations for OpenTreeMap

Home Page: http://www.opentreemap.org

License: Other

Shell 0.12% Python 9.79% Go 88.78% Makefile 1.30%

otm-ecoservice's Introduction

ecoservice Build Status

REST services for calculating eco benefits for trees in an OpenTreeMap database.

Getting Started

In order make the process of developing against or building this project easier, we've wrapped everything inside of a Vagrant project. In addition to Vagrant, Ansible is used to provision the Vagrant virtual machine. This ensures that all of the dependencies are in place.

First, ensure that Vagrant 1.5+ and Ansible 1.4.2+ are installed on your local workstation.

Next, start the Vagrant virtual machine:

$ vagrant up

You will see some Ansible output after the machine boots up. After that, SSH into the machine and execute the test suite:

$ vagrant ssh
vagrant@otm-ecoservice:~$ cd src/github.com/OpenTreeMap/otm-ecoservice/
vagrant@otm-ecoservice:~/src/github.com/OpenTreeMap/otm-ecoservice$ make test
godep go test eco/*
ok      command-line-arguments  0.494s

If you want to build a release, use the release target:

vagrant@otm-ecoservice:~/src/github.com/OpenTreeMap/otm-ecoservice$ make release
vagrant@otm-ecoservice:~/src/github.com/OpenTreeMap/otm-ecoservice$ exit
$ ls -l *.tar.gz
-rw-r--r--  1 hcastro  staff  2714304 Sep  9 15:41 ecoservice.tar.gz

Running the ecoservice

The ecobenefits executable must be run with certain environment variables set:

OTM_DB_USER = 'otm'
OTM_DB_PASSWORD = 'otm'
OTM_DB_NAME = 'otm'
OTM_DB_HOST = 'localhost'
OTM_ECO_DATA_DIR = Absolute path to the data directory (with a trailing slash)
OTM_SERVER_PORT = '13000'

Once environment variables have been set, the ecobenefits service can be launched with:

$ /path/to/ecobenefits

Example Calculation

20 inch Common Fig

Identify the OTM2/USDA code for the given species: FICA

Determine the region the tree is in. For our example we'll use Inland Empire (InlEmpCLM).

Determine the itree code using the master species list and the selected region. BDS OTHER

Calculations then are determined by linear interpolation from the root resource sheets.

For the electricity case we use this csv: https://github.com/OpenTreeMap/otm-ecoservice/blob/master/data/output__InlEmpCLM__electricity.csv

The diameter ranges are in centimeters so we convert 20 in into 50.8 cm. Using those data we find the following range:

            38.10   53.34
BDS OTHER  189.2   189.2

In this case we're interpolating over a horizontal line so we get 189.2 kwh.

Doing the same for natural gas: https://github.com/OpenTreeMap/otm-ecoservice/blob/master/data/output__InlEmpCLM__natural_gas.csv

            38.10   53.34
BDS OTHER  -81.4   -81.4

So the natural gas savings is computed to be -81.4 kbtus. That ends up as -0.814 therms or -23.86 kwh

Continuing with stormwater: https://github.com/OpenTreeMap/otm-ecoservice/blob/master/data/output__InlEmpCLM__hydro_interception.csv

            38.10   53.34
BDS OTHER    3.16    3.16

So we get 3.16 m^3 of water, which converts to 842 gal

Carbon calculations can be performed in the same manner. For storage: https://github.com/OpenTreeMap/otm-ecoservice/blob/master/data/output__InlEmpCLM__co2_storage.csv

            38.10   53.34
BDS OTHER  569.6   569.6

569.6 kgs of CO2 stored converts to 1315 lbs.

CO2 avoided: https://github.com/OpenTreeMap/otm-ecoservice/blob/master/data/output__InlEmpCLM__co2_avoided.csv

            38.10   53.34
BDS OTHER   55.7    55.7

55.7 kgs of CO2 avoided converts to 122.8 lbs

CO2 sequestered: https://github.com/OpenTreeMap/otm-ecoservice/blob/master/data/output__InlEmpCLM__co2_sequestered.csv

            38.10   53.34
BDS OTHER   24.6     0.0

Here we have to actually calculate:

m = dx/dy = -24.6 / 15.24 = -1.614
y0 = y - mx = 0.0 - 53.34 * -1.614 = 86.1
y = mx + b = -1.614 * 50.8 + 86.1 = 4.1 kgs = 9.06 lbs

We can test this particular case by running an eco benefits server and using the curl utility:

$ curl "localhost:13000/eco.json?otmcode=FICA&diameter=20&region=InlEmpCLM"

{
  "Benefits": {
    "aq_nox_avoided": 0.1102,
    "aq_nox_dep": 0.119,
    "aq_ozone_dep": 0.35,
    "aq_pm10_avoided": 0.0273,
    "aq_pm10_dep": 0.185,
    "aq_sox_avoided": 0.2183,
    "aq_sox_dep": 0.016,
    "aq_voc_avoided": 0.0273,
    "bvoc": 0,
    "co2_avoided": 55.7,
    "co2_sequestered": 4.1000000000000085,
    "co2_storage": 569.6,
    "electricity": 189.2,
    "hydro_interception": 3.16,
    "natural_gas": -81.4
  }
}

Terminology

Factors

What i-Tree calls 'benefit categories', we refer to as 'factors' in our source. These are distinct ways in which environmental influence can be quantified for trees. Examples include 'CO2 avoided' and 'electricity (saved)'.

otm-ecoservice's People

Contributors

jwalgran avatar ahinz avatar rickmohr avatar maurizi avatar hectcastro avatar robinisthebird avatar kdeloach avatar george-mcintyre avatar rmiessle avatar dboyer avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.