Changeset 361 in lmdz_wrf for trunk/tools/drawing_tools.py
- Timestamp:
- Mar 18, 2015, 4:13:46 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/drawing_tools.py
r349 r361 698 698 699 699 def variables_values(varName): 700 """ Function to provide values to plot the different variables values from ASCII file 701 'variables_values.dat' 702 variables_values(varName) 703 [varName]= name of the variable 704 return: [var name], [std name], [minimum], [maximum], 705 [long name]('|' for spaces), [units], [color palette] (following: 706 http://matplotlib.org/1.3.1/examples/color/colormaps_reference.html) 707 [varn]: original name of the variable 708 NOTE: It might be better doing it with an external ASII file. But then we 709 got an extra dependency... 710 >>> variables_values('WRFght') 711 ['z', 'geopotential_height', 0.0, 80000.0, 'geopotential|height', 'm2s-2', 'rainbow'] 712 """ 713 fname='variables_values' 714 715 if varName == 'h': 716 print fname + '_____________________________________________________________' 717 print variables_values.__doc__ 718 quit() 719 720 infile = 'variables_values.dat' 721 722 if not os.path.isfile(infile): 723 print errormsg 724 print ' ' + fname + ": File '" + infile + "' does not exist !!" 725 quit(-1) 726 727 # Variable name might come with a statistical surname... 728 stats=['min','max','mean','stdv', 'sum'] 729 730 ifst = False 731 for st in stats: 732 if varName.find(st) > -1: 733 print ' '+ fname + ": varibale '" + varName + "' with a statistical "+\ 734 " surname: '",st,"' !!" 735 Lst = len(st) 736 LvarName = len(varName) 737 varn = varName[0:LvarName - Lst] 738 ifst = True 739 break 740 if not ifst: 741 varn = varName 742 743 ncf = open('variables_values.dat', 'r') 744 745 for line in ncf: 746 if line[0:1] != '#': 747 values = line.replace('\n','').split(',') 748 if len(values) != 8: 749 print errormsg 750 print "problem in varibale:'", values[0], \ 751 'it should have 8 values and it has',len(values) 752 quit(-1) 753 754 if varn[0:6] == 'varDIM': 755 # Variable from a dimension (all with 'varDIM' prefix) 756 Lvarn = len(varn) 757 varvals = [varn[6:Lvarn+1], varn[6:Lvarn+1], 0., 1., \ 758 "variable|from|size|of|dimension|'" + varn[6:Lvarn+1] + "'", '1', \ 759 'rainbow'] 760 else: 761 varvals = [values[1].replace(' ',''), values[2].replace(' ',''), \ 762 np.float(values[3]), np.float(values[4]),values[5].replace(' ',''),\ 763 values[6].replace(' ',''), values[7].replace(' ','')] 764 if values[0] == varn: 765 print varvals 766 ncf.close() 767 return varvals 768 break 769 770 print errormsg 771 print ' ' + fname + ": variable '" + varn + "' not defined !!!" 772 quit(-1) 773 774 return 775 776 def variables_values_old(varName): 700 777 """ Function to provide values to plot the different variables 701 778 variables_values(varName)
Note: See TracChangeset
for help on using the changeset viewer.