Skip to content

Commit

Permalink
Movements on converting xplt.
Browse files Browse the repository at this point in the history
  • Loading branch information
teoliphant committed Nov 3, 2005
1 parent 53267f3 commit 8afa3a1
Show file tree
Hide file tree
Showing 55 changed files with 246 additions and 138 deletions.
14 changes: 8 additions & 6 deletions Lib/sandbox/xplt/GistPlotter.py
@@ -1,9 +1,11 @@
## Automatically adapted for scipy Oct 31, 2005 by

# Copyright (c) 1996, 1997, The Regents of the University of California.
# All rights reserved. See Legal.htm for full text and disclaimer.

from gist import *
from shapetest import *
from Numeric import *
from scipy import *
from scipy_base.fastumath import *
from graftypes import *
from movie import *
Expand Down Expand Up @@ -950,7 +952,7 @@ def _plot_quadmesh ( self , crv ) :
# Use byte scale
(k, l) = shape (crv.z)
_z_ = reshape (bytscl (reshape (crv.z, (k * l,)),
cmin = self._cmin, cmax = self._cmax), (k, l)).astype('b')
cmin = self._cmin, cmax = self._cmax), (k, l)).astype('B')
else :
_z_ = crv.z
if _color_bar_ :
Expand Down Expand Up @@ -1087,7 +1089,7 @@ def _plot_by_regions ( self , crv ) :
# back to 2d.
(k, l) = shape (crv.z)
_z_ = reshape (bytscl (reshape (crv.z, (k * l, )),
cmin = self._cmin, cmax = self._cmax), (k, l)).astype('b')
cmin = self._cmin, cmax = self._cmax), (k, l)).astype('B')
else :
_z_ = crv.z
plf (array (_z_).astype (Float),
Expand Down Expand Up @@ -1697,18 +1699,18 @@ def plot3d (self, graf, draw = 1) :
if s.plane is not None :
pl3tree (s.nv, s.xyzv,
split_bytscl (fval, upper = 0, cmin = zmin,
cmax = zmax).astype('b'), s.plane,
cmax = zmax).astype('B'), s.plane,
cmin = zmin, cmax = zmax, split = 0,
edges = edges)
else :
pl3tree (s.nv, s.xyzv,
split_bytscl (fval, upper = 1, cmin = zmin,
cmax = zmax).astype('b'), s.plane,
cmax = zmax).astype('B'), s.plane,
cmin = zmin, cmax = zmax, split = 0,
edges = edges)
else :
pl3tree (s.nv, s.xyzv, bytscl (fval, top = 199,
cmin = zmin, cmax = zmax).astype('b'), s.plane,
cmin = zmin, cmax = zmax).astype('B'), s.plane,
cmin = zmin, cmax = zmax, split = 0,
edges = edges)
else :
Expand Down
32 changes: 17 additions & 15 deletions Lib/sandbox/xplt/Graphics.py
@@ -1,7 +1,9 @@
## Automatically adapted for scipy Oct 31, 2005 by

#import Tkinter
#from Tkinter import *
#from Scientific.TkWidgets.TkPlotCanvas import *
from Numeric import *
from scipy import *
from scipy_base.fastumath import *
#from _Graphics import *
#import PIL.ImageTk,PIL.Image
Expand All @@ -22,26 +24,26 @@ def read_act(filename):
Palette = {}

def make_palettes():
p = arange(0,256,1,typecode='b')[:,NewAxis] * \
ones((3,),typecode='b')[NewAxis,:]
p = arange(0,256,1,dtype='B')[:,NewAxis] * \
ones((3,),dtype='B')[NewAxis,:]
Palette['gray'] = p

p = arange(0,256,1,typecode='b')[:,NewAxis] * \
array([0,0,1],typecode='b')[NewAxis,:]
p = arange(0,256,1,dtype='B')[:,NewAxis] * \
array([0,0,1],dtype='B')[NewAxis,:]
Palette['blue'] = p

p = arange(0,256,1,typecode='b')[:,NewAxis] * \
array([1,0,0],typecode='b')[NewAxis,:]
p = arange(0,256,1,dtype='B')[:,NewAxis] * \
array([1,0,0],dtype='B')[NewAxis,:]
Palette['red'] = p

p = arange(0,256,1,typecode='b')[:,NewAxis] * \
array([0,1,0],typecode='b')[NewAxis,:]
p = arange(0,256,1,dtype='B')[:,NewAxis] * \
array([0,1,0],dtype='B')[NewAxis,:]
Palette['green'] = p

p = zeros((256,3),'b')
p = zeros((256,3),'B')
dp = (256-40)/128.0
p[:128,2] = arange(40,256,dp,typecode='b')[::-1]
p[128:,0] = arange(40,256,dp,typecode='b')
p[:128,2] = arange(40,256,dp,dtype='B')[::-1]
p[128:,0] = arange(40,256,dp,dtype='B')
Palette['wave'] = p

