1#!/usr/bin/env python
2
3#
4# Example of python script for processing of DMHS netcdf files.
5#
6# -- plot "time evolution" of DM_in and DM_out for a particular
7#    orbital pair, entered as an "element number".
8#
9
10from Numeric import *
11from Scientific.IO.NetCDF import *
12##import biggles
13import Gnuplot, Gnuplot.funcutils
14import sys
15
16#
17fname=sys.argv[1]
18try:
19    element=int(sys.argv[2])
20except:
21    element=0
22
23print "File, element:", fname, element
24
25of = NetCDFFile(fname)
26print "Dimensions:", of.dimensions
27
28#
29dmin=of.variables['dm_in'][1:,0,element]
30dmout=of.variables['dm_out'][1:,0,element]
31
32nsteps = len(dmin)
33print nsteps
34
35step = arrayrange(nsteps)
36
37#p=biggles.FramedPlot(title=fname)
38#p.add(biggles.Curve(step,dmin,color="red"))
39#p.add(biggles.Curve(step,dmout,color="blue"))
40#p.show()
41#p.save_as_img( "gif", 400, 400, fname+".temp.gif" )
42
43
44g = Gnuplot.Gnuplot(debug=1)
45g.title('A simple example') # (optional)
46g('set data style lines') # give gnuplot an arbitrary command
47d1 = Gnuplot.Data(step,dmin)
48d2 = Gnuplot.Data(step,dmout)
49g.plot(d1,d2)
50
51raw_input('Please press return to continue...\n')
52