Index: issm/trunk-jpl/src/m/plot/applyoptions.py
===================================================================
--- issm/trunk-jpl/src/m/plot/applyoptions.py	(revision 19493)
+++ issm/trunk-jpl/src/m/plot/applyoptions.py	(revision 21253)
@@ -32,16 +32,13 @@
 	#ax=p.gca()
 
-	#font {{{
+	# {{{ font
 	fontsize=options.getfieldvalue('fontsize',8)
 	fontweight=options.getfieldvalue('fontweight','normal')
 	fontfamily=options.getfieldvalue('fontfamily','sans-serif')
-	font={
-			'fontsize'		:fontsize,
-			'fontweight'	:fontweight,
-			'family'			:fontfamily
-			}
-	#}}}
-
-	#title {{{
+	font={'fontsize'		:fontsize,
+				'fontweight'	:fontweight,
+				'family'			:fontfamily}
+	# }}}
+	# {{{ title
 	if options.exist('title'):
 		title=options.getfieldvalue('title')
@@ -59,7 +56,6 @@
 		titlefont['weight']=titlefontweight
 		ax.set_title(title,**titlefont)
-	#}}}
-		
-	#xlabel, ylabel, zlabel {{{
+	# }}}
+	# {{{ xlabel, ylabel, zlabel
 	if options.exist('labelfontsize'):
 		labelfontsize=options.getfieldvalue('labelfontsize')
@@ -82,7 +78,6 @@
 	if options.exist('zlabel'):
 		ax.set_zlabel(options.getfieldvalue('zlabel'),**labelfont)
-	#}}}
-
-	#xticks, yticks, zticks (tick locations) {{{
+	# }}}
+	# {{{ xticks, yticks, zticks (tick locations)
 	if options.exist('xticks'):
 		if options.exist('xticklabels'):
@@ -103,7 +98,6 @@
 		else:
 			ax.set_zticks(options.getfieldvalue('zticks'))
-	#}}}
-
-	#xticklabels,yticklabels,zticklabels {{{
+	# }}}
+	# {{{ xticklabels,yticklabels,zticklabels
 	if options.getfieldvalue('ticklabels','off')=='off' or options.getfieldvalue('ticklabels',0)==0:
 		options.addfielddefault('xticklabels',[])
@@ -119,11 +113,9 @@
 		zticklabels=options.getfieldvalue('zticklabels')
 		ax.set_zticklabels(zticklabels)
-	#}}}
-
-	#ticklabel notation {{{
+	# }}}
+	# {{{ ticklabel notation
 	#ax.ticklabel_format(style='sci',scilimits=(0,0))
-	#}}}
-
-	#ticklabelfontsize {{{
+	# }}}
+	# {{{ ticklabelfontsize
 	if options.exist('ticklabelfontsize'):
 		for label in ax.get_xticklabels() + ax.get_yticklabels():
@@ -132,13 +124,12 @@
 			for label in ax.get_zticklabels():
 				label.set_fontsize(options.getfieldvalue('ticklabelfontsize'))
-	#}}}
-
-	#view
+	# }}}
+	# {{{ view TOFIX
 	#if int(md.mesh.dimension) == 3 and options.exist('layer'):
 	#	#options.getfieldvalue('view') ?
 	#	ax=fig.gca(projection='3d')
 	#plt.show()
-
-	#axis {{{
+	# }}}
+	# {{{ axis
 	if options.exist('axis'):
 		if options.getfieldvalue('axis',True)=='off':
@@ -147,10 +138,9 @@
 			p.setp(ax.get_yticklabels(), visible=False)
 	# }}}
-
-	#box
+	# {{{ box
 	if options.exist('box'):
 		eval(options.getfieldvalue('box'))
-
-	#xlim, ylim, zlim {{{
+	# }}}
+	# {{{ xlim, ylim, zlim
 	if options.exist('xlim'):
 		ax.set_xlim(options.getfieldvalue('xlim'))
@@ -159,13 +149,12 @@
 	if options.exist('zlim'):
 		ax.set_zlim(options.getfieldvalue('zlim'))
-	#}}}
-
-	#latlon
-
-	#Basinzoom
-
-	#ShowBasins
-
-	#clim {{{
+	# }}}
+	# {{{ latlon TODO
+	# }}}
+	# {{{ Basinzoom TODO
+	# }}}
+	# {{{ ShowBasins TODO
+	# }}}
+	# {{{ clim
 	if options.exist('clim'):
 		lims=options.getfieldvalue('clim')
@@ -178,21 +167,25 @@
 		if len(data)>0: lims=[data.min(),data.max()]
 		else: lims=[0,1]
-	#}}}
-
-	#shading
+	# }}}
+	# {{{ shading TODO
 	#if options.exist('shading'):
-
-	#grid {{{
+	# }}}
+	# {{{ grid
 	if options.exist('grid'):
 		if 'on' in options.getfieldvalue('grid','on'):
 			ax.grid()
