Index: trunk/tools/drawing.py
===================================================================
--- trunk/tools/drawing.py	(revision 800)
+++ trunk/tools/drawing.py	(revision 801)
@@ -1951,4 +1951,9 @@
         pointsizes = [np.float(pointsizes0)]
 
+    timename = timevals.split('|')[0]
+    timeunit = timevals.split('|')[1].replace('!',' ')
+    timekind = timevals.split('|')[2]
+    timefmt = timevals.split('|')[3]
+
 # Getting values
 ##
@@ -2012,11 +2017,17 @@
 
 # Getting period
+        if ifn > 0: 
+# Referring all times to the same reference time!
+            reftvals = drw.coincident_CFtimes(vdobj[:], timeunit, vdobj.units)
+        else:
+            reftvals = vdobj[:]
+
         dimt = len(vdobj[:])
 
         if period == '-1':
             varvalues.append(vvobj[:])
-            dimvalues.append(vdobj[:])
-            mindvals = np.min(vdobj[:])
-            maxdvals = np.max(vdobj[:])
+            dimvalues.append(reftvals)
+            mindvals = np.min(reftvals)
+            maxdvals = np.max(reftvals)
         else:
             ibeg=-1
@@ -2026,14 +2037,16 @@
 
             for it in range(dimt-1):
-                if vdobj[it] <= tbeg and vdobj[it+1] > tbeg : ibeg = it
-                if vdobj[it] <= tend and vdobj[it+1] > tend: iend = it + 1
+                if reftvals[it] <= tbeg and reftvals[it+1] > tbeg: ibeg = it
+                if reftvals[it] <= tend and reftvals[it+1] > tend: iend = it + 1
                 if ibeg != -1 and iend != -1: break
 
             if ibeg == -1 and iend == -1:
-                print errormsg
+                print warnmsg
                 print '  ' + fname + ': Period:',tbeg,',',tend,'not found!!'
                 print '    ibeg:',ibeg,'iend:',iend
-                print '    period in file:',np.min(vdobj[:]), np.max(vdobj[:])
-                quit(-1)
+                print '    period in file:',np.min(reftvals), np.max(reftvals)
+                print '    getting all the period in file !!!'
+                ibeg = 0
+                iend = dimt
             elif iend == -1:
                 iend = dimt
@@ -2042,5 +2055,5 @@
                 print '    getting last available time instead'
                 print '    ibeg:',ibeg,'iend:',iend
-                print '    period in file:',np.min(vdobj[:]), np.max(vdobj[:])
+                print '    period in file:',np.min(reftvals), np.max(reftvals)
             elif ibeg == -1:
                 ibeg = 0
@@ -2050,10 +2063,10 @@
                 print '    getting first available time instead'
                 print '    ibeg:',ibeg,'iend:',iend
-                print '    period in file:',np.min(vdobj[:]), np.max(vdobj[:])
+                print '    period in file:',np.min(reftvals), np.max(reftvals)
 
             varvalues.append(vvobj[ibeg:iend])
-            dimvalues.append(vdobj[ibeg:iend])
-            mindvals = np.min(vdobj[ibeg:iend])
-            maxdvals = np.max(vdobj[ibeg:iend])
+            dimvalues.append(reftvals[ibeg:iend])
+            mindvals = np.min(reftvals[ibeg:iend])
+            maxdvals = np.max(reftvals[ibeg:iend])
 
             dimt = iend - ibeg
@@ -2061,4 +2074,6 @@
         if mindvals < mintval: mintval = mindvals
         if maxdvals > maxtval: maxtval = maxdvals
+#        print '  ' + fname + ": file '" + filen + "' period:", ibeg, '->', iend,     \
+#            reftvals[ibeg], '->', reftvals[np.min([iend,dimt-1])], timeunit
 
         if ifn == 0:
@@ -2070,13 +2085,24 @@
 
 # Times
-    timename = timevals.split('|')[0]
-    timeunit = timevals.split('|')[1].replace('!',' ')
-    timekind = timevals.split('|')[2]
-    timefmt = timevals.split('|')[3]
 
     dtvals = (maxtval - mintval)/dimt
