Skip to content

Instantly share code, notes, and snippets.

View robintw's full-sized avatar

Robin Wilson robintw

View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@robintw
robintw / prospect.py
Created February 18, 2016 21:51
Code to run PROSPECT model only
import pyprosail
import numpy as np
def run_prospect(N, Cab, Car, Cbrown, Cw, Cm):
wavelengths = np.arange(400, 2501)
pyprosail._prosail_model.prospect_5b(N, Cab, Car, Cbrown, Cw, Cm)
arr = np.transpose(np.vstack( (wavelengths/1000.0, res[:, 0], res[:, 1]) ))
@robintw
robintw / prepare_landsat_image.py
Created February 19, 2016 14:54
Prepare Landsat image code
import recipy
import sys
from LandsatUtils import extract_and_process_uncorrected, BOAReflectance, mask_all_bands
from GDALUtils import image_like
from PyFMask.fmask import run_FMask
import gdal
import logging
import os
import pandas as pd
df = pd.DataFrame({'Name': ['Soton Central', 'Soton Airport', 'London Paddington', 'Malvern Link', 'Great Malvern', 'Oxford'],
'TLC': ['SOU', 'SOA', 'PAD', 'MVL', 'GMV', 'OXF']})
selected_stations = ['London Paddington', 'Malvern Link']
df[df.Name.isin(selected_stations)]
{
"url": "tandfonline\\.com",
"elements": {
"publisher": {
"selector": "//meta[@property='og:site_name']",
"attribute": "content"
},
"journal": {
"selector": "//meta[@name='citation_journal_title']",
"attribute": "content"
@robintw
robintw / python_example_code.py
Created April 5, 2016 10:22
Example code for interview with Robin
import numpy as np
from scipy.signal import convolve2d
def func(arr):
"""
Arguments:
arr: a numpy array (any numeric dtype, any dimensions)
Return value:
byte = bin(maskArray[y][x])[2:].rjust(16, '0')
if byte == "1111111111111111":
outFile.write("-9999 ")
elif byte[14:] == "00":
outFile.write("1 ")
elif byte[14:] == "01":
outFile.write("2 ")
elif byte[14:] == "10":
outFile.write("3 ")
import sys
sys.path.append(r"C:\Dropbox\Dropbox\_PhD\_Code\PythonLibs")
# sys.path.append(r"/Users/robin/Dropbox/_PhD/_Code/PythonLibs")
from LandsatUtils import parse_metadata
from Py6S import *
import numpy as np
import dateutil
from VanHOzone import get_ozone_conc
from scipy.interpolate import interp1d
@robintw
robintw / rasterio-dev-env-osx.yml
Created June 2, 2016 15:29
Conda environment for rasterio development on OS X
# This file may be used to create an environment using:
# $ conda create --name <env> --file <this file>
# platform: osx-64
@EXPLICIT
https://conda.anaconda.org/conda-forge/osx-64/affine-2.0.0.post1-py34_0.tar.bz2
https://repo.continuum.io/pkgs/free/osx-64/alabaster-0.7.7-py34_0.tar.bz2
https://repo.continuum.io/pkgs/free/osx-64/babel-2.3.3-py34_0.tar.bz2
https://repo.continuum.io/pkgs/free/osx-64/boto3-1.3.1-py34_0.tar.bz2
https://repo.continuum.io/pkgs/free/osx-64/botocore-1.4.19-py34_0.tar.bz2
https://repo.continuum.io/pkgs/free/osx-64/curl-7.45.0-0.tar.bz2
https://repo.continuum.io/pkgs/free/osx-64/_license-1.1-py27_0.tar.bz2
https://repo.continuum.io/pkgs/free/osx-64/abstract-rendering-0.5.1-np19py27_0.tar.bz2
https://repo.continuum.io/pkgs/free/osx-64/affine-1.2.0-py27_0.tar.bz2
https://repo.continuum.io/pkgs/free/osx-64/alabaster-0.7.3-py27_0.tar.bz2
https://repo.continuum.io/pkgs/free/osx-64/anaconda-2.3.0-np19py27_0.tar.bz2
https://repo.continuum.io/pkgs/free/osx-64/anaconda-client-1.2.2-py27_0.tar.bz2
https://repo.continuum.io/pkgs/free/osx-64/appnope-0.1.0-py27_0.tar.bz2
https://repo.continuum.io/pkgs/free/osx-64/appscript-1.0.1-py27_0.tar.bz2
https://repo.continuum.io/pkgs/free/osx-64/argcomplete-0.8.9-py27_0.tar.bz2
https://repo.continuum.io/pkgs/free/osx-64/astropy-1.0.6-np110py27_0.tar.bz2