   {:pre [(= (count coll1) (count coll2))]}
   (map #(when-not (pred %2) %1) coll2 coll1))
 
-(defn fix-time-series
-  [pred qual-coll val-coll]
-  (map-indexed vector (mask pred qual-coll val-coll)))
+;; (defn fix-time-series
+;;   [pred qual-coll val-coll]
+;;   (vec
+;;    (map-indexed vector (mask pred qual-coll val-coll))))
 
+
+(defn replace-index-set
+  [idx-set new-val coll]
+  (for [[m n] (map-indexed vector coll)]
+    (if (idx-set m) new-val n)))
 
 (defn bad-ends
   "collect a set of the indices of bad ends. if the bad value is, say, 2, then the

                 [m-coll r-coll])))))

(defn act-on-good
  [func bad-set coll]
  (func
   (filter #(not (contains? bad-set %))
           coll)))

(defn neutralize-ends
  [bad-set reli-coll val-coll]
  (let [avg (act-on-good average bad-set val-coll)
        ends (bad-ends bad-set reli-coll)]
    ends))

;; (map #(if (#{8049} %) 54 %) (mask #{2} reli-test ndvi-test))

(def reli-test [2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2])


                         (partition 2 1 goodpos-seq))
                    (nth value-coll (last goodpos-seq))))))))


(defn mask
  "create a new vector where values from `coll1` are only passed through
  if they satisfy the predicate `pred` for `coll2`.  All other values are
