Index: /trunk/tools/documentation/plotting/cycle.html
===================================================================
--- /trunk/tools/documentation/plotting/cycle.html	(revision 1575)
+++ /trunk/tools/documentation/plotting/cycle.html	(revision 1575)
@@ -0,0 +1,107 @@
+<HTML>
+  <HEAD>
+    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=utf-8"/>
+    <LINK REL="stylesheet" TYPE="text/css" HREF="../PyNCplot.css"/>
+  </HEAD>
+
+  </HEAD>
+  <BODY>
+    <DIV CLASS="valheader">
+      cycle
+    </DIV>
+    <DIV CLASS="valimg">
+      Plotting a temporal circular cycle
+      <TABLE>
+        <TR><TD><IMG WIDTH="100%" SRC="figs/cycle_tair_CRUNCEP_spinup_SESA.png"></IMG></TD></TR>
+        <TR><TD><IMG WIDTH="100%" SRC="figs/cycle_tair_CRUNCEP_spinup_SACZ.png"></IMG></TD></TR>
+      </TABLE>
+    </DIV>
+    <DIV CLASS="valhelp">
+    draw_cycle(ncfile, values)<BR>
+    &nbsp;&nbsp;ncfile = '#' list of files [filen];[slice];[tvarn];[varn]<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;[filen]: name of the file<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;[dimslice]: '|' list of [dimn],[dimrange]<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[dimn]: name of the dimension<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[dimrange]: range for the slice<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* [integer]: which value of the dimension<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* -1: all along the dimension<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* -9: last value of the dimension<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* [beg]@[end]@[inc] slice from [beg] to [end] every [inc]<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* NOTE, no dim name all the dimension size<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[tvarn]: name of the variable time ('WRFtime', for times from WRF)<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[varn]: name of the variable to use for the values<BR>
+    &nbsp;&nbsp;values = [dimxyfmt];[valaxis];[axeskind];[axislab];[axisunits];[rangevals];[cyclevals];[figcyckind];<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[cycticks];[timevals];[labels];[graphtit];[legvalues];[kindfig];[fign];[outfile];[close]<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;[dimxyfmt]=[dxs],[dxf],[Ndx],[ordx],[dys],[dyf],[Ndy],[ordy]: format of the values at each <BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;axis (or single 'auto' for 'auto','auto')<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[dxs]: style of x-axis ('auto' for 'pretty')<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'Nfix', values computed at even 'Ndx'<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'Stringlist', a given list of strings<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'Vfix', values computed at even 'Ndx' increments<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'pretty', values computed following aprox. 'Ndx' at 'pretty' intervals (2.,2.5,4,5,10)<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[dxf]: format of the labels at the x-axis<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[Ndx]: Number of ticks at the x-axis (for 'Stringlist', '@' list of labels)<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[ordx]: angle of orientation of ticks at the x-axis ('auto' for horizontal)<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[dys]: style of y-axis ('auto' for 'pretty')<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[dyf]: format of the labels at the y-axis<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[Ndy]: Number of ticks at the y-axis<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[ordy]: angle of orientation of ticks at the y-axis ('auto' for horizontal)<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;[valaxis]: which axes should be used for the data<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;[axeskind]: type of axes to be plotted<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'centered': crossed at 0,0 at the center of the figure<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'box': around the figure<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;[axislab]: Label for the values-axis ('!' for spaces)<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;[axisunits]: units of the values-label<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;[rangevals]: Range of the axis with the values (single 'None' for 'auto','auto')<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[val1],[val2]: tacking the provided ',' separated list of desired [val1] and [val2]<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'auto': automatically set up range using minv and maxv<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'extremescentered': extremes automatically centered on zero by computing from data -absmax, absmax; <BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;absmax=max(abs(minval),maxval)<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'meancentered': extremes automatically centered on mean by computing from data minv+meanv, maxv-meanv; <BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;meanv=(minval + maxval)/2.<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;[cyclevals] = [cycle],[cycle0]<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[cycle]= numbers of time steps to use for the cycle<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[cycle0]= initial position of time steps whithin the cycle<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;[figcyckind]=[kindname],[valueskind] kind of cycle plot<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'cloud',[color]: values as a cloud of points<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[color]: name of the colorbar to use changing after the end of each cycle ('auto' for 'rainbow')<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'lines',[color],[width],[type]: values a continuous line <BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[color]: name of the colorbar to use changing after the end of each cycle ('auto' for 'rainbow')<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[width]: width of the line to use for all lines ('auto' for 0.5)<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[type]: type of the line to use for all lines ('auto' for '-')<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;[cycticks]= [cycpos]@[cyclab] characteristics of the ticks for the cycle<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[cycpos]: ',' list of positions for the ticks (less than cycle/2)<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[cyclab]: ',' list of labels for the ticks (less than cycle/2)<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;[timevals]: [timen]|[units]|[kind]|[tfmt] time labels characteristics<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[timen]; name of the time variable<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[units]; units string according to CF conventions ([tunits] since <BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[YYYY]-[MM]-[DD] [[HH]:[MI]:[SS]], '!' for spaces)<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[kind]; kind of output<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'Nval': according to a given number of values as 'Nval',[Nval]<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'exct': according to an exact time unit as 'exct',[tunit]; <BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tunit= [Nunits],[tu]; [tu]= 'c': centuries, 'y': year, 'm': month,<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'w': week, 'd': day, 'h': hour, 'i': minute, 's': second, <BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'l': milisecond<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[tfmt]; desired format<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;[labels]: ',' list of labels for the legend ('None' for no-labels, '!' for spaces)<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;[graphtit]: title of the figure '!' for spaces<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;[legvalues]=[locleg]|[fontsize]: <BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[locleg]: location of the legend (0, autmoatic)<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1: 'upper right', 2: 'upper left', 3: 'lower left', 4: 'lower right',<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;5: 'right', 6: 'center left', 7: 'center right', 8: 'lower center',<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;9: 'upper center', 10: 'center'<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[fontsize]: font size for the legend (auto for 12)<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;[kindfig]: kind of output figure (png, pdf, ps)<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;[fign]: name of the figure (without extension)<BR>
+    &nbsp;&nbsp;&nbsp;&nbsp;[close]: whether figure should be close or not<BR>
+    </DIV>
+    <DIV CLASS="valins">
+      * Plotting using continuos lines <BR>
+      &nbsp;&nbsp;$ python ${pyHOME}/drawing.py -o draw_cycle -f 'Forcing_tairstats_OKstomate_CRUNCEP_spinup_SESA.nc;time_counter,-1|stats,2;time_centered;tair_stats' -S 'auto;y;centered;tair;K;None;12,3;lines,rainbow,horizontal,auto,-,2.;1,3,5@Sep/Nov,Jan/Jul,Mar/May;year|seconds!since!1958-01-01!00:00:00|exct,5,y|%Y;SESA;year-evolution!of!CRUNCEP!tair!forcing!at!SESA;0|10;png;cycle_tair_CRUNCEP_spinup_SESA;yes' <BR>
+      * Plotting using cloud of points <BR>
+      &nbsp;&nbsp;$ python ${pyHOME}/drawing.py -o draw_cycle -f 'Forcing_tairstats_OKstomate_CRUNCEP_spinup_SESA.nc;time_counter,-1|stats,2;time_centered;tair_stats' -S 'auto;y;box;tair;K;None;12,3;cloud,rainbow,horizontal,auto,x,2.;1,3,5@Sep/Nov,Jan/Jul,Mar/May;year|seconds!since!1958-01-01!00:00:00|exct,5,y|%Y;tas;year-evolution!of!CRUNCEP!tair!forcing!at!SACZ;0|10;png;cycle_tair_CRUNCEP_spinup_SACZ;yes'
+
+    </DIV>
+  </BODY>
+</HTML>
+
Index: /trunk/tools/documentation/plotting/gallery.html
===================================================================
--- /trunk/tools/documentation/plotting/gallery.html	(revision 1574)
+++ /trunk/tools/documentation/plotting/gallery.html	(revision 1575)
@@ -25,4 +25,6 @@
       <A HREF="barbs.html"><IMG SRC="figs/wind_barbs_2001111003_uw.png" ALT="wind-barbs" STYLE="float:left;width:200px;height:200px" TARGET="value"></IMG></A>
       <A HREF="basins.html"><IMG SRC="figs/basins_named.png" ALT="ORCHIDEE's basin description" STYLE="float:left;width:200px;height:200px" TARGET="value"></IMG></A>
