     (?- (stdout)
         (sample-ascii \"1000\" 0.1 \"/path/to/ascii.csv\" [[8 6] [12 10]]))"
   [m-res ll-res ascii-path tile-seq]
+  {:pre [()]}
   (let [tile-source (memory-source-tap tile-seq)
         ascii-source (grid-source (hfs-textline ascii-path))]
     (<- [?mod-h ?mod-v ?sample ?line ?val]

(ns forma.source.fire
  (:use cascalog.api
        [forma.matrix.utils :only (idx->colrow)]
        [forma.reproject :only (wgs84-index
                                dimensions-at-res)]
        [forma.source.modis :only (latlon->modis pixels-at-res)]
        [clojure.string :only (split)])
  (:require [cascalog.ops :as c]))


  (map (fn [val]
         (try (Float. val)
              (catch Exception _
                val)))
       (split line #",")))

(defn fire-source
  "Takes a source of textlines, and returns 2-tuples with latitude and
  longitude."
  [source]
  (<- [?dataset ?lat ?lon ?kelvin ?datestring]
      (source ?line)
      (identity "fire" :> ?dataset)
      (mangle ?line :> ?lat ?lon ?kelvin _ _ ?datestring _ _ _ _ _ _)))

(defmapop [to-period [t-res]]
  [datestring]
  (let [[month day year] (->> (split datestring #"/")
                              (map #(Integer. %)))]
    (periodize t-res year month day)))
"12/31/2005"

(defn rip-fires
  "Aggregates fire data at the supplied path by modis pixel at the
  supplied resolution."
  [m-res t-res path]
  (let [fires (fire-source (hfs-textline path))]
    (<- [?dataset ?mod-h ?mod-v ?sample ?line ?tperiod ?count ?max-t]
        (fires ?dataset ?lat ?lon ?kelvin ?datestring)
        (to-period [t-res] ?datestring :> ?tperiod)
        (> ?kelvin 330)
        (latlon->modis m-res ?lat ?lon :> ?mod-h ?mod-v ?sample ?line)
        (c/max ?kelvin :> ?max-t)
        (c/count ?count))))

(defn run-rip
  "Rips apart fires!"
  [count m-res t-res path]
  (?- (stdout) (c/first-n (rip-fires m-res t-res path)
                          count)))

;; FOR LATER...
;;
;; ## ASCII Grid Sampling

(defn liberate
