/ECHO-by-Zip-Code

A Jupyter Notebook-based exploration of emissions permits, compliance, and enforcement designed for localization by zip code

Primary LanguageJupyter NotebookGNU General Public License v3.0GPL-3.0

ECHO by Zip Code

A Jupyter Notebook-based exploration of emissions permits, compliance, and enforcement designed for localization by zip code

Code of Conduct


Demo

Below are a few screen shots from a sample report:

Screen Shot 2020-02-07 at 9 48 07 AM Screen Shot 2020-02-07 at 9 48 21 AM Screen Shot 2020-02-07 at 9 48 29 AM Screen Shot 2020-02-07 at 9 48 36 AM Screen Shot 2020-02-07 at 9 48 45 AM


Running the notebook locally

Quickstart

You need:

  • Python
  • Jupyter Notebook
  • ECHO exporter data, unzipped and added to the data folder (should be a .csv and a .xlsx)
  • Python libraries as shown in the notebook

Run jupyter notebook in the project repo to start the notebook.

Setup for beginners

Getting set up with the programming tools

In this section, we will install the programming language Python, and use its package manager "pip" to install Jupyter Notebook.

  • If you've never used the command line/terminal before, you might find it helpful to try this one-page tutorial
  • Install Python on your computer: Python download page
  • Python should come with its package manager pip pre-installed. Type pip into the command line and press enter just to check. Screen Shot 2020-02-06 at 3 38 15 PM If it gives you an error message, you may need to debug. Here are some options:
    • Quit and re-open your terminal; try again
    • Restart your computer; try again
    • Run sudo easy_install pip in the command line; try again
    • Copy and paste your error message into a search engine and see what else you can try
  • Use pip to install Jupyter Notebook: run pip install notebook

Hopefully, you should now be able to run jupyter notebook in the command line. If it's working, it will open your browser and show you all the files in your current directory.

Screen Shot 2020-02-06 at 3 39 26 PM

Getting this repo onto your computer

You will need to install git, which is a version control system that's designed for multiple people to be able to work with the same repo: Git download page. You can test whether it worked by running the command git in the command line.

Screen Shot 2020-02-06 at 3 38 32 PM

Choose where on your computer you want this project to go (Documents, for example). In your command line, use cd to navigate to the folder where you want to save the project.

Now "clone" the repo (copy all of the files from the online repository to your computer) by running:

git clone https://github.com/edgi-govdata-archiving/ECHO-by-Zip-Code.git

Once the process completes, navigate into the cloned repo folder:

cd echo-by-zip-code

If you run jupyter notebook from here, it should open your browser and there should be a file called echo-by-zip.ipynb. Click to open!

Screen Shot 2020-02-06 at 3 33 53 PM

Screen Shot 2020-02-06 at 3 34 07 PM

Getting the data

The data we are using is not a part of the repo. (It could be, but isn't in order to keep the repo small.) You will need to download it separately.

Download the ZIP file from ECHO Exporter on the ECHO Data Downloads page.

Screen Shot 2020-02-06 at 3 34 41 PM

Unzip the file and move its contents into the data folder of your local copy of this repo. It should look like:

echo-by-zip-code/data/ECHO_EXPORTER.csv

(You can put the xlsx file there too, but the code doesn't depend on it. It's a useful file to keep around.)

Installing libraries

When you open the Jupyter notebook, there will be a little code block near the top with the comment # Import libraries.

This code block names the different libraries (packages of many specialized functions for e.g. mapping things or manipulating data) that the notebook is using:

Screen Shot 2020-02-06 at 3 34 19 PM

For each line with an import in front of it, you will need to install a library using the command line.

Open a new window of your terminal, then for each library, install with:

pip install <library>.

For example, since there is a line that says import pandas as pd in the notebook, enter

pip install pandas

into the command line.

Using the notebook

Now that the notebook is running and you have the data & libraries installed, you should be able to run it!

Back in the notebook, you can either click the button that says "Run" to run one cell at a time, or hit "Run All" in the "Cell" menu to run the whole notebook.

Screen Shot 2020-02-06 at 3 49 56 PM

It might take a minute to process all that data! When it's done, you should see some maps and graphs about the ECHO permits in the specified zip code area.

Change the zip code in the code as my_zip to your own zip code and run the notebook again to see a report for your area:

Screen Shot 2020-02-06 at 3 52 03 PM


License & Copyright

Copyright (C) Environmental Data and Governance Initiative (EDGI) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3.0.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

See the LICENSE file for details.