Palette['Aaasmo'] = read_act('%s/Research/Library/Python/Graphics/Aaasmo'% os.environ['HOME'])
Expand All @@ -52,7 +54,7 @@ def _interpolate_colormap(p,num):
assert(p.shape[1]<=3)
pf = p.astype('d')
pfnew = signaltools.resample(pf,num,axis=0)
return pfnew.astype('b')
return pfnew.astype('B')

def read_gist_palettes():
import commands
Expand Down Expand Up @@ -94,7 +96,7 @@ def _makewavebytes(data,bot,top,cmin,cmax):

bytelow = (mid-bot)/(0.0-cmin) * data + mid
bytehigh = (top - mid)/(cmax-0.0) * data + mid
bytedata = where(greater(data,0),bytehigh,bytelow).astype('b')
bytedata = where(greater(data,0),bytehigh,bytelow).astype('B')

return bytedata

Expand All @@ -114,7 +116,7 @@ def _makewavebytes(data,bot,top,cmin,cmax):
## shape = (size[1],size[0])
## image = Image.fromstring("L",shape,bytedata.tostring())
## if p is not None:
## image.putpalette(asarray(p,typecode='b').tostring())
## image.putpalette(asarray(p,dtype='B').tostring())
## return image

def write_frames(data,filename,dim=0,expand=None,cmin=None,cmax=None,p=None):
Expand Down
36 changes: 19 additions & 17 deletions Lib/sandbox/xplt/Mplot.py
@@ -1,20 +1,22 @@
## Automatically adapted for scipy Oct 31, 2005 by

# 1998 - 2003
# Author: Travis Oliphant
# Copyright: SciPy

import gist
import pl3d, plwf
import Numeric
from Numeric import ravel, reshape, repeat, arange, transpose, compress, \
import scipy as Numeric
from scipy import ravel, reshape, repeat, arange, transpose, compress, \
where, ones, NewAxis, asarray
import MLab
from MLab import pi, cos, sin, arctan2, array, angle
import scipy.basic.linalg as MLab
from scipy.basic.linalg import pi, cos, sin, arctan2, array, angle
import types
import write_style
points = 0.0013000
inches = 72.27*points
import scipy
import scipy_base
import scipy.base as scipy_base
import scipy.signal as signal
from scipy.xplt import maxwidth as _maxwidth
from scipy.xplt import maxheight as _maxheight
Expand Down Expand Up @@ -161,8 +163,8 @@ def reverse_dict(dict):

_colornum = {'black':-3, 'white':-4,'red':-5,'green':-6,'blue':-7,'cyan':-8,'magenta':-9,'yellow':-10}
_types = {'-':'solid','|':'dash',':':'dot','-.':'dashdot','-:':'dashdotdot'}
_corder = ['b','r','m','g','c','k','y']
_colors = {'k':'black','r':'red','b':'blue','m':'magenta','g':'green','y':'yellow','c':'cyan','w':'white'}
_corder = ['B','r','m','g','c','k','y']
_colors = {'k':'black','r':'red','B':'blue','m':'magenta','g':'green','y':'yellow','c':'cyan','w':'white'}
_markers = { '+':'\2','.':'\1','*':'\3','o':'\4','x':'\5'}
_current_style='work.gs'

Expand Down Expand Up @@ -214,7 +216,7 @@ def barplot(x,y,width=0.8,color=0):
else:
gist.fma()
Z = color * Numeric.ones(len(N))
gist.plfp(Z.astype('b'),Y,X,N)
gist.plfp(Z.astype('B'),Y,X,N)
return

def hold(state):
Expand All @@ -236,7 +238,7 @@ def hold(state):
return


