Index: ../trunk-jpl/src/m/plot/writejsfile.py
===================================================================
--- ../trunk-jpl/src/m/plot/writejsfile.py	(revision 19035)
+++ ../trunk-jpl/src/m/plot/writejsfile.py	(revision 19036)
@@ -5,53 +5,52 @@
 #      writejsfile(filename,model,keyname)
 #
 
-	nods=length(model.x);
-	nel=size(model.index,1);
-	nx=length(model.contourx1);
+	nods=len(model.x)
+	nel=len(model.index[1])
+	nx=len(model.contourx1)
 	
-	fid=open(filename,'w');
+	fid=open(filename,'w')
 
-	fid.write('model = {};\n');
-	fid.write('model["title"]="{0}";\n'.format(model.title);
-	fid.write('model["initialZoomFactor"]={0};\n'.format(model.initialZoomFactor);
+	fid.write('model = {};\n')
+	fid.write('model["title"]="{0}";\n'.format(model.title)
+	fid.write('model["initialZoomFactor"]={0};\n'.format(model.initialZoomFactor)
 	
 	#write index:
-	fid.write('<!-- model["index"]{{{-->\n');
-	fid.write('model["index"]=[');
-	for i=1:nel-1,
-		fid.write('[{0}, {1}, {2}],'.format(model.index(i,1),model.index(i,2),model.index(i,3));
-	end
-	fid.write('[{0}, {1}, {2}]];\n'.format(model.index(end,1),model.index(end,2),model.index(end,3));
-	fid.write('<!--}}}-->\n');
+	fid.write('<!-- model["index"]{{{-->\n')
+	fid.write('model["index"]=[')
+	for i in xrange(1,nel-1):
+		fid.write('[{0}, {1}, {2}],'.model.index[i][1],model.index[i][2],model.index[i][3])
+	fid.write('[{0}, {1}, {2}]];\n'.format(model.index[-1][1],model.index[-1][2],model.index[-1][3])
+	fid.write('<!--}}}-->\n')
 	
-	writejsfield(fid,'model["x"]',model.x,nods);
-	writejsfield(fid,'model["y"]',model.y,nods);
-	writejsfield(fid,'model["z"]',model.z,nods);
-	writejsfield(fid,'model["surface"]',model.surface,nods);
-	writejsfield(fid,'model["contourx1"]',model.contourx1,nx);
-	writejsfield(fid,'model["contoury1"]',model.contoury1,nx);
-	writejsfield(fid,'model["contourz1"]',model.contourz1,nx);
-	writejsfield(fid,'model["contourx2"]',model.contourx2,nx);
-	writejsfield(fid,'model["contoury2"]',model.contoury2,nx);
-	writejsfield(fid,'model["contourz2"]',model.contourz2,nx);
+	writejsfield(fid,'model["x"]',model.x,nods)
+	writejsfield(fid,'model["y"]',model.y,nods)
+	writejsfield(fid,'model["z"]',model.z,nods)
+	writejsfield(fid,'model["surface"]',model.surface,nods)
+	writejsfield(fid,'model["contourx1"]',model.contourx1,nx)
+	writejsfield(fid,'model["contoury1"]',model.contoury1,nx)
+	writejsfield(fid,'model["contourz1"]',model.contourz1,nx)
+	writejsfield(fid,'model["contourx2"]',model.contourx2,nx)
+	writejsfield(fid,'model["contoury2"]',model.contoury2,nx)
+	writejsfield(fid,'model["contourz2"]',model.contourz2,nx)
 
 
-	results=model.results;
-	fid.write('results={};\n');
+	results=model.results
+	fid.write('results={};\n')
 
-	for i=1:length(results):
-		fid.write('result={};\n');
-		writejsfield(fid,'result["data"]',results(i).data,nods);
-		fid.write('<!--{{{-->\n');
-		fid.write('result["caxis"]=[{0},{1}];\n'.format(results(i).caxis(1),results(i).caxis(2));
-		fid.write('result["label"]="{0}";\n'.format(results(i).label);
-		fid.write('result["shortlabel"]="{0}";\n'.format(results(i).shortlabel);
-		fid.write('result["unit"]="{0}";\n'.format(results(i).unit);
-		if size(results(i).data,2)>1:
-			fid.write('result["time_range"]=[{0},{1}];\n'.format(results(i).time_range(1),results(i).time_range(2));
-		fid.write('results["{0}"]=result;\n'.format(i);
-		fid.write('<!--}}}-->\n');
-	fid.write('model.results=results;\n');
-	fid.write('models["{0}"]=model;\n'.format(keyname);
+	for i in xrange(1,len(results)):
+		fid.write('result={};\n')
+		writejsfield(fid,'result["data"]',results[i].data,nods)
+		fid.write('<!--{{{-->\n')
+		fid.write('result["caxis"]=[{0},{1}];\n'.format(results[i].caxis[1],results[i].caxis[2])
+		fid.write('result["label"]="{0}";\n'.format(results[i].label)
+		fid.write('result["shortlabel"]="{0}";\n'.format(results[i].shortlabel)
+		fid.write('result["unit"]="{0}";\n'.format(results[i].unit)
+		if len(results[i].data[2])>1:
+			fid.write('result["time_range"]=[{0},{1}];\n'.format(results[i].time_range[1],results[i].time_range[2])
+		fid.write('results["{0}"]=result;\n'.format[i]
+		fid.write('<!--}}}-->\n')
+	fid.write('model.results=results;\n')
+	fid.write('models["{0}"]=model;\n'.format(keyname)
 
-	fid.close();
+	fid.close()
Index: ../trunk-jpl/src/m/plot/writejsfield.py
===================================================================
--- ../trunk-jpl/src/m/plot/writejsfield.py	(revision 19035)
+++ ../trunk-jpl/src/m/plot/writejsfield.py	(revision 19036)
@@ -6,19 +6,19 @@
 #
 	#write array:
 	if len(variable[2])==1:
-		fid.write('<!-- {0}{{{-->\n'.format(name));
-		fid.write('{0}=['.format(name));
+		fid.write('<!-- {0}{{{-->\n'.format(name))
+		fid.write('{0}=['.format(name))
 		for i in xrange(1, nods-1):
-			fid.write('{0},',variable[i]);
-		fid.write('{0}];\n',variable[-1]);
-		fid.write('<!--}}}-->\n');
+			fid.write('{0},',variable[i])
+		fid.write('{0}];\n',variable[-1])
+		fid.write('<!--}}}-->\n')
 	else:
 		#multi-sized array: 
-		fid.write('<!-- {0}{{{-->\n'.format(name));
-		fid.write('{0}=[]\n'.format(name));
+		fid.write('<!-- {0}{{{-->\n'.format(name))
+		fid.write('{0}=[]\n'.format(name))
 		for i in xrange(1, len(variable[2])):
-			fid.write('{0}["{1}"]=['.format(name,i));
+			fid.write('{0}["{1}"]=['.format(name,i))
 			for j in xrange(1, nods-1):
-				fid.write('{0},'.format(variable[j,i]));
-			fid.write('{0}];\n'.format(variable[-1,i]));
-		fid.write('<!--}}}-->\n');
+				fid.write('{0},'.format(variable[j,i]))
+			fid.write('{0}];\n'.format(variable[-1,i]))
+		fid.write('<!--}}}-->\n')
Index: ../trunk-jpl/src/m/plot/export_gl.py
===================================================================
--- ../trunk-jpl/src/m/plot/export_gl.py	(revision 19035)
+++ ../trunk-jpl/src/m/plot/export_gl.py	(revision 19036)
@@ -1,8 +1,8 @@
 def export_gl(md,varargin)
 
-	templist=plotoptions(varargin{:}); 
+	templist=plotoptions(varargin[:]); 
 	optionslist=templist.list;
-	options=optionslist{1};
+	options=optionslist[1];
 	options=checkplotoptions(md,options);
 
 	#Setup unique directory in present dir: 
@@ -13,11 +13,10 @@
 	scaling_factor=getfieldvalue(options,'scaling_factor',50);
 
 	#Deal with title: 
-	if exist(options,'title')
+	if options['title']:
 		title=getfieldvalue(options,'title');
-	else
+	else:
 		title='';
-	end
 
 	#initialize model: 
 	model.title=title;
@@ -25,15 +24,15 @@
 
 	#Deal with contour {{{
 
-	contour_lat1=md.mesh.lat(md.mesh.segments(:,1));
+	contour_lat1=md.mesh.lat(md.mesh.segments(	:,1));
 	contour_lat2=md.mesh.lat(md.mesh.segments(:,2));
 	contour_long1=md.mesh.long(md.mesh.segments(:,1));
 	contour_long2=md.mesh.long(md.mesh.segments(:,2));
 	contour_surface1=md.geometry.surface(md.mesh.segments(:,1));
 	contour_surface2=md.geometry.surface(md.mesh.segments(:,2));
 
-	R1=6371000*ones(length(contour_surface1),1)+scaling_factor*contour_surface1;
-	R2=6371000*ones(length(contour_surface2),1)+scaling_factor*contour_surface2;
+	R1=6371000*ones(len(contour_surface1),1)+scaling_factor*contour_surface1;
+	R2=6371000*ones(len(contour_surface2),1)+scaling_factor*contour_surface2;
 
 	contourx1 = R1 .* cosd(contour_lat1) .* cosd(contour_long1);
 	contoury1 = R1 .* cosd(contour_lat1) .* sind(contour_long1);
@@ -78,33 +77,34 @@
 	
 	#Deal with data: 
 	results=struct([]);
-	for i=1:length(optionslist),
-		options=optionslist{i}; options=checkplotoptions(md,options);
+	for i in xrange(1,len(optionslist)),
+		options=optionslist[i]; 
+		options=checkplotoptions(md,options);
 		data=getfieldvalue(options,'data');
-		results(i).data=data;
-		results(i).caxis=getfieldvalue(options,'caxis',[min(data(:)) max(data(:))]);
+		results[i].data=data;
+		results[i].caxis=getfieldvalue(options,'caxis',[min(data) max(data)]);
 
 		label=getfieldvalue(options,'label','');
 		if strcmpi(label,''),
 			#create generic label: 
 			label=['data' num2str(i)];
-		results(i).label=label;
+		results[i].label=label;
 
 		shortlabel=getfieldvalue(options,'shortlabel','');
 		if strcmpi(shortlabel,''),
 			#create generic short label: 
 			shortlabel=['data' num2str(i)];
-		results(i).shortlabel=shortlabel;
+		results[i].shortlabel=shortlabel;
 		
 		if size(data,2)>1,
 			time_range=getfieldvalue(options,'time_range',[0 100]);
-			results(i).time_range=time_range;
+			results[i].time_range=time_range;
 
 		unit=getfieldvalue(options,'unit','');
 		if strcmpi(unit,''),
 			#create generic unit: 
 			unit='SI';
-		results(i).unit=unit;
+		results[i].unit=unit;
 	model.results=results;
 	
 	#Write model to javascript database file: 
