 
 (defn static-chunker
   "Last thing we need is the chunk-tap!"
-  [tile-seq dataset agg ascii-path output-path]
-  (let [src (sample-modis "1000" dataset tile-seq ascii-path agg)]
-    (?- (chunk-tap output-path)
-        (sparse-windower (tilestringer src) ["?sample" "?line"] "?val" 1200 20 0))))
+  [m-res tile-seq dataset agg ascii-path output-path]
+  (io/with-fs-tmp [fs tmp-dir]
+    (let [pix-tap (pixel-generator tmp-dir m-res tile-seq)
+          src (sample-modis m-res dataset pix-tap ascii-path agg)]
+      (?- (chunk-tap output-path)
+          (sparse-windower (tilestringer src) ["?sample" "?line"] "?val" 1200 20 0)))))
 
 (defn s3-path [path]
   (str "s3n://AKIAJ56QWQ45GBJELGQA:6L7JV5+qJ9yXz1E30e3qmm4Yf7E1Xs4pVhuEL8LV@" path))
 
+(def country-tiles [[27 7] [27 8] [27 9] [28 7] [28 8] [28 9] [29 8] [29 9] [30 8] [30 9] [31 8] [31 9]])
 
 (defn -main
   [dataset ascii-path output-path]
-  (static-chunker [[27 7] [27 8] [27 9] [28 7] [28 8] [28 9] [29 8] [29 9] [30 8] [30 9] [31 8] [31 9]]
+  (static-chunker "1000"
+                  country-tiles
                   dataset
                   c/sum
                   ascii-path
                   (s3-path output-path)))
-
-;; (cascalog.io/with-fs-tmp [fs tmp-dir]
-;;   (let [pix-tap (pixel-generator tmp-dir res tileseq)]
-;;     (?<- (stdout)
-;;          [?mod-h ?mod-v ?sample ?line]
-;;          (pix-tap ?mod-h ?mod-v ?sample ?line))))
-

  (:use cascalog.api
        [forma.matrix.utils :only (idx->colrow)]
        [forma.hadoop.io :only (chunk-tap)]
        [forma.hadoop.predicate :only (sparse-windower)]
        [forma.reproject :only (wgs84-index
                                dimensions-at-res
                                modis-sample)]


(defn low-res-sample
  "sample values off of a lower resolution grid than the MODIS grid."
  [dataset m-res ascii-info pixel-tap grid-source]
  (<- [?dataset ?m-res ?t-res ?mod-h ?mod-v ?sample ?line ?outval]
      (grid-source ?row ?col ?outval)
      (identity dataset :> ?dataset)
      (identity "00" :> ?t-res)
      (pixel-tap ?mod-h ?mod-v ?sample ?line)
      (modis-sample ascii-info m-res ?mod-h ?mod-v ?sample ?line :> ?row ?col)))

;; TODO: Right now, we use the 0.1 as an indicator for conversion
;; direction, between modis and wgs84. Replace with a calculation.
