Commit 3f727e6e authored by Germain Clavier's avatar Germain Clavier
Browse files

More changes from python2 to python3... keep faith Germain!

parent 2a291c74
Loading
Loading
Loading
Loading
+883 −781

File changed.

Preview size limit exceeded, changes collapsed.

+282 −255
Original line number Diff line number Diff line
@@ -5,12 +5,26 @@
# DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
# certain rights in this software.  This software is distributed under
# the GNU General Public License.

#
# olog tool
#
# History
#   1/06, Steve Plimpton (SNL): original version
#   2/09, modified to allow different firststr for different log files
#
# ToDo list
#
# Variables
#   nvec = # of vectors
#   nlen = length of each vector
#   names = list of vector names
#   ptr = dictionary, key = name, value = index into data for which column
#   data[i][j] = 2d array of floats, i = 0 to # of entries, j = 0 to nvecs-1
#   firststr = string that begins a time-series section in log file

oneline = "Read other log files (ChemCell, SPPARKS, SPARTA) and extract time-series data"
"""
Read other log files (ChemCell, SPPARKS, SPARTA) and extract time-series data

docstr = """
o = olog("file1")                    read in one or more log files
o = olog("log1 log2.gz")             can be gzipped
o = olog("file*")                    wildcard expands to multiple files
@@ -32,35 +46,27 @@ o.write("file.txt","A","B",...) write listed vectors to a file
  get and write allow abbreviated (uniquely) vector names