+      <A HREF="cycle.html"><IMG SRC="figs/cycle_tair_CRUNCEP_spinup_SESA.png" ALT="cicurlar cycle" STYLE="float:left;width:200px;height:200px" TARGET="value"></IMG></A>
+      <A HREF="cycle.html"><IMG SRC="figs/cycle_tair_CRUNCEP_spinup_SACZ.png" ALT="cicurlar cycle" STYLE="float:left;width:200px;height:200px" TARGET="value"></IMG></A>
       <A HREF="ensemble_time.html"><IMG SRC="figs/Forcing_pr_spacemean.png" ALT="Ensemble time" STYLE="float:left;width:200px;height:200px" TARGET="value"></IMG></A>
       <A HREF="ensemble_time.html"><IMG SRC="figs/T2_spaceensembleIndiv.png" ALT="Ensemble time" STYLE="float:left;width:200px;height:200px" TARGET="value"></IMG></A>
Index: /trunk/tools/documentation/plotting/plotting.html
===================================================================
--- /trunk/tools/documentation/plotting/plotting.html	(revision 1574)
+++ /trunk/tools/documentation/plotting/plotting.html	(revision 1575)
@@ -20,4 +20,5 @@
       <A CLASS="lc" HREF="barbs.html" TARGET="value">barbs</A><BR>
       <A CLASS="lc" HREF="basins.html" TARGET="value">ORCHIDEE's basins</A><BR>