-    tvals = np.arange(mintval, maxtval, dtvals/2.)
+#    dti = mintval-dtvals/2. 
+#    dte = maxtval+dtvals/2. 
+    dti = mintval
+    dte = maxtval
+    tvals = np.arange(dti, dte, dtvals)
+
+    dtiS = drw.datetimeStr_conversion(str(dti) + ',' + timeunit, 'cfTime',           \
+      'Y/m/d H-M-S')
+    dteS = drw.datetimeStr_conversion(str(dte) + ',' + timeunit, 'cfTime',           \
+      'Y/m/d H-M-S')
+
+    print '  ' + fname + ': plotting from: ' + dtiS + ' to ' + dteS
 
     timepos, timelabels = drw.CFtimes_plot(tvals, timeunit, timekind, timefmt)
+
+#    print 'Lluis min/max tval +/- dtval/2:', mintval-dtvals/2., maxtval+dtvals/2.,'dt:', len(tvals)
+#    for it in range(len(timepos)):
+#        print timepos[it], timelabels[it]
 
     if leglabels != 'None':
Index: trunk/tools/drawing_tools.py
===================================================================
--- trunk/tools/drawing_tools.py	(revision 800)
+++ trunk/tools/drawing_tools.py	(revision 801)
@@ -392,5 +392,5 @@
         else:
             refdate = datetimeStr_datetime( yrref + '-' + monref + '-' + dayref +    \
-              + '_00:00:00')
+              '_00:00:00')
 
         if tunits == 'weeks':
@@ -1964,22 +1964,22 @@
         if trefu == 'l': timev = timev - secs0001_1901*1000.
   
-    if refdate.year < 1901:
-        print warnmsg
-        print '  ' + fname + ': changing reference date: ',refdate,                  \
-          'to 1901-01-01_00:00:00 !!!'
-        diffrefs = dt.datetime(1901,1,1,0,0,0) - refdate
-        if gen.searchInlist(dir(diffrefs), 'total_seconds'):
-            secsref_1901 = diffrefs.total_seconds()
-        else:
-            secsref_1901 = diffrefs.days()*3600*24. + diffrefs.seconds()*1.
-        refdate = datetimeStr_datetime('1901-01-01_00:00:00')
-        print 'time 0 :', timev[0]
-        if trefu == 'w': timev = timev - secsref_1901/(7.*24.*3600.)
-        if trefu == 'd': timev = timev - secsref_1901/(24.*3600.)
-        if trefu == 'h': timev = timev - secsref_1901/(3600.)
-        if trefu == 'm': timev = timev - secsref_1901/(60.)
-        if trefu == 's': timev = timev - secsref_1901
-        if trefu == 'l': timev = timev - secsref_1901*1000.
-        print 'time 0 after:', timev[0]
+#    if refdate.year < 1901:
+#        print warnmsg
+#        print '  ' + fname + ': changing reference date: ',refdate,                  \
+#          'to 1901-01-01_00:00:00 !!!'
+#        diffrefs = dt.datetime(1901,1,1,0,0,0) - refdate
+#        if gen.searchInlist(dir(diffrefs), 'total_seconds'):
+#            secsref_1901 = diffrefs.total_seconds()
+#        else:
+#            secsref_1901 = diffrefs.days()*3600*24. + diffrefs.seconds()*1.
+#        refdate = datetimeStr_datetime('1901-01-01_00:00:00')
+#        print 'time 0 :', timev[0]
+#        if trefu == 'w': timev = timev - secsref_1901/(7.*24.*3600.)
+#        if trefu == 'd': timev = timev - secsref_1901/(24.*3600.)
+#        if trefu == 'h': timev = timev - secsref_1901/(3600.)
+#        if trefu == 'm': timev = timev - secsref_1901/(60.)
+#        if trefu == 's': timev = timev - secsref_1901
+#        if trefu == 'l': timev = timev - secsref_1901*1000.
+#        print 'time 0 after:', timev[0]
 
     firstT = timev[0]
@@ -2061,10 +2061,16 @@
             ti = firstTvec[0]
             tf = lastTvec[0]
-            yeari = firstTvec[0]
+            year = firstTvec[0]
 
             TOTsteps = int(TOTdtsecs/(Nunits*31*secsDay)) + 1
 
+            if np.sum(firstTvec[1:5]) > 0:
+                firstTdt = dt.datetime(year, 1, 1, 0, 0, 0)
+                datev = dt.datetime(year, 1, 1, 0, 0, 0)
+
             datev = firstTdt
-            while datev < lastTdt:
+            timeout.append(datev)
+            yr = datev.year
+            while yr + Nunits <= tf :
                 yr = datev.year + Nunits
                 mon = datev.month
