Index: /trunk/tools/drawing.py
===================================================================
--- /trunk/tools/drawing.py	(revision 475)
+++ /trunk/tools/drawing.py	(revision 476)
@@ -169,21 +169,24 @@
         odimyu = '-'
 
-    if len(objdimx.shape) <= 2:
-#        odimxv = objdimx[valshad.shape]
-#        odimyv = objdimy[valshad.shape]
-        odimxv = objdimx[:]
-        odimyv = objdimy[:]
-
-    elif len(objdimx.shape) == 3:
-#        dimcut = [0, slice(0,valshad.shape[0]), slice(0,valshad.shape[1])]
-#        odimxv = objdimx[tuple(dimcut)]
-#        odimyv = objdimy[tuple(dimcut)]
-        odimxv = objdimx[0,:]
-        odimyv = objdimy[0,:]
-    else:
-        print errormsg
-        print '  ' + fname + ': shape of dimension variable:', objdimx.shape,        \
-          ' not ready!!'
-        quit(-1)
+    odimxv, odimyv = dxdy_lonlatDIMS(objdimx[:], objdimy[:], objdimx.dimensions,     \
+      objdimy.dimensions, dimvals)
+
+#    if len(objdimx.shape) <= 2:
+##        odimxv = objdimx[valshad.shape]
+##        odimyv = objdimy[valshad.shape]
+#        odimxv = objdimx[:]
+#        odimyv = objdimy[:]
+
+#    elif len(objdimx.shape) == 3:
+##        dimcut = [0, slice(0,valshad.shape[0]), slice(0,valshad.shape[1])]
+##        odimxv = objdimx[tuple(dimcut)]
+##        odimyv = objdimy[tuple(dimcut)]
+#        odimxv = objdimx[0,:]
+#        odimyv = objdimy[0,:]
+#    else:
+#        print errormsg
+#        print '  ' + fname + ': shape of dimension variable:', objdimx.shape,        \
+#          ' not ready!!'
+#        quit(-1)
 
     shading_nx = []
Index: /trunk/tools/drawing_tools.py
===================================================================
--- /trunk/tools/drawing_tools.py	(revision 475)
+++ /trunk/tools/drawing_tools.py	(revision 476)
@@ -3394,5 +3394,5 @@
         ydims = '0'
 
-    lon0, lat0 = dxdy_lonlat(dimxv,dimyv, xdims, ydims)
+#    lon0, lat0 = dxdy_lonlat(dimxv,dimyv, xdims, ydims)
 
     if not mapv is None:
@@ -4533,4 +4533,79 @@
     return lonv,latv
 
+def dxdy_lonlatDIMS(dxv,dyv,dnx,dny,dd):
+    """ Function to provide lon/lat 2D lilke-matrices from any sort of dx,dy values for a given
+      list of values
+    dxdy_lonlat(dxv,dyv,Lv,lv)
+      dxv: values for the x
+      dyv: values for the y
+      dnx: mnames of the dimensions for values on x
+      dny: mnames of the dimensions for values on y
+      dd: list of [dimname]|[val] for the dimensions use
+        [dimname]: name of the dimension
+        [val]: value (-1 for all the range)
+    """
+
+    fname = 'dxdy_lonlatDIMS'
+
+    print 'Lluis which dimensions x:',ddx,'y:',ddy
+
+    slicex = []
+    ipos=0
+    for dn in dnx:
+        for idd in range(len(dd)):
+            dname = dd[idd].split('|')[0]
+            dvalue = int(dd[idd].split('|')[1])
+            if dn == dname:
+                if dvalue == -1:
+                    slicex.append(slice(0,len(dxv.shape[ipos])))
+                else:
+                    slicex.append(dvalue)
+                break
+        ipos = ipos + 1
+
+    slicey = []
+    ipos=0
+    for dn in dny:
+        for idd in range(len(dd)):
+            dname = dd[idd].split('|')[0]
+            dvalue = int(dd[idd].split('|')[1])
+            if dn == dname:
+                if dvalue == -1:
+                    slicey.append(slice(0,len(dyv.shape[ipos])))
+                else:
+                    slicey.append(dvalue)
+                break
+        ipos = ipos + 1
+
+
+    if len(dxv.shape) > 1:
+        for idim in range(len(dxv.shape)):
+            if idim == ddxx or idim == ddxy:
+                slicex.append(slice(0,dxv.shape[idim]))
+            else:
+                slicex.append(0)
+    else:
+        slicex.append(slice(0,len(dxv)))
+
+    slicey = []
+    if len(dyv.shape) > 1:
+        for idim in range(len(dyv.shape)):
+            if idim == ddyx or idim == ddyy:
+                slicey.append(slice(0,dyv.shape[idim]))
+            else:
+                slicey.append(0)
+    else:
+        slicey.append(slice(0,len(dyv)))
+
+    lonv = dxv[tuple(slicex)]
+    latv = dyv[tuple(slicey)]
+
+    if len(lonv.shape) != len(latv.shape):
+        print '  ' + fname + ': dimension size on x:', len(lonv.shape), 'and on y:', \
+          len(latv.shape),'do not coincide!!'
+        quit(-1)
+
+    return lonv,latv
+
 def plot_2D_shadow_line(varsv,varlv,vnames,vnamel,dimxv,dimyv,dimxu,dimyu,dimn,             \
   colorbar,colln,vs,uts,utl,vtit,kfig,reva,mapv,ifclose):
