- Timestamp:
- Apr 20, 2016, 5:58:40 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/nc_var_tools.py
r707 r708 11415 11415 return dateYmdHMS 11416 11416 11417 def table_tex(tablevals, colnames, rownames, of): 11418 """ Function to write into a LaTeX tabukar from a table of values 11419 tablevals = (ncol nrow) of values 11420 colnames = list with ncol labels for the columns 11421 rownames = list with nrow labels for the rows 11422 of= object ASCII file to write the table 11423 """ 11424 errormsg = 'ERROR -- error -- ERROR -- error' 11425 11426 fname = 'table_tex' 11427 11428 Ncol = tablevals.shape[0] 11429 Nrow = tablevals.shape[1] 11430 11431 if Ncol + 1 != len(colnames): 11432 print errormsg 11433 print ' ' + fname + ': wrong number of column names!!' 11434 print ' data has:', Ncol, 'and you provided:', len(colnames) 11435 print ' remember to provide one more for the label of the rows!' 11436 print ' you provide:',colnames 11437 quit(-1) 11438 11439 if Nrow != len(rownames): 11440 print errormsg 11441 print ' ' + fname + ': wrong number of row names!!' 11442 print ' data has:', Nrow, 'and you provided:', len(rownames) 11443 print ' you provide:',rownames 11444 quit(-1) 11445 11446 colcs = '' 11447 colns = '' 11448 for icol in colnames: 11449 colcs = colcs + 'c' 11450 if icol == colnames[0]: 11451 colns = ' {\\bfseries{' + icol + '}}' 11452 else: 11453 colns = colns + ' & {\\bfseries{' + icol + '}}' 11454 11455 of.write('\n') 11456 of.write("%Automatically written file from function '" + fname + "'\n") 11457 of.write('\\begin{tabular}{l'+colcs+'}\n') 11458 of.write(colns + ' \\\\ \\hline\n') 11459 11460 ir = 0 11461 for irow in rownames: 11462 rowns = '{\\bfseries{' + irow + '}}' 11463 for ic in range(Ncol): 11464 rowns = rowns + ' & ' + str(tablevals[ic,ir]) 11465 rowns = rowns + ' \\\\' 11466 11467 of.write(rowns + '\n') 11468 ir = ir + 1 11469 11470 of.write('\\end{tabular}\n') 11471 11472 return 11473 11417 11474 def radius_dist(dx,dy,ptx,pty): 11418 11475 """ Function to generate a matrix with the distance at a given point
Note: See TracChangeset
for help on using the changeset viewer.