Changeset 1588 in lmdz_wrf for trunk/tools
- Timestamp:
- Jul 3, 2017, 5:51:00 PM (8 years ago)
- Location:
- trunk/tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/drawing_tools.py
r1587 r1588 68 68 # check_arguments: 69 69 # Str_Bool: 70 # pixelgrid: Function to provide the kind of grid distribution for a plot 70 71 # plot_points: 71 72 # plot_2Dfield: … … 353 354 fname = 'interpolate_locs' 354 355 355 if locs == 'h':356 if type(locs) == type('S') and locs == 'h': 356 357 print fname + '_____________________________________________________________' 357 358 print interpolate_locs.__doc__ … … 1542 1543 fname = 'transform' 1543 1544 1545 print fname + ' Lluis: input values trans:', trans, 'dxv:', dxv, 'dyv:', dyv, 'dxt', dxt, 'dyt', dyt, 'dxl', dxl, \ 1546 'dyl', dyl, 'dxtit', dxtit, 'dytit', dytit, 'axxkind', axxkind, 'axykind', axykind 1547 1544 1548 transforms = trans.split('|') 1545 1549 Ntransforms = len(transforms) … … 1594 1598 # axes' title 1595 1599 wdTx = False 1596 if type(dxt) == type('S') and dxt != 0:1600 if dxtit != 0: 1597 1601 newdxtit = str(dxtit) 1598 1602 wdTx = True 1603 print fname + ': Lluis hey:', newdxtit 1599 1604 else: 1600 1605 newdxtit = None 1601 1606 1602 1607 wdTy = False 1603 if type(dyt) == type('S') and dyt != '0':1608 if dytit != '0': 1604 1609 newdytit = str(dytit) 1605 1610 wdTy = True 1611 print fname + ': Lluis hey:', newdytit 1606 1612 else: 1607 1613 newdytit = None … … 1662 1668 if flip == 'x': 1663 1669 newvals = newvals[...,::-1] 1664 if axxkind == 'fixpixel': 1665 if wdtx: 1666 # No pixel deformation 1667 newdxt = 1.-newdxt 1668 elif axxkind == 'data': 1669 if wdvx: 1670 if len(newdxv.shape) > 1: 1671 newdxv = newdxv[...,::-1] 1672 else: 1673 newdxv = newdxv[::-1] 1674 if wdtx: 1675 newdxt = newdxt[::-1] 1676 # if wdlx: 1677 # newdxl = newdxl[::-1] 1670 if wdvx: 1671 if len(newdxv.shape) > 1: 1672 newdxv = newdxv[...,::-1] 1673 else: 1674 newdxv = newdxv[::-1] 1675 if wdtx: 1676 newdxt = newdxt[::-1] 1678 1677 elif flip == 'y': 1679 1678 newvals = newvals[...,::-1,:] 1680 # No pixel deformation 1681 if axykind == 'fixpixel': 1682 if wdty: 1683 # No pixel deformation 1684 newdyt = 1.-newdyt 1685 elif axykind == 'data': 1686 if wdvy: 1687 if len(newdyv.shape) > 1: 1688 newdyv = newdyv[...,::-1] 1689 else: 1690 newdyv = newdyv[::-1] 1691 if wdty: 1692 newdyt = newdyt[::-1] 1693 # if wdly: 1694 # newdyl = newdyl[::-1] 1679 #if wdvy: 1680 # if len(newdyv.shape) > 1: 1681 # newdyv = newdyv[...,::-1] 1682 # else: 1683 # newdyv = newdyv[::-1] 1684 #if wdty: 1685 # newdyt = newdyt[::-1] 1686 #if wdly: 1687 # newdyl = newdyl[::-1] 1695 1688 elif flip == 'z': 1696 1689 newvals = newvals[...,::-1,:,:] … … 1698 1691 print errormsg 1699 1692 print ' '+ fname + ": transformation '" + transform + "' not ready!!" 1693 print ' available ones:', ['transpose', 'flip@x', 'flip@y'] 1700 1694 quit(-1) 1695 1696 print fname + ' Lluis: newdxv:', newdxv, 'newdyv:', newdyv, 'newdxt:', newdxt, 'newdyt:', newdyt, \ 1697 'newdxl', newdxl, 'newdyl', newdyl, 'newdxtit', newdxtit, 'newdytit', newdytit 1701 1698 1702 1699 return newvals, newdxv, newdyv, newdxt, newdyt, newdxl, newdyl, newdxtit, newdytit … … 2857 2854 return xs, xf, Nx, orx, ys, yf, Ny, ory 2858 2855 2856 def pixelgrid(daxisv, axist, axisL, axis, axiskind, trans): 2857 """ Function to provide the kind of grid distribution for a plot 2858 daxisv: values along the axis of the plot 2859 axis: axis of the plot 'x/y' 2860 axist: position of the ticks along the axis 2861 axisL: limits of the axis 2862 axiskind: kind of axis reference 2863 'fixpixel': pixel preserves size all along axis 2864 'data': pixel follows data values (as in a georeferenced map) 2865 trans: transformation applied to the axes. '|' separated list of operations of transformation 2866 'transpose': Transpose matrix of values (x-->y, y-->x) 2867 'flip@[x/y]': Flip the given axis 2868 2869 output: 2870 axisv: resultant values along the axis 2871 newaxist: resultant position of the ticks along the axis 2872 newaxisL: new limits of the axis 2873 """ 2874 fname = 'pixelgrid' 2875 2876 available = ['data', 'fixpixel'] 2877 if not gen.searchInlist(available, axiskind): 2878 print errormsg 2879 print ' ' +fname+ ": wrong kind of grid-size for axis '" + axiskind + "' !!" 2880 print ' available ones:', available 2881 quit(-1) 2882 2883 if len(daxisv.shape) == 1: 2884 dn = daxisv[0] 2885 dx = daxisv[len(daxisv)-1] 2886 Laxis = daxisv.shape[0] 2887 axisint = daxisv 2888 if axiskind == 'fixpixel': 2889 axisv = np.arange(Laxis, dtype=np.float)/(Laxis-1) 2890 elif axiskind == 'data': 2891 axisv = daxisv 2892 elif len(daxisv.shape) == 2: 2893 dn = daxisv[0,0] 2894 if axis == 'x': 2895 Laxis = daxisv.shape[1] 2896 dx = daxisv[0,Laxis-1] 2897 axisint = daxisv[0,:] 2898 if axiskind == 'fixpixel': 2899 for iy in range(daxisv.shape[0]): 2900 axisv[iy,:] = np.arange(Laxis, dtype=np.float)/(Laxis-1) 2901 elif axiskind == 'data': 2902 axisv = daxisv 2903 else: 2904 Laxis = daxisv.shape[0] 2905 dx = daxisv[Laxis-1,0] 2906 axisint = daxisv[:,0] 2907 if axiskind == 'fixpixel': 2908 for ix in range(daxisv.shape[1]): 2909 axisv[:,ix] = np.arange(Laxis, dtype=np.float)/(Laxis-1) 2910 elif axiskind == 'data': 2911 axisv = daxisv 2912 2913 transforms = trans.split('|') 2914 2915 # Axis ticks and axis range 2916 if axiskind == 'fixpixel': 2917 newaxist = interpolate_locs(axist,axisint,'lin')/(Laxis-1) 2918 if gen.searchInlist(transforms, 'flip@' + axis): 2919 newaxisL = np.array([1., 0.]) 2920 else: 2921 newaxisL = np.array([0., 1.]) 2922 elif axiskind == 'data': 2923 newaxist = axist 2924 newaxisL = axisL 2925 2926 return axisv, newaxist, newaxisL 2927 2859 2928 ####### ###### ##### #### ### ## # END of GENERIC functions 2860 2929 … … 4370 4439 #quit() 4371 4440 4372 def plot_2D_shadow_time(varsv, vnames, dim xv, dimyv, dimxu, dimyu, dimn, vaxv, cbarv,\4373 vs, uts, vtit, kfig, reva, taxis, tpos, tlabs, ifclose):4441 def plot_2D_shadow_time(varsv, vnames, dimvv, dimtv, dimvu, dimn, vaxv, cbarv, \ 4442 vs, uts, xpixk, ypixk, vtit, kfig, reva, taxis, tpos, tlabs, ifclose): 4374 4443 """ Plotting a 2D field with one of the axes being time 4375 4444 varsv= 2D values to plot with shading 4376 4445 vnames= shading variable name for the figure 4377 dim[x/y]v= values at the axes of x and y 4378 dim[x/y]u= units at the axes of x and y 4446 dimvv= values at the axis of values 4447 dimtv= values at the axis of time 4448 dimvu= units at the axes of values 4379 4449 dimn= dimension names to plot 4380 4450 vaxv= list with the non-temporal axis paramteres [style, format, number and orientation] … … 4394 4464 percentile_(100-val)-median) 4395 4465 uts= units of the variable to shadow 4396 vtit= title of the variable 4466 [x/ypixk]= kind of grid-pixel for the figure 4467 'data': size pixel along the given axis change according to the values along the axis 4468 'fixpixel': size pixel along the given axis does not change 4469 vtit= title of the figure 4397 4470 kfig= kind of figure (jpg, pdf, png) 4398 4471 reva= … … 4406 4479 fname = 'plot_2D_shadow_time' 4407 4480 4408 if varsv == 'h':4481 if type(varsv) == type('S') and varsv == 'h': 4409 4482 print fname + '_____________________________________________________________' 4410 4483 print plot_2D_shadow_time.__doc__ … … 4417 4490 quit(-1) 4418 4491 4419 dimxv0 = dimxv.copy()4420 dimyv0 = dimyv.copy()4421 4422 dxn = dimxv.min()4423 dxx = dimxv.max()4424 dyn = dimyv.min()4425 dyx = dimyv.max()4426 4427 4492 # Definning ticks labels 4428 4493 if taxis == 'x': 4494 dimxv0 = dimtv.copy() 4495 dimyv0 = dimvv.copy() 4496 4497 dxn = dimtv.min() 4498 dxx = dimtv.max() 4499 dyn = dimvv.min() 4500 dyx = dimvv.max() 4501 4429 4502 dimxt0 = tpos 4430 4503 dimxl0 = tlabs 4431 dimxT0 = dimxu 4504 dimxT0 = 'cf time' 4505 4432 4506 if vaxv[0] == 'pretty': 4433 dimyt0 = np.array(gen.pretty_int(dyn,dyx ,vaxv[2]))4507 dimyt0 = np.array(gen.pretty_int(dyn,dyx+(dyx-dyn)/vaxv[2],vaxv[2])) 4434 4508 elif vaxv[0] == 'Nfix': 4435 4509 dimyt0 = np.arange(dyn,dyx,(dyx-dyn)/(1.*vaxv[2])) … … 4439 4513 for i in range(len(dimyt0)): dimyl0.append('{:{style}}'.format(dimyt0[i], \ 4440 4514 style=vaxv[1])) 4441 dimyT0 = variables_values(dimn[1])[0] + ' (' + units_lunits(dimyu) + ')' 4515 dimyT0 = gen.latex_text(variables_values(dimn[1])[0]) + ' (' + \ 4516 units_lunits(dimvu) + ')' 4442 4517 4443 4518 # No following data values 4444 dimyt0 = np.arange(len(dimyt0),dtype=np.float)/(len(dimyt0)) 4445 pixkind = 'fixpixel' 4446 4447 else: 4519 #dimyt0 = np.arange(len(dimyt0),dtype=np.float)/(len(dimyt0)) 4520 #pixkind = 'fixpixel' 4521 4522 else: 4523 dimxv0 = dimvv.copy() 4524 dimyv0 = dimtv.copy() 4525 4526 dxn = dimvv.min() 4527 dxx = dimvv.max() 4528 dyn = dimtv.min() 4529 dyx = dimtv.max() 4530 4448 4531 if vaxv[0] == 'pretty': 4449 dimxt0 = np.array(gen.pretty_int(dxn,dxx ,vaxv[2]))4532 dimxt0 = np.array(gen.pretty_int(dxn,dxx+(dxx-dxn)/vaxv[2],vaxv[2])) 4450 4533 elif vaxv[0] == 'Nfix': 4451 4534 dimxt0 = np.arange(dxn,dxx,(dxx-dxn)/(1.*vaxv[2])) … … 4455 4538 for i in range(len(dimxt0)): dimxl0.append('{:{style}}'.format(dimxt0[i], \ 4456 4539 style=vaxv[1])) 4457 dimxT0 = variables_values(dimn[0])[0] + ' (' + units_lunits(dimxu) + ')' 4540 dimxT0 = gen.latex_text(variables_values(dimn[0])[0]) + ' (' + \ 4541 units_lunits(dimvu) + ')' 4458 4542 4459 4543 dimyt0 = tpos 4460 4544 dimyl0 = tlabs 4461 dimyT0 = dimyu4545 dimyT0 = 'cf time' 4462 4546 # No following data values 4463 dimxt0 = np.arange(len(dimxt0),dtype=np.float)/(len(dimxt0))4464 pixkind = 'fixpixel'4547 #dimxt0 = np.arange(len(dimxt0),dtype=np.float)/(len(dimxt0)) 4548 #pixkind = 'fixpixel' 4465 4549 4466 4550 if reva is not None: 4467 varsv, dimxv, dimyv, dimxt, dimyt, dimxl, dimyl, dimxT, dimyT =\4468 transform(varsv, reva, dxv=dimxv0, dyv=dimyv0, dxt=dimxt0, dyt=dimyt0,\4551 varsv, dimxv, dimyv, dimxt, dimyt, dimxl, dimyl, dimxT, dimyT, xtrms, ytrms= \ 4552 gen.transform(varsv, reva, dxv=dimxv0, dyv=dimyv0, dxt=dimxt0, dyt=dimyt0, \ 4469 4553 dxl=dimxl0, dyl=dimyl0, dxtit=dimxT0, dytit=dimyT0) 4470 4554 else: … … 4478 4562 dimyT = dimyT0 4479 4563 4480 if len(dimxv.shape) == 3: 4481 dxget='1,2' 4482 elif len(dimxv.shape) == 2: 4483 dxget='0,1' 4484 elif len(dimxv.shape) == 1: 4485 dxget='0' 4486 else: 4487 print errormsg 4488 print ' ' + fname + ': shape of x-values:',dimxv.shape,'not ready!!' 4489 quit(-1) 4490 4491 if len(dimyv.shape) == 3: 4492 dyget='1,2' 4493 elif len(dimyv.shape) == 2: 4494 dyget='0,1' 4495 elif len(dimyv.shape) == 1: 4496 dyget='0' 4497 else: 4498 print errormsg 4499 print ' ' + fname + ': shape of y-values:',dimyv.shape,'not ready!!' 4500 quit(-1) 4501 4502 # No following data values 4503 x = (dimxv-np.min(dimxv))/(np.max(dimxv) - np.min(dimxv)) 4504 y = (dimyv-np.min(dimyv))/(np.max(dimyv) - np.min(dimyv)) 4564 # Which kind of grid-pixel shape do we want? 4565 x, dimxt, xtrms = pixelgrid(dimxv, dimxt, xtrms, 'x', xpixk, reva) 4566 y, dimyt, ytrms = pixelgrid(dimyv, dimyt, ytrms, 'y', ypixk, reva) 4505 4567 4506 4568 # Changing limits of the colors … … 4509 4571 plt.rc('text', usetex=True) 4510 4572 4511 print fname + 'Lluis shapes x:', x.shape, 'y:', y.shape, 'varsv:', varsv.shape4512 4573 plt.pcolormesh(x, y, varsv, cmap=plt.get_cmap(cbarv[0]), vmin=vsend[0], vmax=vsend[1]) 4513 4574 if cbarv[2] == 'horizontal': … … 4523 4584 4524 4585 if taxis == 'x': 4525 plt.xticks((dimxt-dxn)/(dxx-dxn), dimxl) 4586 #plt.xticks((dimxt-dxn)/(dxx-dxn), dimxl) 4587 plt.xticks(dimxt, dimxl) 4526 4588 plt.yticks(dimyt, dimyl, rotation=vaxv[3]) 4527 4589 else: 4528 4590 plt.xticks(dimxt, dimxl, rotation=vaxv[3]) 4529 plt.yticks((dimyt-dyn)/(dyx-dyn), dimyl) 4591 #plt.yticks((dimyt-dyn)/(dyx-dyn), dimyl) 4592 plt.yticks(dimyt, dimyl) 4530 4593 4531 4594 plt.xlabel(dimxT) 4532 4595 plt.ylabel(dimyT) 4533 4596 4534 plt.axis([x .min(), x.max(), y.min(), y.max()])4597 plt.axis([xtrms[0], xtrms[1], ytrms[0], ytrms[1]]) 4535 4598 4536 4599 # units labels -
trunk/tools/generic_tools.py
r1570 r1588 5734 5734 fname = 'interpolate_locs' 5735 5735 5736 if locs == 'h':5736 if type(locs) == type('S') and locs == 'h': 5737 5737 print fname + '_____________________________________________________________' 5738 5738 print interpolate_locs.__doc__ … … 12011 12011 return [valmin, valmax] 12012 12012 12013 def transform(vals, trans, dxv='0', dyv='0', dxt='0', dyt='0', dxl='0', \ 12014 dyl='0', dxtit='0', dytit='0'): 12015 """ Function to transform the values and the axes 12016 vals= values to transform 12017 trans= '|' separated list of operations of transformation 12018 'transpose': Transpose matrix of values (x-->y, y-->x) 12019 'flip@[x/y]': Flip the given axis 12020 d[x/y]v= original values for the [x/y]-axis 12021 d[x/y]t= original ticks for the [x/y]-axis 12022 d[x/y]l= original tick-labels for the [x/y]-axis 12023 d[x/y]tit= original titles for the [x/y]-axis 12024 12025 >>> mat = np.arange(15).reshape(3,5) 12026 >>> xvals = np.zeros((3,5), dtype=np.float) 12027 >>> yvals = np.zeros((3,5), dtype=np.float) 12028 >>> for i in range(5): 12029 >>> xvals[:,i] = -1.25 + i*0.5 12030 >>> for j in range(3): 12031 >>> yvals[j,:] = 40.25 + j*0.5 12032 >>> xticks = np.array([-1.25, -0.25, 0.25]) 12033 >>> yticks = np.array([40.25, 41.25]) 12034 >>> xticklab = ['1.25 W', '0.25 W', '0,25 E'] 12035 >>> yticklab = ['40.25 N', '41.25 N'] 12036 >>> xtit = 'Longitude' 12037 >>> ytit = 'Latitude' 12038 >>> nv, ndxv, ndyv, ndxt, ndyt, dxl, ndyl, ndxT, ndyT = transform(mat, 'transpose', \ 12039 xvals, yvals, xticks, yticks, xticklab, yticklab, xtit, ytit) 12040 [[ 0 5 10] 12041 [ 1 6 11] 12042 [ 2 7 12] 12043 [ 3 8 13] 12044 [ 4 9 14]] 12045 [[ 40.25 40.75 41.25] 12046 [ 40.25 40.75 41.25] 12047 [ 40.25 40.75 41.25] 12048 [ 40.25 40.75 41.25] 12049 [ 40.25 40.75 41.25]] 12050 [[-1.25 -1.25 -1.25] 12051 [-0.75 -0.75 -0.75] 12052 [-0.25 -0.25 -0.25] 12053 [ 0.25 0.25 0.25] 12054 [ 0.75 0.75 0.75]] 12055 [ 40.25 41.25] 12056 [-1.25 -0.25 0.25] 12057 ['41.25 N', '40.25 N'] 12058 ['0,25 E', '0.25 W', '1.25 W'] 12059 Latitude 12060 Longitude 12061 """ 12062 fname = 'transform' 12063 12064 transforms = trans.split('|') 12065 Ntransforms = len(transforms) 12066 12067 newvals = vals.copy() 12068 12069 # values 12070 wdvx = False 12071 if type(dxv) == type('S') and dxv == '0': 12072 newdxv = None 12073 else: 12074 newdxv = dxv.copy() 12075 wdvx = True 12076 12077 wdvy = False 12078 if type(dyv) == type('S') and dyv == '0': 12079 newdyv = None 12080 else: 12081 newdyv = dyv.copy() 12082 wdvy = True 12083 12084 # ticks 12085 wdtx = False 12086 if type(dxt) == type('S') and dxt == '0': 12087 newdxt = None 12088 else: 12089 newdxt = dxt.copy() 12090 wdtx = True 12091 12092 wdty = False 12093 if type(dyt) == type('S') and dyt == '0': 12094 newdyt = None 12095 else: 12096 newdyt = dyt.copy() 12097 wdty = True 12098 12099 # label in ticks 12100 wdlx = False 12101 if type(dxl) == type('S') and dxl == '0': 12102 newdxl = None 12103 else: 12104 newdxl = list(dxl) 12105 wdlx = True 12106 12107 wdly = False 12108 if type(dyl) == type('S') and dyl == '0': 12109 newdyl = None 12110 else: 12111 newdyl = list(dyl) 12112 wdly = True 12113 12114 # axes' title 12115 wdTx = False 12116 if dxtit != 0: 12117 newdxtit = str(dxtit) 12118 wdTx = True 12119 else: 12120 newdxtit = None 12121 12122 wdTy = False 12123 if dytit != '0': 12124 newdytit = str(dytit) 12125 wdTy = True 12126 else: 12127 newdytit = None 12128 12129 # axis limits. They will be used to flip the axis in plot if necessary 12130 if len(dxv.shape) == 1: 12131 newxaxislim = np.array([dxv[0], dxv[len(dxv)-1]]) 12132 elif len(dxv.shape) == 2: 12133 newxaxislim = np.array([dxv[0,0], dxv[0,dxv.shape[1]-1]]) 12134 else: 12135 print errormsg 12136 print ' ' + fname + ": wrong rank of data for axis 'x':", dxv.shape, '!!' 12137 print ' must be of rank 2!!' 12138 quit(-1) 12139 12140 if len(dyv.shape) == 1: 12141 newyaxislim = np.array([dyv[0], dyv[len(dyv)-1]]) 12142 elif len(dyv.shape) == 2: 12143 newyaxislim = np.array([dyv[0,0], dyv[dyv.shape[0]-1],0]) 12144 else: 12145 print errormsg 12146 print ' ' + fname + ": wrong rank of data for axis 'y':", dyv.shape, '!!' 12147 print ' must be of rank 2!!' 12148 quit(-1) 12149 12150 for transform in transforms: 12151 if transform == 'transpose': 12152 newvals = np.transpose(newvals) 12153 if wdvx and wdvy: 12154 copy = newdxv.copy() 12155 newdxv = np.transpose(newdyv) 12156 newdyv = np.transpose(copy) 12157 # else: 12158 # print errormsg 12159 # print ' ' + fname + ": it can not be '" + transform + "' without " +\ 12160 # ' both dimxvals:', dxv, ' and dimyvals:', dyv, ' !!' 12161 # quit(-1) 12162 12163 if wdtx and wdtx: 12164 copy = newdxt.copy() 12165 newdxt = np.transpose(newdyt) 12166 newdyt = np.transpose(copy) 12167 # else: 12168 # print errormsg 12169 # print ' ' + fname + ": it can not be '" + transform + "' without " +\ 12170 # ' both dimxtickvals:', dxt, ' and dimytickvals:', dyt, ' !!' 12171 # quit(-1) 12172 12173 if wdlx and wdly: 12174 copy = list(newdxl) 12175 newdxl = list(newdyl) 12176 newdyl = list(copy) 12177 # else: 12178 # print errormsg 12179 # print ' ' + fname + ": it can not be '" + transform + "' without " +\ 12180 # ' both dimxlabels:', dxl, ' and dimylabels:', dyl, ' !!' 12181 # quit(-1) 12182 12183 if wdTx and wdTy: 12184 copy = str(newdxtit) 12185 newdxtit = str(newdytit) 12186 newdytit = str(copy) 12187 # else: 12188 # print errormsg 12189 # print ' ' + fname + ": it can not be '" + transform + "' without " +\ 12190 # ' both dimx title:', dxtit, ' and dimytitle:', dytit, ' !!' 12191 # quit(-1) 12192 12193 copy = newxaxislim.copy() 12194 newxaxislim = newyaxislim 12195 newyaxislim = copy 12196 12197 elif transform[0:4] == 'flip': 12198 if transform.find('@') == -1: 12199 print errormsg 12200 print ' ' + fname + ": no ax given for '" + transform + "' !!" 12201 quit(-1) 12202 12203 flip = transform.split('@')[1] 12204 if flip == 'x': 12205 if len(newxaxislim.shape) == 1: 12206 newxaxislim = newxaxislim[::-1] 12207 else: 12208 for iy in len(newxaxislim.shape[0]): 12209 newxaxislim[iy,:] = newxaxislim[iy,::-1] 12210 elif flip == 'y': 12211 if len(newyaxislim.shape) == 1: 12212 newyaxislim = newyaxislim[::-1] 12213 else: 12214 for ix in len(newyaxislim.shape[1]): 12215 newyaxislim[:,ix] = newyaxislim[::-1,ix] 12216 elif flip == 'z': 12217 newvals = newvals[...,::-1,:,:] 12218 else: 12219 print errormsg 12220 print ' '+ fname + ": transformation '" + transform + "' not ready!!" 12221 print ' available ones:', ['transpose', 'flip@x', 'flip@y'] 12222 quit(-1) 12223 12224 return newvals, newdxv, newdyv, newdxt, newdyt, newdxl, newdyl, newdxtit, newdytit, newxaxislim, newyaxislim 12225 12226 #mat = np.arange(15).reshape(3,5) 12227 #xvals = np.zeros((3,5), dtype=np.float) 12228 #yvals = np.zeros((3,5), dtype=np.float) 12229 #for i in range(5): 12230 # xvals[:,i] = -1.25 + i*0.5 12231 #for j in range(3): 12232 # yvals[j,:] = 40.25 + j*0.5 12233 #xticks = np.array([-1.25, -0.25, 0.25]) 12234 #yticks = np.array([40.25, 41.25]) 12235 #xticklab = ['1.25 W', '0.25 W', '0,25 E'] 12236 #yticklab = ['40.25 N', '41.25 N'] 12237 #xtit = 'Longitude' 12238 #ytit = 'Latitude' 12239 #nv, ndxv, ndyv, ndxt, ndyt, dxl, ndyl, ndxT, ndyT = transform(mat, 'flip@y', \ 12240 # xvals, yvals, xticks, yticks, xticklab, yticklab, xtit, ytit) 12241 # 12242 #print nv, ndxv, ndyv, ndxt, ndyt, dxl, ndyl, ndxT, ndyT 12013 12243 #quit() 12244 12245 12246 #quit()
Note: See TracChangeset
for help on using the changeset viewer.