On Thu, 7 Feb 2008, Florencio Garcia wrote:
> For example, is there an alternative to: (to-appended filename
> (after-time T output-dpwr)) so that instead of appending all the maps of
> the energy density I get a summation of them for the time I collect
> them?
>
> I can always manually extract all the slices into files and then
> manipulate them with some software, but I bet there must be an easier
> way to tell MEEP to just add things up.
No, Meep doesn't have any built-in way to add up files. However, it
should be pretty easy to write one using the h5math utility function.
Off the top of my head, something like the following should work:
(define (sum-h5 fname step-func)
(let ((first-step? true))
(lambda (to-do)
(if first-step?
(begin ; just copy the output file to fname
(set! first-step? false)
((convert-h5 true
(string-append "h5math -e \"d1\" \"" fname "\"")
step-func) to-do))
; otherwise, add the output file to fname
((convert-h5 true
(string-append "h5math -e \"d1 + d2\" \"" fname
"\" " fname "\"")
step-func) to-do)))))
Then do e.g.
(run (after-time T (sum-h5 "dpwr-sum.h5" output-dpwr)))
which will total all of the dpwr .h5 files to a file dpwr-sum.h5 (deleting
the individual step .h5 files).
Steven
_______________________________________________
meep-discuss mailing list
[email protected]
http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/meep-discuss