--- /dev/null 2004-02-18 08:26:44.000000000 -0700 +++ /home/sjplimp/pizza/src/histo.py 2005-12-20 15:06:56.000000000 -0700 @@ -0,0 +1,86 @@ +# Pizza.py toolkit, www.cs.sandia.gov/~sjplimp/pizza.html +# Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories +# +# Copyright (2005) Sandia Corporation. Under the terms of Contract +# 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. + +# histo tool + +oneline = "Particle density histogram from a dump" + +docstr = """ +h = histo(d) d = dump/cdump object + +x,y = h.compute('x',N,lo,hi) compute histogram in dim with N bins + + lo/hi are optional, if not used histo will be over entire box +""" + +# History +# 12/05, Steve Plimpton (SNL): original version + +# ToDo list + +# Variables +# data = dump object + +# Imports and external programs + +# Class definition + +class histo: + + # -------------------------------------------------------------------- + + def __init__(self,data): + self.data = data + + # -------------------------------------------------------------------- + + def compute(self,dim,nbins,lo=None,hi=None): + if dim == 'x': idim = 2 + elif dim == 'y': idim = 3 + elif dim == 'z': idim = 4 + else: raise StandardError,"illegal dim value" + + y = nbins*[0] + + count = 0 + n = flag = 0 + while 1: + which,time,flag = self.data.iterator(flag) + if flag == -1: break + time,box,atoms,bonds,tris,lines = self.data.viz(which) + + if not lo: + if dim == 'x': + lo = box[0] + hi = box[3] + elif dim == 'y': + lo = box[1] + hi = box[4] + elif dim == 'z': + lo = box[2] + hi = box[5] + + delta = (hi-lo) / nbins; + invdelta = 1.0/delta + + for atom in atoms: + coord = atom[idim] + ibin = int((coord-lo) * invdelta) + if ibin < 0 or ibin >= nbins: continue + y[ibin] += 1 + count += 1 + + n += 1 + + x = nbins*[0] + for i in xrange(nbins): x[i] = (i+0.5)*delta + + print "histogram snapshots = ",n + print "histogram counts (per snap) = %d (%g)" % (count,float(count)/n) + print "histogram bounds = ",lo,hi + return x,y --- /dev/null 2004-02-18 08:26:44.000000000 -0700 +++ /home/sjplimp/pizza/doc/histo.txt 2005-12-20 15:07:04.000000000 -0700 @@ -0,0 +1,40 @@ +"Pizza.py WWW Site"_pws - "Pizza.py Documentation"_pd - "Pizza.py Tools"_pc :c + +:link(pws,http://www.cs.sandia.gov/~sjplimp/pizza.html) +:link(pd,Manual.html) +:link(pc,Section_tools.html) + +:line + +histo tool :h3 + +[Purpose:] + +Particle density histogram from a dump. + +[Description:] + +The histo tool creates spatial histograms of particle snapshots in +a dump file. + +The histo constructor takes an object that stores atom snapshots +("dump"_dump.html, "data"_data.html) as its argument. + +The compute() method creates a histogram in a specific dimension at a +desired resolution, averaged across all selected snapshots and atoms +in the dump. The returned vectors can be plotted; x is the distance +along the chosen dimension, y is the histogram counts. + +[Usage:] + +h = histo(d) d = dump/cdump object :pre + +x,y = h.compute('x',N,lo,hi) compute histogram in dim with N bins :pre + + lo/hi are optional, if not used histo will be over entire box :pre + +[Related tools:] + +"dump"_dump.html + +[Prerequisites:] none --- /dev/null 2004-02-18 08:26:44.000000000 -0700 +++ /home/sjplimp/pizza/doc/histo.html 2005-12-20 15:08:32.000000000 -0700 @@ -0,0 +1,45 @@ + +
Purpose: +
+Particle density histogram from a dump. +
+Description: +
+The histo tool creates spatial histograms of particle snapshots in +a dump file. +
+The histo constructor takes an object that stores atom snapshots +(dump, data) as its argument. +
+The compute() method creates a histogram in a specific dimension at a +desired resolution, averaged across all selected snapshots and atoms +in the dump. The returned vectors can be plotted; x is the distance +along the chosen dimension, y is the histogram counts. +
+Usage: +
+h = histo(d) d = dump/cdump object ++
x,y = h.compute('x',N,lo,hi) compute histogram in dim with N bins
+
+lo/hi are optional, if not used histo will be over entire box ++
Related tools: +
+dump +
+Prerequisites: none +
+ --- /home/sjplimp/oldpizza/doc/Section_tools.txt 2005-11-07 17:10:41.000000000 -0700 +++ /home/sjplimp/pizza/doc/Section_tools.txt 2005-12-20 15:08:24.000000000 -0700 @@ -25,7 +25,7 @@ File conversion: pdb, vtk, xyz GUI wrappers: animate, image, plotview, vcr Plotting: gnu, matlab -Miscellaneous: pair, vec :tb(s=:) +Miscellaneous: histo, pair, vec :tb(s=:) Within the plotting and viz categories, individual tools share many common methods, so the tools can often be used interchangeably. For @@ -43,6 +43,7 @@ "dump.py"_dump.html; Read, write, manipulate LAMMPS dump files and atom attributes "gl.py"_gl.html; 3d interactive visualization via OpenGL "gnu.py"_gnu.html; Create plots via "GnuPlot"_gnuplot plotting program +"histo.py"_histo.html; Particle density histogram from a dump "image.py"_image.html; View and manipulate images "log.py"_log.html; Read LAMMPS log files and extract thermodynamic data "matlab.py"_matlab.html; Create plots via "MatLab"_matlab numerical analysis program --- /home/sjplimp/oldpizza/doc/Section_tools.html 2005-11-07 17:10:41.000000000 -0700 +++ /home/sjplimp/pizza/doc/Section_tools.html 2005-12-20 15:08:32.000000000 -0700 @@ -29,7 +29,7 @@Within the plotting and viz categories, individual tools share many @@ -49,6 +49,7 @@
List of tools in Pizza.py:
| dump.py | Read, write, manipulate LAMMPS dump files and atom attributes |
| gl.py | 3d interactive visualization via OpenGL |
| gnu.py | Create plots via GnuPlot plotting program |
| histo.py | Particle density histogram from a dump |
| image.py | View and manipulate images |
| log.py | Read LAMMPS log files and extract thermodynamic data |
| matlab.py | Create plots via MatLab numerical analysis program |