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
# 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")) |
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
;; Sam, I got up to 21, some of which now reside forma-clj | |
(def nums | |
[1 | |
2 | |
3 | |
4 | |
5 | |
6]) |
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 | |
from osgeo import gdal | |
def progress(n, interval=100): | |
"Print progress at regular intervals" | |
# don't want to divide by zero on first try | |
if n > 0: | |
if n % interval == 0: | |
print "Parsing item %i" % n | |
return |
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
drop if prob201108 == . & hansen == 0 | |
drop country ecoid gadm coastdist modh modv sample line prob200512 | |
drop if prob201108 < 50 & hansen == 0 | |
outsheet using "/Users/robin/Dropbox/code/forma-app/data/IDN.csv", comma noquote |
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
(let [lat 90 | |
lon -180 | |
series [1 2 3] | |
j (partial join ",")] | |
(j [lat (j [lon (j series)])])) |
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
(defn get-max | |
[v] | |
(apply max (flatten v))) | |
(let [src (hfs-seqfile "s3n://formaresults/finaloutput/*")] | |
(??<- [?count] | |
(src ?s-res ?mod-h ?mod-v ?s ?l ?prob-series) | |
(get-max ?prob-series :> ?max) | |
(>= ?max 0.5) | |
(c/count ?count))) |
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
(defmain through-reli | |
[tmp-root pail-path ts-pail-path out-path run-key country-seq] | |
(let [{:keys [s-res t-res est-end] :as est-map} (forma-run-parameters run-key) | |
mk-filter (fn [vcf-path ts-src] | |
(forma/filter-query (hfs-seqfile vcf-path) | |
(:vcf-limit est-map) | |
ts-src))] | |
(assert est-map (str run-key " is not a valid run key!")) | |
(workflow [tmp-root] | |
vcf-step |