-	#}}}
-
-	#colormap {{{
+	# }}}
+	# {{{ colormap
 	# default sequential colormap
 	defaultmap=truncate_colormap(mpl.cm.gnuplot2,0.1,0.9,128)
 	cmap=options.getfieldvalue('colormap',defaultmap)
-	norm = mpl.colors.Normalize(vmin=lims[0], vmax=lims[1])
+	if options.exist('log'):
+		norm = mpl.colors.LogNorm(vmin=lims[0], vmax=lims[1])
+	else:
+		norm = mpl.colors.Normalize(vmin=lims[0], vmax=lims[1])
 	options.addfield('colornorm',norm)
+	if options.exist('cmap_set_bad'):
+		NaNcolor=options.getfieldvalue('cmap_set_bad','w')
+		cmap.set_bad(NaNcolor,1.0)
 	cbar_extend=0
 	if options.exist('cmap_set_over'):
@@ -205,113 +198,109 @@
 		cbar_extend+=2
 	options.addfield('colormap',cmap)
-	#}}}
-
-	#contours {{{
+	# }}}
+	# {{{ contours
 	if options.exist('contourlevels'):
 		plot_contour(md,data,options,ax)
-	#}}}
-
-	#wrapping
-
-	#colorbar {{{
+	# }}}
+	# {{{ wrapping TODO
+	# }}}
+	# {{{ colorbar
 	if options.getfieldvalue('colorbar',1)==1:
-	    if cbar_extend==0:
-	    	extend='neither'
-	    elif cbar_extend==1:
-	    	extend='max'
-	    elif cbar_extend==2:
-	    	extend='min'
-	    elif cbar_extend==3:
-	    	extend='both'
-	    cb = mpl.colorbar.ColorbarBase(ax.cax, cmap=cmap, norm=norm, extend=extend)
-	    if options.exist('alpha'):
-	    	cb.set_alpha(options.getfieldvalue('alpha'))
-	    if options.exist('colorbarnumticks'):
-	    	cb.locator=MaxNLocator(nbins=options.getfieldvalue('colorbarnumticks',5))
-	    else:
-	    	cb.locator=MaxNLocator(nbins=5) # default 5 ticks
-	    if options.exist('colorbartickspacing'):
-	    	locs=npy.arange(lims[0],lims[1]+1,options.getfieldvalue('colorbartickspacing'))
-	    	cb.set_ticks(locs)
-	    if options.exist('colorbarlines'):
-	    	locs=npy.arange(lims[0],lims[1]+1,options.getfieldvalue('colorbarlines'))
-	    	cb.add_lines(locs,['k' for i in range(len(locs))],npy.ones_like(locs))
-	    if options.exist('colorbarlineatvalue'):
-                locs=options.getfieldvalue('colorbarlineatvalue')
-                colors=options.getfieldvalue('colorbarlineatvaluecolor',['k' for i in range (len(locs))])
-                widths=options.getfieldvalue('colorbarlineatvaluewidth',npy.ones_like(locs))
-                cb.add_lines(locs,colors,widths)
-	    if options.exist('colorbartitle'):
-	        if options.exist('colorbartitlepad'):
-	    	    cb.set_label(options.getfieldvalue('colorbartitle'),\
-                            labelpad=options.getfieldvalue('colorbartitlepad'),fontsize=fontsize)
-	    	else:
-	    	    cb.set_label(options.getfieldvalue('colorbartitle'),fontsize=fontsize)
-	    cb.ax.tick_params(labelsize=fontsize)
-            cb.solids.set_rasterized(True)
-	    cb.update_ticks()
-            cb.set_alpha(1)
-            cb.draw_all()
-	    plt.sca(ax) # return to original axes control
-	#}}}
-
-        #expdisp {{{
-        if options.exist('expdisp'):
-            filename=options.getfieldvalue('expdisp')
-            style=options.getfieldvalue('expstyle','k')
-            linewidth=options.getfieldvalue('explinewidth',1)
-            for i in xrange(len(filename)):
-                filenamei=filename[i]
-                stylei=style[i]
-                if type(linewidth)==list:
-                    linewidthi=linewidth[i]
-                else:
-                    linewidthi=linewidth
-                expdisp(filenamei,ax,linestyle=stylei,linewidth=linewidthi,unitmultiplier=options.getfieldvalue('unit',1))
-        #}}}
-
-	#area
-
-	#text {{{
+		if cbar_extend==0:
+			extend='neither'
+		elif cbar_extend==1:
+			extend='max'
+		elif cbar_extend==2:
+			extend='min'
+		elif cbar_extend==3:
+			extend='both'
+		cb = mpl.colorbar.ColorbarBase(ax.cax, cmap=cmap, norm=norm, extend=extend)
+		if options.exist('alpha'):
+			cb.set_alpha(options.getfieldvalue('alpha'))
+		if options.exist('colorbarnumticks'):
+			cb.locator=MaxNLocator(nbins=options.getfieldvalue('colorbarnumticks',5))
+		else:
+			cb.locator=MaxNLocator(nbins=5) # default 5 ticks
+		if options.exist('colorbartickspacing'):
+			locs=npy.arange(lims[0],lims[1]+1,options.getfieldvalue('colorbartickspacing'))
+			cb.set_ticks(locs)
+		if options.exist('colorbarlines'):
+			locs=npy.arange(lims[0],lims[1]+1,options.getfieldvalue('colorbarlines'))
+			cb.add_lines(locs,['k' for i in range(len(locs))],npy.ones_like(locs))
+		if options.exist('colorbarlineatvalue'):
+			locs=options.getfieldvalue('colorbarlineatvalue')
+			colors=options.getfieldvalue('colorbarlineatvaluecolor',['k' for i in range (len(locs))])
+			widths=options.getfieldvalue('colorbarlineatvaluewidth',npy.ones_like(locs))
+			cb.add_lines(locs,colors,widths)
+		if options.exist('colorbartitle'):
+			if options.exist('colorbartitlepad'):
+				cb.set_label(options.getfieldvalue('colorbartitle'),
+										 labelpad=options.getfieldvalue('colorbartitlepad'),fontsize=fontsize)
+			else:
+				cb.set_label(options.getfieldvalue('colorbartitle'),fontsize=fontsize)
+				cb.ax.tick_params(labelsize=fontsize)
+				cb.solids.set_rasterized(True)
+				cb.update_ticks()
+				cb.set_alpha(1)
+				cb.draw_all()
+		plt.sca(ax) # return to original axes control
+	# }}}
+	# {{{ expdisp
+	if options.exist('expdisp'):
+		filename=options.getfieldvalue('expdisp')
+		style=options.getfieldvalue('expstyle','k')
+		linewidth=options.getfieldvalue('explinewidth',1)
+		for i in xrange(len(filename)):
+			filenamei=filename[i]
+			stylei=style[i]
+			if type(linewidth)==list:
+				linewidthi=linewidth[i]
+			else:
+				linewidthi=linewidth
+			expdisp(filenamei,ax,linestyle=stylei,linewidth=linewidthi,unitmultiplier=options.getfieldvalue('unit',1))
+	# }}}
+	# {{{ area TODO
+	# }}}
+	# {{{ text
 	if options.exist('text'):
