From d9c0eeebc69e9b76bd579a3e6e1bc6482e397cdf Mon Sep 17 00:00:00 2001 From: Mark Evenson Date: Sat, 3 Sep 2022 08:28:31 +0200 Subject: [PATCH] Summarize output files suitable for plotting --- mevenson/simulation/glacier.asd | 1 + mevenson/simulation/plot.lisp | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 mevenson/simulation/plot.lisp diff --git a/mevenson/simulation/glacier.asd b/mevenson/simulation/glacier.asd index d807e33..96f7bff 100644 --- a/mevenson/simulation/glacier.asd +++ b/mevenson/simulation/glacier.asd @@ -8,5 +8,6 @@ :pathname "./" :components ((:file "package") (:file "json-path") + (:file "plot") (:file "glacier"))))) diff --git a/mevenson/simulation/plot.lisp b/mevenson/simulation/plot.lisp new file mode 100644 index 0000000..11d956f --- /dev/null +++ b/mevenson/simulation/plot.lisp @@ -0,0 +1,25 @@ +(in-package :glacier) + +(defun summarize (file) + (let* ((s + (alexandria:read-file-into-string file)) + (j + (jsown:parse s)) + (rounds + (loop :for column :in (get-path j '$.columns) + :collecting (get-path column '$.values)))) + (loop :for round :in rounds + :collecting ;; TODO optimize + (list + (length + (remove-if-not #'zerop round)) + (length + (remove-if-not + (lambda (x) (= 1 x)) + round)) + (length + (remove-if-not + (lambda (x) (= 2 x)) + round)))))) + +