 
 (defn low-res-sample
   "sample values off of a lower resolution grid than the MODIS grid."
-  [dataset ascii-info mod-source grid-source]
+  [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)
-      (mod-source ?m-res ?mod-h ?mod-v ?sample ?line)
-      (modis-sample ascii-info ?m-res ?mod-h ?mod-v ?sample ?line :> ?row ?col)))
+      (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.


(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))))

(defn s3-path [path]
  (str "s3n://AKIAJ56QWQ45GBJELGQA:6L7JV5+qJ9yXz1E30e3qmm4Yf7E1Xs4pVhuEL8LV@" path))

(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]]
                  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))))


                                   hv->tilestring)]
        [clojure.string :only (split)])
  (:require [cascalog.ops :as c]
            [cascalog.io :as io]
            [clojure.contrib.duck-streams :as duck])
  (:gen-class))

