<div dir="ltr"><div><div><div><div><div><div>While not WRF, the last example at: <a href="http://www.ncl.ucar.edu/Applications/iso.shtml">http://www.ncl.ucar.edu/Applications/iso.shtml</a><br><br></div>may give you an idea of how to approach the issue.<br>
<br>===<br></div>Also, please send *all* WRF questions to <a href="mailto:wrfhelp@ucar.edu">wrfhelp@ucar.edu</a><br></div>The know the WRF model best.<br></div>You can cc ncl-talk@ucar but, really, wrfhelp should be your primary <br>
</div>contact for assorted WRF related issues.<br><br></div>Good luck<br><div><div><div><br></div></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Aug 2, 2014 at 12:06 PM, Modise Wiston <span dir="ltr"><<a href="mailto:modise.wiston@postgrad.manchester.ac.uk" target="_blank">modise.wiston@postgrad.manchester.ac.uk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
<div style="direction:ltr;font-family:Tahoma;color:#000000;font-size:10pt"><font face="Times New Roman" size="3"><i>To whom it may concern</i></font>
<div><font face="Times New Roman" size="3"><i><br>
</i></font></div>
<div><font face="Times New Roman" size="3"><i>Hi all,</i></font></div>
<div><font face="Times New Roman" size="3"><i><br>
</i></font></div>
<div><font face="Times New Roman" size="3"><i>I am trying to determine the cloud droplet number concentration (QNDROP) from my [WRF-Chem] model simulation. The script [see the code below] is such that the code loops through the x-y-z (i-j-k) planes and finds
the max (& min) QNDROP along the vertical (model levels). The code is such that it exits/stops just after the first cloud band only -without continuing through all the layers above the first cloud band. This also calculates CCN number concentrations below
the cloud base.</i></font></div>
<div><font face="Times New Roman" size="3"><i><br>
</i></font></div>
<div><font face="Times New Roman" size="3"><i><b>How can I make it (or write a function/code) to calculate the height at which the max QNDROP occurs..?</b> I have been trying to go through several NCL examples (functions) but couldn't figure out out how to
do this.. (I would like to plot 'height vs max QNDROP' on the horizontal lat-lon domain) </i></font></div>
<div><font face="Times New Roman" size="3"><i><br>
</i></font></div>
<div><font face="Times New Roman" size="3"><i>Any help is appreciated please..</i></font></div>
<div><font face="Times New Roman" size="3"><i>Thank you,</i></font></div>
<div><font face="Times New Roman" size="3"><i>M. Wiston</i></font></div>
<div><font face="Times New Roman" size="3"><i>The University of Manchester </i></font></div>
<div>-----------------------------------------------------------------------------------------------------------</div>
<div>
<div> dt = 6 <span style="white-space:pre-wrap"></span> </div>
<div> do ifil = 0, 0; numFILES-48, dt<span style="white-space:pre-wrap">
</span> </div>
<div> a = addfile(FILES(ifil)+".nc","r") </div>
<div><span style="white-space:pre-wrap"></span></div>
<div> ;list time step to output data</div>
<div> times = wrf_user_list_times(a) </div>
<div> ntimes = dimsizes(times) </div>
<div> <span style="white-space:pre-wrap"> </span></div>
<div> do it = 0,ntimes-1,2 <span style="font-size:10pt;white-space:pre-wrap">
</span></div>
<div><span style="white-space:pre-wrap"></span> do ispec = 0, nspec-1 </div>
<div> species = speclist(ispec)</div>
<div><span style="white-space:pre-wrap"></span> </div>
<div><span style="white-space:pre-wrap"></span> ;Obtain the variables from the file </div>
<div><span style="white-space:pre-wrap"></span> if(isfilevar(a,"QNDROP")) </div>
<div><span style="white-space:pre-wrap"></span>N = wrf_user_getvar(a,"QNDROP",it) </div>
<div><span style="white-space:pre-wrap"></span>Nd = (N*1.2923)/1e6 ; convert from /kg to /sm^3 then to /scm^3</div>
<div><span style="white-space:pre-wrap"></span>Nd@units = "/cm^3" ; converted units</div>
<div><span style="white-space:pre-wrap"></span> end if<span style="font-size:10pt"> </span></div>
<div><span style="white-space:pre-wrap"></span> </div>
<div> ;define an array to hold data </div>
<div><span style="white-space:pre-wrap"></span> dimsNd = dimsizes(Nd) </div>
<div><span style="white-space:pre-wrap"></span> print(dimsNd)</div>
<div><span style="white-space:pre-wrap"></span> </div>
<div> ;----------------Determine the domain size (grid points and vert. levels)----------------;</div>
<div><span style="white-space:pre-wrap"></span> ; (321 x 251) ; grid points along "i" (hor) by "j" (vert) direction ;</div>
<div><span style="white-space:pre-wrap"></span> ; (e_we:lat, e_sn:lon) ;</div>
<div><span style="white-space:pre-wrap"></span> ; 40 vert levels:(k) ; model levels ;</div>
<div><span style="white-space:pre-wrap"></span> ; Print output gives: k = 40 ;NB: this is read starting from zero (i.e. 0-39) ;</div>
<div><span style="white-space:pre-wrap"></span> ; j = 250 ; </div>
<div><span style="white-space:pre-wrap"></span> ; i = 320 ;</div>
<div><span style="white-space:pre-wrap"></span> ;------------------------------------------------------------------------------------------------;</div>
<div><span style="white-space:pre-wrap"></span> min_Nd = new( (/dimsNd(1),dimsNd(2)/),float ) </div>
<div><span style="white-space:pre-wrap"></span> max_Nd = new( (/dimsNd(1),dimsNd(2)/),float )</div>
<div><span style="white-space:pre-wrap"></span> c_btm = new( (/dimsNd(1),dimsNd(2)/),integer )</div>
<div><span style="white-space:pre-wrap"></span> c_top = new( (/dimsNd(1),dimsNd(2)/),integer )</div>
<div><span style="white-space:pre-wrap"></span> </div>
<div><span style="white-space:pre-wrap"></span> do j = 0, dimsNd(1)-1 ; loop along j </div>
<div><span style="white-space:pre-wrap"></span>do i = 0, dimsNd(2)-1 ; loop along i</div>
<div><span style="white-space:pre-wrap"></span> ; cldfrc = (i*j)</div>
<div><span style="white-space:pre-wrap"></span> c_btm(j,i) = -1 ;define cloud base and cloud top limits to confine the execution</div>
<div><span style="white-space:pre-wrap"></span> c_top(j,i) = -1<span style="font-size:10pt"> </span></div>
<div><span style="white-space:pre-wrap"></span> do k = 0, dimsNd(0)-2 ; loop [vertically] through levels</div>
<div><span style="white-space:pre-wrap"></span> ; print("k= "+k) <span style="font-size:10pt;white-space:pre-wrap">
</span></div>
<div><span style="white-space:pre-wrap"></span> if(Nd(k,j,i) .le. cut_pnt .and. Nd((k+1),j,i) .gt. cut_pnt) </div>
<div><span style="white-space:pre-wrap"></span> c_btm(j,i) = (k+1) ;[cloud base] </div>
<div><span style="white-space:pre-wrap"></span> ; print("c_btm = "+c_btm(j,i)) </div>
<div><span style="white-space:pre-wrap"></span> </div>
<div><span style="white-space:pre-wrap"></span> else if (Nd(k,j,i) .gt. cut_pnt .and. Nd((k+1),j,i) .le. cut_pnt) then</div>
<div><span style="white-space:pre-wrap"></span> c_top(j,i) = k ;[cloud top]</div>
<div><span style="white-space:pre-wrap"></span>break ; exit the the process after the first cloud band</div>
<div><span style="white-space:pre-wrap"></span> end if</div>
<div><span style="white-space:pre-wrap"></span> end if<span style="font-size:10pt"> </span></div>
<div><span style="white-space:pre-wrap"></span> end do <span style="font-size:10pt;white-space:pre-wrap">
</span><span style="font-size:10pt"> </span></div>
<div> ; min_Nd(i) = min(Nd(:,i)) </div>
<div><span style="white-space:pre-wrap"></span> ; max_Nd(i) = max(Nd(:,i)) <span style="font-size:10pt"> </span></div>
<div><span style="white-space:pre-wrap"></span> ; min_Nd(j) = min(Nd(:,j)) </div>
<div><span style="white-space:pre-wrap"></span> ; max_Nd(j) = max(Nd(:,j)) <span style="font-size:10pt"> </span></div>
<div><span style="white-space:pre-wrap"></span> ; min_Nd(j,i) = min(Nd(:,j,i)) </div>
<div><span style="white-space:pre-wrap"></span> ; max_Nd(j,i) = max(Nd(0:3,j,i)) </div>
<div><span style="white-space:pre-wrap"></span> </div>
<div><span style="white-space:pre-wrap"></span> if(c_btm(j,i) .eq. -1 .and. c_top(j,i) .eq. -1) </div>
<div><span style="white-space:pre-wrap"></span> max_Nd(j,i) = 0.0 </div>
<div><span style="white-space:pre-wrap"></span> </div>
<div><span style="white-space:pre-wrap"></span> else if (c_btm(j,i) .gt. -1 .and. c_top(j,i) .gt. -1) then </div>
<div><span style="white-space:pre-wrap"></span> max_Nd(j,i) = max( Nd(c_btm(j,i):c_top(j,i),j,i) ) </div>
<div><span style="white-space:pre-wrap"></span> ;print(min_Nd(j,i)) </div>
<div><span style="white-space:pre-wrap"></span> ;print("max_Nd = " +max_Nd(j,i))</div>
<div> print("| "+sprintf("%5.3f",max_Nd(j,i))+ " | "+sprintf("%2.1f", c_btm(j,i))+" | "+sprintf("%2.1f", c_btm(j,i))+" |" )</div>
<div><span style="white-space:pre-wrap"></span> end if</div>
<div><span style="white-space:pre-wrap"></span> end if </div>
<div><span style="white-space:pre-wrap"></span> end do </div>
<div><span style="white-space:pre-wrap"></span> end do </div>
<div> ;------------------------------------------------------------------------------------------<span style="font-size:10pt"> </span></div>
<div><span style="white-space:pre-wrap"></span> ;;get the CCN number concentration from the file </div>
<div><span style="white-space:pre-wrap"></span>Cn1 = wrf_user_getvar(a,"CCN1",it)</div>
<div><span style="white-space:pre-wrap"></span>Cn2 = wrf_user_getvar(a,"CCN2",it)</div>
<div><span style="white-space:pre-wrap"></span>Cn3 = wrf_user_getvar(a,"CCN3",it)</div>
<div><span style="white-space:pre-wrap"></span>Cn4 = wrf_user_getvar(a,"CCN4",it)</div>
<div><span style="white-space:pre-wrap"></span>Cn5 = wrf_user_getvar(a,"CCN5",it)</div>
<div><span style="white-space:pre-wrap"></span> Cn6 = wrf_user_getvar(a,"CCN6",it)</div>
<div><span style="white-space:pre-wrap"></span> z = wrf_user_getvar(a,"z",it)</div>
<div><span style="white-space:pre-wrap"></span> w = wrf_user_getvar(a,"wa",it) ; vertical [updraft..??] velocity</div>
<div><span style="white-space:pre-wrap"></span> w@units = "m/s"</div>
<div><span style="white-space:pre-wrap"></span> </div>
<div><span style="white-space:pre-wrap"></span> p = wrf_user_getvar(a, "p",it) ;extract p and tk to convert to STP</div>
<div> tk = wrf_user_getvar(a,"tk",it)</div>
<div><span style="white-space:pre-wrap"></span>C1 = Cn1*((tk/p)*(P_std/T_std)) </div>
<div><span style="white-space:pre-wrap"></span>C2 = Cn2*((tk/p)*(P_std/T_std))</div>
<div><span style="white-space:pre-wrap"></span>C3 = Cn3*((tk/p)*(P_std/T_std))</div>
<div><span style="white-space:pre-wrap"></span>C4 = Cn4*((tk/p)*(P_std/T_std))</div>
<div><span style="white-space:pre-wrap"></span>C5 = Cn5*((tk/p)*(P_std/T_std))</div>
<div><span style="white-space:pre-wrap"></span>C6 = Cn6*((tk/p)*(P_std/T_std))</div>
<div><span style="white-space:pre-wrap"></span>C1@units = "/cm^3" </div>
<div><span style="white-space:pre-wrap"></span> </div>
<div><span style="white-space:pre-wrap"></span>C1_btm = new( (/dimsNd(1),dimsNd(2)/),float )</div>
<div><span style="white-space:pre-wrap"></span>C2_btm = new( (/dimsNd(1),dimsNd(2)/),float )</div>
<div><span style="white-space:pre-wrap"></span>C3_btm = new( (/dimsNd(1),dimsNd(2)/),float )</div>
<div><span style="white-space:pre-wrap"></span>C4_btm = new( (/dimsNd(1),dimsNd(2)/),float )</div>
<div><span style="white-space:pre-wrap"></span>C5_btm = new( (/dimsNd(1),dimsNd(2)/),float )</div>
<div><span style="white-space:pre-wrap"></span>C6_btm = new( (/dimsNd(1),dimsNd(2)/),float )</div>
<div><span style="white-space:pre-wrap"></span>SS = new( (/dimsNd(1),dimsNd(2)/),float )</div>
<div><span style="white-space:pre-wrap"></span> </div>
<div><span style="white-space:pre-wrap"></span>do j = 0, dimsNd(1)-1 </div>
<div><span style="white-space:pre-wrap"></span> do i = 0, dimsNd(2)-1 </div>
<div><span style="white-space:pre-wrap"></span> if(c_btm(j,i) .eq. -1)</div>
<div><span style="white-space:pre-wrap"></span> C1_btm(j,i) = 0.0</div>
<div><span style="white-space:pre-wrap"></span> C2_btm(j,i) = 0.0</div>
<div><span style="white-space:pre-wrap"></span> C3_btm(j,i) = 0.0</div>
<div><span style="white-space:pre-wrap"></span> C4_btm(j,i) = 0.0</div>
<div><span style="white-space:pre-wrap"></span> C5_btm(j,i) = 0.0</div>
<div><span style="white-space:pre-wrap"></span> C6_btm(j,i) = 0.0</div>
<div><span style="white-space:pre-wrap"></span> </div>
<div><span style="white-space:pre-wrap"></span> else if(c_btm(j,i) .ne. -1) then</div>
<div><span style="white-space:pre-wrap"></span> C1_btm(j,i) = ( C1(c_btm(j,i),j,i) )</div>
<div><span style="white-space:pre-wrap"></span> C2_btm(j,i) = ( C2(c_btm(j,i),j,i) )</div>
<div><span style="white-space:pre-wrap"></span> C3_btm(j,i) = ( C3(c_btm(j,i),j,i) )</div>
<div><span style="white-space:pre-wrap"></span> C4_btm(j,i) = ( C4(c_btm(j,i),j,i) )</div>
<div><span style="white-space:pre-wrap"></span> C5_btm(j,i) = ( C5(c_btm(j,i),j,i) )</div>
<div><span style="white-space:pre-wrap"></span> C6_btm(j,i) = ( C6(c_btm(j,i),j,i) )</div>
<div><span style="white-space:pre-wrap"></span> </div>
<div><span style="white-space:pre-wrap"></span> ; print("Cn1 = " +C1_btm(j,i)) </div>
<div><span style="white-space:pre-wrap"></span> ; print("Cn2 = " +C2_btm(j,i)) </div>
<div><span style="white-space:pre-wrap"></span> ; print("Cn3 = " +C3_btm(j,i))</div>
<div><span style="white-space:pre-wrap"></span> ; print("Cn4 = " +C4_btm(j,i))</div>
<div><span style="white-space:pre-wrap"></span> ; print("Cn5 = " +C5_btm(j,i))</div>
<div><span style="white-space:pre-wrap"></span> ; print("Cn6 = " +C6_btm(j,i))</div>
<div> print("| "+sprintf("%4.3f", C1_btm(j,i))+" | "+sprintf("%4.3f", C2_btm(j,i))+" | "+sprintf("%4.3f", C3_btm(j,i))+" | "+\</div>
<div><span style="white-space:pre-wrap"></span>sprintf("%4.3f", C4_btm(j,i))+" | "+sprintf("%4.3f", C5_btm(j,i))+" | "+sprintf("%4.3f", C6_btm(j,i))+" |" )</div>
<div><span style="white-space:pre-wrap"></span> end if</div>
<div><span style="white-space:pre-wrap"></span> end if</div>
<div><span style="white-space:pre-wrap"></span> end do<span style="white-space:pre-wrap">
</span> </div>
<div><span style="white-space:pre-wrap"></span> end do<span style="white-space:pre-wrap">
</span> </div>
<div> ;````````````````````````````````````````````````````````````````````````````````` <span style="font-size:10pt"> </span></div>
<div> ; if(max_Nd(j,i) .le. C1_btm(j,i))</div>
<div> ; SS(j,i) = 0.01</div>
<div> </div>
<div> ; else if(max_Nd(j,i) .gt. C1_btm(j,i) .and. max_Nd(j,i) .le. C2_btm(j,i))</div>
<div> ; SS(j,i) = "0.02%"</div>
<div> </div>
<div> ; else if(max_Nd(j,i) .gt. C2_btm(j,i) .and. max_Nd(j,i) .le. C3_btm(j,i))</div>
<div> ; SS(j,i) = "0.1%"</div>
<div> </div>
<div> ; else if (max_Nd(j,i) .gt. C3_btm(j,i) .and. max_Nd(j,i) .le. C4_btm(j,i))</div>
<div> ; SS(j,i) = "0.2%"</div>
<div> </div>
<div> ; else if (max_Nd(j,i) .gt. C4_btm(j,i) .and. max_Nd(j,i) .le. C5_btm(j,i))</div>
<div> ; SS(j,i) = "0.5%"</div>
<div> </div>
<div> ; else if (max_Nd(j,i) .gt. C5_btm(j,i) .and. max_Nd(j,i) .le. C6_btm(j,i))</div>
<div> ; SS(j,i) = "1.0%"</div>
<div> ; end if</div>
<div> ; end if</div>
<div> ; end if</div>
<div> ; end if</div>
<div> ; end if</div>
<div> ; end if</div>
<div> ;-------------------------------------------------------------------------------------------</div>
<div><span style="white-space:pre-wrap"></span> ;Set some Basic Plot options</div>
<div><span style="white-space:pre-wrap"></span> res = True</div>
<div><span style="white-space:pre-wrap"></span> res@tiMainString = "CCN nmbr @: " +times(it) ; main field title</div>
<div><span style="white-space:pre-wrap"></span> mpres = True</div>
<div><span style="white-space:pre-wrap"></span> pltres = True</div>
<div><span style="white-space:pre-wrap"></span> </div>
<div><span style="white-space:pre-wrap"></span> res@gsnMaximize = False</div>
<div><span style="white-space:pre-wrap"></span> res@gsnFrame = False</div>
<div><span style="white-space:pre-wrap"></span> res@gsnDraw = False</div>
<div><span style="white-space:pre-wrap"></span> res@cnFillOn = True</div>
<div><span style="white-space:pre-wrap"></span> res@cnLinesOn = False ; turn off contour lines</div>
<div><span style="white-space:pre-wrap"></span> res@cnLineLabelsOn = False ; lables the data on contours/map grids</div>
<div><span style="white-space:pre-wrap"></span> res@gsnSpreadColors = True</div>
<div><span style="white-space:pre-wrap"></span> res@lbOrientation = "Horizontal" ; orientates the linear scale </div>
<div> res@cnLevelSelectionMode = "ExplicitLevels"</div>
<div> ;-------------------------------------------------------------------------------------------</div>
<div><span style="white-space:pre-wrap"></span> res@tiYAxisString = "" </div>
<div><span style="white-space:pre-wrap"></span> res@tiXAxisString = "Nmbr cont'n (/cm^3)" </div>
<div><span style="white-space:pre-wrap"></span> res@tiXAxisSide = "Bottom"<span style="font-size:10pt"> </span></div>
<div> </div>
<div><span style="white-space:pre-wrap"></span> ;res@tiMainString = "Droplet nmbr at: " +times(it)</div>
<div><span style="white-space:pre-wrap"></span> contour_Nd = wrf_contour(a,wks,max_Nd,res)</div>
<div><span style="white-space:pre-wrap"></span> </div>
<div> plot_Nd = wrf_map_overlays(a,wks,(/contour_Nd/),pltres,res) ; plots data on a map backgrnd</div>
<div><span style="white-space:pre-wrap"></span> ; contour_Cn1 = wrf_contour(a,wks,C1_btm,res)</div>
<div><span style="white-space:pre-wrap"></span> ; plot_Cn1 = wrf_map_overlays(a,wks,(/contour_Cn1/),pltres,res)</div>
<div><span style="white-space:pre-wrap"></span></div>
<div><span style="white-space:pre-wrap"></span> ; contour_Cn2 = wrf_contour(a,wks,C2_btm,res)</div>
<div><span style="white-space:pre-wrap"></span> ; plot_Cn2 = wrf_map_overlays(a,wks,(/contour_Cn2/),pltres,res)</div>
<div><span style="white-space:pre-wrap"></span> ; contour_Cn3 = wrf_contour(a,wks,C3_btm,res)</div>
<div><span style="white-space:pre-wrap"></span> ; plot_Cn3 = wrf_map_overlays(a,wks,(/contour_Cn3/),pltres,res)</div>
<div><span style="white-space:pre-wrap"></span> ; contour_Cn4 = wrf_contour(a,wks,C4_btm,res)</div>
<div><span style="white-space:pre-wrap"></span> ; plot_Cn4 = wrf_map_overlays(a,wks,(/contour_Cn4/),pltres,res)</div>
<div><span style="white-space:pre-wrap"></span> ; contour_Cn5 = wrf_contour(a,wks,C5_btm,res)</div>
<div><span style="white-space:pre-wrap"></span> ; plot_Cn5 = wrf_map_overlays(a,wks,(/contour_Cn5/),pltres,res)</div>
<div> <span style="white-space:pre-wrap"> </span> ; contour_Cn6 = wrf_contour(a,wks,C6_btm,res)</div>
<div><span style="white-space:pre-wrap"></span> ; plot_Cn6 = wrf_map_overlays(a,wks,(/contour_Cn6/),pltres,res)</div>
<div><span style="white-space:pre-wrap"></span> </div>
<div> ; delete(contour_Nd)</div>
<div><span style="white-space:pre-wrap"></span> ; delete(contour_Cn1)</div>
<div><span style="white-space:pre-wrap"></span> </div>
<div><span style="white-space:pre-wrap"></span> ; map = wrf_map(wks,a,res)</div>
<div><span style="white-space:pre-wrap"></span> ; overlay(map,contour_Nd)</div>
<div><span style="white-space:pre-wrap"></span> ; overlay(map,contour_Cn1)</div>
<div><span style="white-space:pre-wrap"></span> ; overlay(plot0,plot3)</div>
<div><span style="white-space:pre-wrap"></span> ; gsn_panel(wks,plots,(/3,2/),True)</div>
<div><span style="white-space:pre-wrap"></span></div>
<div><span style="white-space:pre-wrap"></span> ; draw(plot) </div>
<div><span style="white-space:pre-wrap"></span> ; frame(wks) </div>
<div> end do </div>
<div> end do </div>
<div><br>
</div>
<div>end </div>
</div>
<div>---------------------------------------------------------------------------------------------------------------</div>
</div>
</div>
<br>_______________________________________________<br>
ncl-talk mailing list<br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>