Changeset 1447 in lmdz_wrf for trunk/tools
- Timestamp:
- Feb 12, 2017, 8:21:48 PM (8 years ago)
- Location:
- trunk/tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/drawing.py
r1438 r1447 31 31 ## e.g. # drawing.py -o draw_Neighbourghood_evol -S 'vas:Time|-1|WRFtime,south_north|44|XLAT,west_east|88|XLONG:south_north,west_east:5:auto:time|($[DD]^{[HH]}$),time|($[DD]^{[HH]}$):exct,1,h|exct,3,h:$%d^{%H}$,$%d^{%H}$:5|pts|neighbourghood|temporal|evolution|on|2001|Nov.|at|x=88,|y=44:0.0,20.:rainbow,auto,auto:auto:png:vas_Neigh_evol:True' -f ~/PY/wrfout_d01_2001-11-11_00:00:00 -v V10 32 32 ## e.g. # drawing.py -o draw_points -S 'SuperStorm/tslist.dat,#,3,2,1:SuperStorm|sfc|stations:auto:cyl,i:labelled,10,r:auto:None:0:png:stations_loc:True' -f 'geo_em.d02.nc,XLONG_M,XLAT_M,HGT_M,Time|0@west_east|30;180;1@south_north|175;255;1,height,0.,1500.,terrain,auto,auto,m' 33 ## e.g. # drawing.py -o draw_WindRose -S 'lon|7;lat|2:anglespeedfreq;16;8;40.;auto;auto:November!ERA-I!daily!mean!wind!at!850!hPa:png:cardinals:False:WindRose:True' -v u,v -f reg1_daymean_mon11_lev850_kmh.nc 34 ## e.g. # drawing.py -o draw_WindRose -S 'lon|7;lat|2:linepoint;multicoltime;time;auto;auto;auto;auto;exct,5,d;%m/%d;date!([DD]/[MM]):November!ERA-I!daily!mean!wind!at!850!hPa:png:cardinals:False:WindRose:True' -v u,v -f reg1_daymean_mon11_lev850_kmh.nc 35 ## e.g. # drawing.py -o draw_Taylor -f 'file0.nc@var,file1.nc@var,file2.nc@var,file3.nc@var' -S '$10.\sin(0.05t2\pi)$:x:8:k,b,r,g,#FFBB00:$10.25\sin(0.025+0.05t2\pi)$,$10.25\sin(0.025+0.05125t2\pi)$,$10.5\sin(0.05+0.05t2\pi)$,$10.\sin(0.05+0.0525t2\pi)$:legend,0,8:norm:sinus!Taylor!diagram:png:yes:True' -v reffile.nc,var 33 36 34 37 ## e.g. # drawing.py -o draw_trajectories -f 'WRF/control/trajectory.dat@-1@/home/lluis/etudes/domains/WL_HyMeX_HighRes_C/geo_em.d03.nc#XLONG_M#XLAT_M,WRF_LMDZ/wlmdza/trajectory.dat@-1@/home/lluis/etudes/domains/WL_HyMeX_C/geo_em.d01.nc#XLONG_M#XLAT_M,WRF_LMDZ/wlmdzb/trajectory.dat@-1@/home/lluis/etudes/domains/WL_HyMeX_C/geo_em.d01.nc#XLONG_M#XLAT_M,WRF_LMDZ/wlmdzb_ii/trajectory.dat@-1@/home/lluis/etudes/domains/WL_HyMeX_C/geo_em.d01.nc#XLONG_M#XLAT_M' -S '$WRF_{CRM}$,$LMDZ_{AR4.0}$,$LMDZ_{NPv3.1}$,$LMDZ_{NPv3.1b}$|None|medicane trajectories|pdf|cyl,i' -v obs/trajectory.dat,satellite,-1 … … 81 84 # draw_river_desc: Function to plot rivers' description from ORCHIDEE's routing scheme 82 85 # draw_subbasin: Function to plot subbasin from 'routnig.nc' ORCDHIEE 86 # draw_Taylor: Function to draw a Taylor diagram (Taylor 2001) 83 87 # draw_vertical_levels: plotting vertical levels distribution 84 # plot_WindRose: Function to plot a wind rose (from where the dinw blows)88 # draw_WindRose: Function to plot a wind rose (from where the dinw blows) 85 89 86 90 mainn = 'drawing.py' … … 96 100 'draw_Neighbourghood_evol', \ 97 101 'draw_points', 'draw_points_lonlat', \ 98 'draw_ptZvals', 'draw_river_desc', 'draw_subbasin', 'draw_ timeSeries',\99 'draw_t opo_geogrid',\102 'draw_ptZvals', 'draw_river_desc', 'draw_subbasin', 'draw_Taylor', \ 103 'draw_timeSeries', 'draw_topo_geogrid', \ 100 104 'draw_topo_geogrid_boxes', 'draw_trajectories', 'draw_vals_trajectories', \ 101 105 'draw_vectors', 'draw_vertical_levels', 'list_graphics', 'draw_WindRose', \ … … 5453 5457 return 5454 5458 5459 def draw_Taylor(ncfile, values, varname): 5460 """ Function to draw a Taylor diagram (Taylor 2001) 5461 From script: 5462 # Copyright: This document has been placed in the public domain. 5463 5464 Taylor diagram (Taylor, 2001) test implementation. 5465 5466 http://www-pcmdi.llnl.gov/about/staff/Taylor/CV/Taylor_diagram_primer.htm 5467 5468 __version__ = "Time-stamp: <2012-02-17 20:59:35 ycopin>" 5469 __author__ = "Yannick Copin <yannick.copin@laposte.net>" 5470 5471 ncfile= ',' list of netCDF file and vartiable to use ([ncfile1]@[var1], [...[nmcvileN]@[varN]]) 5472 values=[reflabel]:[mark]:[col]:[size]:[labels]:[[kindlabels]:[taylorkind]:[imgtit]:[figkind]:[outputfile]:[close] 5473 [reflabel]: label of the reference values in the graph 5474 [mark]: ',' list of kind of markers (single value for the same for all values) 5475 [col]: ',' list of color of markers (single value for the same for all values) 5476 [size]: ',' list of sizes of markers (single value for the same for all values) 5477 [labels]: ',' list of label of markers ('None' for without) 5478 [kindlabels]: kind of labels in plot 5479 'markfollow': on top of the mark of each pair of stddev, corr 5480 'legend',[loc],[charsize]: as a traditional legend and [loc] position [charsize] (size of labels, 'auto' for 12) 5481 1: 'upper right', 2: 'upper left', 3: 'lower left', 4: 'lower right', 5482 5: 'right', 6: 'center left', 7: 'center right', 8: 'lower center', 5483 9: 'upper center', 10: 'center' 5484 [taylorkind]: kind of Taylor plot 5485 'direct': direct values 5486 'norm': normalized to the stdandard deviation of reference 5487 [imgtit]: title of the image ('!' for spaces) 5488 [figkind]: kind of the figure 5489 [outputfile]: Whether is required to create a netcdf file with the information used in the Taylor diagram 5490 [close]: whether the figure has to be closed 5491 varname= [refncfile],[refvn] name of the reference faile and name of the variables within to use as reference 5492 """ 5493 from scipy import stats as sts 5494 5495 fname = 'draw_Taylor' 5496 5497 if values == 'h': 5498 print fname + '_____________________________________________________________' 5499 print draw_Taylor.__doc__ 5500 quit() 5501 5502 expectargs = '[reflabel]:[mark]:[size]:[col]:[labels]:[kindlabels]:' + \ 5503 '[taylorkind]:[imgtit]:[figkind]:[outputfile]:[close]' 5504 drw.check_arguments(fname,values,expectargs,':') 5505 5506 reflabel = values.split(':')[0] 5507 mark = values.split(':')[1] 5508 col = values.split(':')[2] 5509 size = values.split(':')[3] 5510 labels = values.split(':')[4] 5511 kindlabels = values.split(':')[5] 5512 taylorkind = values.split(':')[6] 5513 imgtit = values.split(':')[7].replace('!', ' ') 5514 figkind = values.split(':')[8] 5515 outputfile = gen.Str_Bool(values.split(':')[9]) 5516 close = gen.Str_Bool(values.split(':')[10]) 5517 5518 # Reference parameters 5519 refncfile = varname.split(',')[0] 5520 refvn = varname.split(',')[1] 5521 5522 # Marker types 5523 if mark.find(',') != -1: 5524 marktyp = mark.split(',') 5525 else: 5526 marktyp = [mark] 5527 5528 # Marker sizes 5529 if size.find(',') != -1: 5530 marksize = size.split(',') 5531 else: 5532 marksize = [size] 5533 5534 # Marker Colors 5535 if col.find(',') != -1: 5536 markcol = col.split(',') 5537 else: 5538 markcol = [col] 5539 5540 # Marker Labels 5541 if labels != 'None': 5542 marklabs = [reflabel] + labels.split(',') 5543 else: 5544 marklabs = None 5545 5546 # Getting reference values 5547 if not os.path.isfile(refncfile): 5548 print errormsg 5549 print ' ' + fname + ": reference file '" + refncfile + "' does not exist !!" 5550 quit(-1) 5551 5552 # List of used files 5553 usedfilens = [] 5554 # List of used variables 5555 usedvarns = [] 5556 5557 usedfilens.append(refncfile) 5558 usedvarns.append(refvn) 5559 5560 oref = NetCDFFile(refncfile, 'r') 5561 refvars = oref.variables.keys() 5562 if not gen.searchInlist(refvars, refvn): 5563 print errormsg 5564 print ' ' + fname + ": reference file '" + refncfile + "' does not have " + \ 5565 "variable '" + refvn + "' !!" 5566 quit(-1) 5567 orefv = oref.variables[refvn] 5568 refvals = orefv[:] 5569 varunits = orefv.units 5570 oref.close() 5571 5572 # Statistics values 5573 filevars = ncfile.split(',') 5574 Nfiles = len(filevars) 5575 meanvalues = [] 5576 stdvalues = [] 5577 corrvalues = [] 5578 corrpvalues = [] 5579 biasvalues = [] 5580 maevalues = [] 5581 rmsevalues = [] 5582 5583 meanref = refvals.mean() 5584 stdref = refvals.std() 5585 5586 if taylorkind == 'norm': 5587 print ' ' + fname + ': normalizing diagram' 5588 stdvalues.append(1.) 5589 else: 5590 stdvalues.append(stdref) 5591 5592 meanvalues.append(meanref) 5593 corrvalues.append(1.) 5594 corrpvalues.append(1.) 5595 biasvalues.append(0.) 5596 maevalues.append(0.) 5597 rmsevalues.append(0.) 5598 5599 print ' ' + fname + ': File statistics _______' 5600 for filevar in filevars: 5601 filen = filevar.split('@')[0] 5602 varn = filevar.split('@')[1] 5603 if not os.path.isfile(refncfile): 5604 print errormsg 5605 print ' ' + fname + ": file '" + filen + "' does not exist !!" 5606 quit(-1) 5607 ovalf = NetCDFFile(filen, 'r') 5608 valvars = ovalf.variables.keys() 5609 if not gen.searchInlist(valvars, varn): 5610 print errormsg 5611 print ' ' + fname + ": file '" + filen + "' does not have variable '" + \ 5612 varn + "' !!" 5613 quit(-1) 5614 oval = ovalf.variables[varn] 5615 vals = oval[:] 5616 ovalf.close() 5617 5618 usedfilens.append(filen) 5619 usedvarns.append(varn) 5620 5621 gen.same_shape(refvals,vals) 5622 5623 if taylorkind == 'norm': 5624 valstdv = vals.std()/stdref 5625 else: 5626 valstdv = vals.std() 5627 corrv, corrp = sts.pearsonr(refvals, vals) 5628 5629 diff = vals - refvals 5630 meanvalues.append(vals.mean()) 5631 stdvalues.append(valstdv) 5632 corrvalues.append(corrv) 5633 corrpvalues.append(corrp) 5634 biasvalues.append(diff.mean()) 5635 maevalues.append(np.abs(diff).mean()) 5636 rmsevalues.append(diff.std()) 5637 print ' ', filen, 'val bias:', diff.mean(), 'std:', valstdv, 'corr:', \ 5638 corrv, 'rmse:', diff.std() 5639 5640 drw.plot_Taylor(stdvalues, corrvalues, corrpvalues, varunits, marktyp, marksize, \ 5641 markcol, marklabs, kindlabels, taylorkind, imgtit, figkind, close) 5642 5643 if outputfile: 5644 ofilen = 'Taylor.nc' 5645 print ' ' + fname + ": creation of oputput file '" + ofilen + "' " 5646 outnc = NetCDFFile(ofilen, 'w') 5647 5648 # create dimensions 5649 newdim = outnc.createDimension('file',Nfiles) 5650 newdim = outnc.createDimension('Lstring',256) 5651 5652 # create variable-dimension 5653 newvar = outnc.createVariable('file', 'c', ('file','Lstring')) 5654 ncvar.writing_str_nc(newvar,usedfilens[1:-1],256) 5655 ncvar.basicvardef(newvar,'used_files','files used in Taylor plot','-') 5656 5657 # Variables 5658 newvar = outnc.createVariable('refvar', 'c', ('Lstring')) 5659 ncvar.writing_1str_nc(newvar, 'refvarn', 256) 5660 ncvar.basicvardef(newvar,'refvar','reference variable', varunits) 5661 ncvar.set_attributek(newvar,'file',refncfile,'S') 5662 ncvar.set_attributek(newvar,'mean',meanref,'R') 5663 ncvar.set_attributek(newvar,'standard_deviation',stdref,'R') 5664 5665 newvar = outnc.createVariable('varn', 'c', ('file','Lstring')) 5666 ncvar.writing_str_nc(newvar,usedvarns[1:-1],256) 5667 ncvar.basicvardef(newvar,'used_variables','variables used in Taylor plot','-') 5668 5669 newvar = outnc.createVariable('stddev','f4',('file')) 5670 newvar[:] = stdvalues[1:Nfiles+1] 5671 ncvar.basicvardef(newvar,'standard_deviation','standard deviation',varunits) 5672 5673 newvar = outnc.createVariable('corr','f4',('file')) 5674 newvar[:] = corrvalues[1:Nfiles+1] 5675 ncvar.basicvardef(newvar,'correlation','correlation with reference values', \ 5676 '-') 5677 5678 newvar = outnc.createVariable('corrp','f4',('file')) 5679 newvar[:] = corrpvalues[1:Nfiles+1] 5680 ncvar.basicvardef(newvar,'p_value_correlations','p-value of the correlation'+\ 5681 ' with reference values', '-') 5682 5683 newvar = outnc.createVariable('mean','f4',('file')) 5684 newvar[:] = meanvalues[1:Nfiles+1] 5685 ncvar.basicvardef(newvar,'mean','mean of values', varunits) 5686 5687 newvar = outnc.createVariable('bias','f4',('file')) 5688 newvar[:] = biasvalues[1:Nfiles+1] 5689 ncvar.basicvardef(newvar,'bias','bias with reference values',varunits) 5690 5691 newvar = outnc.createVariable('mae','f4',('file')) 5692 newvar[:] = maevalues[1:Nfiles+1] 5693 ncvar.basicvardef(newvar,'mae','Mean Absolute Error with reference values',varunits) 5694 5695 newvar = outnc.createVariable('rmse','f4',('file')) 5696 newvar[:] = rmsevalues[1:Nfiles+1] 5697 ncvar.basicvardef(newvar,'rmse','Root Mean Square Error with reference values',varunits) 5698 5699 # Global values 5700 outnc.setncattr('original_source_script', 'test_taylor_4panel.py') 5701 outnc.setncattr('authors_source_script', 'Yannick Copin') 5702 outnc.setncattr('url_source_script', 'http://www-pcmdi.llnl.gov/about/' + \ 5703 'staff/Taylor/CV/Taylor_diagram_primer.htm') 5704 ncvar.add_global_PyNCplot(outnc, 'drawing.py', fname, '1.0') 5705 5706 outnc.sync() 5707 outnc.close() 5708 print fname + ": succesful writting of file '" + ofilen + "' !!" 5709 5710 return 5711 5712 5455 5713 #quit() 5456 5714 … … 5475 5733 'draw_2D_shad_line', 'draw_2D_shad_line_time', 'draw_2lines', 'draw_2lines_time', \ 5476 5734 'draw_lines', \ 5477 'draw_lines_time', 'draw_points', 'draw_ topo_geogrid_boxes', 'draw_trajectories',\5478 'draw_ vals_trajectories', 'variable_values']5735 'draw_lines_time', 'draw_points', 'draw_Taylor', 'draw_topo_geogrid_boxes', \ 5736 'draw_trajectories', 'draw_vals_trajectories', 'variable_values'] 5479 5737 5480 5738 errormsg='ERROR -- error -- ERROR -- error' … … 5552 5810 elif oper == 'draw_subbasin': 5553 5811 draw_subbasin(opts.ncfile, opts.values) 5812 elif oper == 'draw_Taylor': 5813 draw_Taylor(opts.ncfile, opts.values, opts.varname) 5554 5814 elif oper == 'draw_timeSeries': 5555 5815 draw_timeSeries(opts.ncfile, opts.values, opts.varname) -
trunk/tools/drawing_tools.py
r1441 r1447 37 37 pointsizesauto = [7.] 38 38 39 ####### Fun tions39 ####### Functions 40 40 # check_colorBar: Check if the given colorbar exists in matplotlib 41 41 # colorbar_vals: Function to provide the colorbar values for a figure … … 83 83 # plot_2lines_time: Function to plot two time-lines in different axes (x/x2 or y/y2) 84 84 # plot_lines: Function to plot a collection of lines 85 # plot_Taylor: Function to draw a Taylor diagram (Taylor 2001) 85 86 # plot_WindRose: Function to plot a wind rose (from where the dinw blows) 86 87 # plot_ZQradii: Function to plot following radial averages only at exact grid poins … … 1719 1720 fname = 'legend_values' 1720 1721 1721 locleg = int(legstring.split( '|')[0])1722 fontsize0 = legstring.split( '|')[1]1722 locleg = int(legstring.split(char)[0]) 1723 fontsize0 = legstring.split(char)[1] 1723 1724 if fontsize0 == 'auto': 1724 1725 fontsize = 12 … … 8394 8395 8395 8396 # Global values 8396 newnc.setncattr('author', 'L. Fita') 8397 newattr = ncvar.set_attributek(newnc, 'institution', unicode('Laboratoire ' +\ 8398 'de M' + unichr(233) + 't' + unichr(233) + 'orologie Dynamique'), 'U') 8399 newnc.setncattr('university', 'Pierre Marie Curie - Jussieu') 8400 newnc.setncattr('center', 'Centre National de Recherches Scientifiques') 8401 newnc.setncattr('city', 'Paris') 8402 newnc.setncattr('country', 'France') 8403 newnc.setncattr('script', 'nc_var_tools.py') 8404 newnc.setncattr('function', fname) 8405 newnc.setncattr('version', '1.0') 8397 ncvar.add_global_PyNCplot(newnc, 'drawing_tools.py', fname, '1.0') 8406 8398 newnc.setncattr('original_file', origfilen) 8407 8399 … … 8411 8403 8412 8404 return 8405 8406 def plot_Taylor(stdv, corrv, corrpv, vunits, mtyp, mcol, msize, mlabs, labkind, \ 8407 tkind, itit, kfig, closefig): 8408 """ Function to draw a Taylor diagram (Taylor 2001) 8409 From script: 8410 # Copyright: This document has been placed in the public domain. 8411 8412 Taylor diagram (Taylor, 2001) test implementation. 8413 8414 http://www-pcmdi.llnl.gov/about/staff/Taylor/CV/Taylor_diagram_primer.htm 8415 8416 __version__ = "Time-stamp: <2012-02-17 20:59:35 ycopin>" 8417 __author__ = "Yannick Copin <yannick.copin@laposte.net>" 8418 8419 stdv= standard deviation values 8420 corrv= correlation values 8421 corrpv= pearson correlation p-value 8422 vunits= units of the variable 8423 mtyp= list of type of markers 8424 mcol= list of color of markers 8425 msize= list of size of markers 8426 mlabs= list of labels for markers (None for any) 8427 labkind= kind of labels in plot 8428 'markfollow': on top of the mark of each pair of stddev, corr 8429 'legend',[loc],[charsize]: as a traditional legend 8430 tkind: kind of Taylor plot 8431 'direct': direct values 8432 'norm': normalized to the stdandard deviation of reference 8433 itit= title of figure 8434 kfig= kind of figure 8435 closefig= whether figure has to be closed or not 8436 """ 8437 from matplotlib.projections import PolarAxes 8438 import mpl_toolkits.axisartist.floating_axes as FA 8439 import mpl_toolkits.axisartist.grid_finder as GF 8440 8441 fname = 'plot_Taylor2' 8442 colelines = '#DDDDDD' 8443 8444 # Which size of the Taylor plot (should go until pi, since there are corr > 0.?) 8445 if np.min(corrv) < 0.: 8446 print warnmsg 8447 print ' ' + fname + ': minimum correlation:', np.min(corrv),'is negative !!' 8448 print ' extending Taylor plot until pi' 8449 maxang = np.pi 8450 else: 8451 maxang = np.pi/2. 8452 8453 # Transforming correlations to given angles 8454 Tcorrv = np.arccos(corrv) 8455 8456 plt.rc('text', usetex=True) 8457 Nvalues = len(stdv) 8458 colors, lines, points, Llines, Spoints = ColorsLinesPointsStyles(Nvalues, \ 8459 mcol, [','], mtyp, [2], msize, None) 8460 8461 fig = plt.figure() 8462 rect = 111 8463 8464 tr = PolarAxes.PolarTransform() 8465 8466 # Correlation labels 8467 if maxang <= np.pi/2.: 8468 rlocs = np.concatenate((np.arange(10)/10.,[0.95,0.99])) 8469 else: 8470 rlocs = np.concatenate(([-0.99, -0.95], (-10+np.arange(10))/10., [0.0], \ 8471 np.arange(10)/10., [0.95,0.99], [1.])) 8472 8473 tlocs = np.arccos(rlocs) # Conversion to polar angles 8474 gl1 = GF.FixedLocator(tlocs) # Positions 8475 tf1 = GF.DictFormatter(dict(zip(tlocs, map(str,rlocs)))) 8476 8477 # Standard deviation radius 8478 smin = 0 8479 smax = np.max([1.25*stdv[0], np.max(stdv)]) 8480 label = '_' 8481 8482 ghelper = FA.GridHelperCurveLinear(tr, extremes=(0,maxang,smin, smax), \ 8483 grid_locator1=gl1, tick_formatter1=tf1) 8484 8485 ax = FA.FloatingSubplot(fig, rect, grid_helper=ghelper) 8486 fig.add_subplot(ax) 8487 8488 # Adjust axes 8489 ax.axis["top"].set_axis_direction("bottom") # "Angle axis" 8490 ax.axis["top"].toggle(ticklabels=True, label=True) 8491 ax.axis["top"].major_ticklabels.set_axis_direction("top") 8492 ax.axis["top"].label.set_axis_direction("top") 8493 ax.axis["top"].label.set_text("Correlation") 8494 8495 ax.axis["left"].set_axis_direction("bottom") # "X axis" 8496 ax.axis["left"].label.set_text("Standard deviation") 8497 8498 if maxang <= np.pi/2.: 8499 ax.axis["right"].set_axis_direction("top") # "Y axis" 8500 ax.axis["right"].toggle(ticklabels=True) 8501 ax.axis["right"].major_ticklabels.set_axis_direction("left") 8502 else: 8503 ax.axis["right"].set_axis_direction("top") # "Y axis" 8504 ax.axis["right"].toggle(ticklabels=True) 8505 ax.axis["right"].major_ticklabels.set_axis_direction("bottom") 8506 8507 ax.axis["bottom"].set_visible(False) # Useless 8508 8509 # Contours along standard deviations 8510 ax.grid(False) 8511 8512 ax = ax.get_aux_axes(tr) # Polar coordinates 8513 8514 # Adding correlation lines 8515 if maxang > np.pi/2.: 8516 #thetalabs = ['1.', '0.99', '0.95', '0.9', '0.8', '0.7', '0.6', '0.5', '0.4', \ 8517 # '0.3', '0.2', '0.1', '0.0', -0.1, -0.2, -0.3, -0.4, -0.5, -0.6, -0.7, -0.8,\ 8518 # -0.9, -0.95, -0.99, -1.] 8519 thetalabs = ['0.99', '0.95', '0.8', '0.6', '0.4', '0.2', 0.0, -0.2, -0.4, \ 8520 -0.6, -0.8, -0.95, -0.99, -1.] 8521 else: 8522 thetalabs = ['0.99', '0.95', '0.8', '0.6', '0.4', '0.2'] 8523 8524 # Correlation lines 8525 Nlref = 100 8526 dang = maxang/(Nlref-1) 8527 lref = np.zeros((Nlref,2), dtype=np.float) 8528 for iang in thetalabs: 8529 ang = np.arccos(np.float(iang)) 8530 lref[:,0] = ang 8531 for ia in range(Nlref): 8532 lref[ia,1] = smax*ia/(Nlref-1) 8533 ax.plot(lref[:,0], lref[:,1], '--', color=colelines, linewidth=1) 8534 8535 # Adding dash line from ref 8536 for ia in range(Nlref): 8537 lref[ia,0] = dang*ia 8538 lref[ia,1] = stdv[0] 8539 ax.plot(lref[:,0], lref[:,1], '-.', label='_', color='#AAAAAA', linewidth=1) 8540 8541 # Adding concentrical circular lines from ref 8542 dang = np.pi/(Nlref-1) 8543 if maxang > np.pi/2.: 8544 Nlines = 8 8545 rads = gen.pretty_int(0., stdv[0]*5./2.,Nlines) 8546 anglab = np.pi*7./8. 8547 else: 8548 Nlines = 4 8549 rads = gen.pretty_int(0., stdv[0]*3./2.,Nlines) 8550 anglab = np.pi*1.4/2. 8551 8552 for rad in rads: 8553 for ia in range(Nlref): 8554 x = stdv[0] + rad*np.cos(dang*ia) 8555 y = rad*np.sin(dang*ia) 8556 if np.sqrt(x**2+y**2) <= smax: 8557 lref[ia,0] = np.arctan2(y,x) 8558 lref[ia,1] = np.sqrt(x**2+y**2) 8559 else: 8560 lref[ia,0] = None 8561 lref[ia,1] = None 8562 8563 # Labelling distance from ref 8564 if dang*ia >= anglab and dang*ia <= anglab+dang: 8565 Slab = '{0:.2g}'.format(rad) 8566 ax.annotate(Slab, xy=(lref[ia,0],lref[ia,1]), color='#AAAAAA') 8567 8568 ax.plot(lref[:,0], lref[:,1], '--', color='#AAAAAA', linewidth=0.5) 8569 8570 if labkind[0:6] == 'legend': 8571 for iv in range(Nvalues): 8572 if Nvalues != len(mlabs): 8573 print errormsg 8574 print ' ' + fname + ': number of vaules:', Nvalues, 'and labels:', \ 8575 len(mlabs), 'do not coincide !!' 8576 print ' labels provided:', mlabs 8577 quit(-1) 8578 ax.plot(Tcorrv[iv], stdv[iv], lines[iv], color=colors[iv], \ 8579 marker=points[iv], markersize=Spoints[iv], \ 8580 label=gen.latex_text(mlabs[iv])) 8581 else: 8582 for iv in range(Nvalues): 8583 ax.plot(Tcorrv[iv], stdv[iv], lines[iv], color=colors[iv], \ 8584 marker=points[iv], markersize=Spoints[iv]) 8585 8586 if labkind == 'markfollow': 8587 for iv in range(Nvalues): 8588 ax.annotate(gen.latex_text(mlabs[iv]), xy=(Tcorrv[iv],stdv[iv])) 8589 elif labkind[0:6] == 'legend': 8590 legvals = labkind.split(',') 8591 gloc, gsize = legend_values(legvals[1] + ':' + legvals[2], ':') 8592 ax.legend(loc=gloc, prop={'size':gsize}) 8593 8594 fig.suptitle(gen.latex_text(itit)) 8595 if tkind == 'norm': 8596 labstd = 'standard deviation (norm.)' 8597 else: 8598 labstd = 'standard deviation (' + units_lunits(vunits) + ')' 8599 8600 output_kind(kfig, 'Taylor', closefig) 8601 8602 return 8603 8604
Note: See TracChangeset
for help on using the changeset viewer.