This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns eleph.start | |
(:use [cascalog api]) | |
(:require [elephantdb.cascalog.core :as e]) | |
(:import [elephantdb.persistence JavaBerkDB])) | |
(def data [ | |
[1 "dan"] | |
[2 "sam"] | |
[3 "robin"] | |
[4 "david"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo add-apt-repository ppa:ubuntugis/ppa | |
sudo apt-get update | |
sudo apt-get install gdal-bin | |
sudo apt-get -y install python-gdal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro sam [expr pos neg zero] | |
`(cond (pos? ~expr) ~pos | |
(neg? ~expr) ~neg | |
:else ~zero)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
forvalues year = 2005/2011 { | |
forvalues month = 1/12 { | |
if `month' < 10 { | |
local mo_str = "0`month'" | |
} | |
else { | |
local mo_str = "`month'" | |
} | |
local yearmo = "`year'`mo_str'" | |
di "`yearmo'" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
for i in range(2000, 2013): | |
rain = np.fromfile("precl_mon_v1.0.lnx.%i.gri0.5m" % i, dtype="f", count=-1) | |
print "year:", i | |
print "max:", rain.max() | |
print "min:", rain.min() | |
print "first 100:", rain[:100] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
outsheet modh modv sample line hansen prob$start_datestr-prob$end_datestr using "/Users/robin/code/forma-analysis/data/$iso$underscore$bboxname.csv" if prob$end_datestr !=. & lat <= $top & lat >= $bottom & lon >= $left & lon <= $right, comma replace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* Snippit is a useful reminder of how Stata does reshapes | |
reshape long prob, string i(yearmo) | |
reshape long prob, string | |
reshape long i, string i(iso) j(yo) | |
reshape long prob, string i(id2) j(yearmo) | |
replace yearmo = dotm(yearmo) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
s3cmd cp --recursive s3://formastaging/MOD13A3/2011-10-01/ s3://modisfiles/MOD13A3/2011-10-01/ | |
s3cmd cp --recursive s3://formastaging/MOD13A3/2011-11-01/ s3://modisfiles/MOD13A3/2011-11-01/ | |
s3cmd cp --recursive s3://formastaging/MOD13A3/2011-12-01/ s3://modisfiles/MOD13A3/2011-12-01/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from osgeo import gdal | |
import os | |
layer_dict = {"reli":"reliability", "qual":"Quality", "ndvi":"NDVI", "evi":"EVI"} | |
def print_data(layer, data): | |
print data | |
print "data:", layer | |
print "type:", data.dtype | |
print "mean:", data.mean() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# gdal_translate -ot Byte -of GTiff -a_nodata 0 IDN_new.asc IDN.tif | |
fp = open("IDN.asc", "r") | |
fout = open("IDN_new.asc", "w") | |
n = 0 | |
for line in fp: | |
# replace -9999 with zeros - much smaller file | |
newline = "0".join(line.split("-9999")) |
OlderNewer