+      <A CLASS="lc" HREF="cycle.html" TARGET="value">circular cycle</A><BR>
       <A CLASS="lc" HREF="ensemble_time.html" TARGET="value">Ensemble time</A><BR>
       <A CLASS="lc" HREF="Neighbourgh_evol.html" TARGET="value">Neighbourghood evolution</A><BR>
Index: /trunk/tools/drawing.py
===================================================================
--- /trunk/tools/drawing.py	(revision 1574)
+++ /trunk/tools/drawing.py	(revision 1575)
@@ -51,5 +51,5 @@
 ## e.g. # drawing.py -o draw_time_lag -f 'Forcing_rainstats_OKstomate_SESA_norm_meanstd_stat2.nc;time_centered,-1;time_counter;rainnorm%DiPolo_evapstats_SESA_norm_meanstd_OKstomate.nc;time_counter,-1|stats,2;time_counter;evapnorm:Forcing_rainstats_OKstomate_SACZ_norm_meanstd_stat2.nc;time_centered,-1;time_counter;rainnorm%DiPolo_evapstats_SACZ_norm_meanstd_OKstomate.nc;time_counter,-1|stats,2;time_counter;evapnorm' -S 'auto;centered;pr;1;evap;1;-5,5;-2,2;year|seconds!since!1958-01-01!00:00:00|exct,5,y|%Y;SESA,SACZ;simplepts,1,#AA0000@#0000AA,x,2.;1-month!time-lag!at!SACZ!between!pr!&!evap!normalized!by!mean/stddev;0|12;png;mon1_timelag_pr-evap_SACZ;yes'
 ## e.g. # drawing.py -o draw_ensembles_time -f 'Forcing_rain_SESA.nc;time_counter,-1|stats,0;time_centered;rain_stats;ensemble#Forcing_rain_SESA.nc;time_counter,-1|stats,1;time_centered;rain_stats;ensemble#Forcing_rain_SESA.nc;time_counter,-1|stats,2;time_centered;rain_stats;data' -S 'auto;y;tas;mm/d;auto,auto;#0000FF:-:2.:,:2.;year|seconds!since!1958-01-01!00:00:00|exct,5,y|%Y;FromFile;$pr_{space-mean}^{SESA}$;cloud,#AAAADD,auto;$pr_{space-mean}$!evolution!at!SESA;0|10;png;Forcing_pr_spacemean;no;yes'
-
+## e.g. # drawing.py -o draw_cycle -f 'Forcing_tairstats_OKstomate_CRUNCEP_spinup_SESA.nc;time_counter,-1|stats,2;time_centered;tair_stats' -S 'auto;y;centered;tair;K;None;12,3;lines,rainbow,horizontal,auto,-,2.;1,3,5@Sep/Nov,Jan/Jul,Mar/May;year|seconds!since!1958-01-01!00:00:00|exct,5,y|%Y;SESA;year-evolution!of!CRUNCEP!tair!forcing!at!SESA;0|10;png;cycle_tair_CRUNCEP_spinup_SESA;yes'
 
 #######
@@ -71,4 +71,5 @@
 # draw_barbs: Function to plot wind barbs
 # draw_basins: Function to plot river basins with their discharge vector and basins id (from 'routing.nc')
+# draw_cycle: Function to plot a variale with a circular cycle
 # draw_ensembles_time: Function to plot an ensembles of data following an axis-time
 # draw_lines: Function to draw different lines at the same time from different files
@@ -103,5 +104,5 @@
   'draw_2D_shad_line',                                                               \
   'draw_2D_shad_line_time', 'draw_bar', 'draw_bar_line', 'draw_bar_line_time',       \
-  'draw_bar_time', 'draw_barbs', 'draw_basins', 'draw_ensembles_time',               \
+  'draw_bar_time', 'draw_barbs', 'draw_basins', 'draw_cycle', 'draw_ensembles_time', \
   'draw_2lines', 'draw_2lines_time', 'draw_lines', 'draw_lines_time',                \
   'draw_Neighbourghood_evol',                                                        \
@@ -8100,4 +8101,245 @@
     return
 
