From: Axel Kohlmeyer (akohlmey_at_gmail.com)
Date: Tue Sep 17 2013 - 08:18:57 CDT

On Mon, Sep 16, 2013 at 6:51 PM, Martin, Erik W <Erik.Martin_at_stjude.org> wrote:
> Hi, I'm trying to write a script that measures a pair distribution function over a sliding window through a trajectory. I would like to output "r" in the first column of a text file, then "g(r)" for each window in subsequent columns. However, in my loop I'm having a very hard time getting tcl to handle the data in a way that makes this manageable. Does anyone have any experience writing this type of script, or any general tcl advice they could give me for how to do this?

well, this sounds like you need to practice a bit of list management in Tcl.

http://www.tcl.tk/man/tcl8.5/tutorial/Tcl14.html
http://www.tcl.tk/man/tcl8.5/tutorial/Tcl15.html

measure gofr returns a list of lists. the list with the r values
should be identical, so you only need to keep one copy around.
for the rest you can have your own list of lists which holds all g(r)
lists. for each new frame you add a g(r) result to the list and after
you have reached your sliding window size, you also remove the first
list. for printing you can then simply do a nested loop where you loop
over the various lists and compute the averages in the inner loop and
print the result along with r in the outer loop. pretty
straightforward altogether.

cheers,
   axel.

>
> Thanks a lot,
> Erik
>
> Email Disclaimer: www.stjude.org/emaildisclaimer
> Consultation Disclaimer: www.stjude.org/consultationdisclaimer
>
>

-- 
Dr. Axel Kohlmeyer  akohlmey_at_gmail.com  http://goo.gl/1wk0
International Centre for Theoretical Physics, Trieste. Italy.