"""

# History
#   1/06, Steve Plimpton (SNL): original version
#   2/09, modified to allow different firststr for different log files

# ToDo list

# Variables
#   nvec = # of vectors
#   nlen = length of each vector
#   names = list of vector names
#   ptr = dictionary, key = name, value = index into data for which column
#   data[i][j] = 2d array of floats, i = 0 to # of entries, j = 0 to nvecs-1
#   firststr = string that begins a time-series section in log file

# Imports and external programs

import sys, re, glob
from os import popen
import sys
import re
import glob
import os

try: tmp = PIZZA_GUNZIP
except: PIZZA_GUNZIP = "gunzip"
try:
    tmp = PIZZA_GUNZIP
except (NameError, ModuleNotFoundError, ImportError):
    PIZZA_GUNZIP = "gunzip"

# Class definition


class olog:

    # --------------------------------------------------------------------

  def __init__(self,*list):
    def __init__(self, *args):
        self.nvec = 0
        self.names = []
        self.ptr = {}
@@ -70,14 +76,17 @@ class olog:

        # flist = list of all log file names

    words = list[0].split()
        words = args[0].split()
        self.flist = []
    for word in words: self.flist += glob.glob(word)
        for word in words:
            self.flist += glob.glob(word)
        if len(self.flist) == 0 and len(list) == 1:
      raise StandardError,"no log file specified"
            sys.exit("no log file specified")

    if len(list) > 1 and len(list[1]): self.firststr = list[1]
    if len(list) == 3: self.ave = 1
        if len(args) > 1 and len(args[1]):
            self.firststr = args[1]
        if len(args) == 3:
            self.ave = 1

        self.read_all()

@@ -86,12 +95,14 @@ class olog:

    def read_all(self):
        self.read_header(self.flist[0])
    if self.nvec == 0: raise StandardError,"log file has no values"
        if self.nvec == 0:
            sys.exit("log file has no values")

        # read all files

    for file in self.flist: self.read_one(file)
    print
        for file in self.flist:
            self.read_one(file)
        print()

        # if no average, sort entries by timestep, cull duplicates
        # if average, call self.average()
@@ -99,21 +110,22 @@ class olog:
        if self.ave == 0:
            self.data.sort(self.compare)
            self.cull()
    else: self.average()
        else:
            self.average()

        self.nlen = len(self.data)
    print "read %d log entries" % self.nlen
        print("read %d log entries" % self.nlen)

    # --------------------------------------------------------------------

    def get(self, *keys):
        if len(keys) == 0:
      raise StandardError, "no log vectors specified"
            sys.exit("no log vectors specified")

    map = []
        keylist = []
        for key in keys:
      if self.ptr.has_key(key):
        map.append(self.ptr[key])
            if key in self.ptr:
                keylist.append(self.ptr[key])
            else:
                count = 0
                for i in range(self.nvec):
@@ -121,27 +133,29 @@ class olog:
                        count += 1
                        index = i
                if count == 1:
          map.append(index)
                    keylist.append(index)
                else:
          raise StandardError, "unique log vector %s not found" % key
                    sys.exit("unique log vector %s not found" % key)

        vecs = []
        for i in range(len(keys)):
            vecs.append(self.nlen * [0])
      for j in xrange(self.nlen):
        vecs[i][j] = self.data[j][map[i]]
            for j in range(self.nlen):
                vecs[i][j] = self.data[j][keylist[i]]

    if len(keys) == 1: return vecs[0]
    else: return vecs
        if len(keys) == 1:
            return vecs[0]
        else:
            return vecs

    # --------------------------------------------------------------------

    def write(self, filename, *keys):
        if len(keys):
      map = []
            keylist = []
            for key in keys:
        if self.ptr.has_key(key):
          map.append(self.ptr[key])
                if key in self.ptr:
                    keylist.append(self.ptr[key])
                else:
                    count = 0
                    for i in range(self.nvec):
@@ -149,17 +163,16 @@ class olog:
                            count += 1
                            index = i
                    if count == 1:
            map.append(index)
                        keylist.append(index)
                    else:
            raise StandardError, "unique log vector %s not found" % key
                        sys.exit("unique log vector %s not found" % key)
        else:
      map = range(self.nvec)
            keylist = range(self.nvec)

        f = open(filename, "w")
    for i in xrange(self.nlen):
      for j in xrange(len(map)):
        print >>f,self.data[i][map[j]],
      print >>f
        for i in range(self.nlen):
            for j in range(len(keylist)):
                f.write("{}\n".format(self.data[i][map[j]]))
        f.close()

    # --------------------------------------------------------------------
@@ -177,8 +190,10 @@ class olog:
    def cull(self):
        i = 1
        while i < len(self.data):
      if self.data[i][0] == self.data[i-1][0]: del self.data[i]
      else: i += 1
            if self.data[i][0] == self.data[i - 1][0]:
                del self.data[i]
            else:
                i += 1

    # --------------------------------------------------------------------

@@ -189,18 +204,20 @@ class olog:

        i = j = 0
        while i < len(self.data):
      if self.data[i][0] == 0: j = 0
            if self.data[i][0] == 0:
                j = 0
            if j >= nlen:
                counts.append(0)
                data.append(self.nvec * [0])
                nlen += 1
            counts[j] += 1
      for m in xrange(self.nvec): data[j][m] += self.data[i][m]
            for m in range(self.nvec):
                data[j][m] += self.data[i][m]
            j += 1
            i += 1

    for i in xrange(nlen):
      for j in xrange(self.nvec):
        for i in range(nlen):
            for j in range(self.nvec):
                data[i][j] /= counts[j]

        self.nlen = nlen
@@ -210,7 +227,7 @@ class olog:

    def read_header(self, file):
        if file[-3:] == ".gz":
      txt = popen("%s -c %s" % (PIZZA_GUNZIP,file),'r').read()
            txt = popen("%s -c %s" % (PIZZA_GUNZIP, file), "r").read()
        else:
            txt = open(file).read()

@@ -226,21 +243,24 @@ class olog:

    # --------------------------------------------------------------------

  def read_one(self,*list):
    def read_one(self, *args):

        # if 2nd arg exists set file ptr to that value
        # read entire (rest of) file into txt

    file = list[0]
        file = args[0]
        if file[-3:] == ".gz":
      f = popen("%s -c %s" % (PIZZA_GUNZIP,file),'rb')
            f = popen("%s -c %s" % (PIZZA_GUNZIP, file), "rb")
        else:
      f = open(file,'rb')
            f = open(file, "rb")

    if len(list) == 2: f.seek(list[1])
        if len(args) == 2:
            f.seek(args[1])
        txt = f.read()
    if file[-3:] == ".gz": eof = 0
    else: eof = f.tell()
        if file[-3:] == ".gz":
            eof = 0
        else:
            eof = f.tell()
        f.close()

        start = last = 0
@@ -256,23 +276,29 @@ class olog:
            s1 = txt.find(self.firststr, start)
            s2 = txt.find("Loop time of", start + 1)

      if s1 >= 0 and s2 >= 0 and s1 < s2:    # found s1,s2 with s1 before s2
            # found s1,s2 with s1 before s2
            if s1 >= 0 and s2 >= 0 and s1 < s2:
                s1 = txt.find("\n", s1) + 1
      elif s1 >= 0 and s2 >= 0 and s2 < s1:  # found s1,s2 with s2 before s1
            # found s1,s2 with s2 before s1
            elif s1 >= 0 and s2 >= 0 and s2 < s1:
                s1 = 0
      elif s1 == -1 and s2 >= 0:             # found s2, but no s1
            # found s2, but no s1
            elif s1 == -1 and s2 >= 0:
                last = 1
                s1 = 0
      elif s1 >= 0 and s2 == -1:             # found s1, but no s2
            # found s1, but no s2
            elif s1 >= 0 and s2 == -1:
                last = 1
                s1 = txt.find("\n", s1) + 1
                s2 = txt.rfind("\n", s1) + 1
                eof -= len(txt) - s2
      elif s1 == -1 and s2 == -1:            # found neither
            # found neither
            # could be end-of-file section
            # or entire read was one chunk
            elif s1 == -1 and s2 == -1:

        if txt.find("Loop time of",start) == start:   # end of file, so exit
                # end of file, so exit
                if txt.find("Loop time of", start) == start:
                    eof -= len(txt) - start  # reset eof to "Loop"
                    break

@@ -280,7 +306,8 @@ class olog:
                s1 = 0
                s2 = txt.rfind("\n", s1) + 1
                eof -= len(txt) - s2
	if s1 == s2: break
                if s1 == s2:
                    break

            chunk = txt[s1:s2-1]
            start = s2
@@ -295,7 +322,7 @@ class olog:

            # print last timestep of chunk

      print int(self.data[len(self.data)-1][0]),
            print(int(self.data[len(self.data) - 1][0]))
            sys.stdout.flush()

        return eof
+259 −230
Original line number Diff line number Diff line
@@ -5,12 +5,19 @@
# DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
# certain rights in this software.  This software is distributed under
# the GNU General Public License.

#
# pair tool
#
# History
#   8/05, Steve Plimpton and Paul Crozier (SNL): original version
#   9/05, Paul Crozier (SNL): added lj/cut and lj/cut/coul/cut
#
# ToDo list
#
# Variables

oneline = "Compute LAMMPS pairwise energies"

docstr = """
"""
Compute LAMMPS pairwise energies
p = pair("lj/charmm/coul/charmm")   create pair object for specific pair style

  available styles: lj/cut, lj/cut/coul/cut, lj/charmm/coul/charmm
@@ -33,20 +40,15 @@ e_vdwl,e_coul = p.single(rsq,itype,jtype,q1,q2,...) compute LJ/Coul energy
    lj/charmm/coul/charmm = rsq,itype,jtype,q1,q2
"""

