Index: trunk/tools/generic.py
===================================================================
--- trunk/tools/generic.py	(revision 808)
+++ trunk/tools/generic.py	(revision 809)
@@ -17,13 +17,18 @@
 # Character to split serie of values
 cV = '@'
+# Character for spaces
+cE = '!'
+
 # List of available operations
-operations=['coincident_CFtimes', 'count_cond', 'grid_combinations', 'PolyArea',     \
-  'radial_points',                                                                   \
+operations=['coincident_CFtimes', 'count_cond', 'datetimeStr_conversion',            \
+  'grid_combinations',                                                               \
+  'interpolate_locs', 'PolyArea',                                                    \
+  'radial_points', 'radius_dist',                                                    \
   'rmNOnum', 'running_mean',                                                         \
   'significant_decomposition', 'squared_radial',                                     \
-  'unitsDate', 'wdismean']
+  'table_tex_file', 'unitsDate', 'wdismean']
 
 hundredvals = '0'
-for i in range(1,100): hundredvals = hundredvals + '@' + str(i)
+for i in range(1,100): hundredvals = hundredvals + cV + str(i)
 
 vs100 = '0@1@2@3@4@5@6@7@8@9@10@11@12@13@14@15@16@17@18@19@20@21@22@23@24@25@26@27'
@@ -35,9 +40,13 @@
 ## e.g. # generic.py -o 'coincident_CFtimes' -S '0@1@2@3@4@5@6@7@8@9,seconds since 1949-12-01 00:00:00,hours since 1949-12-01 00:00:00'
 ## e.g. # generic.py -o count_cond -S 0@1@2@3@4@5@6@7@8@9,4,le
+## e.g. # generic.py -o datetimeStr_conversion -S '1976-02-17_08:32:05,Y-m-d_H:M:S,matYmdHMS'
 ## e.g. # generic.py -o grid_combinations -S 1,2
+## e.g. # generic.py -o interpolate_locs -S -1.2@2.4@5.6@7.8@12.0,0.5@2.5,lin
 ## e.g. # generic.py -o PolyArea -S -0.5@0.5@0.5@-0.5,0.5@0.5@-0.5@-0.5
 ## e.g. # generic.py -o radial_points -S 0.785398163397,5
+## e.g. # generic.py -o radius_dist -S 3,5,2,2
 ## e.g. # generic.py -o rmNOnum -S LMD123IPSL
-## e.g. # generic.py -o significant_decomposition -S 3.576,-2
+## e.g. # generic.py -o significant_decomposition -S 3.576,-2,0@1@2@3@4@5@6@7@8@9@10@11@12@13@14,a@b@c@d@e,i@ii@iii,table.tex
+## e.g. # generic.py -o table_tex_file -S '5,3,0@5@10@1@6@11@2@7@12@3@8@13@4@9@14,!@a@b@c@d@e,i@ii@iii,table.tex'
 ## e.g. # generic.py -o unitsDate -S '19490101000000,19760217082932,second'
 ## e.g. # generic.py -o running_mean -S 0@1@2@3@4@5@6@7@8@9,10
@@ -82,5 +91,5 @@
             print gen.coincident_CFtimes.__doc__
             quit(-1)
-        vals0 = np.array(vals[0].split('@'), dtype=np.float)
+        vals0 = np.array(vals[0].split(cV), dtype=np.float)
         print gen.coincident_CFtimes(vals0, vals[1], vals[2])
 
@@ -98,8 +107,23 @@
             print gen.count_cond.__doc__
             quit(-1)
-        vals0 = np.array(vals[0].split('@'), dtype=np.float)
-        print gen.count_cond(np.array(vals[0].split('@'), dtype=np.float),           \
+        vals0 = np.array(vals[0].split(cV), dtype=np.float)
+        print gen.count_cond(np.array(vals[0].split(cV), dtype=np.float),           \
           np.float(vals[1]), vals[2])
 
+elif oper == 'datetimeStr_conversion':
+    Nvals = 3
+    vals = opts.values.split(cS)
+    if vals[0] == 'h':
+        print gen.datetimeStr_conversion.__doc__
+        quit(-1)
+    else:
+        if len(vals) != Nvals:
+            print errormsg
+            print '  ' + main + ": operation '" + oper + "' requires", Nvals, 'and', \
+              len(vals), ' has passed!!'
+            print gen.datetimeStr_conversion.__doc__
+            quit(-1)
+        print gen.datetimeStr_conversion(vals[0], vals[1], vals[2])
+
 elif oper == 'grid_combinations':
     Nvals = 2
@@ -117,4 +141,22 @@
 
         print gen.grid_combinations(np.int(vals[0]), np.int(vals[1]))
+
+elif oper == 'interpolate_locs':
+    Nvals = 3
+    vals = opts.values.split(cS)
+    if vals[0] == 'h':
+        print gen.interpolate_locs.__doc__
+        quit(-1)
+    else:
+        if len(vals) != Nvals:
+            print errormsg
+            print '  ' + main + ": operation '" + oper + "' requires", Nvals, 'and', \
+              len(vals), ' has passed!!'
+            print gen.interpolate_locs.__doc__
+            quit(-1)
+        vals0 = np.array(vals[0].split(cV), dtype=np.float)
+        vals1 = np.array(vals[1].split(cV), dtype=np.float)
+
+        print gen.interpolate_locs(vals0, vals1, vals[2])
 
 elif oper == 'PolyArea':
@@ -151,4 +193,19 @@
         print gen.radial_points(np.float(vals[0]), int(vals[1]))
 
+elif oper == 'radius_dist':
+    Nvals = 1
+    vals = opts.values.split(cS)
+    if vals[0] == 'h':
+        print gen.radius_dist.__doc__
+        quit(-1)
+    else:
+        if len(vals) != Nvals:
+            print errormsg
+            print '  ' + main + ": operation '" + oper + "' requires", Nvals, 'and', \
+              len(vals), ' has passed!!'
+            print gen.radius_dist.__doc__
+            quit(-1)
+        print gen.radius_dist(int(vals[0]), int(vals[1]), int(vals[2]), int(vals[2]))
+
 elif oper == 'rmNOnum':
     Nvals = 1
@@ -179,5 +236,5 @@
             print gen.running_mean.__doc__
             quit(-1)
-        print gen.running_mean(np.array(vals[0].split('@'), dtype=np.float), int(vals[1]))
+        print gen.running_mean(np.array(vals[0].split(cV), dtype=np.float), int(vals[1]))
 
 elif oper == 'significant_decomposition':
@@ -211,4 +268,25 @@
         print gen.squared_radial(int(vals[0]))
 
+elif oper == 'table_tex_file':
+    Nvals = 6
+    vals = opts.values.split(cS)
+    if vals[0] == 'h':
+        print gen.table_tex_file.__doc__
+        quit(-1)
+    else:
+        if len(vals) != Nvals:
+            print errormsg
+            print '  ' + main + ": operation '" + oper + "' requires", Nvals, 'and', \
+              len(vals), ' has passed!!'
+            print gen.table_tex_file.__doc__
+            quit(-1)
+        vals2 = np.array(vals[2].split(cV),dtype=np.float).reshape(int(vals[0]),     \
+          int(vals[1]))
+        vals3 = vals[3].replace(cE,' ').split(cV)
+        vals4 = vals[4].replace(cE,' ').split(cV)
+
+        print gen.table_tex_file(int(vals[0]), int(vals[1]), vals2, vals3, vals4,    \
+          vals[5])
+
 elif oper == 'unitsDate':
     Nvals = 3
@@ -239,6 +317,6 @@
             print gen.wdismean.__doc__
             quit(-1)
-        vals0 = np.array(vals[0].split('@'), dtype=np.float)
-        vals1 = np.array(vals[1].split('@'), dtype=np.float).reshape(2,2)
+        vals0 = np.array(vals[0].split(cV), dtype=np.float)
+        vals1 = np.array(vals[1].split(cV), dtype=np.float).reshape(2,2)
 
         print gen.wdismean(vals0, vals1)
Index: trunk/tools/generic_tools.py
===================================================================
--- trunk/tools/generic_tools.py	(revision 808)
+++ trunk/tools/generic_tools.py	(revision 809)
@@ -4528,7 +4528,7 @@
 
 def table_tex(tablevals, colnames, rownames, of):
-    """ Function to write into a LaTeX tabukar from a table of values
+    """ Function to write into a LaTeX tabular from a table of values
       tablevals = (ncol nrow) of values
-      colnames = list with ncol labels for the columns
+      colnames = list with ncol labels for the columns (1 more than data for the row names)
       rownames = list with nrow labels for the rows
       of= object ASCII file to write the table
@@ -4581,4 +4581,31 @@
 
     of.write('\\end{tabular}\n')
+
+    return
+
+def table_tex_file(Ncol, Nrow, tablevals, colnames, rownames, ofile):
+    """ Function to write into a file a LaTeX tabular from a table of values
+      tablevals = (ncol nrow) of values
+      colnames = list with ncol labels for the columns (1 more than data for the row names)
+      rownames = list with nrow labels for the rows
+      ofile= ASCII file to write the table
+    >>> values = np.arange(15).reshape(5,3)
+    >>> colns = ['a','b','c','d','e']
+    >>> rowns = ['i','ii','iii']
+    >>> table_text_file(5, 3, values, colns, rowns, 'table.tex')
+    """
+    fname = 'table_tex_file'
+
+    objf = open(ofile, 'w')
+    objf.write('\\documentclass{article}\n')
+    objf.write('\n')
+    objf.write('\\begin{document}\n')
+
+    table_tex(tablevals, colnames, rownames, objf)
+
+    objf.write('\\end{document}\n')
+    objf.close()
+
+    print fname + "': successfull written of '" + ofile + "' !!"
 
     return
@@ -4641,5 +4668,4 @@
 
     return lonvv, latvv
-
 
 def interpolate_locs(locs,coords,kinterp):
