Build and test the environment

This document explains how to set up your environment for the geocomputing course.

1. Install Anaconda

First, install Anaconda for Python 3.5, following the instructions there.

If you wish, you can also install git for your platform, but it's not a requirement.

2. Get the course materials

If you are using git, clone this repo: https://github.com/EvanBianco/Practical_Programming_for_Geoscientists

If not, download this ZIP file: https://github.com/EvanBianco/Practical_Programming_for_Geoscientists/archive/master.zip

Put the folder somewhere you will find it again.

This file is in the top level folder, called Build_ad_test_environment.ipynb.

3. a. Set up the environment

Do the following in a terminal:

conda config –-add channels conda-forge
conda create –n geocomputing python=3.5 anaconda

Start the environment:

source activate geocomputing

Now install packages:

conda install numpy  # Ensures latest.
conda install obspy
conda install geopandas
conda install ipyparallel
conda install tqdm
conda install folium
pip install lasio
pip install welly
pip install bruges

All of this should go without trouble.

3. b. Enter the environment and the repo

Now you will need to start running this notebook.

# If you didn't do this already:
git clone https://github.com/EvanBianco/Practical_Programming_for_Geoscientists

Then...

cd geocomputing
jupyter notebook Build_and_test_environment.ipynb

or if you're already running it, restart its kernel... and we can go on to check the environment.

4. Check anaconda basics


In [ ]:
!python -V

# Should be 3.5

In [ ]:
import numpy as np
import matplotlib.pyplot as plt
from scipy.signal import ricker

5. Check conda installs

If any of these fail, go out to a terminal and do this, replacing <package> with the name of the package.

source activate geocomp  # Or whatever is the name of the environment
conda install <package>

In [ ]:
import pandas as pd

In [ ]:
import requests

In [ ]:
import numba

In [ ]:
import ipyparallel as ipp

In [ ]:
import obspy

In [ ]:
import geopandas as gpd  # Not a catastrophe if missing.

In [ ]:
import folium    # Not a catastrophe if missing.

6. Check pip installs

If any of these fail, go out to a terminal and do this, replacing <package> with the name of the package.

source activate geocomp  # Or whatever is the name of the environment
pip install <package>

In [ ]:
import lasio

In [ ]:
import welly

In [ ]:
import bruges as b

7. Download data


In [2]:
import os
import requests

In [ ]:
files = [
    '2D_Land_vibro_data_2ms.tgz',
    '3D_gathers_pstm_nmo_X1001.sgy',
    'Penobscot_0-1000ms.sgy.gz',
    'Penobscot_NumPy.npy.gz',
]

url = "https://s3.amazonaws.com/agilegeo/"

In [ ]:
localpath = ''  # For CWD.

for file in files:
    print(file)
    r = requests.get(url+file, stream=True)

    chunk_size = 1024 * 1024 # 1MB

    with open(os.path.join(localpath, file), 'wb') as fd:
        for chunk in r.iter_content(chunk_size):
            if chunk:
                fd.write(chunk)

In [ ]: