This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
This file contains hidden or 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 modis->latlon | |
| "Converts the supplied MODIS coordinates into `[lat, lon]` based on | |
| the supplied resolution. | |
| Example usage: | |
| (modis->latlon \"1000\" 8 6 12 12) | |
| ;=> (29.89583333333333 -115.22901262147285)" | |
| [res mod-h mod-v sample line] | |
| (->> (modis->global-mags res mod-h mod-v sample line) |
This file contains hidden or 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
| ;; work in progress! | |
| (defn mf | |
| [lat lon zoom] | |
| (let [min-lat -90])) | |
| (defn my-func | |
| [lat lon zoom] | |
| (let [tile-range (bit-shift-left 1 zoom) | |
| y lat |
This file contains hidden or 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 convert-16->32 | |
| "Convert period in original output for Vizzuality from 16-day to monthly periodicity. | |
| For common data model" | |
| [] | |
| (let [in-res "16" | |
| out-res "32" | |
| start-epoch (date/datetime->period in-res "2000-01-01") | |
| start-epoch-new-res (date/datetime->period out-res "2000-01-01") | |
| src (hfs-seqfile "s3n://formaresults/analysis/xyzperiod") |
This file contains hidden or 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 validation | |
| (:use cascalog.api)) | |
| (defn build-query | |
| [lat lon] | |
| (let [lat-f (float lat) | |
| lon-f (float lon) | |
| ;;url_head "http://timrobertson100.cartodb.com/api/v2/sql?q=" | |
| ;;query_stub "select%20iso_a2%20from%20countries%20WHERE%20ST_DWithin(the_geom,%20ST_SetSRID(ST_Point(" | |
| url_head "http://viz2.cartodb.com/api/v2/sql?q=" |