annotate utils/export.lisp @ 248:e5ff7d53f084

Add :initform nil to linked-event composition slot.
author Jamie Forth <j.forth@gold.ac.uk>
date Thu, 24 Feb 2011 11:23:18 +0000
parents 87320b5ba2e5
children
rev   line source
j@219 1 (cl:in-package #:amuse-utils)
j@219 2
j@219 3 (defun beats->seconds (composition &optional (stream t))
j@219 4 "Prints a table of beat timepoints in seconds."
j@219 5 (loop for i from 0 to (timepoint (cut-off composition))
j@219 6 do (format stream
j@219 7 "~A~C~F~%" i #\Tab
j@219 8 (amuse-utils:beats-to-seconds
j@219 9 (make-moment i) composition))))
j@219 10
j@219 11 (defun export-data-from-composition (function composition pathname)
j@219 12 "Function that applies another function to a composition, witing
j@219 13 the output to a file, e.g. use this to call beats->seconds."
j@219 14 (with-open-file (stream pathname
j@219 15 :direction :output
j@219 16 :if-exists :supersede)
j@219 17 (funcall function composition stream)))
j@219 18
j@219 19 (defun export-data-from-dataset (dataset function pathname)
j@219 20 "Same as above except that processes an entire amuse-dataset."
j@219 21 (loop for composition-identifier in
j@219 22 (%list-slot-sequence-data dataset)
j@219 23 do (with-open-file (stream
j@219 24 (concatenate 'string pathname
j@219 25 (princ-to-string
j@219 26 (composition-id
j@219 27 composition-identifier)))
j@219 28 :direction :output
j@219 29 :if-exists :supersede)
j@219 30 (funcall function
j@219 31 (get-composition composition-identifier) stream))))