def errorbars(x,y,err,ptcolor='r',linecolor='b',pttype='o',linetype='-',fac=0.25):
def errorbars(x,y,err,ptcolor='r',linecolor='B',pttype='o',linetype='-',fac=0.25):
"""Draw connected points with errorbars.
Description:
Expand Down Expand Up @@ -474,7 +476,7 @@ def arrow(x0,y0,x1,y1,color=0,ang=45.0,height=6,width=1.5,lc=None):
y1a = y1 + hypot*sin(tha) / conv_factory
y1b = y1 + hypot*sin(thb) / conv_factory
gist.pldj([x0],[y0],[x1],[y1],color=lc,width=width)
gist.plfp(array([color],'b'),[y1,y1a,y1b],[x1,x1a,x1b],[3])
gist.plfp(array([color],'B'),[y1,y1a,y1b],[x1,x1a,x1b],[3])
return

def _parse_type_arg(thearg,nowplotting):
Expand Down Expand Up @@ -645,7 +647,7 @@ def addbox(x0,y0,x1,y1,color='black',width=1,type='-'):

def write_palette(tofile,pal):
pal = Numeric.asarray(pal)
if pal.typecode() not in ['b','1','s','i','l']:
if pal.dtypechar not in ['B','b','s','i','l']:
raise ValueError, "Palette data must be integer data."
palsize = pal.shape
if len(palsize) > 2:
Expand All @@ -657,7 +659,7 @@ def write_palette(tofile,pal):
pal = pal[:,0]
palsize = pal.shape
if len(palsize) == 1:
pal = Numeric.multiply.outer(pal,ones((3,),pal.typecode()))
pal = Numeric.multiply.outer(pal,ones((3,),pal.dtypechar))
palsize = pal.shape
if not (palsize[1] == 3 or palsize[0] == 3):
raise TypeError, "If input is 2-d, the length of at least one dimension must be 3."
Expand Down Expand Up @@ -712,7 +714,7 @@ def change_palette(pal):
raise ValueError, "Palette %s not found." % pal
else:
data = Numeric.transpose(Numeric.asarray(pal))
data = data.astype('b')
data = data.astype('B')
gist.palette(*transpose(data))
#filename = os.path.join(_user_path,'_temp.gp')
#write_palette(filename,data)
Expand All @@ -724,7 +726,7 @@ def matview(A,cmax=None,cmin=None,palette=None,color='black'):
"""Plot an image of a matrix.
"""
A = Numeric.asarray(A)
if A.typecode() in ['D','F']:
if A.dtypechar in ['D','F']:
print "Warning: complex array given, plotting magnitude."
A = abs(A)
M,N = A.shape
Expand All @@ -750,12 +752,12 @@ def matview(A,cmax=None,cmin=None,palette=None,color='black'):
# bottom left corner column
posy = -ays*(byv-ayv)/(bys-ays) + ayv
posx = -axs*(bxv-axv)/(bxs-axs) + axv
gist.plt('1',posx,posy-0.005,justify='LT',color=color)
gist.plt('b',posx,posy-0.005,justify='LT',color=color)
# bottom left corner row
gist.plt(str(M),posx-0.005,posy,justify='RB',color=color)
# top left corner row
posy = (M-ays)*(byv-ayv)/(bys-ays) + ayv
gist.plt('1',posx-0.005,posy,justify='RT',color=color)
gist.plt('b',posx-0.005,posy,justify='RT',color=color)
# bottom right column
posy = -ays*(byv-ayv)/(bys-ays) + ayv
posx = (N-axs)*(bxv-axv)/(bxs-axs) + axv
Expand Down Expand Up @@ -1137,7 +1139,7 @@ def title3(text,color=None,font='helvetica',fontsize=18,deltax=0.0,deltay=0.0):
height=fontsize, color=color)

def stem(m, y, linetype='b-', mtype='mo', shift=0.013):
y0 = Numeric.zeros(len(y),y.typecode())
y0 = Numeric.zeros(len(y),y.dtypechar)
y1 = y
x0 = m
x1 = m
Expand Down
4 changes: 3 additions & 1 deletion Lib/sandbox/xplt/NarPlotter.py
@@ -1,8 +1,10 @@
## Automatically adapted for scipy Oct 31, 2005 by

# Copyright (c) 1996, 1997, The Regents of the University of California.
# All rights reserved. See Legal.htm for full text and disclaimer.

import narcisse
from Numeric import *
from scipy import *
from scipy_base.fastumath import *
# We need types to check args to some routines
from types import *
Expand Down
2 changes: 2 additions & 0 deletions Lib/sandbox/xplt/__init__.py
@@ -1,3 +1,5 @@
## Automatically adapted for scipy Oct 31, 2005 by


from info_xplt import __doc__

Expand Down
4 changes: 3 additions & 1 deletion Lib/sandbox/xplt/animation2d.py
@@ -1,7 +1,9 @@
## Automatically adapted for scipy Oct 31, 2005 by

# Copyright (c) 1996, 1997, The Regents of the University of California.
# All rights reserved. See Legal.htm for full text and disclaimer.

from Numeric import *
from scipy import *
from scipy_base.fastumath import *
from shapetest import *
from graftypes import *
Expand Down
4 changes: 3 additions & 1 deletion Lib/sandbox/xplt/berts.py
@@ -1,7 +1,9 @@
## Automatically adapted for scipy Oct 31, 2005 by

# Copyright (c) 1996, 1997, The Regents of the University of California.
# All rights reserved. See Legal.htm for full text and disclaimer.

from Numeric import *
from scipy import *
from scipy_base.fastumath import *
from mesh3d import Mesh3d
from graph3d import Graph3d
Expand Down
4 changes: 3 additions & 1 deletion Lib/sandbox/xplt/cellarray.py
@@ -1,8 +1,10 @@
## Automatically adapted for scipy Oct 31, 2005 by

# Copyright (c) 1996, 1997, The Regents of the University of California.
# All rights reserved. See Legal.htm for full text and disclaimer.

# The following is so I know about arrays:
from Numeric import *
from scipy import *
from scipy_base.fastumath import *
from shapetest import *
from graftypes import *
Expand Down
8 changes: 5 additions & 3 deletions Lib/sandbox/xplt/colorbar.py
@@ -1,8 +1,10 @@
## Automatically adapted for scipy Oct 31, 2005 by

# Copyright (c) 1996, 1997, The Regents of the University of California.
# All rights reserved. See Legal.htm for full text and disclaimer.

# ed williams' colorbar stuff
from Numeric import *
from scipy import *
from scipy_base.fastumath import *
from arrayfns import *
from gist import *
Expand Down Expand Up @@ -56,14 +58,14 @@ def color_bar (minz, maxz, split = 0, ncol = None, ymax=0.85, ymin=0.44, xmin0=0
ncol = 100 + (1 - split) * 100
plsys (0)
if type (minz) == type (maxz) == type (1) : # Do not change!!!
plotval = reshape (arange (minz, maxz + 1, typecode = 'b'),
plotval = reshape (arange (minz, maxz + 1, typecode = 'B'),
(maxz + 1 - minz, 1))
pli (plotval, xmin0, ymin, xmax0, ymax) # draw bar
elif not split :
pli (reshape (span (0, 1, ncol), (ncol, 1)),
xmin0, ymin, xmax0, ymax) # draw bar
else :
pli (reshape (split_bytscl (span (0, 1, ncol), 0).astype ('b'), (ncol, 1)),
pli (reshape (split_bytscl (span (0, 1, ncol), 0).astype ('B'), (ncol, 1)),
xmin0, ymin, xmax0, ymax) # draw bar
pldj (array ( [xmin0, xmin0]), array ( [ymin, ymax]), array ( [xmax0, xmax0]),
array ( [ymin, ymax]), color=color)
Expand Down
2 changes: 2 additions & 0 deletions Lib/sandbox/xplt/config_pygist.py
@@ -1,3 +1,5 @@
## Automatically adapted for scipy Oct 31, 2005 by


import os
import sys
Expand Down
4 changes: 3 additions & 1 deletion Lib/sandbox/xplt/curve.py
@@ -1,8 +1,10 @@
## Automatically adapted for scipy Oct 31, 2005 by

# Copyright (c) 1996, 1997, The Regents of the University of California.
# All rights reserved. See Legal.htm for full text and disclaimer.

# The following is so I know about arrays:
from Numeric import *
from scipy import *
from scipy_base.fastumath import *
from shapetest import *
from graftypes import *
Expand Down
4 changes: 3 additions & 1 deletion Lib/sandbox/xplt/demo5.py
@@ -1,3 +1,5 @@
## Automatically adapted for scipy Oct 31, 2005 by

# Copyright (c) 1996, 1997, The Regents of the University of California.
# All rights reserved. See Legal.htm for full text and disclaimer.

Expand All @@ -8,7 +10,7 @@
from yorick import *
from gist import *
from arrayfns import *
from MLab import rand
from scipy.basic.linalg import rand

window3 (hcp = "talk.ps", dump = 1)

Expand Down
6 changes: 4 additions & 2 deletions Lib/sandbox/xplt/ezplot.py
@@ -1,3 +1,5 @@
## Automatically adapted for scipy Oct 31, 2005 by

# Copyright (c) 1996, 1997, The Regents of the University of California.
# All rights reserved. See Legal.htm for full text and disclaimer.

Expand Down Expand Up @@ -155,7 +157,7 @@ def _set_initial_defaults_ ( ) :
from cellarray import *

import shapetest
from Numeric import *
from scipy import *
from scipy_base.fastumath import *

_ezdict_ = {'t': 'true' , 'T': 'true', 'y': 'true', 'Y': 'true',
Expand Down Expand Up @@ -1727,7 +1729,7 @@ def plotf (*args, ** keywords) :
__rt_ = _rt_
if n != 0 :
if type (args[0][0][0]) == IntType :
plvar = keywords ["cindex"] = array(args [0],'b') # Gist knows chars
plvar = keywords ["cindex"] = array(args [0],'B') # Gist knows chars
else :
plvar = keywords ["pvar"] = args [0]
if n > 1 :
Expand Down

0 comments on commit 8afa3a1

Please sign in to comment.