Skip to content

Instantly share code, notes, and snippets.

View robintw's full-sized avatar

Robin Wilson robintw

View GitHub Profile
@robintw
robintw / convert_to_pm25.py
Created July 21, 2016 15:50
Code to convert AOT data to PM2.5
import numbers
import gdal
import numpy as np
import os
import tempfile
from subprocess import call
import logging
from resample_image import resample_raster
@robintw
robintw / read_aeronet.py
Created July 17, 2016 10:30
Simple function to read AERONET data into a Pandas DataFrame
import pandas as pd
def read_aeronet(filename):
"""Read a given AERONET AOT data file, and return it as a dataframe.
This returns a DataFrame containing the AERONET data, with the index
set to the timestamp of the AERONET observations. Rows or columns
consisting entirely of missing data are removed. All other columns
are left as-is.
"""
@robintw
robintw / rasterio_to_xarray.py
Created July 11, 2016 13:26
Simple code to create an xarray.DataArray from a file that can be read by rasterio
import rasterio
import xarray as xr
import numpy as np
def rasterio_to_xarray(fname):
"""Converts the given file to an xarray.DataArray object"""
with rasterio.drivers():
with rasterio.open(fname) as src:
data = src.read(1)
from Py6S import *
s = SixS()
s.altitudes.set_sensor_satellite_level()
s.altitudes.set_target_sea_level()
s.atmos_profile = AtmosProfile.UserWaterAndOzone(3.6, 0.9)
s.aot550 = 0.5
@robintw
robintw / Dockerfile
Created July 2, 2016 09:04
Dockerfile based on conda
# This Dockerfile builds a container
# (describe ..)
FROM continuumio/miniconda3
MAINTAINER Sam Murphy <samsammurphy@gmail.com>
RUN conda install numpy scipy matplotlib pandas
RUN apt-get update && apt-get install -y \
gfortran \
@robintw
robintw / Dockerfile
Created July 2, 2016 08:45
Dockerfile based on apt-get
# This Dockerfile builds a container
# (describe ..)
FROM ubuntu:14.04
MAINTAINER Sam Murphy <samsammurphy@gmail.com>
ENV Python_version 3.4.3
RUN apt-get update && apt-get install -y \
wget \
@robintw
robintw / Dockerfile
Created July 2, 2016 08:41
Dockerfile to build Py6S container using apt-get to install dependencies
# This Dockerfile builds a container
# (describe ..)
FROM ubuntu:14.04
MAINTAINER Sam Murphy <samsammurphy@gmail.com>
ENV Python_version 3.4.3
RUN apt-get update && apt-get install -y \
gfortran \
@robintw
robintw / GDALPythonExample.py
Created June 27, 2016 11:16
Example output
In [15]: gdal.Warp('data.vrt', 'robin2.tif', srcSRS = 'EPSG:4326', dstSRS = 'EPSG:27700', geoloc=True)
ERROR 4: No such file or directory
---------------------------------------------------------------------------
SystemError Traceback (most recent call last)
<ipython-input-15-279de83a9634> in <module>()
----> 1 gdal.Warp('data.vrt', 'robin2.tif', srcSRS = 'EPSG:4326', dstSRS = 'EPSG:27700', geoloc=True)
/Users/robin/anaconda3/lib/python3.5/site-packages/osgeo/gdal.py in Warp(destNameOrDestDS, srcDSOrSrcDSTab, **kwargs)
547
548 if _is_str_or_unicode(destNameOrDestDS):
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
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