+def draw_cycle(ncfile, values):
+    """ Function to plot a variale with a circular cycle
+      ncfile = '#' list of files [filen];[slice];[tvarn];[varn]
+        [filen]: name of the file
+        [dimslice]: '|' list of [dimn],[dimrange]
+          [dimn]: name of the dimension
+          [dimrange]: range for the slice
+            * [integer]: which value of the dimension
+            * -1: all along the dimension
+            * -9: last value of the dimension
+            * [beg]@[end]@[inc] slice from [beg] to [end] every [inc]
+            * NOTE, no dim name all the dimension size
+        [tvarn]: name of the variable time ('WRFtime', for times from WRF)
+        [varn]: name of the variable to use for the values
+      values = [dimxyfmt];[valaxis];[axeskind];[axislab];[axisunits];[rangevals];[cyclevals];[figcyckind];
+          [cycticks];[timevals];[labels];[graphtit];[legvalues];[kindfig];[fign];[outfile];[close]
+        [dimxyfmt]=[dxs],[dxf],[Ndx],[ordx],[dys],[dyf],[Ndy],[ordy]: format of the values at each 
+            axis (or single 'auto' for 'auto','auto')
+          [dxs]: style of x-axis ('auto' for 'pretty')
+            'Nfix', values computed at even 'Ndx'
+            'Stringlist', a given list of strings
+            'Vfix', values computed at even 'Ndx' increments
+            'pretty', values computed following aprox. 'Ndx' at 'pretty' intervals (2.,2.5,4,5,10)
+          [dxf]: format of the labels at the x-axis
+          [Ndx]: Number of ticks at the x-axis (for 'Stringlist', '@' list of labels)
+          [ordx]: angle of orientation of ticks at the x-axis ('auto' for horizontal)
+          [dys]: style of y-axis ('auto' for 'pretty')
+          [dyf]: format of the labels at the y-axis
+          [Ndy]: Number of ticks at the y-axis
+          [ordy]: angle of orientation of ticks at the y-axis ('auto' for horizontal)
+        [valaxis]: which axes should be used for the data
+        [axeskind]: type of axes to be plotted
+          'centered': crossed at 0,0 at the center of the figure
+          'box': around the figure
+        [axislab]: Label for the values-axis ('!' for spaces)
+        [axisunits]: units of the values-label
+        [rangevals]: Range of the axis with the values (single 'None' for 'auto','auto')
+          [val1],[val2]: tacking the provided ',' separated list of desired [val1] and [val2]
+          'auto': automatically set up range using minv and maxv
+          'extremescentered': extremes automatically centered on zero by computing from data -absmax, absmax; 
+            absmax=max(abs(minval),maxval)
+          'meancentered': extremes automatically centered on mean by computing from data minv+meanv, maxv-meanv; 
+            meanv=(minval + maxval)/2.
+        [cyclevals] = [cycle],[cycle0]
+          [cycle]= numbers of time steps to use for the cycle
+          [cycle0]= initial position of time steps whithin the cycle
+        [figcyckind]=[kindname],[valueskind] kind of cycle plot
+          'cloud',[color]: values as a cloud of points
+            [color]: name of the colorbar to use changing after the end of each cycle ('auto' for 'rainbow')
+          'lines',[color],[width],[type]: values a continuous line 
+            [color]: name of the colorbar to use changing after the end of each cycle ('auto' for 'rainbow')
+            [width]: width of the line to use for all lines ('auto' for 0.5)
+            [type]: type of the line to use for all lines ('auto' for '-')
+        [cycticks]= [cycpos]@[cyclab] characteristics of the ticks for the cycle
+          [cycpos]: ',' list of positions for the ticks (less than cycle/2)
+          [cyclab]: ',' list of labels for the ticks (less than cycle/2)
+        [timevals]: [timen]|[units]|[kind]|[tfmt] time labels characteristics
+          [timen]; name of the time variable
+          [units]; units string according to CF conventions ([tunits] since 
+            [YYYY]-[MM]-[DD] [[HH]:[MI]:[SS]], '!' for spaces)
+          [kind]; kind of output
+            'Nval': according to a given number of values as 'Nval',[Nval]
+            'exct': according to an exact time unit as 'exct',[tunit]; 
+              tunit= [Nunits],[tu]; [tu]= 'c': centuries, 'y': year, 'm': month,
+               'w': week, 'd': day, 'h': hour, 'i': minute, 's': second, 
+               'l': milisecond
+          [tfmt]; desired format
+        [labels]: ',' list of labels for the legend ('None' for no-labels, '!' for spaces)
+        [graphtit]: title of the figure '!' for spaces
+        [legvalues]=[locleg]|[fontsize]: 
+          [locleg]: location of the legend (0, autmoatic)
+            1: 'upper right', 2: 'upper left', 3: 'lower left', 4: 'lower right',
+            5: 'right', 6: 'center left', 7: 'center right', 8: 'lower center',
+            9: 'upper center', 10: 'center'
+          [fontsize]: font size for the legend (auto for 12)
+        [kindfig]: kind of output figure (png, pdf, ps)
+        [fign]: name of the figure (without extension)
+        [close]: whether figure should be close or not
+    """
+    fname = 'draw_cycle'
+
+    if values == 'h':
+        print fname + '____________________________________________________________'
+        print draw_cycle.__doc__
+        quit()
+
+    expectargs = '[dimxyfmt];[valaxis];[axeskind];[axislab];[axisunits];' +          \
+      '[rangevals];[cyclevals];[figcyckind];[cycticks];[timevals];[labels];'+ \
+      '[graphtit];[legvalues];[kindfig];[fign];[close]'
+    drw.check_arguments(fname,values,expectargs,';')
+
+    dimxyfmt = values.split(';')[0]
+    valaxis = values.split(';')[1]
+    axiskind = values.split(';')[2]
+    axislab = values.split(';')[3].replace('!',' ')
+    axisunits = values.split(';')[4]
+    rangevals = values.split(';')[5]
+    cyclevals = values.split(';')[6]
+    figcyckind = values.split(';')[7]
+    cycticks = values.split(';')[8].split('@')
+    timevals = values.split(';')[9]
+    labels = gen.str_list(values.split(';')[10].replace('!', ' '), ',')
+    graphtit = values.split(';')[11].replace('!',' ')
+    legvalues = values.split(';')[12]
+    kindfig = values.split(';')[13]
+    fign = values.split(';')[14]
+    close = gen.Str_Bool(values.split(';')[15])
+
+    # cycle
+    cycle = int(cyclevals.split(',')[0])
+    cycle0 = int(cyclevals.split(',')[1])
+
+    # time-values
+    expectargs = '[timen]|[units]|[kind]|[tfmt]'
+    drw.check_arguments('timevals: '+fname,timevals,expectargs,'|')
+
+    timen = timevals.split('|')[0].replace('!',' ')
+    timeunit = timevals.split('|')[1].replace('!',' ')
+    timekind = timevals.split('|')[2]
+    timefmt = timevals.split('|')[3]
+
+    # files
+    valfiles = gen.str_list(ncfile, '#')
+
+    values = []
+    timevalues = []
+
+    mintval = gen.fillValueF
+    maxtval = -gen.fillValueF
+    minvval = gen.fillValueF
+    maxvval = -gen.fillValueF
+
+    ifile = 0
+    dimt = -gen.fillValueF
+    for fdv in valfiles:
+        fvals = fdv.split(';')
+        expectedargs = '[filen];[slice];[tvarn];[varn]'
+        gen.check_arguments('filevals: '+fname, fdv, expectedargs, ';')
+        filen = fvals[0]
+        dimrange = fvals[1]
+        tvarn = fvals[2]
+        yvarn = fvals[3]
+
+        if not os.path.isfile(filen):
+            print errormsg
+            print '  ' + fname + ': file "' + filen + '" does not exist !!'
+            quit(-1)
+
+        onc = NetCDFFile(filen, 'r')
+        if tvarn == 'WRFtime':
+            datesv = []
+            if tvarn == 'WRFtime':
+                fdates = onc.variables['Times'][:]
+                for it in range(fdates.shape[0]):
+                    datesv.append(gen.datetimeStr_conversion(fdates[it,:],           \
+                      'WRFdatetime','cfTime,' + timeunit))
+            tvs = np.array(datesv, dtype=np.float)
+            tunitsvar = timeunit
+        else:
+            if not onc.variables.has_key(tvarn):
+                print errormsg
+                print '  ' +fname+ ': file "' +filen+ "' does not have variable '" + \
+                  tvarn + "' for the time-values !!"
+                print '    available ones:', onc.variables.keys()
+                onc.close()
+                quit(-1)
+            otvar = onc.variables[tvarn]
+            tvs, tdims = ncvar.slice_variable(otvar, dimrange.replace(',',':'))
+            tunitsvar = otvar.units
+
+        if not onc.variables.has_key(yvarn):
+            print errormsg
+            print '  ' +fname+ ': file "' +filen+ "' does not have variable '" +     \
+              yvarn + "' for the y-values !!"
+            print '    available ones:', onc.variables.keys()
+            onc.close()
+            quit(-1)
+
+        oyvar = onc.variables[yvarn]
+        yvs, ydims = ncvar.slice_variable(oyvar, dimrange.replace(',',':'))
+
+        # Referring all times to the same reference time!
+        reftvals = gen.coincident_CFtimes(tvs, timeunit, tunitsvar)
+
+        onc.close()
+
+        if len(reftvals) > dimt: dimt = len(reftvals)
+
+        reftn = reftvals.min()
+        reftx = reftvals.max()
+        if reftn < mintval: mintval = reftn
+        if reftx > maxtval: maxtval = reftx
+        refvn = yvs.min()
+        refvx = yvs.max()
+        if refvn < minvval: minvval = refvn
+        if refvx > maxvval: maxvval = refvx
+
+        values.append(yvs)
+        timevalues.append(reftvals)
+
+        ifile = ifile + 1
+
+    # cycle ticks
+    pos=cycticks[0].split(',')
+    ll=cycticks[1].split(',')
+    ctick = []
+    clab = []
+    for ip in range(len(pos)):
+        ctick.append(np.float(pos[ip]))
+        clab.append(gen.latex_text(ll[ip]))
+
+    # Times
+    dtvals = (maxtval - mintval)/10
+    dti = mintval
+    dte = maxtval
+    tvalsticks = np.arange(dti, dte+dtvals, 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(tvalsticks, timeunit, timekind, timefmt)
+
+    # ranges
+    rng = gen.minmax_range(minvval, maxvval, rangevals)
+
+    xstyl, xaxf, Nxax, xaxor, ystyl, yaxf, Nyax, yaxor = drw.format_axes(dimxyfmt,',')
+    xaxis = [xstyl, xaxf, Nxax, xaxor]
+    yaxis = [ystyl, yaxf, Nyax, yaxor]
+
+    # Legend 
+    legloc, legsiz = drw.legend_values(legvalues,'|')
+
+    drw.plot_cycle(values, timevalues, xaxis, yaxis, valaxis, axiskind, axislab,     \
+      axisunits, rng, cycle, cycle0, figcyckind, labels, ctick, clab, timen, timepos,\
+      timelabels, graphtit, legloc, legsiz, kindfig, fign, close)
+
+    return
+
 #quit()
 
@@ -8123,5 +8365,5 @@
   'draw_2D_shad_line', 'draw_2D_shad_line_time', 'draw_2lines', 'draw_2lines_time',  \
   'draw_bar', 'draw_bar_line', 'draw_bar_line_time', 'draw_bar_time',                \
-  'draw_ensembles_time', 'draw_lines',                                               \
+  'draw_cycle', 'draw_ensembles_time', 'draw_lines',                                 \
   'draw_lines_time', 'draw_points', 'draw_Taylor', 'draw_time_lag',                  \
   'draw_topo_geogrid_boxes',                                                         \
@@ -8192,4 +8434,6 @@
     elif oper == 'draw_basins':
         draw_basins(opts.ncfile, opts.values)
+    elif oper == 'draw_cycle':
+        draw_cycle(opts.ncfile, opts.values)
     elif oper == 'draw_ensembles_time':
         draw_ensembles_time(opts.ncfile, opts.values)
Index: /trunk/tools/drawing_tools.py
===================================================================
--- /trunk/tools/drawing_tools.py	(revision 1574)
+++ /trunk/tools/drawing_tools.py	(revision 1575)
@@ -89,4 +89,5 @@
 # plot_bars_time: Function to plot a bar plot with multiple columns with time axis
 # plot_bars_line: Function to plot a bar and lines plot with multiple columns with a time-axis
+# plot_cycle: Function to plot a variale with a circular cycle
 # plot_lines: Function to plot a collection of lines
 # plot_Taylor: Function to draw a Taylor diagram (Taylor 2001)
@@ -10419,2 +10420,279 @@
 
     return
+
+def plot_cycle(vals, tvals, xaxv, yaxv, axkind, axistype, axlab, axunits, axrng,     \
+      cyc, cyc0, cyck, labs, cycp, cycl, tn, tpos, tlabs, gtit, lloc, lsiz, kfig, fn,\
+      ifclose):
+    """ Function to plot a cycle
+      vals= list of cyclic values 
+      tvals= list with the time-values
+      [x/y]axv= values at the axes x and y
+      axkind= in which axis should the values be plotted ('x', 'y')
+      axlab= label of the axis values
+      axunits= units of the axis values
+      axrng= range of the axis values
+      cyc= number of time steps of a whole cycle
+      cyc0= initial position of time steps whithin the cycle
+      cyck=[kindname],[valueskind] kind of cycle plot
+        'cloud',[color],[cbaror],[cbarfmt],[marker],[markersize]: values as a cloud of points
+          [color]: name of the colorbar to use changing after the end of each cycle ('auto' for 'rainbow')
+          [cbaror]: orientation of the colorbar ('auto' for vertical)
+          [cbarfmt]: format of the numbers in the colorbar ('auto' for %5.2g)
+          [marker]: '@' list of kind of marker (single value for the same for all)
+          [markersize]: '@' list of size of marker (single value for the same for all)
+        'lines',[color],[width],[type]: values a continuous line 
+          [color]: name of the colorbar to use changing after the end of each cycle ('auto' for 'rainbow')
+          [width]: width of the line to use for all lines ('auto' for 0.5)
+          [type]: type of the line to use for all lines ('auto' for '-')
+      labs= list of labels for legend of lines (None for no legend, and 'None' for no specific label)
+      cycp= position of the cycle ticks
+      cycl= labels of the cycle ticks
+      tn= label of the time-axis
+      tpos= position of the time-ticks
+      tlabs= labels of the time-ticks
+      gtit= title of the figure
+      lloc= location of the legend (0, autmoatic)
+        1: 'upper right', 2: 'upper left', 3: 'lower left', 4: 'lower right',
+        5: 'right', 6: 'center left', 7: 'center right', 8: 'lower center',
+        9: 'upper center', 10: 'center'
+      lsiz= font size of the legend
+      kfig= kind of output: pdf, png, ps
+      fn= name of the figure
+      ifclose= whether figure should be closed
+    """
+    fname = 'plot_cycle'
+
+    Nvalues = len(vals)
+
+    dyn = axrng[0]
+    dyx = axrng[1]
+
+    axstyles = ['pretty', 'Nfix', 'Stringlist', 'Vfix']
+    if yaxv[0] == 'pretty':
+        dimyt = np.array(gen.pretty_int(dyn,dyx,yaxv[2]))
+        dimyl = np.array(dimyt, dtype=str)
+    elif yaxv[0] == 'Nfix':
+        dimyt = np.arange(dyn,dyx,(dyx-dyn)/(yaxv[2]+1))
+        dimyl = np.arange(dyn,dyx,(dyx-dyn)/Lymaxvals)
+        axytype='fixpixel'
+    elif yaxv[0] == 'Vfix':
+        dynvfix = int(dyn/yaxv[2])
+        dimyt = np.arange(dynvfix*xaxv[2],dyx,yaxv[2])
+        axytype='data'
+    else:
+        print errormsg
+        print '  ' + fname + ": x-xais style '" + xaxv[0] + "' not ready !!"
+        print '    available ones: ', axstyles
+        quit(-1)
+
+    # kind of cycle figure:
+    figv = cyck.split(',')
+    figtypen = figv[0]
+
+    # Computing cycling x-positions
+    cycx = []
+    for it in range(cyc):
+        itx = cyc0 + it
+        if itx <= cyc/2:
+            cycx.append(itx)
+        else:
+            if cyc-itx > 0:
+              cycx.append(cyc-itx)
+            else:
+              cycx.append(np.abs(cyc-itx))
+    cycx.append(cyc0)
+    print '  ' + fname + ': cycle positions:', cycx
+
+    plt.rc('text', usetex=True)
+    fig, ax = plt.subplots(1)
+
+    for iv in range(Nvalues):
+        xvs = vals[iv]
+        dimt = len(xvs)
+        Ncyc = dimt/cyc
+
+        # Normalizing position of the ticks
+        if iv == 0:
+            tminv = np.min(tvals[iv])
+            tmaxv = np.max(tvals[iv])
+            tpos = tpos*Ncyc/tmaxv
+
+        if figtypen == 'cloud':
+            expectargs = 'cloud,[color],[cbaror],[cbarfmt],[marker],[marekersize]'
+            check_arguments(fname + " & 'cloud'", cyck, expectargs,',')
+
+            colbar = gen.auto_val(figv[1], 'rainbow')
+            cbaror = gen.auto_val(figv[2], 'vertical')
+            cbarfmt = gen.auto_val(figv[3], '%5.2g')
+            mtype = gen.str_list_rep(figv[4],'@',Nvalues)
+            msize = gen.str_list_rep(figv[5],'@',Nvalues)
+
+            my_cmap = plt.cm.get_cmap(colbar)
+            norm = mpl.colors.Normalize(0.,Ncyc)
+
+            if labs is not None and labs[iv] != 'None':
+                for ic in range(Ncyc):
+                    clv = my_cmap(norm(ic*1.))
+                    for it in range(cyc):
+                        Tt = cyc*ic+it
+                        if Tt + 1 > dimt-1: break
+                        if ic == 0 and it == 0:
+                            if axkind == 'y':
+                                plt.plot(cycx[it], xvs[Tt], color=clv, marker=mtype[iv],  \
+                                  markersize=np.float(msize[iv]),                    \
+                                  label=gen.latex_text(labs[iv]))
+                            else:
+                                plt.plot(xvs[Tt], cycx[it], color=clv, marker=mtype[iv],  \
+                                  markersize=np.float(msize[iv]),                    \
+                                  label=gen.latex_text(labs[iv]))
+                        else:
+                            if axkind == 'y':
+                                plt.plot(cycx[it], xvs[Tt], color=clv, marker=mtype[iv],   \
+                                  markersize=np.float(msize[iv]))
+                            else:
+                                plt.plot(xvs[Tt], cycx[it], color=clv, marker=mtype[iv],  \
+                                  markersize=np.float(msize[iv]))
+            else:
+                for ip in range(Ncyc):
+                    clv = my_cmap(norm(ip*1.))
+                    for it in range(cyc):
+                        Tt = cyc*ic+it
+                        if Tt + 1 > dimt-1: break
+                        if axkind == 'y':
+                            plt.plot(cycx[it], xvs[Tt], color=clv, marker=mtype[iv],      \
+                              markersize=np.float(msize[iv]))
+                        else:
+                            plt.plot(xvs[Tt], cycx[it], color=clv, marker=mtype[iv],      \
+                              markersize=np.float(msize[iv]))
+
+        # Plotting with lines
+        elif figtypen == 'lines':
+            expectargs = 'lines,[color],[cbaror],[cbarfmt],[linetype],[linewidth]'
+            check_arguments(fname + " & 'cloud'", cyck, expectargs,',')
+
+            colbar = gen.auto_val(figv[1], 'rainbow')
+            cbaror = gen.auto_val(figv[2], 'vertical')
+            cbarfmt = gen.auto_val(figv[3], '%5.2g')
+            ltype = gen.str_list_rep(figv[4],'@',Nvalues)
+            lwdth = gen.str_list_rep(figv[5],'@',Nvalues)
+
+            my_cmap = plt.cm.get_cmap(colbar)
+            tminv = np.min(tvals[iv])
+            tmaxv = np.max(tvals[iv])
+            norm = mpl.colors.Normalize(0.,Ncyc)
+
+            if labs is not None and labs[iv] != 'None':
+                for ic in range(Ncyc):
+                    clv = my_cmap(norm(ic*1.))
+                    for it in range(cyc):
+                        Tt = cyc*ic+it
+                        if Tt + 1 > dimt-1: break
+                        xl = [cycx[it], cycx[it+1]]
+                        yl = [xvs[Tt], xvs[Tt+1]]
+                        if ic == 0 and it == 0:
+                            if axkind == 'y':
+                                plt.plot(xl, yl, ltype[iv], color=clv,               \
+                                  linewidth=np.float(lwdth[iv]),                     \
+                                  label=gen.latex_text(labs[iv]))
+                            else:
+                                plt.plot(yl, xl, marker=ltype[iv], color=clv,        \
+                                  linewidth=np.float(lwdth[iv]),                     \
+                                  label=gen.latex_text(labs[iv]))
+                        else:
+                            if axkind == 'y':
+                                plt.plot(xl, yl, ltype[iv], color=clv,               \
+                                  linewidth=np.float(lwdth[iv]))
+                            else:
+                                plt.plot(yl, xl, ltype[iv], color=clv,               \
+                                  linewidth=np.float(lwdth[iv]))
+            else:
+                for ip in range(Ncyc):
+                    clv = my_cmap(norm(ip*1.))
+                    for it in range(cyc):
+                        Tt = cyc*ic+it
+                        if Tt + 1 > dimt-1: break
+                        xl = [cycx[it], cycx[it+1]]
+                        yl = [xvs[Tt], xvs[Tt+1]]
+                        if axkind == 'y':
+                            plt.plot(xl, yl, ltype[iv], color=clv,                   \
+                              linewidth=np.float(lwdth[iv]))
+                        else:
+                            plt.plot(yl, xl, ltype[iv], color=clv,                   \
+                              linewidth=np.float(lwdth[iv]))
+        else:
+            print errormsg
+            print '  ' + fname + ": cycle figure named '" + figtypen + "' not reay !!"
+            print '    availabe ones:', ['cloud', 'lines']
+            quit(-1)
+
+    if axistype == 'box':
+        print gen.infmsg
+        print '    ' + fname + ': plotting with around axes'
+    elif axistype == 'centered':
+        # Drawing centered axes
+        # From http://stackoverflow.com/questions/31556446/drawing-axis-in-the-midde-of-the-figue-in-python
+        # Move left y-axis and bottim x-axis to centre, passing through (0,0)
+        ax.spines['left'].set_position('center')
+        ax.spines['bottom'].set_position('center')
+
+        # Eliminate upper and right axes
+        ax.spines['right'].set_color('none')
+        ax.spines['top'].set_color('none')
+
+        ax.xaxis.set_label_coords(0.5, -0.025)
+        ax.yaxis.set_label_coords(-0.025, 0.5)
+
+    else:
+        print errormsg
+        print '  ' + fname + ": axis plotting type '" + axistype + "' not ready !!"
+        print '    available ones:', ['box', 'centered']
+        quit(-1)
+
+    if axkind == 'y':
+        plt.xticks(cycp, cycl, rotation=xaxv[3])
+        plt.yticks(dimyt, list(dimyl), rotation=yaxv[3])
+        if axunits != 'None':
+            plt.ylabel(gen.latex_text(axlab) + ' (' + units_lunits(axunits) + ')')
+        else:
+            plt.ylabel(gen.latex_text(axlab))
+        plt.xlim(-1., cyc/2.+1)
+        plt.ylim(axrng[0], axrng[1])
+    else:
+        plt.xticks(dimyt, list(dimyl), rotation=yaxv[3])
+        plt.yticks(cycp, cycl, rotation=xaxv[3])
+        if axunits != 'None':
+            plt.xlabel(gen.latex_text(axlab) + ' (' + units_lunits(axunits) + ')')
+        else:
+            plt.xlabel(gen.latex_text(axlab))
+        plt.xlim(axrng[0], axrng[1])
+        plt.ylim(-1., cyc/2.+1)
+
+    if labs is not None:
+        plt.legend(loc=lloc, prop={'size':lsiz})
+
+    # Colorbar
+    if gen.searchInlist(['cloud', 'lines'], figtypen):
+        # FROM: http://stackoverflow.com/questions/8342549/matplotlib-add-colorbar-to-a-sequence-of-line-plots
+        # For matplotlib v1.3 or greater the code becomes:
+        sm = plt.cm.ScalarMappable(cmap=colbar, norm=norm)
+        # fake up the array of the scalar mappable. Urgh...
+        sm._A = []
+        #cbar = plt.colorbar(sm)
+
+        if cbaror == 'horizontal':
+            cbar = plt.colorbar(sm, ticks=[tpos], format=cbarfmt, orientation=cbaror)
+            cbar.ax.set_xticklabels(tlabs,rotation=90)
+        else:
+            print warnmsg
+            print '  ' + fname + ": This is odd, because in 'vertical' mode does " + \
+              "not work the re-labelling of the ticking!"
+            cbar = plt.colorbar(sm, ticks=[tpos], format=cbarfmt, orientation=cbaror)
+            cbar.ax.set_xticklabels(tlabs)
+
+        cbar.set_label(gen.latex_text(tn))
+
+    plt.title(gen.latex_text(gtit))
+
+    output_kind(kfig, fn, ifclose)
+
+    return