# History
#   8/05, Steve Plimpton and Paul Crozier (SNL): original version
#   9/05, Paul Crozier (SNL): added lj/cut and lj/cut/coul/cut

# ToDo list

# Variables

# Imports and external programs

from math import sqrt
import sys
from numpy import sqrt

# Class definition


class pair:

    # --------------------------------------------------------------------
@@ -68,7 +70,7 @@ class pair:
            self.init_func = self.init_lj_charmm_coul_charmm
            self.single_func = self.single_lj_charmm_coul_charmm
        else:
      raise StandardError, "this pair style not yet supported"
            sys.exit("this pair style not yet supported")

    # --------------------------------------------------------------------
    # generic coeff method
@@ -79,14 +81,14 @@ class pair:
    # --------------------------------------------------------------------
    # generic init method, as many args as needed

  def init(self,*list):
    self.init_func(list)
    def init(self, *args):
        self.init_func(args)

    # --------------------------------------------------------------------
    # generic single method, as many args as needed

  def single(self,*list):
    return self.single_func(list)
    def single(self, *args):
        return self.single_func(args)

    # --------------------------------------------------------------------
    # --------------------------------------------------------------------
@@ -99,36 +101,40 @@ class pair:

        self.lj3 = []
        self.lj4 = []
    for i in xrange(ntypes):
        for i in range(ntypes):
            self.lj3.append(ntypes * [0])
            self.lj4.append(ntypes * [0])
      for j in xrange(ntypes):
            for j in range(ntypes):
                epsilon_ij = sqrt(epsilon[i] * epsilon[j])
                sigma_ij = sqrt(sigma[i] * sigma[j])
        self.lj3[i][j] = 4.0 * epsilon_ij * pow(sigma_ij,12.0);
        self.lj4[i][j] = 4.0 * epsilon_ij * pow(sigma_ij,6.0);
                self.lj3[i][j] = 4.0 * epsilon_ij * pow(sigma_ij, 12.0)
                self.lj4[i][j] = 4.0 * epsilon_ij * pow(sigma_ij, 6.0)

    # --------------------------------------------------------------------
    # args = cutlj

  def init_lj_cut(self,list):
    cut_lj = list[0]
    def init_lj_cut(self, args):
        cut_lj = args[0]
        self.cut_ljsq = cut_lj * cut_lj

    # --------------------------------------------------------------------
    # args = rsq,itype,jtype

  def single_lj_cut(self,list):
    rsq = list[0]
    itype = list[1]
    jtype = list[2]
    def single_lj_cut(self, args):
        rsq = args[0]
        itype = args[1]
        jtype = args[2]

        r2inv = 1.0 / rsq

        if rsq < self.cut_ljsq:
            r6inv = r2inv * r2inv * r2inv
      eng_vdwl = r6inv*(self.lj3[itype][jtype]*r6inv-self.lj4[itype][jtype])
    else: eng_vdwl = 0.0
            eng_vdwl = r6inv * (
                    self.lj3[itype][jtype] * r6inv
                    - self.lj4[itype][jtype]
                    )
        else:
            eng_vdwl = 0.0

        return eng_vdwl

