Created
June 2, 2011 21:23
-
-
Save sritchie/1005368 to your computer and use it in GitHub Desktop.
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
(def | |
^{:doc "Predicate macro aggregator that extracts a timeseries, given | |
`?chunk`, `?temporal-resolution` and `?date`. Currently only | |
functions when `?chunk` is an instance of `forma.schema.IntArray`."} | |
extract-tseries | |
(<- [?temporal-res ?date ?chunk :> ?pix-idx ?t-start ?t-end ?tseries] | |
(datetime->period ?temporal-res ?date :> ?tperiod) | |
(:sort ?tperiod) | |
(timeseries ?tperiod ?chunk :> ?pix-idx ?t-start ?t-end ?tseries))) | |
(def | |
^{:doc "Predicate macro; extracts relevant spatial data | |
from the supplied chunk fields."} | |
extract-attrs | |
(<- [?tilestring ?spatial-res ?chunk-size ?chunkid ?pix-idx :> ?tile-h ?tile-v ?sample ?line] | |
(tilestring->hv ?tilestring :> ?tile-h ?tile-v) | |
(tile-position ?spatial-res ?chunk-size ?chunkid ?pix-idx :> ?sample ?line))) | |
(defn process-tseries | |
"Given a source of chunks, this subquery generates timeseries with | |
all relevant accompanying information." | |
[chunk-source] | |
(<- [?dataset ?spatial-res ?temporal-res ?tile-h ?tile-v ?sample ?line ?t-start ?t-end ?tseries] | |
(chunk-source ?dataset ?spatial-res ?temporal-res ?tilestring ?date ?chunkid ?int-chunk) | |
(io/num-ints ?int-chunk :> ?chunk-size) | |
(extract-tseries ?temporal-res ?date ?int-chunk :> ?pix-idx ?t-start ?t-end ?tseries) | |
(extract-attrs ?tilestring ?spatial-res | |
?chunk-size ?chunkid ?pix-idx :> ?tile-h ?tile-v ?sample ?line))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment