Changeset 2082 in lmdz_wrf
- Timestamp:
- Aug 12, 2018, 12:05:20 AM (7 years ago)
- Location:
- trunk/tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/drawing.py
r2081 r2082 122 122 123 123 errormsg = 'ERROR -- error -- ERROR -- error' 124 infmsg = 'INFORMATION -- information -- INFORMATION -- information' 124 125 warnmsg = 'WARNING -- waring -- WARNING -- warning' 125 126 fillValue=1.e20 … … 10304 10305 """ Function to plot vertical levels from WRF wrfinput_d[nn] file 10305 10306 filenames= ',' list of name of files to use 10306 values = [labs]:[colors]:[markers]:[legvals]:[imgtit]:[imgkind]:[ close]10307 values = [labs]:[colors]:[markers]:[legvals]:[imgtit]:[imgkind]:[newfile]:[close] 10307 10308 [labs]= ',' list of labels for the plot (LaTeX like) 10308 10309 [colors]= ',' list of colors for the lines ('auto' for automatic) 10309 10310 [markers]= '@' list of markers for the lines ('auto' for automatic) 10310 [legvals]=[loclegend]|[fonstsize] values for the legend10311 [legvals]=[loclegend]|[fonstsize]|[ncol] values for the legend 10311 10312 [locleg]: location of the legend (0, automatic) 10312 10313 1: 'upper right', 2: 'upper left', 3: 'lower left', 4: 'lower right', … … 10314 10315 9: 'upper center', 10: 'center' 10315 10316 [fontsize]: font size for the legend ('auto' for 12) 10317 [ncol]: number of columns ('auto' for 1) 10316 10318 [imgtit]= title of the image ('!' for spaces) 10317 10319 [imgkind]= kind of file output of the image (ps, pns, pdf, ...) 10320 [newfile]= whether the possible pre-existing file with the required data be 10321 should removed or not ('yes/no') 10318 10322 [close]= whether figure should be closed or not 10319 10323 """ 10324 import subprocess as sub 10325 10320 10326 fname = 'draw_WRFeta_levels' 10321 10327 … … 10325 10331 quit() 10326 10332 10327 expectargs = '[labs]:[colors]:[markers]:[legvals]:[imgtit]:[imgkind]:[close]' 10333 expectargs = '[labs]:[colors]:[markers]:[legvals]:[imgtit]:[imgkind]:' + \ 10334 '[newfile]:[close]' 10328 10335 drw.check_arguments(fname,values,expectargs,':') 10329 10336 … … 10336 10343 imgtit = values.split(':')[4].replace('!', ' ') 10337 10344 imgkind = values.split(':')[5] 10338 close = gen.Str_Bool(values.split(':')[6]) 10345 newfile = gen.Str_Bool(values.split(':')[6]) 10346 close = gen.Str_Bool(values.split(':')[7]) 10339 10347 10340 10348 files = filenames.split(',') 10349 Nfiles = len(files) 10350 10341 10351 allhgtsea = [] 10342 10352 allxhgt = [] 10353 allpsea = [] 10354 allpxhgt = [] 10343 10355 allhgtxhgt = [] 10344 10356 alldhgtsea = [] 10345 10357 alldhgtxhgt = [] 10358 alldpsea = [] 10359 alldpxhgt = [] 10346 10360 alletaw = [] 10347 10361 alletau = [] 10348 10349 for filen in files: 10350 if not os.path.isfile(filen): 10351 print errormsg 10352 print ' ' + fname + ": file '" + filen + "' does not exist !!" 10353 quit(-1) 10354 10355 onc = NetCDFFile(filen, 'r') 10356 ophb = onc.variables['PHB'] 10357 olandseamask = onc.variables['LANDMASK'] 10358 ohgt = onc.variables['HGT'] 10359 oznw = onc.variables['ZNW'] 10360 oznu = onc.variables['ZNU'] 10361 10362 dimx = ophb.shape[3] 10363 dimy = ophb.shape[2] 10364 dimz = ophb.shape[1] 10365 dimt = ophb.shape[0] 10366 10367 for j in range(10,dimy): 10368 for i in range(10,dimx): 10369 if olandseamask[0,j,i] == 0: 10370 hgtssea = ophb[0,:,j,i]/9.8 10371 break 10372 10373 maxhgt = np.max(ohgt[0,:,:]) 10374 ijxhgt = gen.index_mat(ohgt[0,:,:], maxhgt) 10375 hgtsxhgt = ophb[0,:, ijxhgt[0], ijxhgt[1]]/9.8 10376 10377 allhgtsea.append(hgtssea) 10378 allxhgt.append(maxhgt) 10379 allhgtxhgt.append(hgtsxhgt) 10380 alldhgtsea.append(hgtssea[1:dimz]-hgtssea[0:dimz-1]) 10381 alldhgtxhgt.append(hgtsxhgt[1:dimz]-hgtsxhgt[0:dimz-1]) 10382 alletaw.append(oznw[0,:]) 10383 alletau.append(oznu[0,:]) 10384 10362 alldimz = [] 10363 10364 # Creation of a file with the data 10365 titS = imgtit.replace(' ','-') 10366 ofilen = 'WRFeta_levels_' + titS + '.nc' 10367 10368 # Removing pre-existing file 10369 if newfile: 10370 if os.path.isfile(ofilen): 10371 print ' ' + fname + ": removing pre-existing file with required '" + \ 10372 "data '" + ofilen + "' !!" 10373 sub.call('rm ' + ofilen, shell=True) 10374 10375 if not os.path.isfile(ofilen): 10376 10377 maxdz = -10 10378 for filen in files: 10379 if not os.path.isfile(filen): 10380 print errormsg 10381 print ' ' + fname + ": file '" + filen + "' does not exist !!" 10382 quit(-1) 10383 10384 onc = NetCDFFile(filen, 'r') 10385 ophb = onc.variables['PHB'] 10386 opb = onc.variables['PB'] 10387 olandseamask = onc.variables['LANDMASK'] 10388 ohgt = onc.variables['HGT'] 10389 oznw = onc.variables['ZNW'] 10390 oznu = onc.variables['ZNU'] 10391 10392 dimx = ophb.shape[3] 10393 dimy = ophb.shape[2] 10394 dimz = ophb.shape[1] 10395 dimt = ophb.shape[0] 10396 dimzp = opb.shape[1] 10397 10398 if maxdz < dimz: maxdz = dimz 10399 10400 for j in range(10,dimy): 10401 for i in range(10,dimx): 10402 if olandseamask[0,j,i] == 0: 10403 hgtssea = ophb[0,:,j,i]/9.8 10404 pssea = opb[0,:,j,i] 10405 break 10406 10407 maxhgt = np.max(ohgt[0,:,:]) 10408 ijxhgt = gen.index_mat(ohgt[0,:,:], maxhgt) 10409 hgtsxhgt = ophb[0,:, ijxhgt[0], ijxhgt[1]]/9.8 10410 psxhgt = opb[0,:, ijxhgt[0], ijxhgt[1]] 10411 10412 allhgtsea.append(hgtssea) 10413 allxhgt.append(maxhgt) 10414 allhgtxhgt.append(hgtsxhgt) 10415 allpsea.append(pssea) 10416 allpxhgt.append(psxhgt) 10417 alldhgtsea.append(hgtssea[1:dimz]-hgtssea[0:dimz-1]) 10418 alldhgtxhgt.append(hgtsxhgt[1:dimz]-hgtsxhgt[0:dimz-1]) 10419 alldpsea.append(pssea[0:dimzp-1]-pssea[1:dimzp]) 10420 alldpxhgt.append(psxhgt[0:dimzp-1]-psxhgt[1:dimzp]) 10421 alletaw.append(oznw[0,:]) 10422 alletau.append(oznu[0,:]) 10423 alldimz.append(dimz) 10424 10425 onc.close() 10426 10427 print infmsg 10428 print ' ' + fname + ": creation of file '" + ofilen + "' to keep required"+ \ 10429 "values to plot !!" 10430 onewnc = NetCDFFile(ofilen, 'w') 10431 10432 # Dimensions 10433 newdim = onewnc.createDimension('Nfiles', Nfiles) 10434 newdim = onewnc.createDimension('Lstring', 250) 10435 newdim = onewnc.createDimension('evert', maxdz) 10436 10437 # Variabledimensions 10438 newvar = onewnc.createVariable('Nfiles', 'c', ('Nfiles', 'Lstring')) 10439 ncvar.writing_str_nc(newvar, files, 250) 10440 ncvar.basicvardef(newvar,'files','Files used to retrieve data','-') 10441 10442 newvar = onewnc.createVariable('evert_file', 'i', ('Nfiles')) 10443 ncvar.basicvardef(newvar,'evert_file','number vertical layers per file','-') 10444 newvar[:] = alldimz 10445 10446 # Variables 10447 newvar = onewnc.createVariable('hgtsea', 'f', ('Nfiles', 'evert'), \ 10448 fill_value=gen.fillValueF) 10449 ncvar.basicvardef(newvar,'hgtsea','heights above sea point', 'm') 10450 for iff in range(Nfiles): newvar[iff,0:alldimz[iff]] = allhgtsea[iff] 10451 10452 newvar = onewnc.createVariable('pressea', 'f', ('Nfiles', 'evert'), \ 10453 fill_value=gen.fillValueF) 10454 ncvar.basicvardef(newvar,'pressea','pressures above sea point', 'Pa') 10455 for iff in range(Nfiles): newvar[iff,0:alldimz[iff]-1] = allpsea[iff] 10456 10457 newvar = onewnc.createVariable('hgtmax', 'f', ('Nfiles')) 10458 ncvar.basicvardef(newvar,'hgtmax','maximum height', 'm') 10459 newvar[:] = allxhgt 10460 10461 newvar = onewnc.createVariable('hgtxhgt', 'f', ('Nfiles', 'evert'), \ 10462 fill_value=gen.fillValueF) 10463 ncvar.basicvardef(newvar,'hgtxhgt','heights above maximum height', 'm') 10464 for iff in range(Nfiles): newvar[iff,0:alldimz[iff]] = allhgtxhgt[iff] 10465 10466 newvar = onewnc.createVariable('presxhgt', 'f', ('Nfiles', 'evert'), \ 10467 fill_value=gen.fillValueF) 10468 ncvar.basicvardef(newvar,'presxhgt','pressures above maximum height', 'Pa') 10469 for iff in range(Nfiles): newvar[iff,0:alldimz[iff]-1] = allpxhgt[iff] 10470 10471 onewnc.sync() 10472 10473 newvar = onewnc.createVariable('dhgtsea', 'f', ('Nfiles', 'evert'), \ 10474 fill_value=gen.fillValueF) 10475 ncvar.basicvardef(newvar,'dhgtsea','delta heights above sea point', 'm') 10476 for iff in range(Nfiles): newvar[iff,0:alldimz[iff]-1] = alldhgtsea[iff] 10477 10478 newvar = onewnc.createVariable('dhgtxhgt', 'f', ('Nfiles', 'evert'), \ 10479 fill_value=gen.fillValueF) 10480 ncvar.basicvardef(newvar,'dhgtxhgt','delta heights above maximum height', 'm') 10481 for iff in range(Nfiles): newvar[iff,0:alldimz[iff]-1] = alldhgtxhgt[iff] 10482 10483 newvar = onewnc.createVariable('dpressea', 'f', ('Nfiles', 'evert'), \ 10484 fill_value=gen.fillValueF) 10485 ncvar.basicvardef(newvar,'dpressea','delta pressures above sea point', 'Pa') 10486 for iff in range(Nfiles): newvar[iff,0:alldimz[iff]-2] = alldpsea[iff] 10487 10488 newvar = onewnc.createVariable('dpresxhgt', 'f', ('Nfiles', 'evert'), \ 10489 fill_value=gen.fillValueF) 10490 ncvar.basicvardef(newvar,'dpresxhgt','delta pressures above maximum height', \ 10491 'Pa') 10492 for iff in range(Nfiles): newvar[iff,0:alldimz[iff]-2] = alldpxhgt[iff] 10493 10494 newvar = onewnc.createVariable('eta_full', 'f', ('Nfiles', 'evert'), \ 10495 fill_value=gen.fillValueF) 10496 ncvar.basicvardef(newvar,'eta_full','full eta layers', '-') 10497 for iff in range(Nfiles): newvar[iff,0:alldimz[iff]] = alletaw[iff] 10498 10499 newvar = onewnc.createVariable('eta_half', 'f', ('Nfiles', 'evert'), \ 10500 fill_value=gen.fillValueF) 10501 ncvar.basicvardef(newvar,'eta_half','half eta layers', '-') 10502 for iff in range(Nfiles): newvar[iff,0:alldimz[iff]-1] = alletau[iff] 10503 10504 onewnc.sync() 10505 onewnc.close() 10506 print fname + ": succesfull written of file '" + ofilen + "' with all data !!" 10507 10508 else: 10509 print fname + ": readding existing file '" + ofilen + "' with all data !!" 10510 print " if a new file is required set variable 'newfile' to 'yes'" 10511 onc = NetCDFFile(ofilen, 'r') 10512 10513 ovar = onc.variables['hgtsea'] 10514 allhgtseav = ovar[:] 10515 ovar = onc.variables['pressea'] 10516 allpseav = ovar[:] 10517 ovar = onc.variables['hgtmax'] 10518 allxhgtv = ovar[:] 10519 ovar = onc.variables['hgtxhgt'] 10520 allhgtxhgtv = ovar[:] 10521 ovar = onc.variables['presxhgt'] 10522 allpxhgtv = ovar[:] 10523 ovar = onc.variables['dhgtsea'] 10524 alldhgtseav = ovar[:] 10525 ovar = onc.variables['dhgtxhgt'] 10526 alldhgtxhgtv = ovar[:] 10527 ovar = onc.variables['dpressea'] 10528 alldpseav = ovar[:] 10529 ovar = onc.variables['dpresxhgt'] 10530 alldpxhgtv = ovar[:] 10531 ovar = onc.variables['eta_full'] 10532 alletawv = ovar[:] 10533 ovar = onc.variables['eta_half'] 10534 alletauv = ovar[:] 10535 10385 10536 onc.close() 10386 10537 10538 for iff in range(Nfiles): 10539 allhgtsea.append(allhgtseav[iff,:].compressed()) 10540 allxhgt.append(allxhgtv[iff]) 10541 allhgtxhgt.append(allhgtxhgtv[iff,:].compressed()) 10542 allpsea.append(allpseav[iff,:].compressed()) 10543 allpxhgt.append(allpxhgtv[iff,:].compressed()) 10544 alldhgtsea.append(alldhgtseav[iff,:].compressed()) 10545 alldhgtxhgt.append(alldhgtxhgtv[iff,:].compressed()) 10546 alldpsea.append(alldpseav[iff,:].compressed()) 10547 alldpxhgt.append(alldpxhgtv[iff,:].compressed()) 10548 alletaw.append(alletawv[iff,:].compressed()) 10549 alletau.append(alletauv[iff,:].compressed()) 10550 10387 10551 # Legend 10388 locleg, legfontsize = drw.legend_values(legvals,'|')10389 10390 drw.plot_WRFeta_levels(allhgtsea, all xhgt, allhgtxhgt, alldhgtsea, alldhgtxhgt,\10391 all etaw, alletau, labs, colors, markers, [locleg, legfontsize], imgtit,\10392 imgkind, close)10552 locleg, legfontsize, legncol = drw.legend_values(legvals,'|') 10553 10554 drw.plot_WRFeta_levels(allhgtsea, allpsea, allxhgt, allhgtxhgt, allpxhgt, \ 10555 alldhgtsea, alldhgtxhgt, alldpsea, alldpxhgt, alletaw, alletau, labs, colors, \ 10556 markers, [locleg, legfontsize, legncol], imgtit, imgkind, close) 10393 10557 10394 10558 return 10395 #foldn='/media/lluis/ExtDiskC_ext3/DATA/estudios/FPS_Alps/additional/IOP/sims/'10396 #fils=foldn + '120lev/simin_vars.nc,' + foldn + '80lev/simin_vars.nc,' + foldn + \10397 # '50lev/simin_vars.nc,' + foldn + '50lev_assigned/simin_vars.nc,' + foldn + \10398 # '38lev/simin_vars.nc'10399 #vals='120lev,80lev,50lev,50leva,38lev:auto:auto:0|8:FPS!Alps!vertical!levels:pdf:true'10559 foldn='/media/lluis/ExtDiskC_ext3/DATA/estudios/FPS_Alps/additional/IOP/sims/wrfinput_select/' 10560 fils=foldn + '120lev_cdxwrf2/simin_vars.nc,' + foldn + '80lev_cdxwrf2/simin_vars.nc,' + foldn + \ 10561 '50lev_cdxwrf2/simin_vars.nc,' + foldn + '50lev_assigned/simin_vars.nc,' + foldn + \ 10562 '38lev_cdxwrf2/simin_vars.nc' 10563 vals='120lev,80lev,50lev,50leva,38lev:auto:auto:0|4|2:FPS!Alps!vertical!levels:pdf:no:true' 10400 10564 #print fils 10401 #draw_WRFeta_levels(fils, vals)10565 draw_WRFeta_levels(fils, vals) 10402 10566 10403 10567 #quit() -
trunk/tools/drawing_tools.py
r2081 r2082 1823 1823 9: 'upper center', 10: 'center' 1824 1824 [fontsize]: font size for the legend ('auto' for 12) 1825 [ncol]: number of columns for the legend ('auto' for 1) 1825 1826 char= separation character 1826 1827 """ … … 1833 1834 else: 1834 1835 fontsize = int(fontsize0) 1835 1836 return locleg, fontsize 1836 if len(legstring.split(char)) == 2: 1837 return locleg, fontsize 1838 else: 1839 ncol = int(legstring.split(char)[2]) 1840 return locleg, fontsize, ncol 1837 1841 1838 1842 ####### ####### ####### ####### ####### ####### ####### ####### ####### ####### … … 12733 12737 plt.plot(stlon, stlat, stmrk, color=stcol, markersize=stsiz) 12734 12738 if stlab != 'None': 12735 plt.annotate(gen.latex_text(stlab), xy=(stlon+ddlon,stlat), \12739 plt.annotate(gen.latex_text(stlab), xy=(stlon+ddlon,stlat), \ 12736 12740 xycoords='data', color=stcol, fontsize=fontsiz) 12737 12741 … … 12743 12747 return 12744 12748 12745 def plot_WRFeta_levels(ahgtsea, a xhgt, ahgtxhgt, adhgtsea, adhgtxhgt, aetaw, aetau,\12746 12749 def plot_WRFeta_levels(ahgtsea, apsea, axhgt, ahgtxhgt, apxhgt, adhgtsea, adhgtxhgt, \ 12750 adpsea, adpxhgt, aetaw, aetau, labels, cols, marks, legvs, figtitle, kfig, close): 12747 12751 """ Function to plot different sets of WRF eta-levels 12748 12752 ahgtsea: all hegights of a point above sea 12753 apsea: all pressures of a point above sea 12749 12754 axhgt: all maximum hegights 12750 12755 ahgtxhgt: all hegights of the point above mximum height 12756 apxhgt: all pressures of the point above mximum height 12751 12757 adhgtsea: all relative heights of a point above sea 12752 12758 adhgtxhgt: all relative heights of the point above maximum topo 12759 adpsea: all relative pressures of a point above sea 12760 adpxhgt: all relative pressures of the point above maximum topo 12753 12761 aetaw: all eta-full values 12754 12762 aetau: all eta-half values … … 12756 12764 cols: colors 12757 12765 marks: markers 12758 legvs: [legloc, legfs ] legend values12766 legvs: [legloc, legfs, legncol] legend values 12759 12767 figtitle: title of figure 12760 12768 kfig: kind of file of graphical output … … 12767 12775 plt.rc('text', usetex=True) 12768 12776 12769 fig, ax = plt.subplots(4)12770 12771 plt.subplot( 2,2,1)12777 fig, axs = plt.subplots(8) 12778 12779 plt.subplot(4,2,1) 12772 12780 # Absolute heights 12773 12781 Nlabs = len(labels) … … 12787 12795 markersize=4, label=None, color=cols[ilab]) 12788 12796 12789 plt.xlabel('$\eta$-level', color='k') 12790 plt.ylabel('absolute height ($m$)', color='black') 12797 plt.xlabel('$\eta$-level', color='k', fontsize=6) 12798 plt.ylabel('absolute height ($m$)', color='black', fontsize=6) 12799 plt.xlim(1.,0.) 12791 12800 plt.yscale('log') 12792 12801 12793 plt.title('Absolute Heights',position=titleloc) 12794 plt.legend(loc=legvs[0], prop={'size':legvs[1]}) 12795 12796 plt.subplot(2,2,2) 12802 plt.title('Heights',position=titleloc, fontsize=8) 12803 plt.legend(loc=legvs[0], prop={'size':legvs[1]}, ncol=legvs[2]) 12804 12805 plt.subplot(4,2,2) 12806 # Absolute pressures 12807 Nlabs = len(labels) 12808 nx = 100000. 12809 xx = -100000. 12810 for ilab in range(Nlabs): 12811 hgtssea = apsea[ilab]/100. 12812 hgtsxhgt = apxhgt[ilab]/100. 12813 znw = aetau[ilab] 12814 12815 nv = np.min(hgtssea) 12816 if nx > nv: nx = nv 12817 nv = np.min(hgtsxhgt) 12818 if nx > nv: nx = nv 12819 xv = np.max(hgtssea) 12820 if xx < nv: xx = xv 12821 xv = np.max(hgtsxhgt) 12822 if xx < nv: xx = xv 12823 12824 plt.plot(znw, hgtssea, '-', marker=marks[ilab], linewidth=1.5, markersize=4, \ 12825 label='$p_{sea}^{'+labels[ilab]+'}$', color=cols[ilab]) 12826 if ilab == 0: 12827 plt.plot(znw, hgtsxhgt, '-.', marker=marks[ilab], linewidth=1.5, \ 12828 markersize=4, label='$p_{hgtmax}^{'+labels[ilab]+'}$', color=cols[ilab]) 12829 else: 12830 plt.plot(znw, hgtsxhgt, '-.', marker=marks[ilab], linewidth=1.5, \ 12831 markersize=4, label=None, color=cols[ilab]) 12832 12833 plt.xlabel('$\eta$-level', color='k', fontsize=6) 12834 plt.ylabel('absolute pressure ($hPa$)', color='black', fontsize=6) 12835 plt.xlim(1.,0.) 12836 plt.ylim(xx,nx) 12837 #plt.yscale('log') 12838 12839 plt.title('pressures',position=titleloc, fontsize=8) 12840 #plt.legend(loc=legvs[0], prop={'size':legvs[1]}) 12841 12842 plt.subplot(4,2,3) 12843 # Relative heights 12844 Nlabs = len(labels) 12845 for ilab in range(Nlabs): 12846 hgtssea = adhgtsea[ilab] 12847 hgtsxhgt = adhgtxhgt[ilab] 12848 znw = aetau[ilab] 12849 12850 plt.plot(znw, hgtssea, '-', marker=marks[ilab], linewidth=1.5, markersize=4, \ 12851 label='$\delta hgt_{sea}^{'+labels[ilab]+'}$', color=cols[ilab]) 12852 if ilab == 0: 12853 plt.plot(znw, hgtsxhgt, '-.', marker=marks[ilab], linewidth=1.5, \ 12854 markersize=4, label='$\delta hgt_{hgtmax}^{'+labels[ilab]+'}$', \ 12855 color=cols[ilab]) 12856 else: 12857 plt.plot(znw, hgtsxhgt, '-.', marker=marks[ilab], linewidth=1.5, \ 12858 markersize=4, label=None, color=cols[ilab]) 12859 plt.xlabel('$\eta$-level', color='k', fontsize=6) 12860 plt.ylabel('$\delta height$ ($m$)', color='black', fontsize=6) 12861 plt.xlim(1.,0.) 12862 plt.yscale('log') 12863 12864 #plt.title('Relative Heights',position=titleloc, fontsize=8) 12865 #plt.legend(loc=0, prop={'size':10}) 12866 12867 plt.subplot(4,2,4) 12868 # Relative heights 12869 Nlabs = len(labels) 12870 for ilab in range(Nlabs): 12871 hgtssea = adpsea[ilab] 12872 hgtsxhgt = adpxhgt[ilab] 12873 dz = len(aetaw[ilab]) 12874 znw = aetaw[ilab][1:dz-1] 12875 12876 plt.plot(znw, hgtssea, '-', marker=marks[ilab], linewidth=1.5, markersize=4, \ 12877 label='$\delta p_{sea}^{'+labels[ilab]+'}$', color=cols[ilab]) 12878 if ilab == 0: 12879 plt.plot(znw, hgtsxhgt, '-.', marker=marks[ilab], linewidth=1.5, \ 12880 markersize=4, label='$\delta p_{hgtmax}^{'+labels[ilab]+'}$', \ 12881 color=cols[ilab]) 12882 else: 12883 plt.plot(znw, hgtsxhgt, '-.', marker=marks[ilab], linewidth=1.5, \ 12884 markersize=4, label=None, color=cols[ilab]) 12885 plt.xlabel('$\eta$-level', color='k', fontsize=6) 12886 plt.ylabel('$\delta pressure$ ($Pa$)', color='black', fontsize=6) 12887 plt.xlim(1.,0.) 12888 plt.yscale('log') 12889 12890 #plt.title('Relative pressures',position=titleloc, fontsize=8) 12891 #plt.legend(loc=0, prop={'size':10}) 12892 12893 plt.subplot(4,2,5) 12797 12894 # Absolute heights & relative 12798 12895 Nlabs = len(labels) 12896 nx = 10000. 12897 xx = -10000. 12799 12898 for ilab in range(Nlabs): 12800 12899 hgtssea = ahgtsea[ilab] … … 12814 12913 # linewidth=1.5, markersize=4, label=None, color=cols[ilab]) 12815 12914 12816 plt.xlabel('ab oslute height ($m$)', color='k')12817 plt.ylabel('$\delta height$ ($m$)', color='black' )12915 plt.xlabel('absolute height ($m$)', color='k', fontsize=6) 12916 plt.ylabel('$\delta height$ ($m$)', color='black', fontsize=6) 12818 12917 plt.xscale('log') 12819 12918 plt.yscale('log') 12820 12919 12821 plt.title('Absolute \& relative heights',position=titleloc)12920 #plt.title('Absolute \& relative heights',position=titleloc, fontsize=8) 12822 12921 #plt.legend(loc=0, prop={'size':10}) 12823 12922 12824 plt.subplot( 2,2,3)12825 # Relative heights12923 plt.subplot(4,2,6) 12924 # Absolute pressures & relative 12826 12925 Nlabs = len(labels) 12926 nx = 100000. 12927 xx = -100000. 12827 12928 for ilab in range(Nlabs): 12828 hgtssea = adhgtsea[ilab] 12829 hgtsxhgt = adhgtxhgt[ilab] 12830 znw = aetau[ilab] 12831 12832 plt.plot(znw, hgtssea, '-', marker=marks[ilab], linewidth=1.5, markersize=4, \ 12833 label='$\delta hgt_{sea}^{'+labels[ilab]+'}$', color=cols[ilab]) 12834 if ilab == 0: 12835 plt.plot(znw, hgtsxhgt, '-.', marker=marks[ilab], linewidth=1.5, \ 12836 markersize=4, label='$\delta hgt_{hgtmax}^{'+labels[ilab]+'}$', \ 12837 color=cols[ilab]) 12838 else: 12839 plt.plot(znw, hgtsxhgt, '-.', marker=marks[ilab], linewidth=1.5, \ 12840 markersize=4, label=None, color=cols[ilab]) 12841 plt.xlabel('$\eta$-level', color='k') 12842 plt.ylabel('$\delta height$ ($m$)', color='black') 12929 hgtssea = apsea[ilab]/100. 12930 hgtsxhgt = apxhgt[ilab]/100. 12931 dhgtssea = adpsea[ilab] 12932 dhgtsxhgt = adpxhgt[ilab] 12933 dz = len(hgtssea) 12934 12935 nv = np.min(hgtssea[1:dz]) 12936 if nx > nv: nx = nv 12937 nv = np.min(hgtsxhgt[1:dz]) 12938 if nx > nv: nx = nv 12939 xv = np.max(hgtssea[1:dz]) 12940 if xx < nv: xx = xv 12941 xv = np.max(hgtsxhgt[1:dz]) 12942 if xx < nv: xx = xv 12943 12944 plt.plot(hgtssea[1:dz], dhgtssea, '-', marker=marks[ilab], linewidth=1.5, \ 12945 markersize=4, label='$p_{sea}^{'+labels[ilab]+'}$', color=cols[ilab]) 12946 # if ilab == 0: 12947 # plt.plot(hgtsxhgt[1:dz], dhgtsxhgt, '-.', marker=marks[ilab], \ 12948 # linewidth=1.5, markersize=4, label='$hgt_{hgtmax}^{'+labels[ilab]+'}$',\ 12949 # color=cols[ilab]) 12950 # else: 12951 # plt.plot(hgtsxhgt[1:dz], dhgtsxhgt, '-.', marker=marks[ilab], \ 12952 # linewidth=1.5, markersize=4, label=None, color=cols[ilab]) 12953 12954 plt.xlabel('absolute pressure ($hPa$)', color='k', fontsize=6) 12955 plt.ylabel('$\delta pressure$ ($Pa$)', color='black', fontsize=6) 12956 plt.xlim(xx,nx) 12957 12958 #plt.xscale('log') 12843 12959 plt.yscale('log') 12844 12960 12845 plt.title('Relative Heights',position=titleloc)12961 #plt.title('Absolute \& relative pressures',position=titleloc, fontsize=8) 12846 12962 #plt.legend(loc=0, prop={'size':10}) 12847 12963 12848 plt.subplot( 2,2,4)12964 plt.subplot(4,2,7) 12849 12965 # Absoulte heights & grid-level 12850 12966 Nlabs = len(labels) … … 12866 12982 markersize=0, label=None, color=cols[ilab]) 12867 12983 plt.grid() 12868 plt.xlabel('\% z-grid point', color='k' )12869 plt.ylabel('height ($m$)', color='black' )12984 plt.xlabel('\% z-grid point', color='k', fontsize=6) 12985 plt.ylabel('height ($m$)', color='black', fontsize=6) 12870 12986 #plt.xscale('log') 12871 12987 plt.yscale('log') 12872 12988 12873 plt.title('grid point',position=titleloc)12989 #plt.title('grid point',position=titleloc, fontsize=8) 12874 12990 #plt.legend(loc=0, prop={'size':10}) 12875 12991 12992 plt.subplot(4,2,8) 12993 # Absoulte pressures & grid-level 12994 Nlabs = len(labels) 12995 nx = 100000. 12996 xx = -100000. 12997 for ilab in range(Nlabs): 12998 hgtssea = apsea[ilab]/100. 12999 hgtsxhgt = apxhgt[ilab]/100. 13000 znw = aetau[ilab] 13001 dz = len(hgtssea) 13002 zi = np.arange(1.,dz+1.)*100./dz 13003 13004 nv = np.min(hgtssea[1:dz]) 13005 if nx > nv: nx = nv 13006 nv = np.min(hgtsxhgt[1:dz]) 13007 if nx > nv: nx = nv 13008 xv = np.max(hgtssea[1:dz]) 13009 if xx < nv: xx = xv 13010 xv = np.max(hgtsxhgt[1:dz]) 13011 if xx < nv: xx = xv 13012 13013 plt.plot(zi, hgtssea, '-', marker=marks[ilab], linewidth=1.5, markersize=0, \ 13014 label='$\delta p_{sea}^{'+labels[ilab]+'}$', color=cols[ilab]) 13015 if ilab == 0: 13016 plt.plot(zi, hgtsxhgt, '-.', marker=marks[ilab], linewidth=1.5, \ 13017 markersize=0, label='$\delta p_{hgtmax}^{' + labels[ilab] + '}$', \ 13018 color=cols[ilab]) 13019 else: 13020 plt.plot(zi, hgtsxhgt, '-.', marker=marks[ilab], linewidth=1.5, \ 13021 markersize=0, label=None, color=cols[ilab]) 13022 plt.grid() 13023 plt.xlabel('\% z-grid point', color='k', fontsize=6) 13024 plt.ylabel('pressure ($hPa$)', color='black', fontsize=6) 13025 13026 plt.ylim(xx,nx) 13027 #plt.xscale('log') 13028 #plt.yscale('log') 13029 13030 #plt.title('grid point',position=titleloc, fontsize=8) 13031 #plt.legend(loc=0, prop={'size':10}) 13032 12876 13033 fig.suptitle(gen.latex_text(figtitle)) 12877 plt.subplots_adjust(wspace=0. 3, hspace=0.4)13034 plt.subplots_adjust(wspace=0.4, hspace=0.6) 12878 13035 12879 13036 figname = 'WRFeta_levels'
Note: See TracChangeset
for help on using the changeset viewer.