@@ -143,46 +149,54 @@ class pair:

        self.lj3 = []
        self.lj4 = []
    for i in xrange(ntypes):
        for i in range(ntypes):
            self.lj3.append(ntypes * [0])
            self.lj4.append(ntypes * [0])
      for j in xrange(ntypes):
            for j in range(ntypes):
                epsilon_ij = sqrt(epsilon[i] * epsilon[j])
                sigma_ij = sqrt(sigma[i] * sigma[j])
        self.lj3[i][j] = 4.0 * epsilon_ij * pow(sigma_ij,12.0);
        self.lj4[i][j] = 4.0 * epsilon_ij * pow(sigma_ij,6.0);
                self.lj3[i][j] = 4.0 * epsilon_ij * pow(sigma_ij, 12.0)
                self.lj4[i][j] = 4.0 * epsilon_ij * pow(sigma_ij, 6.0)

    # --------------------------------------------------------------------
    # args = cutlj, cut_coul (cut_coul optional)

  def init_lj_cut_coul_cut(self,list):
    def init_lj_cut_coul_cut(self, args):
        self.qqr2e = 332.0636  # convert energy to kcal/mol
    cut_lj = list[0]
        cut_lj = args[0]
        self.cut_ljsq = cut_lj * cut_lj

    if len(list) == 1: cut_coul = cut_lj
    else: cut_coul = list[1]
        if len(args) == 1:
            cut_coul = cut_lj
        else:
            cut_coul = args[1]
        self.cut_coulsq = cut_coul * cut_coul

    # --------------------------------------------------------------------
    # args = rsq,itype,jtype,q1,q2

  def single_lj_cut_coul_cut(self,list):
    rsq = list[0]
    itype = list[1]
    jtype = list[2]
    q1 = list[3]
    q2 = list[4]
    def single_lj_cut_coul_cut(self, args):
        rsq = args[0]
        itype = args[1]
        jtype = args[2]
        q1 = args[3]
        q2 = args[4]

        r2inv = 1.0 / rsq

    if rsq < self.cut_coulsq: eng_coul = self.qqr2e * q1*q2*sqrt(r2inv)
    else: eng_coul = 0.0
        if rsq < self.cut_coulsq:
            eng_coul = self.qqr2e * q1 * q2 * sqrt(r2inv)
        else:
            eng_coul = 0.0

        if rsq < self.cut_ljsq:
            r6inv = r2inv * r2inv * r2inv
      eng_vdwl = r6inv*(self.lj3[itype][jtype]*r6inv-self.lj4[itype][jtype])
    else: eng_vdwl = 0.0
            eng_vdwl = r6inv * (
                    self.lj3[itype][jtype] * r6inv
                    - self.lj4[itype][jtype]
                    )
        else:
            eng_vdwl = 0.0

        return eng_coul, eng_vdwl

