Re: still problems with namdplot

From: Gadi Oron (gadi_at_proteologics.com)
Date: Sun Apr 18 2004 - 01:51:42 CDT

Hi,

On Thu, 2004-04-15 at 22:13, Cheri M Turman wrote:
> Hi all,
> I had this problem earlier but I got distracted and I am just now
> getting back to it. Jim Philips advised me to use the new script with
> xmgrace, which is what I am currently using. I no longer get the
...

I've revised the namdplot script to work with gnuplot instead of
xmgrace. I find it better since closing the plot window does not require
confirmation. It is a complete rewrite in bash instead of csh, so it
might work better.

A second variant I've written plots the same variable from 2 runs
together.

A third script is great for those who work over slow connection. It
displays the plot in the text window.

All these files are attached to this email. Hope it helps.

- Gadi

-- 
================= Gadi ORON, PhD -o- Proteologics ======================
========== gadi/at/proteologics.com ========== +972 8 9475666 ==========
A 'full' life in my experience is usually full only of other people's demands.
******************************************************************************
This e-mail message, together with any attachments, contains information of
Proteologics, Ltd (Rehovot, Israel) that may be confidential, proprietary
copyrighted and/or legally privileged, and is intended solely for the use of
the individual or entity named in this message. If you are not the intended
recipient, please notify us immediately and do not disclose, distribute, or
retain this e-mail or any part of it.  Proteologics, Ltd reserves the right to
monitor all e-mail communications through its network.
** eSafe scanned this email for viruses, vandals and malicious content. **
******************************************************************************


#!/bin/tcsh

# Written in 1999 by Jim Phillips, Theoretical Biophysics Group,
# Beckman Institute, University of Illinois at Urbana-Champaign.

if ( $#argv < 1 ) then
  echo "Usage: $0 [zero] [diff] [from <first>] [to <last>] [<yfield> [<yfield> ...] [vs <xfield>]] <file1> <file2>"
  exit -1
endif

set titles = `awk '/^ETITLE:/ { print; exit }' $argv[$#argv]`
echo $titles

if ( $#argv < 2 ) then
  echo "Usage: $0 [zero] [diff] [from <first>] [to <last>] [<yfield> [<yfield> ...] [vs <xfield>]] <file>"
  exit -1
endif

if ( $1 == zero ) then
  set zero = 1
  shift argv
else
  set zero = 0
endif

if ( $1 == diff ) then
  set zero = 1
  set diff = 1
  shift argv
else
  set diff = 0
endif

if ( $1 == from ) then
  shift argv
  set first_step = $1
  shift argv
else
  set first_step = 0
endif

if ( $1 == to ) then
  shift argv
  set last_step = $1
  shift argv
else
  set last_step = 0
endif

set ytargets =
while ( $#argv > 2 && $1 != vs )
  @ pos = 1
  foreach t ( $titles )
    if ( $t == $1 ) set ytargets = ( $ytargets $pos )
    @ pos++
  end
  shift argv
end
if ( $#ytargets == 0 ) exit -1

set xtarget = 2
if ( $1 == vs ) then
  shift argv
  @ pos = 1
  foreach t ( $titles )
    if ( $t == $1 ) set xtarget = $pos
    @ pos++
  end
  shift argv
endif

set file = ($argv[1] $argv[2])

set ytitle =
foreach y ( $ytargets )
  set ytitle = ( $ytitle $titles[$y] )
end
set xtitle = $titles[$xtarget]

echo Plotting $ytitle vs $xtitle

set title = "Comparing 1: $file[1] to 2: $file[2]"

set open = '{'
set close = '}'
set dollar = '$'

if ( $zero ) then
  set prog = "BEGIN $open zset = 0 $close"
else
  set prog = ""
endif

if ( $first_step ) then
  set prog = "$prog ${dollar}2 < $first_step $open next $close ;"
endif

if ( $last_step ) then
  set prog = "$prog ${dollar}2 > $last_step $open next $close ;"
endif

if ( $zero ) then
  set subtitle = "change from initial value"
  set prog = "$prog zset == 0 $open zset = 1;"
  foreach y ( $ytargets )
    set prog = "$prog z$y = $dollar$y;"
  end
  set prog = "$prog $close"
  set prog = "$prog $open print $dollar$xtarget"
  foreach y ( $ytargets )
    set prog = "$prog, $dollar$y - z$y"
  end
  set prog = "$prog $close"
  if ( $diff ) then
    set subtitle = "running backward difference"
    set prog = "$prog $open"
    foreach y ( $ytargets )
      set prog = "$prog z$y = $dollar$y;"
    end
    set prog = "$prog $close"
  endif
else
  set subtitle = ""
  set prog = "$prog $open print $dollar$xtarget"
  foreach y ( $ytargets )
    set prog = "$prog, $dollar$y"
  end
  set prog = "$prog $close"
endif

set quote = '"'
set p_subtitle = "SUBTITLE $quote$subtitle$quote"

set tmpfile = (/tmp/namdplot.$USER.$$.1.tmp /tmp/namdplot.$USER.$$.2.tmp)

set p_cmd = 0
foreach i (1 2)
    @ pos = 2
    foreach t ( $ytitle )
        if ( "$p_cmd" == "0" ) then
            set p_cmd = "plot $quote$tmpfile[$i]$quote u 1:$pos t $quote$t ($i)$quote"
        else
            set p_cmd = "$p_cmd, $quote$tmpfile[$i]$quote u 1:$pos t $quote$t ($i)$quote"
        endif
    @ pos++
    end

grep '^ENERGY:' $file[$i] | grep -v '[a-z]' | awk "$prog" > $tmpfile[$i]
end

#xmgrace \
# -pexec "LEGEND on" \
# -pexec "$l_cmd[1]" \
# -pexec "$l_cmd[2]" \
# -pexec "$l_cmd[3]" \
# -pexec "$l_cmd[4]" \
# -pexec "$l_cmd[5]" \
# -pexec "$l_cmd[6]" \
# -pexec "$l_cmd[7]" \
# -pexec "$l_cmd[8]" \
# -pexec "$l_cmd[9]" \
# -pexec "$l_cmd[10]" \
# -pexec "$p_title" -pexec "$p_subtitle" -pexec "$p_xaxis" \
# -pexec "XAXIS TICKLABEL FORMAT DECIMAL" -pexec "XAXIS TICKLABEL PREC 0" \
# -pexec "YAXIS TICKLABEL FORMAT DECIMAL" -pexec "YAXIS TICKLABEL PREC 0" \
# -autoscale xy -remove -nxy $tmpfile &

echo \
set term x11\; \
set mouse\; \
set title $quote$title$quote\; \
set xlabel $quote$xtitle$quote\; \
$p_cmd\; \
| gnuplot -persist


This archive was generated by hypermail 2.1.6 : Wed Feb 29 2012 - 15:37:32 CST