From: Pawel Kedzierski (pawel.kedzierski_at_pwr.edu.pl)
Date: Wed Aug 19 2015 - 09:23:22 CDT

A great tool to extract data from text files is awk, available in Unix
system (or gawk aka gnu awk otherwise).
With awk getting a a CSV spreadsheet from NAMD log file is a one-line
command like this:

awk '/^ENERGY:/{print $2, $11, $14}' OFS=, namd.log > spreadsheet.csv

This example will save columns 2 (TS), 11 (KINETIC) and 14 (POTENTIAL;
column numbers from NVE run) from lines starting with "ENERGY:" to file
spreadsheet.csv using comma as output field separator.
Extracting column heads and even the actual calculations can be done
with awk alone but such a simple example is easy to understand and
adapt, and you need to identify the column numbers anyway as they depend
on the calculations.

To extract all columns in a text file with (single line of) headers and
preserved column alignment, easily imported to Excel or Calc:

awk '/^ETITLE:/{if(h==0){print;h=1}};/^ENERGY:/{print}' namd.log > data.txt

A little more tricky example will give you all columns with headers as a
csv spreadsheet:

awk '/^ETITLE:/{if(h==0){$1="";print;h=1}};/^ENERGY:/{$1="";print}'
OFS=, namd.log > spreadsheet.csv

It will remove the labels from the first colums - a trick to make the
conversion of field separators in entire line.
This was actually tested with GNU awk as I work on linux.
HTH,
Pawel

W dniu 19.08.2015 o 03:38, Ern Seang Ong pisze:
>
> Hi VMD users,
>
> I have listed following questions about extracting data from NAMD log
> file.
>
> 1.I have run a simulation and I need to calculate the viscosity of the
> equilibrated system by using Green-Kubo relation. For the viscosity
> calculation, I need to the values of stress tensor (pressure in 3x3
> matrix), temperature and volume, which are available in the NAMD log
> file, but I do not know how to extract those values out into a
> spreadsheet.
>
> 2.Is there any way for me to export the graph as displayed in multiplot?
>
No idea what kind of graph you mean, but you can always extract the
plotted data from the Multiplot graph window, for example: File->Save as
ASCII matrix (this is a text file with aligned, space separated columns).

> 3.Is there any Tcl script available for viscosity calculation (using
> eg. Green-Kubo relations) in VMD?
>
> Thank you.
>
> Ernest
>
> ------------------------------------------------------------------------
>
>
> UNSW AUSTRALIA
> UNSW CANBERRA AT THE AUSTRALIAN DEFENCE FORCE ACADEMY
> PO Box 7916, CANBERRA BC 2610, Australia
> Web: http://unsw.adfa.edu.au
>
>
> CRICOS Provider no. 00098G
>
> This message is intended for the addressee named and may
> contain confidential information. If you are not the
> intended recipient, please delete it and notify the sender.
> Views expressed in this message are those of the individual
> sender and are not necessarily the views of UNSW.
>