@@ -197,71 +211,86 @@ class pair:

        self.lj3 = []
        self.lj4 = []
    for i in xrange(ntypes):
        for i in range(ntypes):
            self.lj3.append(ntypes * [0])
            self.lj4.append(ntypes * [0])
      for j in xrange(ntypes):
            for j in range(ntypes):
                epsilon_ij = sqrt(epsilon[i] * epsilon[j])
                sigma_ij = 0.5 * (sigma[i] + sigma[j])
        self.lj3[i][j] = 4.0 * epsilon_ij * pow(sigma_ij,12.0);
        self.lj4[i][j] = 4.0 * epsilon_ij * pow(sigma_ij,6.0);
                self.lj3[i][j] = 4.0 * epsilon_ij * pow(sigma_ij, 12.0)
                self.lj4[i][j] = 4.0 * epsilon_ij * pow(sigma_ij, 6.0)

    # --------------------------------------------------------------------
    # args = cutlj_inner,cutlj,cutcoul_inner,cut_coul (last 2 optional)

  def init_lj_charmm_coul_charmm(self,list):
    def init_lj_charmm_coul_charmm(self, args):
        self.qqr2e = 332.0636  # convert energy to kcal/mol
    cut_lj_inner = list[0]
    cut_lj = list[1]
        cut_lj_inner = args[0]
        cut_lj = args[1]

        self.cut_lj_innersq = cut_lj_inner * cut_lj_inner
        self.cut_ljsq = cut_lj * cut_lj

    if len(list) == 2:
        if len(args) == 2:
            cut_coul_inner = cut_lj_inner
            cut_coul = cut_lj
        else:
      cut_coul_inner = list[2]
      cut_coul = list[3]
            cut_coul_inner = args[2]
            cut_coul = args[3]
        self.cut_coul_innersq = cut_coul_inner * cut_coul_inner
        self.cut_coulsq = cut_coul * cut_coul

    self.denom_lj = (self.cut_ljsq-self.cut_lj_innersq) *  \
      (self.cut_ljsq-self.cut_lj_innersq) *  \
      (self.cut_ljsq-self.cut_lj_innersq);
    self.denom_coul = (self.cut_coulsq-self.cut_coul_innersq) *  \
      (self.cut_coulsq-self.cut_coul_innersq) *  \
      (self.cut_coulsq-self.cut_coul_innersq);
        self.denom_lj = (
            (self.cut_ljsq - self.cut_lj_innersq)
            * (self.cut_ljsq - self.cut_lj_innersq)
            * (self.cut_ljsq - self.cut_lj_innersq)
        )
        self.denom_coul = (
            (self.cut_coulsq - self.cut_coul_innersq)
            * (self.cut_coulsq - self.cut_coul_innersq)
            * (self.cut_coulsq - self.cut_coul_innersq)
        )

    # --------------------------------------------------------------------
    # args = rsq,itype,jtype,q1,q2

  def single_lj_charmm_coul_charmm(self,list):
    rsq = list[0]
    itype = list[1]
    jtype = list[2]
    q1 = list[3]
    q2 = list[4]
    def single_lj_charmm_coul_charmm(self, args):
        rsq = args[0]
        itype = args[1]
        jtype = args[2]
        q1 = args[3]
        q2 = args[4]

        r2inv = 1.0 / rsq

        if rsq < self.cut_coulsq:
            eng_coul = self.qqr2e * q1 * q2 * sqrt(r2inv)
            if rsq > self.cut_coul_innersq:
        switch1 = (self.cut_coulsq-rsq) * (self.cut_coulsq-rsq) *  \
                  (self.cut_coulsq + 2.0*rsq - 3.0*self.cut_coul_innersq) /  \
                  self.denom_coul
                switch1 = (
                    (self.cut_coulsq - rsq)
                    * (self.cut_coulsq - rsq)
                    * (self.cut_coulsq + 2.0*rsq - 3.0*self.cut_coul_innersq)
                    / self.denom_coul
                )
                eng_coul *= switch1
    else: eng_coul = 0.0
        else:
            eng_coul = 0.0

        if rsq < self.cut_ljsq:
            r6inv = r2inv * r2inv * r2inv
      eng_vdwl = r6inv*(self.lj3[itype][jtype]*r6inv-self.lj4[itype][jtype])
            eng_vdwl = r6inv * (
                    self.lj3[itype][jtype] * r6inv
                    - self.lj4[itype][jtype]
                    )
            if rsq > self.cut_lj_innersq:
        switch1 = (self.cut_ljsq-rsq) * (self.cut_ljsq-rsq) *  \
                  (self.cut_ljsq + 2.0*rsq - 3.0*self.cut_lj_innersq) /  \
                  self.denom_lj
                switch1 = (
                    (self.cut_ljsq - rsq)
                    * (self.cut_ljsq - rsq)
                    * (self.cut_ljsq + 2.0 * rsq - 3.0 * self.cut_lj_innersq)
                    / self.denom_lj
                )
                eng_vdwl *= switch1
    else: eng_vdwl = 0.0
        else:
            eng_vdwl = 0.0

        return eng_coul, eng_vdwl
