Changeset 1132 in lmdz_wrf for trunk/tools
- Timestamp:
- Oct 3, 2016, 6:04:16 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/drawing_tools.py
r1129 r1132 1465 1465 1466 1466 def transform(vals, trans, dxv='0', dyv='0', dxt='0', dyt='0', dxl='0', \ 1467 dyl='0', dxtit='0', dytit='0' ):1467 dyl='0', dxtit='0', dytit='0', axxkind='fixpixel', axykind='fixpixel'): 1468 1468 """ Function to transform the values and the axes 1469 1469 vals= values to transform … … 1475 1475 d[x/y]l= original tick-labels for the [x/y]-axis 1476 1476 d[x/y]tit= original titles for the [x/y]-axis 1477 ax[x/y]kind= kind of axis reference 1478 'fixpixel': pixel preserves size all along axis 1479 'data': pixel follows data values (as in a georeferenced map) 1477 1480 1478 1481 >>> mat = np.arange(15).reshape(3,5) … … 1631 1634 if flip == 'x': 1632 1635 newvals = newvals[...,::-1] 1633 # if wdvx: 1634 # if len(newdxv.shape) > 1: 1635 # newdxv = newdxv[...,::-1] 1636 # else: 1637 # newdxv = newdxv[::-1] 1638 # if wdtx: 1639 # newdxt = newdxt[::-1] 1640 if wdlx: 1641 newdxl = newdxl[::-1] 1636 if axxkind == 'fixpixel': 1637 if wdtx: 1638 # No pixel deformation 1639 newdxt = 1.-newdxt 1640 elif axxkind == 'data': 1641 if wdvx: 1642 if len(newdxv.shape) > 1: 1643 newdxv = newdxv[...,::-1] 1644 else: 1645 newdxv = newdxv[::-1] 1646 if wdtx: 1647 newdxt = newdxt[::-1] 1648 # if wdlx: 1649 # newdxl = newdxl[::-1] 1642 1650 elif flip == 'y': 1643 1651 newvals = newvals[...,::-1,:] 1644 # if wdvy: 1645 # Ny=len(newdyt) 1646 # if len(newdyv.shape) > 1: 1647 # newdyv = newdyv[...,::-1] 1648 # else: 1649 # newdyv = newdyv[::-1] 1650 # if wdty: 1651 # newdyt = newdyt[::-1] 1652 if wdly: 1653 newdyl = newdyl[::-1] 1652 # No pixel deformation 1653 if axykind == 'fixpixel': 1654 if wdty: 1655 # No pixel deformation 1656 newdyt = 1.-newdyt 1657 elif axykind == 'data': 1658 if wdvy: 1659 if len(newdyv.shape) > 1: 1660 newdyv = newdyv[...,::-1] 1661 else: 1662 newdyv = newdyv[::-1] 1663 if wdty: 1664 newdyt = newdyt[::-1] 1665 # if wdly: 1666 # newdyl = newdyl[::-1] 1654 1667 elif flip == 'z': 1655 1668 newvals = newvals[...,::-1,:,:] … … 3838 3851 dimxv0 = dimxv.copy() 3839 3852 dimyv0 = dimyv.copy() 3840 dimxt0 = np.array(pretty_int(dimxv.min(),dimxv.max(),10)) 3841 dimyt0 = np.array(pretty_int(dimyv.min(),dimyv.max(),10)) 3853 3854 dimxt0 = np.array(pretty_int(dimxv.min(),dimxv.max(),5)) 3855 dimyt0 = np.array(pretty_int(dimyv.min(),dimyv.max(),5)) 3842 3856 dimxl0 = [] 3843 3857 for i in range(len(dimxt0)): dimxl0.append('{:.1f}'.format(dimxt0[i])) 3844 3858 dimyl0 = [] 3845 3859 for i in range(len(dimyt0)): dimyl0.append('{:.1f}'.format(dimyt0[i])) 3860 3846 3861 dimxT0 = variables_values(dimn[0])[0] + ' (' + units_lunits(dimxu) + ')' 3847 3862 dimyT0 = variables_values(dimn[1])[0] + ' (' + units_lunits(dimyu) + ')' 3863 3864 if mapv is not None: 3865 pixkind = 'data' 3866 else: 3867 # No following data values 3868 dimxt0 = np.arange(len(dimxt0),dtype=np.float)/(len(dimxt0)) 3869 dimyt0 = np.arange(len(dimyt0),dtype=np.float)/(len(dimyt0)) 3870 pixkind = 'fixpixel' 3848 3871 3849 3872 if reva is not None: … … 3933 3956 3934 3957 else: 3935 x = lon0 3936 y = lat0 3958 # No following data values 3959 #x = dimxv 3960 #y = dimyv 3961 x = (dimxv-np.min(dimxv))/(np.max(dimxv) - np.min(dimxv)) 3962 y = (dimyv-np.min(dimyv))/(np.max(dimyv) - np.min(dimyv)) 3937 3963 3938 3964 vsend = np.zeros((2), dtype=np.float) … … 4034 4060 plt.ylabel(dimyT) 4035 4061 4036 txpos = pretty_int(x.min(),x.max(),5) 4037 typos = pretty_int(y.min(),y.max(),5) 4038 txlabels = list(txpos) 4039 for i in range(len(txlabels)): txlabels[i] = '{:6g}'.format(txlabels[i]) 4040 tylabels = list(typos) 4041 for i in range(len(tylabels)): tylabels[i] = '{:6g}'.format(tylabels[i]) 4062 # Using output from transform 4063 # print 'x min:', x.min(),'max:',x.max() 4064 # print 'y min:', y.min(),'max:',y.max() 4065 # txpos = pretty_int(x.min(),x.max(),5) 4066 # typos = pretty_int(y.min(),y.max(),5) 4067 # txlabels = list(txpos) 4068 # for i in range(len(txlabels)): txlabels[i] = '{:6g}'.format(txlabels[i]) 4069 # tylabels = list(typos) 4070 # for i in range(len(tylabels)): tylabels[i] = '{:6g}'.format(tylabels[i]) 4042 4071 4043 4072 plt.axis([x.min(), x.max(), y.min(), y.max()]) 4044 4073 4045 4074 if mapv is None: 4046 plt.xticks(txpos, txlabels) 4047 plt.yticks(typos, tylabels) 4075 # plt.xticks(txpos, txlabels) 4076 # plt.yticks(typos, tylabels) 4077 plt.xticks(dimxt, dimxl) 4078 plt.yticks(dimyt, dimyl) 4048 4079 4049 4080 # units labels … … 7508 7539 7509 7540 # graphtit = gtitle.replace('_','\_').replace('&','\&') 7510 graphtit = g title7541 graphtit = gen.latex_text(gtitle) 7511 7542 7512 7543 plt.title(graphtit,position=titleloc)
Note: See TracChangeset
for help on using the changeset viewer.