-	    text=options.getfieldvalue('text')
-	    textx=options.getfieldvalue('textx')
-	    texty=options.getfieldvalue('texty')
-	    textcolor=options.getfieldvalue('textcolor')
-	    textweight=options.getfieldvalue('textweight')
-	    textrotation=options.getfieldvalue('textrotation')
-            textfontsize=options.getfieldvalue('textfontsize')
-	    for label,x,y,size,color,weight,rotation in zip(text,textx,texty,textfontsize,textcolor,textweight,textrotation):
-                ax.text(x,y,label,transform=ax.transAxes,fontsize=size,color=color,weight=weight,rotation=rotation)
-	#}}}
-
-	#north arrow
-
-	#scale ruler
-
-	#streamlines
-        if options.exist('streamlines'):
-            plot_streamlines(md,options,ax)
-
-
-	#axis positions
-
-	#figure position
-
-	#axes position
-
-	#showregion
-
-	#flat edges of a partition
-
-	#scatter
-
-	#backgroundcolor
-
-	#figurebackgroundcolor
-
-	#lighting
-
-	#point cloud
-
-	#inset
+		text=options.getfieldvalue('text')
+		textx=options.getfieldvalue('textx')
+		texty=options.getfieldvalue('texty')
+		textcolor=options.getfieldvalue('textcolor')
+		textweight=options.getfieldvalue('textweight')
+		textrotation=options.getfieldvalue('textrotation')
+		textfontsize=options.getfieldvalue('textfontsize')
+		for label,x,y,size,color,weight,rotation in zip(text,textx,texty,textfontsize,textcolor,textweight,textrotation):
+			ax.text(x,y,label,transform=ax.transAxes,fontsize=size,color=color,weight=weight,rotation=rotation)
+	# }}}
+	# {{{ north arrow TODO
+	# }}}
+	# {{{ scale ruler TODO
+	# }}}
+	# {{{ streamlines TOFIX
+	if options.exist('streamlines'):
+		plot_streamlines(md,options,ax)
+	# }}}
+	# {{{ axis positions TODO
+	# }}}
+	# {{{ figure position TODO
+	# }}}
+	# {{{ axes position TODO
+	# }}}
+	# {{{ showregion TODO
+	# }}}
+	# {{{ flat edges of a partition TODO
+	# }}}
+	# {{{ scatter TODO
+	# }}}
+	# {{{ backgroundcolor TODO
+	# }}}
+	# {{{ figurebackgroundcolor TODO
+	# }}}
+	# {{{ lighting TODO
+	# }}}
+	# {{{ point cloud TODO
+	# }}}
+	# {{{ inset TODO
+	# }}}
+	