+2038 −1579

File changed.

Preview size limit exceeded, changes collapsed.

+172 −156
Original line number Diff line number Diff line
@@ -5,12 +5,29 @@
# DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
# certain rights in this software.  This software is distributed under
# the GNU General Public License.

#
# plotview tool
#
#
#
# History
#   8/05, Matt Jones (BYU): original version
#
# ToDo list
#   option to plot all N vectors against linear index?
#
# Variables
#   source = source of vector data
#   plot = plotting object
#   nplots = # of plots (not including 1st vector)
#   names = names of plots (from vector source)
#   radiovar = index of clicked radio button (0 = none, 1-N)
#   checkbuttons = list of check button objects
#   checkvars = list of status of check buttons
#   checkold = list of status of check buttons before click

oneline = "Plot multiple vectors from a data set"

docstr = """
"""
Plot multiple vectors from a data set
p = plotview(d,pl)      create GUI for viewing plots

  d = Pizza.py object that contains vectors (log, vec)
@@ -30,29 +47,17 @@ p.file("pressure") filename prefix for saving a plot
p.save()                save currently selected plot to file.eps
"""

# History
#   8/05, Matt Jones (BYU): original version

# ToDo list
#   option to plot all N vectors against linear index?

# Variables
#   source = source of vector data
#   plot = plotting object
#   nplots = # of plots (not including 1st vector)
#   names = names of plots (from vector source)
#   radiovar = index of clicked radio button (0 = none, 1-N)
#   checkbuttons = list of check button objects
#   checkvars = list of status of check buttons
#   checkold = list of status of check buttons before click

# Imports and external programs

import sys, re, glob, time
from Tkinter import *
import sys
import re
import glob
import time
import tkinter as tk

# Class definition


class plotview:

    # --------------------------------------------------------------------
@@ -63,27 +68,29 @@ class plotview:

        # create GUI

    from __main__ import tkroot
    root = Toplevel(tkroot)
    root.title('Pizza.py plotview tool')
        # from __main__ import tkroot

    self.frame1 = Frame(root)
    self.frame2 = Frame(root)
    self.frame3 = Frame(root)
        tkroot = tk.Tk()
        root = tk.Toplevel(tkroot)
        root.title("Pizza.py plotview tool")

    Button(self.frame1,text="Print As:",command=self.save).pack(side=TOP)
    self.entry = Entry(self.frame1,width=16)
        self.frame1 = tk.Frame(root)
        self.frame2 = tk.Frame(root)
        self.frame3 = tk.Frame(root)

        tk.Button(self.frame1, text="Print As:", command=self.save).pack(side=tk.TOP)
        self.entry = tk.Entry(self.frame1, width=16)
        self.entry.insert(0, "tmp")
    self.entry.pack(side=TOP)
        self.entry.pack(side=tk.TOP)

    Label(self.frame2,text="Select").pack(side=LEFT)
    Label(self.frame2,text = "Display").pack(side=RIGHT)
        tk.Label(self.frame2, text="Select").pack(side=tk.LEFT)
        tk.Label(self.frame2, text="Display").pack(side=tk.RIGHT)

        self.nplots = source.nvec
        self.names = source.names
        self.x = self.names[0]

    self.radiovar = IntVar()
        self.radiovar = tk.IntVar()
        self.checkbuttons = []
        self.checkvars = []
        self.checkold = []
@@ -98,24 +105,29 @@ class plotview:
            self.plot.ytitle(self.names[i])
            self.plot.title(self.names[i])

      b = BooleanVar()
            b = tk.BooleanVar()
            b.set(0)
            self.checkvars.append(b)
            self.checkold.append(0)

      line = Frame(self.frame3)
            line = tk.Frame(self.frame3)
            rtitle = "%d %s" % (i + 1, self.names[i])
      Radiobutton(line, text=rtitle, value=i+1, variable=self.radiovar,
                  command=self.radioselect).pack(side=LEFT)
      cbutton = Checkbutton(line, variable=b, command=self.check)
      cbutton.pack(side=RIGHT)
            tk.Radiobutton(
                line,
                text=rtitle,
                value=i + 1,
                variable=self.radiovar,
                command=self.radioselect,
            ).pack(side=tk.LEFT)
            cbutton = tk.Checkbutton(line, variable=b, command=self.check)
            cbutton.pack(side=tk.RIGHT)
            self.checkbuttons.append(cbutton)
      line.pack(side=TOP,fill=X)
            line.pack(side=tk.TOP, fill=tk.X)

        self.radiovar.set(0)
    self.frame1.pack(side=TOP)
    self.frame2.pack(side=TOP,fill=X)
    self.frame3.pack(side=TOP,fill=X)
        self.frame1.pack(side=tk.TOP)
        self.frame2.pack(side=tk.TOP, fill=tk.X)
        self.frame3.pack(side=tk.TOP, fill=tk.X)

    # --------------------------------------------------------------------
    # set radio button and checkbox
@@ -129,13 +141,15 @@ class plotview:
    # only invoke if currently unset

    def yes(self, n):
    if not self.checkvars[n-1].get(): self.checkbuttons[n-1].invoke()
        if not self.checkvars[n - 1].get():
            self.checkbuttons[n - 1].invoke()

    # --------------------------------------------------------------------
    # only invoke if currently set

    def no(self, n):
    if self.checkvars[n-1].get(): self.checkbuttons[n-1].invoke()
        if self.checkvars[n - 1].get():
            self.checkbuttons[n - 1].invoke()

    # --------------------------------------------------------------------

@@ -148,7 +162,8 @@ class plotview:

    def save(self):
        n = self.radiovar.get()
    if n == 0: raise StandardError,"no plot selected"
        if n == 0:
            sys.exit("no plot selected")
        name = self.entry.get()
        self.plot.save(name)

@@ -174,7 +189,8 @@ class plotview:
                    x, y = self.source.get(self.x, self.names[i])
                    self.plot.plot(x, y)
                else:
          if self.radiovar.get() == i+1: self.radiovar.set(0)
                    if self.radiovar.get() == i + 1:
                        self.radiovar.set(0)
                    self.plot.hide(i + 1)
                self.checkold[i] = int(self.checkvars[i].get())

Loading