- Timestamp:
- Oct 25, 2016, 7:56:03 PM (8 years ago)
- Location:
- trunk/tools
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/documentation/PyNCplot.css
r1223 r1231 21 21 color:rgb(0,0,0);font-size:0.9em;} 22 22 23 div.valimg{width:40%;height: 85%;text-align:center;position:absolute;top:5%;left:0%;background-color:rgb(255,255,255);}24 div.valhelp{width:60%;height: 85%;text-align:left;position:absolute;top:5%;left:40%;background-color:rgb(240,240,240);23 div.valimg{width:40%;height:75%;text-align:center;position:absolute;top:5%;left:0%;background-color:rgb(255,255,255);} 24 div.valhelp{width:60%;height:75%;text-align:left;position:absolute;top:5%;left:40%;background-color:rgb(240,240,240); 25 25 font-size:0.9em;overflow-y:auto} 26 div.valins{width:100%;height: 10%;text-align:left;position:absolute;bottom:10%;left:0%;background-color:rgb(192,192,192);26 div.valins{width:100%;height:20%;text-align:left;position:absolute;top:80%;left:0%;background-color:rgb(192,192,192); 27 27 font-size:0.9em;font-family:"monospace";overflow-x:auto} 28 28 -
trunk/tools/documentation/intro.html
r1223 r1231 11 11 Scripts use python's <A CLASS="la" HREF="http://matplotlib.org" TARGET="_blank">matplotlib</A> and <A CLASS="la" HREF="https://pypi.python.org/pypi/netCDF4" TARGET="_blank">netCDF4</A> libraries. Additionally some functions use some specific Fortran based libraries developed on purpose for the case. <BR> 12 12 <BR> 13 It attempts to facilitate the research throughout two main goals: 13 Climate Data Operators (<A CLASS="la" HREF="https://code.zmaw.de/projects/cdo" TARGET="_blank">CDO</A>) are very powerful tools but it only properly works if files are <A CLASS="la" HREF="http://cfconventions.org" TARGET="_blank">CF-compilant</A>. netCDF Operator (<A CLASS="la" HREF="http://nco.sourceforge.net" TARGET="la">NCO</A>) are also very versatile and powerful, but they can not do everything. Thus, one faces sometimes to process netCDF files via a sort of mixing of both tools and it is almost impossible to add new capabilities to them. <A CLASS="la" HREF="http://www.ferret.noaa.gov/Ferret" TARGET="_blank">Ferret</A> is quite a useful tool, but its quick characteristics limit the output which at the same time it is in a low quality. When one is working with multiple models highly appreciates a single tool to work with their output. 14 PyNCplot attempts to facilitate the research throughout two main goals: 14 15 <OL CLASS="roman"> 15 16 <LI>Manage all day-base needs for netCDF files from an unique platform, in this case, python based</LI> … … 32 33 $ svn co http://svn.lmd.jussieu.fr/LMDZ_WRF/trunk/tools PyNCplot 33 34 </CODE></PRE> 35 There are several python tutorials, just to add more basic ones: <A CLASS="la" HREF="http://www.xn--llusfb-5va.cat/python/ShanCourse/PythonCourse.html" TARGET="_blank">Shan's python course</A>, <A CLASS="la" HREF="https://forge.ipsl.jussieu.fr/igcmg_doc/wiki/Train#BOOTCAMPIPSL" TARGET="_blank">IPSL Boot Camp</A> 36 This web page will be always `underconstuction' as far as there are still some new operations/graphics to add, or to finish to document all the existing ones 37 <P STYLE="text-align:right">Lluís, October 2016</P> 34 38 </BODY> 35 39 </HTML> -
trunk/tools/documentation/plotting/2Dshad.html
r1216 r1231 19 19 [sminv],[smaxv]:[figt]:[kindfig]:[reverse]:[mapv]:[close]<BR> 20 20 [vnamefs]: Name in the figure of the variable to be shaded<BR> 21 [dimvals]: ',' list of [dimname]|[value] telling at which dimension of the <BR> 22 variable a given value is required (-1, all the length)<BR> 23 [dimx/yvn]: name of the variables with the values of the final dimensions (x,y)<BR> 24 [dimxyfmt]=[dxs],[dxf],[Ndx],[ordx],[dys],[dyf],[Ndy],[ordx]: format of the values at each axis (or 'auto')<BR> 25 [dxs]: style of x-axis ('auto' for 'pretty')<BR> 26 'Nfix', values computed at even 'Ndx'<BR> 27 'Vfix', values computed at even 'Ndx' increments<BR> 28 'pretty', values computed following aprox. 'Ndx' at 'pretty' intervals (2.,2.5,4,5,10)<BR> 29 [dxf]: format of the labels at the x-axis ('auto' for '%5g')<BR> 30 [Ndx]: Number of ticks at the x-axis ('auto' for 5)<BR> 31 [ordx]: angle of orientation of ticks at the x-axis ('auto' for horizontal)<BR> 32 [dys]: style of y-axis ('auto' for 'pretty')<BR> 33 [dyf]: format of the labels at the y-axis ('auto' for '%5g')<BR> 34 [Ndy]: Number of ticks at the y-axis ('auto' for 5)<BR> 35 [ordy]: angle of orientation of ticks at the y-axis ('auto' for horizontal)<BR> 36 [colorbarvals]=[colbarn],[fmtcolorbar],[orientation]<BR> 37 [colorbarn]: name of the color bar<BR> 38 [fmtcolorbar]: format of the numbers in the color bar 'C'-like ('auto' for %6g)<BR> 39 [orientation]: orientation of the colorbar ('vertical' (default, by 'auto'), 'horizontal')<BR> 40 [smin/axv]: minimum and maximum value for the shading or:<BR> 41 'Srange': for full range<BR> 42 'Saroundmean@val': for mean-xtrm,mean+xtrm where xtrm = np.min(mean-min@val,max@val-mean)<BR> 43 'Saroundminmax@val': for min*val,max*val<BR> 44 'Saroundpercentile@val': for median-xtrm,median+xtrm where xtrm = np.min(median-percentile_(val),<BR> 45 percentile_(100-val)-median)<BR> 46 'Smean@val': for -xtrm,xtrm where xtrm = np.min(mean-min*@val,max*@val-mean)<BR> 47 'Smedian@val': for -xtrm,xtrm where xtrm = np.min(median-min@val,max@val-median)<BR> 48 'Spercentile@val': for -xtrm,xtrm where xtrm = np.min(median-percentile_(val),<BR> 49 percentile_(100-val)-median)<BR> 50 [figt]: title of the figure ('|' for spaces)<BR> 51 [kindfig]: kind of figure<BR> 52 [reverse]: Transformation of the values<BR> 53 * 'transpose': reverse the axes (x-->y, y-->x)<BR> 54 * 'flip'@[x/y]: flip the axis x or y<BR> 55 [mapv]: map characteristics: [proj],[res]<BR> 56 see full documentation: <HREF CLASS="lc" HREF="http://matplotlib.org/basemap" TARGET="_blank">http://matplotlib.org/basemap</A><BR> 57 [proj]: projection<BR> 58 * 'cyl', cilindric<BR> 59 * 'lcc', lambert conformal<BR> 60 [res]: resolution:<BR> 61 * 'c', crude<BR> 62 * 'l', low<BR> 63 * 'i', intermediate<BR> 64 * 'h', high<BR> 65 * 'f', full<BR> 66 [close]: Whether figure should be finished or not<BR> 67 valules= 'rh:z|-1,x|-1:z|-1,x|-1:lat:pressure:BuPu:0.,100.:rh:pdf:flip@y:None'<BR> 21 [dimvals]: ',' list of [dimname]|[value] telling at which dimension of the <BR> 22 variable a given value is required (-1, all the length)<BR> 23 [dimx/yvn]: name of the variables with the values of the final dimensions (x,y)<BR> 24 [dimxyfmt]=[dxs],[dxf],[Ndx],[ordx],[dys],[dyf],[Ndy],[ordx]: format of the values at each axis (or 'auto')<BR> 25 [dxs]: style of x-axis ('auto' for 'pretty')<BR> 26 'Nfix', values computed at even 'Ndx'<BR> 27 'Vfix', values computed at even 'Ndx' increments<BR> 28 'pretty', values computed following aprox. 'Ndx' at 'pretty' intervals (2.,2.5,4,5,10)<BR> 29 [dxf]: format of the labels at the x-axis ('auto' for '%5g')<BR> 30 [Ndx]: Number of ticks at the x-axis ('auto' for 5)<BR> 31 [ordx]: angle of orientation of ticks at the x-axis ('auto' for horizontal)<BR> 32 [dys]: style of y-axis ('auto' for 'pretty')<BR> 33 [dyf]: format of the labels at the y-axis ('auto' for '%5g')<BR> 34 [Ndy]: Number of ticks at the y-axis ('auto' for 5)<BR> 35 [ordy]: angle of orientation of ticks at the y-axis ('auto' for horizontal)<BR> 36 [colorbarvals]=[colbarn],[fmtcolorbar],[orientation]<BR> 37 [colorbarn]: name of the color bar<BR> 38 [fmtcolorbar]: format of the numbers in the color bar 'C'-like ('auto' for %6g)<BR> 39 [orientation]: orientation of the colorbar ('vertical' (default, by 'auto'), 'horizontal')<BR> 40 [smin/axv]: minimum and maximum value for the shading or:<BR> 41 'Srange': for full range<BR> 42 'Saroundmean@val': for mean-xtrm,mean+xtrm where xtrm = np.min(mean-min@val,max@val-mean)<BR> 43 'Saroundminmax@val': for min*val,max*val<BR> 44 'Saroundpercentile@val': for median-xtrm,median+xtrm where xtrm = np.min(median-percentile_(val),<BR> 45 percentile_(100-val)-median)<BR> 46 'Smean@val': for -xtrm,xtrm where xtrm = np.min(mean-min*@val,max*@val-mean)<BR> 47 'Smedian@val': for -xtrm,xtrm where xtrm = np.min(median-min@val,max@val-median)<BR> 48 'Spercentile@val': for -xtrm,xtrm where xtrm = np.min(median-percentile_(val),<BR> 49 percentile_(100-val)-median)<BR> 50 [figt]: title of the figure ('|' for spaces)<BR> 51 [kindfig]: kind of figure<BR> 52 [reverse]: Transformation of the values<BR> 53 * 'transpose': reverse the axes (x-->y, y-->x)<BR> 54 * 'flip'@[x/y]: flip the axis x or y<BR> 55 [mapv]: map characteristics: [proj],[res]<BR> 56 see full documentation: <HREF CLASS="lc" HREF="http://matplotlib.org/basemap" TARGET="_blank">http://matplotlib.org/basemap</A><BR> 57 [proj]: projection<BR> 58 * 'cyl', cilindric<BR> 59 * 'lcc', lambert conformal<BR> 60 [res]: resolution:<BR> 61 * 'c', crude<BR> 62 * 'l', low<BR> 63 * 'i', intermediate<BR> 64 * 'h', high<BR> 65 * 'f', full<BR> 66 [close]: Whether figure should be finished or not<BR> 68 67 varn= [varsn] name of the variable to plot with shading<BR> 69 68 </DIV> -
trunk/tools/documentation/plotting/2Dshad_cont.html
r1216 r1231 14 14 </DIV> 15 15 <DIV CLASS="valhelp"> 16 16 draw_2D_shad_cont(ncfile, values, varn)<BR> 17 ncfile= [ncfilevars],[ncfilevarc] files to use (one value, same file)<BR> 18 values=[vnamefs]:[dimvals]:[dimvalc]:[dimxvn]:[dimyvn]:[dimxyfmt]:[colorbarvals]:[ckind]:[clabfmt]:[sminv],[smaxv]:[sminc],[smaxv],[Nlev]:[figt]:[kindfig]:[reverse]:[mapv]:[close]<BR> 19 [vnamefs],[vnamefc]: Name in the figure of the shaded and the contour variables<BR> 20 [dimvals/c]: list of [dimname]|[value] telling at which dimension of the <BR> 21 variable a given value is required (no dimension name, all the length)<BR> 22 [dimx/yvn]: names of the variables with the values of the dimensions for the plot<BR> 23 [dimxyfmt]=[dxf],[Ndx],[dyf],[Ndy]: format of the values at each axis<BR> 24 [dxs]: style of x-axis ('auto' for 'pretty')<BR> 25 'Nfix', values computed at even 'Ndx'<BR> 26 'Vfix', values computed at even 'Ndx' increments<BR> 27 'pretty', values computed following aprox. 'Ndx' at 'pretty' intervals (2.,2.5,4,5,10)<BR> 28 [dxf]: format of the labels at the x-axis<BR> 29 [Ndx]: Number of ticks at the x-axis<BR> 30 [ordx]: angle of orientation of ticks at the x-axis ('auto' for horizontal)<BR> 31 [dys]: style of y-axis ('auto' for 'pretty')<BR> 32 [dyf]: format of the labels at the y-axis<BR> 33 [Ndy]: Number of ticks at the y-axis<BR> 34 [ordy]: angle of orientation of ticks at the y-axis ('auto' for horizontal)<BR> 35 [colorbarvals]=[colbarn],[fmtcolorbar],[orientation]<BR> 36 [colorbarn]: name of the color bar<BR> 37 [fmtcolorbar]: format of the numbers in the color bar 'C'-like ('auto' for %6g)<BR> 38 [orientation]: orientation of the colorbar ('vertical' (default, by 'auto'), 'horizontal')<BR> 39 [ckind]: kind of contours <BR> 40 'cmap': as it gets from colorbar<BR> 41 'fixc,[colname]': fixed color [colname], all stright lines<BR> 42 'fixsigc,[colname]': fixed color [colname], >0 stright, <0 dashed line<BR> 43 [clabfmt]: format of the labels in the contour (None, also possible)<BR> 44 [smin/axv]: minimum and maximum value for the shading or<BR> 45 'Srange': for full range<BR> 46 'Saroundmean@val': for mean-xtrm,mean+xtrm where xtrm = np.min(mean-min@val,max@val-mean)<BR> 47 'Saroundminmax@val': for min*val,max*val<BR> 48 'Saroundpercentile@val': for median-xtrm,median+xtrm where xtrm = np.min(median-percentile_(val),<BR> 49 percentile_(100-val)-median)<BR> 50 'Smean@val': for -xtrm,xtrm where xtrm = np.min(mean-min*@val,max*@val-mean)<BR> 51 'Smedian@val': for -xtrm,xtrm where xtrm = np.min(median-min@val,max@val-median)<BR> 52 'Spercentile@val': for -xtrm,xtrm where xtrm = np.min(median-percentile_(val),<BR> 53 percentile_(100-val)-median)<BR> 54 [sminc]:[smaxv]:[Nlev]: minimum, maximum and number of values for the contour<BR> 55 [figt]: title of the figure ('|' for spaces)<BR> 56 [kindfig]: kind of figure<BR> 57 [reverse]: does the values be transposed? 'True/False', <BR> 58 [mapv]: map characteristics: [proj],[res]<BR> 59 see full documentation: http://matplotlib.org/basemap/<BR> 60 [proj]: projection<BR> 61 * 'cyl', cilindric<BR> 62 * 'lcc', lamvbert conformal<BR> 63 [res]: resolution:<BR> 64 * 'c', crude<BR> 65 * 'l', low<BR> 66 * 'i', intermediate<BR> 67 * 'h', high<BR> 68 * 'f', full<BR> 69 [close]: Whether figure should be finished or not<BR> 70 varn= [varsn],[varcn] name of the variable to plot with shading variable with contour<BR> 17 71 </DIV> 18 72 <DIV CLASS="valins"> -
trunk/tools/documentation/plotting/2Dshad_cont_time.html
r1216 r1231 14 14 </DIV> 15 15 <DIV CLASS="valhelp"> 16 16 draw_2D_shad_cont_time(ncfile, values, varn)<BR> 17 ncfile= [ncfilevars],[ncfilevarc] files to use (one value, same file)<BR> 18 values=[vnamefs];[dimvals];[dimvalc];[dimxvn];[dimyvn];[dimxyf];[colorbarvals];[ckind];[clabfmt];[sminv],[smaxv];[sminc],[smaxv],[Nlev];[figt];[kindfig];[reverse];[timevals];[close]<BR> 19 [vnamefs],[vnamefc]: Name in the figure of the shaded and the contour variables<BR> 20 [dimvals/c]: list of [dimname]|[value] telling at which dimension of the <BR> 21 variable a given value is required (no dimension name, all the length)<BR> 22 [dimxvn]: name of the variables with the values of the dimension of the x-axis ('WRFtime' for WRF times)<BR> 23 [dimyvn]: name of the variables with the values of the dimension of the y-axis ('WRFtime' for WRF times)<BR> 24 [dimxyf]=[dxf],[Ndx],[dyf],[Ndy]: format of the values at each axis<BR> 25 [dxs]: style of x-axis ('auto' for 'pretty')<BR> 26 'Nfix', values computed at even 'Ndx' (unique map plotted with constant pixel size)<BR> 27 'Vfix', values computed at even 'Ndx' increments<BR> 28 'pretty', values computed following aprox. 'Ndx' at 'pretty' intervals (2.,2.5,4,5,10)<BR> 29 [dxf]: format of the labels at the x-axis<BR> 30 [Ndx]: Number of ticks at the x-axis<BR> 31 [ordx]: angle of orientation of ticks at the x-axis ('auto' for horizontal)<BR> 32 [dys]: style of y-axis ('auto' for 'pretty')<BR> 33 [dyf]: format of the labels at the y-axis<BR> 34 [Ndy]: Number of ticks at the y-axis<BR> 35 [ordy]: angle of orientation of ticks at the y-axis ('auto' for horizontal)<BR> 36 [colorbarvals]=[colbarn],[fmtcolorbar],[orientation]<BR> 37 [colorbarn]: name of the color bar<BR> 38 [fmtcolorbar]: format of the numbers in the color bar 'C'-like ('auto' for %6g)<BR> 39 [orientation]: orientation of the colorbar ('vertical' (default, by 'auto'), 'horizontal')<BR> 40 [ckind]: kind of contours <BR> 41 'cmap': as it gets from colorbar<BR> 42 'fixc,[colname]': fixed color [colname], all stright lines<BR> 43 'fixsigc,[colname]': fixed color [colname], >0 stright, <0 dashed line<BR> 44 [clabfmt]: format of the labels in the contour (None, also possible)<BR> 45 [smin/axv]: minimum and maximum value for the shading or:<BR> 46 'Srange': for full range<BR> 47 'Saroundmean@val': for mean-xtrm,mean+xtrm where xtrm = np.min(mean-min@val,max@val-mean)<BR> 48 'Saroundminmax@val': for min*val,max*val<BR> 49 'Saroundpercentile@val': for median-xtrm,median+xtrm where xtrm = np.min(median-percentile_(val),<BR> 50 percentile_(100-val)-median)<BR> 51 'Smean@val': for -xtrm,xtrm where xtrm = np.min(mean-min*@val,max*@val-mean)<BR> 52 'Smedian@val': for -xtrm,xtrm where xtrm = np.min(median-min@val,max@val-median)<BR> 53 'Spercentile@val': for -xtrm,xtrm where xtrm = np.min(median-percentile_(val),<BR> 54 percentile_(100-val)-median)<BR> 55 [sminc]:[smaxv]:[Nlev]: minimum, maximum and number of values for the contour<BR> 56 [figt]: title of the figure ('|' for spaces)<BR> 57 [kindfig]: kind of figure<BR> 58 [reverse]: modification to the dimensions:<BR> 59 'transposed': transpose matrices<BR> 60 'flip',[x/y]: flip only the dimension [x] or [y]<BR> 61 [timevals]: [timen]|[units]|[kind]|[tfmt]|[label] time labels characteristics<BR> 62 [timen]; name of the time variable ('WRFtime' for WRF times)<BR> 63 [units]; units string according to CF conventions ([tunits] since <BR> 64 [YYYY]-[MM]-[DD] [[HH]:[MI]:[SS]], '!' for spaces)<BR> 65 [kind]; kind of output<BR> 66 'Nval': according to a given number of values as 'Nval',[Nval]<BR> 67 'exct': according to an exact time unit as 'exct',[tunit]; <BR> 68 tunit= [Nunits],[tu]; [tu]= 'c': centuries, 'y': year, 'm': month,<BR> 69 'w': week, 'd': day, 'h': hour, 'i': minute, 's': second, <BR> 70 'l': milisecond<BR> 71 [tfmt]; desired format<BR> 72 [label]; label at the graph ('!' for spaces)<BR> 73 [close]: Whether figure should be finished or not<BR> 74 varn= [varsn],[varcn] name of the variable to plot with shading variable with contour<BR> 17 75 </DIV> 18 76 <DIV CLASS="valins"> -
trunk/tools/documentation/plotting/2Dshad_time.html
r1211 r1231 15 15 </DIV> 16 16 <DIV CLASS="valhelp"> 17 17 draw_2D_shad_time(ncfile, values, varn)<BR> 18 ncfile= file to use<BR> 19 values=[vnamefs]~[dimvals]~[dimxvn]~[dimyvn]~[dimvfmt]~[colorbarvals]~[sminv],[smaxv]~[figt]~<BR> 20 [kindfig]~[reverse]~[timevals]~[close]<BR> 21 [vnamefs]: Name in the figure of the variable to be shaded<BR> 22 [dimvals]: ',' list of [dimname]|[value] telling at which dimension of the <BR> 23 variable a given value is required (-1, all the length, [beg]@[end] for an interval)<BR> 24 [dimx/yvn]: name of the variables with the values of the final dimensions (x,y) ('WRFtime' for WRF times)<BR> 25 [dimvfmt]=[dvs],[dvf],[Ndv],[ordv]: format of the values for the non-temporal axis (or 'auto')<BR> 26 [dvs]: style of non-temporal axis ('auto' for 'pretty')<BR> 27 'Nfix', values computed at even 'Ndx'<BR> 28 'Vfix', values computed at even 'Ndx' increments<BR> 29 'pretty', values computed following aprox. 'Ndx' at 'pretty' intervals (2.,2.5,4,5,10)<BR> 30 [dvf]: format of the labels at the x-axis ('auto' for '%5g')<BR> 31 [Ndv]: Number of ticks at the x-axis ('auto' for 5)<BR> 32 [ordv]: angle of orientation of ticks at the x-axis ('auto' for horizontal)<BR> 33 [colorbarvals]=[colbarn],[fmtcolorbar],[orientation]<BR> 34 [colorbarn]: name of the color bar<BR> 35 [fmtcolorbar]: format of the numbers in the color bar 'C'-like ('auto' for %6g)<BR> 36 [orientation]: orientation of the colorbar ('vertical' (default, by 'auto'), 'horizontal')<BR> 37 [smin/axv]: minimum and maximum value for the shading or:<BR> 38 'Srange': for full range<BR> 39 'Saroundmean@val': for mean-xtrm,mean+xtrm where xtrm = np.min(mean-min@val,max@val-mean)<BR> 40 'Saroundminmax@val': for min*val,max*val<BR> 41 'Saroundpercentile@val': for median-xtrm,median+xtrm where xtrm = np.min(median-percentile_(val),<BR> 42 percentile_(100-val)-median)<BR> 43 'Smean@val': for -xtrm,xtrm where xtrm = np.min(mean-min*@val,max*@val-mean)<BR> 44 'Smedian@val': for -xtrm,xtrm where xtrm = np.min(median-min@val,max@val-median)<BR> 45 'Spercentile@val': for -xtrm,xtrm where xtrm = np.min(median-percentile_(val),<BR> 46 percentile_(100-val)-median)<BR> 47 [figt]: title of the figure ('|' for spaces)<BR> 48 [kindfig]: kind of figure<BR> 49 [reverse]: Transformation of the values<BR> 50 * 'transpose': reverse the axes (x-->y, y-->x)<BR> 51 * 'flip'@[x/y]: flip the axis x or y<BR> 52 [timevals]: [timen]|[units]|[kind]|[tfmt]|[label]|[timeaxis] time labels characteristics<BR> 53 [timen]; name of the time variable ('WRFtime' for WRF times)<BR> 54 [units]; units string according to CF conventions ([tunits] since <BR> 55 [YYYY]-[MM]-[DD] [[HH]:[MI]:[SS]], '!' for spaces)<BR> 56 [kind]; kind of output<BR> 57 'Nval': according to a given number of values as 'Nval',[Nval]<BR> 58 'exct': according to an exact time unit as 'exct',[tunit]; <BR> 59 tunit= [Nunits],[tu]; [tu]= 'c': centuries, 'y': year, 'm': month,<BR> 60 'w': week, 'd': day, 'h': hour, 'i': minute, 's': second, <BR> 61 'l': milisecond<BR> 62 [tfmt]; desired format<BR> 63 [label]; label at the graph ('!' for spaces)<BR> 64 [close]: should figure be closed (finished)<BR> 65 varn= [varsn] name of the variable to plot with shading<BR> 18 66 </DIV> 19 67 <DIV CLASS="valins"> -
trunk/tools/documentation/plotting/plotting.html
r1211 r1231 11 11 <A CLASS="lc" HREF="2Dshad_cont.html" TARGET="value">2D shadow contour</A><BR> 12 12 <A CLASS="lc" HREF="2Dshad_cont_time.html" TARGET="value">2D shadow contour time</A><BR> 13 <A CLASS="lc" HREF="2Dshad_line.html" TARGET="value">2D shadow line</A><BR> 13 14 </DIV> 14 15 <DIV CLASS="valmenu"> -
trunk/tools/drawing.py
r1219 r1231 21 21 ## e.g. # drawing.py -o draw_2D_shad_cont -f wrfout_d01_2001-11-11_00:00:00 -S 'huss,tas:west_east|-1,south_north|-1,Time|2:Time|2:XLONG:XLAT:auto:Blues,auto,auto:fixc,r:%3g:Srange,Srange:260,300,9:huss|&|tas|at|2001-11-11|02|UTC:png:None:cyl,c:True' -v Q2,T2 22 22 ## e.g. # drawing.py -o draw_2D_shad_cont_time -f wrfout_d01_2001-11-11_00:00:00 -S 'hfls,tas;west_east|-1,south_north|27,Time|-1;south_north|27;XLONG;WRFtime;auto;BuPu,auto,auto;fixc,y;%3g;Srange,Srange;260,300,9;huss|&|tas|evolution|at|south_north=27;png;None;WRFtime|hours!since!1949-12-01|exct,1,h|$%d^{%H}$|date!($[DD]^{[HH]}$);True' -v LH,T2 23 ## e.g. # drawing.py -o draw_2D_shad_line -f wrfout_d01_2001-11-11_00:00:00,wrfout_d01_2001-11-11_00:00:00 -S 'hus,hgt:west_east|-1,south_north|96,Time|2,bottom_top|-1:XLONG:ZNU:auto:rainbow,auto,horizontal:Srange,Srange:k,0.,4000.,auto,auto,auto,45.:vert.|sec.|hus|at|y=96|on|2001-11-11|02|UTC:png:flip@y:None:True' -v QVAPOR,HGT 23 24 ## e.g. # drawing.py -f ~/etudes/domains/MEDCORDEX/geo_em.d01.nc -o draw_2D_shad_cont -S 'height,landmask:Time|0:Time|0:XLONG_M:XLAT_M:terrain:fixc,k:None:0.,3000.:0,1,10:MEDCORDEX height & landmask:pdf:False:lcc,i' -v HGT_M,LANDMASK 24 25 ## e.g. # drawing.py -o draw_2D_shad_line -f 'mean_dtcon-pluc-pres_lat.nc,mean_dtcon-pluc-pres_lat.nc' -S 'dtcon,prc:bottom_top|-1,south_north|-1:latmean:presmean:seismic,k:-5.,5.:monthly|dtcon|&|prc:pdf:flip@y:None:True' -v 'dtconmean,prcmean' … … 774 775 """ plotting two fields, one with shading and the other with contour lines being 775 776 one of the dimensions of time characteristics 776 draw_2D_shad_cont (ncfile, values, varn)777 draw_2D_shad_cont_time(ncfile, values, varn) 777 778 ncfile= [ncfilevars],[ncfilevarc] files to use (one value, same file) 778 779 values=[vnamefs];[dimvals];[dimvalc];[dimxvn];[dimyvn];[dimxyf];[colorbarvals];[ckind];[clabfmt];[sminv],[smaxv];[sminc],[smaxv],[Nlev];[figt];[kindfig];[reverse];[timevals];[close] … … 1061 1062 draw_2D_shad_line(ncfile, values, varn) 1062 1063 ncfile= [ncfiles],[ncfilel] file to use for the shading and for the line 1063 values=[vnamefs],[vnamefl]:[dimvals]:[dimxvn]:[dimyvn]:[ colorbar],[colline]:[sminv],[smaxv]:[figt]:1064 values=[vnamefs],[vnamefl]:[dimvals]:[dimxvn]:[dimyvn]:[dimxyfmt]:[colorbarvals]:[smin/axv]:[linevalues]:[figt]: 1064 1065 [kindfig]:[reverse]:[mapv]:[close] 1065 1066 [vnamefs]: Name in the figure of the variable to be shaded … … 1068 1069 variable a given value is required (-1, all the length) 1069 1070 [dimx/yvn]: name of the variables with the values of the final dimensions (x,y) 1070 [colorbar]: name of the color bar 1071 [colline]: name of the color for the line 1071 [dimxyfmt]=[dxs],[dxf],[Ndx],[ordx],[dys],[dyf],[Ndy],[ordx]: format of the values at each axis (or 'auto') 1072 [dxs]: style of x-axis ('auto' for 'pretty') 1073 'Nfix', values computed at even 'Ndx' 1074 'Vfix', values computed at even 'Ndx' increments 1075 'pretty', values computed following aprox. 'Ndx' at 'pretty' intervals (2.,2.5,4,5,10) 1076 [dxf]: format of the labels at the x-axis ('auto' for '%5g') 1077 [Ndx]: Number of ticks at the x-axis ('auto' for 5) 1078 [ordx]: angle of orientation of ticks at the x-axis ('auto' for horizontal) 1079 [dys]: style of y-axis ('auto' for 'pretty') 1080 [dyf]: format of the labels at the y-axis ('auto' for '%5g') 1081 [Ndy]: Number of ticks at the y-axis ('auto' for 5) 1082 [ordy]: angle of orientation of ticks at the y-axis ('auto' for horizontal) 1083 [colorbarvals]=[colbarn],[fmtcolorbar],[orientation] 1084 [colorbarn]: name of the color bar 1085 [fmtcolorbar]: format of the numbers in the color bar 'C'-like ('auto' for %6g) 1086 [orientation]: orientation of the colorbar ('vertical' (default, by 'auto'), 'horizontal') 1087 [smin/axv]: minimum and maximum value for the shading or: 1088 'Srange': for full range 1089 'Saroundmean@val': for mean-xtrm,mean+xtrm where xtrm = np.min(mean-min@val,max@val-mean) 1090 'Saroundminmax@val': for min*val,max*val 1091 'Saroundpercentile@val': for median-xtrm,median+xtrm where xtrm = np.min(median-percentile_(val), 1092 percentile_(100-val)-median) 1093 'Smean@val': for -xtrm,xtrm where xtrm = np.min(mean-min*@val,max*@val-mean) 1094 'Smedian@val': for -xtrm,xtrm where xtrm = np.min(median-min@val,max@val-median) 1095 'Spercentile@val': for -xtrm,xtrm where xtrm = np.min(median-percentile_(val), 1096 percentile_(100-val)-median) 1097 [linevalues]=[colline],[sminl],[smaxl],[dls],[dlf],[Ndl],[ordl] 1098 [colline]: name of the color for the line 1099 [smin/axv]: minimum and maximum value for the line or: 1100 'Srange': for full range 1101 'Saroundmean@val': for mean-xtrm,mean+xtrm where xtrm = np.min(mean-min@val,max@val-mean) 1102 'Saroundminmax@val': for min*val,max*val 1103 'Saroundpercentile@val': for median-xtrm,median+xtrm where xtrm = np.min(median-percentile_(val), 1104 percentile_(100-val)-median) 1105 'Smean@val': for -xtrm,xtrm where xtrm = np.min(mean-min*@val,max*@val-mean) 1106 'Smedian@val': for -xtrm,xtrm where xtrm = np.min(median-min@val,max@val-median) 1107 'Spercentile@val': for -xtrm,xtrm where xtrm = np.min(median-percentile_(val), 1108 percentile_(100-val)-median) 1109 [dls]: style of line-axis ('auto' for 'pretty') 1110 [dlf]: format of the labels at the line-axis ('auto' for '%5g') 1111 [Ndl]: Number of ticks at the line-axis ('auto' for 5) 1112 [ordl]: angle of orientation of ticks at the line-axis ('auto' for horizontal) 1072 1113 [smin/axv]: minimum and maximum value for the shading 1073 1114 [figt]: title of the figure ('|' for spaces) … … 1087 1128 * 'h', high 1088 1129 * 'f', full 1130 [close]: Whether figure should be finished or not 1089 1131 valules= 'rh:z|-1,x|-1:z|-1,x|-1:lat:pressure:BuPu:0.,100.:rh:pdf:flip@y:None' 1090 1132 varn= [varsn],[varnl] name of the variable to plot with shading and with line … … 1098 1140 1099 1141 farguments = '[vnamefs],[vnamefl]:[dimvals]:[dimxvn]:[dimyvn]:' + \ 1100 '[ colorbar],[colline]:[sminv],[smaxv]:[figt]:[kindfig]:[reverse]:' +\1101 '[ mapv]:[close]'1142 '[dimxyfmt]:[colorbarvals]:[smin/axv]:[linevalues]:[figt]:[kindfig]:' + \ 1143 '[reverse]:[mapv]:[close]' 1102 1144 drw.check_arguments(fname,values,farguments,':') 1103 1145 … … 1106 1148 vdimxn = values.split(':')[2] 1107 1149 vdimyn = values.split(':')[3] 1108 colbarn = values.split(':')[4].split(',')[0] 1109 shadminmax = values.split(':')[5] 1110 figtitle = values.split(':')[6].replace('|',' ') 1111 figkind = values.split(':')[7] 1112 revals = values.split(':')[8] 1113 mapvalue = values.split(':')[9] 1114 # varn = values.split(':')[10] 1150 dimxyf = values.split(':')[4] 1151 colorbarvals = values.split(':')[5] 1152 shadminmax = values.split(':')[6] 1153 linevalues = values.split(':')[7] 1154 figtitle = values.split(':')[8].replace('|',' ') 1155 figkind = values.split(':')[9] 1156 revals = values.split(':')[10] 1157 mapvalue = values.split(':')[11] 1158 close = gen.Str_Bool(values.split(':')[12]) 1115 1159 1116 1160 ncfiles = ncfile.split(',')[0] … … 1137 1181 1138 1182 # Dimensions names 1139 ## print fname + ' obj dimnames: ', objvars.dimensions, dimvals, len(dimvals.split(','))1140 ## dimnamesv = []1141 ## for idd in range(len(objvars.dimensions)):1142 ## cutdim = False1143 ## for idc in range(len(dimvals.split(','))):1144 ## dimcutn = dimvals.split(',')[idc].split(':')[0]1145 ## print objvars.dimensions[idd], dimcutn1146 ## if objvars.dimensions[idd] == dimcutn:1147 ## cutdim = True1148 ## break1149 ## if not cutdim: dimnamesv.append(objvars.dimensions[idd])1150 1183 dimnamesv = [vdimxn, vdimyn] 1151 1184 … … 1165 1198 objdimx = objsf.variables[vdimxn] 1166 1199 objdimy = objsf.variables[vdimyn] 1167 odimxu = objdimx.getncattr('units') 1168 odimyu = objdimy.getncattr('units') 1169 1170 if len(objdimx.shape) <= 2: 1171 # odimxv = objdimx[valshad.shape] 1172 # odimyv = objdimy[valshad.shape] 1173 odimxv = objdimx[:] 1174 odimyv = objdimy[:] 1175 1176 elif len(objdimx.shape) == 3: 1177 # dimcut = [0, slice(0,valshad.shape[0]), slice(0,valshad.shape[1])] 1178 # odimxv = objdimx[tuple(dimcut)] 1179 # odimyv = objdimy[tuple(dimcut)] 1180 odimxv = objdimx[0,:] 1181 odimyv = objdimy[0,:] 1182 else: 1183 print errormsg 1184 print ' ' + fname + ': shape of dimension variable:', objdimx.shape, \ 1185 ' not ready!!' 1186 quit(-1) 1187 1188 shading_nx = np.zeros((2), dtype=np.float) 1189 shading_nx[0] = np.float(shadminmax.split(',')[0]) 1190 shading_nx[1] = np.float(shadminmax.split(',')[1]) 1191 1192 if mapvalue == 'None': mapvalue = None 1200 if drw.searchInlist(objdimx.ncattrs(),'units'): 1201 odimxu = objdimx.getncattr('units') 1202 else: 1203 print warnmsg 1204 print ' ' + fname + ": variable dimension '" + vdimxn + "' without units!!" 1205 odimxu = '-' 1206 1207 if drw.searchInlist(objdimy.ncattrs(),'units'): 1208 odimyu = objdimy.getncattr('units') 1209 else: 1210 print warnmsg 1211 print ' ' + fname + ": variable dimension '" + vdimyn + "' without units!!" 1212 odimyu = '-' 1213 1214 odimxv, odimyv = drw.dxdy_lonlatDIMS(objdimx[:], objdimy[:], objdimx.dimensions, \ 1215 objdimy.dimensions, dimvals.replace(':','|').split(',')) 1216 1217 shading_nx = [] 1218 if shadminmax.split(',')[0][0:1] != 'S': 1219 shading_nx.append(np.float(shadminmax.split(',')[0])) 1220 else: 1221 shading_nx.append(shadminmax.split(',')[0]) 1222 1223 if shadminmax.split(',')[1][0:1] != 'S': 1224 shading_nx.append(np.float(shadminmax.split(',')[1])) 1225 else: 1226 shading_nx.append(shadminmax.split(',')[1]) 1193 1227 1194 1228 # line plot 1195 1229 ## 1230 linearg = linevalues.split(',') 1231 if linevalues.split(',')[1][0:1] != 'S': 1232 linearg[1] = np.float(linevalues.split(',')[1]) 1233 if linevalues.split(',')[2][0:1] != 'S': 1234 linearg[2] = np.float(linevalues.split(',')[2]) 1235 if linearg[3] == 'auto': linearg[3] = 'pretty' 1236 if linearg[4] == 'auto': linearg[4] = '5g' 1237 if linearg[5] == 'auto': linearg[5] = 5 1238 if linearg[6] == 'auto': linearg[6] = 0. 1239 1196 1240 ncfilel = ncfile.split(',')[1] 1197 1241 vnamelfig = values.split(':')[0].split(',')[1] 1198 1242 varnl = varn.split(',')[1] 1199 colline = values.split(':')[4].split(',')[1] 1200 1243 1244 if not os.path.isfile(ncfilel): 1245 print errormsg 1246 print ' ' + fname + ': file for line "' + ncfilel + '" does not exist !!' 1247 quit(-1) 1201 1248 objlf = NetCDFFile(ncfilel,'r') 1249 1250 if not objlf.variables.has_key(varnl): 1251 print errormsg 1252 print ' ' + fname + ': line file "' + ncfilel + \ 1253 '" does not have variable "' + varnl + '" !!' 1254 quit(-1) 1202 1255 objlvar = objlf.variables[varnl] 1203 1204 linevals = objlvar[:] 1256 linevals, dimsline = drw.slice_variable(objlvar, dimvals.replace(',','|')) 1205 1257 varlunits = objlvar.units 1206 1258 1259 if mapvalue == 'None': mapvalue = None 1260 1261 colbarn, fmtcolbar, colbaror = drw.colorbar_vals(colorbarvals,',') 1262 colormapv = [colbarn, fmtcolbar, colbaror] 1263 1264 xstyl, xaxf, Nxax, xaxor, ystyl, yaxf, Nyax, yaxor = drw.format_axes(dimxyf,',') 1265 xaxis = [xstyl, xaxf, Nxax, xaxor] 1266 yaxis = [ystyl, yaxf, Nyax, yaxor] 1267 1268 if revals == 'None': 1269 revals = None 1270 1207 1271 drw.plot_2D_shadow_line(valshad, linevals, vnamesfig, vnamelfig, odimxv, odimyv, \ 1208 odimxu, odimyu, dimnamesv, colbarn, colline, shading_nx, varunits, varlunits,\1209 figtitle, figkind, revals, mapvalue, True)1272 odimxu, odimyu, dimnamesv, xaxis, yaxis, colormapv, linearg, shading_nx, \ 1273 varunits, varlunits, figtitle, figkind, revals, mapvalue, close) 1210 1274 1211 1275 objsf.close() -
trunk/tools/drawing_tools.py
r1219 r1231 5060 5060 return lonv,latv 5061 5061 5062 def plot_2D_shadow_line(varsv, varlv,vnames,vnamel,dimxv,dimyv,dimxu,dimyu,dimn,\5063 colorbar,colln,vs,uts,utl,vtit,kfig,reva,mapv,ifclose):5062 def plot_2D_shadow_line(varsv, varlv, vnames, vnamel, dimxv, dimyv, dimxu, dimyu, \ 5063 dimn, xaxv, yaxv, cbarv, linev, vs, uts, utl, vtit, kfig, reva, mapv, ifclose): 5064 5064 """ Plotting a 2D field with shadows and another one with a line 5065 5065 varsv= 2D values to plot with shading … … 5070 5070 dim[x/y]u = units at the axes of x and y 5071 5071 dimn= dimension names to plot 5072 colorbar= name of the color bar to use 5073 colln= color for the line 5072 xaxv= list with the x-axis paramteres [style, format, number and orientation] 5073 yaxv= list with the y-axis paramteres [style, format, number and orientation] 5074 cbarv= list with the parameters of the color bar [colorbar, cbarfmt, cbaror] 5075 colorbar: name of the color bar to use 5076 cbarfmt: format of the numbers in the colorbar 5077 cbaror: orientation of the colorbar 5078 linev= list with the values for the line [colorline, min, max, ticks: style, format, number and orientation] 5074 5079 vs= minmum and maximum values to plot in shadow 5080 'Srange': for full range 5081 'Saroundmean@val': for mean-xtrm,mean+xtrm where xtrm = np.min(mean-min@val,max@val-mean) 5082 'Saroundminmax@val': for min*val,max*val 5083 'Saroundpercentile@val': for median-xtrm,median+xtrm where xtrm = np.min(median-percentile_(val), 5084 percentile_(100-val)-median) 5085 'Smean@val': for -xtrm,xtrm where xtrm = np.min(mean-min*@val,max*@val-mean) 5086 'Smedian@val': for -xtrm,xtrm where xtrm = np.min(median-min@val,max@val-median) 5087 'Spercentile@val': for -xtrm,xtrm where xtrm = np.min(median-percentile_(val), 5088 percentile_(100-val)-median) 5075 5089 uts= units of the variable to shadow 5076 5090 utl= units of the variable to line … … 5103 5117 quit() 5104 5118 5105 if reva[0:4] == 'flip': 5106 reva0 = 'flip' 5107 if len(reva.split('@')) != 2: 5108 print errormsg 5109 print ' ' + fname + ': flip is given', reva, 'but not axis!' 5110 quit(-1) 5111 else: 5112 reva0 = reva 5113 5114 if reva0 == 'transpose': 5115 print ' reversing the axes of the figure (x-->y, y-->x)!!' 5116 varsv = np.transpose(varsv) 5117 dxv = dimyv 5118 dyv = dimxv 5119 dimxv = dxv 5120 dimyv = dyv 5119 if len(varsv.shape) != 2: 5120 print errormsg 5121 print ' ' + fname + ': wrong variable shape:',varsv.shape,'is has to be 2D!!' 5122 quit(-1) 5123 if len(varlv.shape) != 1: 5124 print errormsg 5125 print ' ' + fname + ': wrong line shape:',varlv.shape,'is has to be 1D!!' 5126 quit(-1) 5127 5128 # Axis ticks 5129 # Usually axis > x must be the lon, thus... 5130 dimxv0 = dimxv.copy() 5131 dimyv0 = dimyv.copy() 5132 5133 dxn = dimxv.min() 5134 dxx = dimxv.max() 5135 dyn = dimyv.min() 5136 dyx = dimyv.max() 5137 5138 if xaxv[0] == 'pretty': 5139 dimxt0 = np.array(gen.pretty_int(dxn,dxx,xaxv[2])) 5140 elif xaxv[0] == 'Nfix': 5141 dimxt0 = np.arange(dxn,dxx,(dxx-dxn)/(1.*xaxv[2])) 5142 elif xaxv[0] == 'Vfix': 5143 dimxt0 = np.arange(0,dxx,xaxv[2]) 5144 if yaxv[0] == 'pretty': 5145 dimyt0 = np.array(gen.pretty_int(dyn,dyx,yaxv[2])) 5146 elif yaxv[0] == 'Nfix': 5147 dimyt0 = np.arange(dyn,dyx,(dyx-dyn)/(1.*yaxv[2])) 5148 elif yaxv[0] == 'Vfix': 5149 dimyt0 = np.arange(0,dyx,yaxv[2]) 5150 5151 dimxl0 = [] 5152 for i in range(len(dimxt0)): dimxl0.append('{:{style}}'.format(dimxt0[i], style=xaxv[1])) 5153 dimyl0 = [] 5154 for i in range(len(dimyt0)): dimyl0.append('{:{style}}'.format(dimyt0[i], style=yaxv[1])) 5155 5156 dimxT0 = variables_values(dimn[0])[0] + ' (' + units_lunits(dimxu) + ')' 5157 dimyT0 = variables_values(dimn[1])[0] + ' (' + units_lunits(dimyu) + ')' 5158 5159 if mapv is not None: 5160 pixkind = 'data' 5161 else: 5162 # No following data values 5163 dimxt0 = np.arange(len(dimxt0),dtype=np.float)/(len(dimxt0)) 5164 dimyt0 = np.arange(len(dimyt0),dtype=np.float)/(len(dimyt0)) 5165 pixkind = 'fixpixel' 5166 5167 if reva is not None: 5168 varsv, dimxv, dimyv, dimxt, dimyt, dimxl, dimyl, dimxT, dimyT = \ 5169 transform(varsv, reva, dxv=dimxv0, dyv=dimyv0, dxt=dimxt0, dyt=dimyt0, \ 5170 dxl=dimxl0, dyl=dimyl0, dxtit=dimxT0, dytit=dimyT0) 5171 else: 5172 dimxv = dimxv0 5173 dimyv = dimyv0 5174 dimxt = dimxt0 5175 dimyt = dimyt0 5176 dimxl = dimxl0 5177 dimyl = dimyl0 5178 dimxT = dimxT0 5179 dimyT = dimyT0 5121 5180 5122 5181 if len(dimxv[:].shape) == 3: 5123 lon0 = dimxv[0,]5182 xdims = '1,2' 5124 5183 elif len(dimxv[:].shape) == 2: 5125 lon0 = dimxv[:] 5184 xdims = '0,1' 5185 elif len(dimxv[:].shape) == 1: 5186 xdims = '0' 5126 5187 5127 5188 if len(dimyv[:].shape) == 3: 5128 lat0 = dimyv[0,]5189 ydims = '1,2' 5129 5190 elif len(dimyv[:].shape) == 2: 5130 lat0 = dimyv[:] 5131 5132 if len(dimxv[:].shape) == 1 and len(dimyv[:].shape) == 1: 5133 lon00 = dimxv[:] 5134 lon0 = np.zeros( (len(lat00),len(lon00)), dtype=np.float ) 5135 5136 for iy in range(len(lat00)): 5137 lon0[iy,:] = lon00 5138 for ix in range(len(lon00)): 5139 lat0[:,ix] = lat00 5140 5191 ydims = '0,1' 5192 elif len(dimyv[:].shape) == 1: 5193 ydims = '0' 5194 5195 # lon0 = dimxv 5196 # lat0 = dimyv 5197 lon0, lat0 = dxdy_lonlat(dimxv,dimyv, xdims, ydims) 5141 5198 if not mapv is None: 5142 5199 map_proj=mapv.split(',')[0] … … 5146 5203 dy = lat0.shape[0] 5147 5204 5148 nlon = lon0[0,0] 5149 xlon = lon0[dy-1,dx-1] 5150 nlat = lat0[0,0] 5151 xlat = lat0[dy-1,dx-1] 5152 5153 # Thats too much! :) 5154 # if lonlatLims is not None: 5155 # print ' ' + fname + ': cutting the domain to plot !!!!' 5156 # plt.xlim(lonlatLims[0], lonlatLims[2]) 5157 # plt.ylim(lonlatLims[1], lonlatLims[3]) 5158 # print ' limits: W-E', lonlatLims[0], lonlatLims[2] 5159 # print ' limits: N-S', lonlatLims[1], lonlatLims[3] 5160 5161 # if map_proj == 'cyl': 5162 # nlon = lonlatLims[0] 5163 # nlat = lonlatLims[1] 5164 # xlon = lonlatLims[2] 5165 # xlat = lonlatLims[3] 5166 # elif map_proj == 'lcc': 5167 # lon2 = (lonlatLims[0] + lonlatLims[2])/2. 5168 # lat2 = (lonlatLims[1] + lonlatLims[3])/2. 5169 # nlon = lonlatLims[0] 5170 # xlon = lonlatLims[2] 5171 # nlat = lonlatLims[1] 5172 # xlat = lonlatLims[3] 5205 nlon = np.min(lon0) 5206 xlon = np.max(lon0) 5207 nlat = np.min(lat0) 5208 xlat = np.max(lat0) 5173 5209 5174 5210 lon2 = lon0[dy/2,dx/2] … … 5190 5226 quit(-1) 5191 5227 5192 if len(dimxv.shape) == 1: 5193 lons, lats = np.meshgrid(dimxv, dimyv) 5228 x,y = m(lon0,lat0) 5229 5230 else: 5231 x = (dimxv-np.min(dimxv))/(np.max(dimxv) - np.min(dimxv)) 5232 y = (dimyv-np.min(dimyv))/(np.max(dimyv) - np.min(dimyv)) 5233 5234 # Changing limits of the colors 5235 vsend = graphic_range(vs,varsv) 5236 5237 plt.rc('text', usetex=True) 5238 5239 plt.pcolormesh(x, y, varsv, cmap=plt.get_cmap(cbarv[0]), vmin=vsend[0], \ 5240 vmax=vsend[1]) 5241 if cbarv[2] == 'horizontal': 5242 cbar = plt.colorbar(format=cbarv[1],orientation=cbarv[2]) 5243 # From: http://stackoverflow.com/questions/32050030/rotation-of-colorbar-tick-labels-in-matplotlib 5244 ticklabels= cbar.ax.get_xticklabels() 5245 Nticks = len(ticklabels) 5246 ticklabs = [] 5247 for itick in range(Nticks): ticklabs.append(ticklabels[itick].get_text()) 5248 cbar.ax.set_xticklabels(ticklabs,rotation=90) 5249 else: 5250 cbar = plt.colorbar(format=cbarv[1],orientation=cbarv[2]) 5251 5252 if not mapv is None: 5253 if cbarv[0] == 'gist_gray': 5254 m.drawcoastlines(color="red") 5194 5255 else: 5195 if len(dimxv.shape) == 3: 5196 lons = dimxv[0,:,:] 5197 else: 5198 lons = dimxv[:] 5199 5200 if len(dimyv.shape) == 3: 5201 lats = dimyv[0,:,:] 5202 else: 5203 lats = dimyv[:] 5204 5205 x,y = m(lons,lats) 5206 5207 else: 5208 if len(dimxv.shape) == 3: 5209 x = dimxv[0,:,:] 5210 elif len(dimxv.shape) == 2: 5211 x = dimxv 5212 else: 5213 # Attempt of simplier way... 5214 # x = np.zeros((lon0.shape), dtype=np.float) 5215 # for j in range(lon0.shape[0]): 5216 # x[j,:] = dimxv 5217 5218 ## This way is too complicated and maybe not necessary ? (assuming dimxv.shape == dimyv.shape) 5219 if len(dimyv.shape) == 1: 5220 x = np.zeros((len(dimyv),len(dimxv)), dtype=np.float) 5221 for j in range(len(dimxv)): 5222 x[j,:] = dimxv 5223 else: 5224 x = np.zeros((dimyv.shape), dtype=np.float) 5225 if x.shape[0] == dimxv.shape[0]: 5226 for j in range(x.shape[1]): 5227 x[:,j] = dimxv 5228 else: 5229 for j in range(x.shape[0]): 5230 x[j,:] = dimxv 5231 5232 if len(dimyv.shape) == 3: 5233 y = dimyv[0,:,:] 5234 elif len(dimyv.shape) == 2: 5235 y = dimyv 5236 else: 5237 # y = np.zeros((lat0.shape), dtype=np.float) 5238 # for i in range(lat0.shape[1]): 5239 # x[:,i] = dimyv 5240 5241 # Idem 5242 if len(dimxv.shape) == 1: 5243 y = np.zeros((len(dimyv),len(dimxv)), dtype=np.float) 5244 for i in range(len(dimxv)): 5245 y[:,i] = dimyv 5246 else: 5247 y = np.zeros((dimxv.shape), dtype=np.float) 5248 if y.shape[0] == dimyv.shape[0]: 5249 for i in range(y.shape[1]): 5250 y[:,i] = dimyv 5251 else: 5252 for j in range(y.shape[0]): 5253 y[j,:] = dimyv 5254 5255 plt.rc('text', usetex=True) 5256 5257 plt.pcolormesh(x, y, varsv, cmap=plt.get_cmap(colorbar), vmin=vs[0], vmax=vs[1]) 5258 cbar = plt.colorbar() 5259 5260 if not mapv is None: 5261 m.drawcoastlines() 5262 5263 meridians = gen.pretty_int(nlon,xlon,5) 5256 m.drawcoastlines() 5257 5258 meridians = gen.pretty_int(nlon,xlon,xaxv[2]) 5264 5259 m.drawmeridians(meridians,labels=[True,False,False,True]) 5265 parallels = gen.pretty_int(nlat,xlat, 5)5260 parallels = gen.pretty_int(nlat,xlat,xaxv[2]) 5266 5261 m.drawparallels(parallels,labels=[False,True,True,False]) 5267 5262 … … 5269 5264 plt.ylabel('S-N') 5270 5265 else: 5271 plt.xlabel( variables_values(dimn[1])[0] + ' (' + units_lunits(dimxu) + ')')5272 plt.ylabel( variables_values(dimn[0])[0] + ' (' + units_lunits(dimyu) + ')')5266 plt.xlabel(dimxT) 5267 plt.ylabel(dimyT) 5273 5268 5274 5269 # Line 5275 5270 ## 5276 5277 if reva0 == 'flip' and reva.split('@')[1] == 'y': 5278 b=-np.max(y[0,:])/np.max(varlv) 5279 a=np.max(y[0,:]) 5280 else: 5281 b=np.max(y[0,:])/np.max(varlv) 5282 a=0. 5271 # Line does not suffer the flipping of the y-axis it is independent to it 5272 # if reva is not None and reva[0:4] == 'flip' and reva.split('@')[1] == 'y': 5273 # b=-np.max(y)/np.max(varlv) 5274 # a=np.max(y) 5275 # else: 5276 # b=np.max(y)/np.max(varlv) 5277 # a=0. 5278 vlsend = graphic_range([linev[1],linev[2]],varlv) 5279 b=(1.-vlsend[0])/(vlsend[1]-vlsend[0]) 5280 a=0. 5283 5281 5284 5282 newlinv = varlv*b+a 5285 if reva0 == 'transpose': 5286 plt.plot(newlinv, x[0,:], '-', color=colln, linewidth=2) 5287 else: 5288 plt.plot(x[0,:], newlinv, '-', color=colln, linewidth=2) 5289 5290 txpos = gen.pretty_int(x.min(),x.max(),10) 5291 typos = gen.pretty_int(y.min(),y.max(),10) 5292 txlabels = list(txpos) 5293 for i in range(len(txlabels)): txlabels[i] = str(txlabels[i]) 5294 tylabels = list(typos) 5295 for i in range(len(tylabels)): tylabels[i] = str(tylabels[i]) 5296 5297 tllabels = gen.pretty_int(np.min(varlv),np.max(varlv),len(txlabels)) 5298 for it in range(len(tllabels)): 5299 yval = (tllabels[it]*b+a) 5300 plt.plot([x.max()*0.97, x.max()], [yval, yval], '-', color='k') 5301 plt.annotate(tllabels[it], xy=(1.01,tllabels[it]/np.max(varlv)), \ 5302 xycoords='axes fraction') 5303 5304 # set the limits of the plot to the limits of the data 5305 if reva0 == 'flip': 5306 if reva.split('@')[1] == 'x': 5307 plt.axis([x.max(), x.min(), y.min(), y.max()]) 5308 else: 5309 plt.axis([x.min(), x.max(), y.max(), y.min()]) 5310 else: 5311 plt.axis([x.min(), x.max(), y.min(), y.max()]) 5283 if reva is not None and reva == 'transpose': 5284 plt.plot(newlinv, x, '-', color=linev[0], linewidth=2) 5285 else: 5286 plt.plot(x, newlinv, '-', color=linev[0], linewidth=2) 5287 5288 plt.axis([x.min(), x.max(), y.min(), y.max()]) 5312 5289 5313 5290 plt.tick_params(axis='y',right='off') 5314 5291 if mapv is None: 5315 plt.xticks(txpos, txlabels) 5316 plt.yticks(typos, tylabels) 5317 5318 tllabels = gen.pretty_int(np.min(varlv),np.max(varlv),len(txlabels)) 5319 for it in range(len(tllabels)): 5320 plt.annotate(tllabels[it], xy=(1.01,tllabels[it]/np.max(varlv)), xycoords='axes fraction') 5292 plt.xticks(dimxt, dimxl, rotation=xaxv[3]) 5293 plt.yticks(dimyt, dimyl, rotation=yaxv[3]) 5321 5294 5322 5295 # units labels 5323 cbar.set_label(vnames.replace('_','\_') + ' (' + units_lunits(uts) + ')') 5324 5325 plt.annotate(vnamel +' (' + units_lunits(utl) + ')', xy=(0.75,0.04), 5326 xycoords='figure fraction', color=colln) 5296 cbar.set_label(gen.latex_text(vnames) + ' (' + units_lunits(uts) + ')') 5297 5298 # line ticks 5299 dln = vlsend[0] 5300 dlx = vlsend[1] 5301 5302 if linev[3] == 'pretty': 5303 dimlt = np.array(gen.pretty_int(dln,dlx,yaxv[2])) 5304 elif linev[3] == 'Nfix': 5305 dimlt = np.arange(dln,dlx,(dlx-dln)/(1.*yaxv[2])) 5306 elif linev[3] == 'Vfix': 5307 dimlt = np.arange(0,dlx,yaxv[2]) 5308 5309 dimll = [] 5310 for i in range(len(dimlt)): dimll.append('{:{style}}'.format(dimlt[i], style=linev[4])) 5311 5312 for it in range(len(dimlt)): 5313 yval = (dimlt[it]*b+a) 5314 plt.plot([x.max()*0.97, x.max()], [yval, yval], '-', color='k') 5315 plt.annotate(dimll[it], xy=(1.01,yval), xycoords='axes fraction',rotation=linev[6]) 5316 5317 # plt.annotate(tllabels[it], xy=(1.01,tllabels[it]/np.max(varlv)), \ 5318 # xycoords='axes fraction') 5319 5320 plt.annotate(gen.latex_text(vnamel)+ ' ('+units_lunits(utl)+')', xy=(0.75,0.04), \ 5321 xycoords='figure fraction', color=linev[0]) 5327 5322 figname = '2Dfields_shadow_line' 5328 graphtit = vtit.replace('_','\_').replace('&','\&')5323 graphtit = gen.latex_text(vtit) 5329 5324 5330 5325 plt.title(graphtit)
Note: See TracChangeset
for help on using the changeset viewer.