<div dir="ltr"><p class="MsoNormal" style="margin:0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">Firstly, my sincere apologies for this very long mail.</p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">Coming from a weather forecasting
background, it is preferable to have the title on the graphic as, e.g.</p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">WRF Surface Pressure, Winds and
Temperatures</p>
<p class="MsoNormal" style="margin:0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">Valid at 06Z on 2022-04-07, From 00Z on 2022-04-07"</p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">This quickly tells the forecaster
1) what he/she is looking at, 2) the validity time and date, and 3) the model initiation
time and date.</p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">The current titling and subtitling
in wrf-ncl scripts is not convenient for a forecasting setup.</p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">In the script below I have stripped
off the ncl hard-coded titles, mainly with ”opts@FieldTitle = " " and
opts@PlotLevelID = " ", and then setting all units to “”</p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">Not knowing how to extract part of
a file name in ncl, I have used perl to extract yyyy-mm-dd and hh from
wrfout_d01_yyy-mm-dd_hh:mm:ss. These are written to files and are like below</p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">Variable: data1</p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">Type: string</p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">Total Size: 104 bytes</p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif"> 13 values</p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">Number of Dimensions: 1</p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">Dimensions and sizes: [13]</p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">Coordinates: </p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">Number Of Attributes: 1</p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">
_FillValue : missing</p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">(0) 2022-03-28</p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">(1) 2022-03-28</p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">(2) 2022-03-28</p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">(3) 2022-03-28</p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">(4) 2022-03-28</p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">(5) 2022-03-28</p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">(6) 2022-03-28</p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">(7) 2022-03-28</p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">(8) 2022-03-28</p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">(9) 2022-03-28</p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif"> </p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">Variable: data2</p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">Type: string</p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">Total Size: 104 bytes</p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif"> 13 values</p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">Number of Dimensions: 1</p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">Dimensions and sizes: [13]</p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">Coordinates: </p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">Number Of Attributes: 1</p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">
_FillValue : missing</p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">(0) 00</p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">(1) 01</p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">(2) 02</p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">(3) 03</p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">(4) 04</p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">(5) 05</p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">(6) 06</p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">(7) 07</p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">(8) 08</p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">(9) 09</p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">(10) 10</p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">(11) 11</p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">(12) 12</p>
<p class="MsoNormal" style="margin:6pt 0cm 0cm;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">If anyone can assist</p>
<p class="gmail-MsoListParagraphCxSpFirst" style="margin:6pt 0cm 0.0001pt 21.3pt;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif"><span style="background-color:rgb(0,0,255)"><font color="#f3f3f3">1.<span style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:7pt;line-height:normal;font-family:"Times New Roman""> </span>how
to read data1 and data2 into 1d subscripted arrays</font></span></p>
<p class="gmail-MsoListParagraphCxSpMiddle" style="margin:6pt 0cm 0.0001pt 21.3pt;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif"><span style="background-color:rgb(0,0,255)"><font color="#f3f3f3">2.<span style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:7pt;line-height:normal;font-family:"Times New Roman""> </span>how
to correctly position the main title, if possible</font></span></p>
<p class="gmail-MsoListParagraphCxSpMiddle" style="margin:6pt 0cm 0.0001pt 21.3pt;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif"> </p>
<p class="gmail-MsoListParagraphCxSpLast" style="margin:6pt 0cm 0.0001pt;line-height:15pt;font-size:12pt;font-family:Arial,sans-serif">I
know ncl scripts are being migrated to python, so this may not be interesting.</p><div><br></div><div><br>; Example script to produce plots for a WRF real-data run,<br>; with the ARW coordinate dynamics option.<br>; Interpolating to specified pressure levels<br><br>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"<br>load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"<br><br>begin<br>;<br>; The WRF ARW input file. <br> DATADir = "/home/zmumba/DA/OUTPUT/2022022800/noda/"<br> FILES = systemfunc (" ls -1 " + DATADir + "wrfout_d01* ")<br> numFILES = dimsizes(FILES)<br><br> files_all = addfiles(FILES+".nc","r")<br><br><br>; Perl script takes the files and extracts yyyy-mm-dd and hh<br>;-----------------------------------------------------------<br> system("perl /home/zmumba/DA/SCRIPTS/03_Ncl_Scripts/<a href="http://sort_files.pl">sort_files.pl</a>")<br><br> data1 = asciiread("/home/zmumba/DA/SCRIPTS/03_Ncl_Scripts/datesfile.txt",-1,"string")<br> data2 = asciiread("/home/zmumba/DA/SCRIPTS/03_Ncl_Scripts/timesfile.txt",-1,"string")<br><br><br>; Need to read files above into a 1d array to be used in title<br>;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,<br><br><br>;Code below does not work<br>;-------------------------<br> ; Init_date = date1(0)<br> ; Init_time = date2(0)<br>;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,<br> ;do i = 0, numFILES-1<br> ; valid_date(i) = data1(i)<br> ; valid_time(i) = data2(i)<br> ; print(valid_time(i))<br> ;end do<br>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br><br>; We generate plots, but what kind do we prefer?<br>; type = "x11"<br>; type = "pdf"<br>; type = "ps"<br>; type = "ncgm"<br> type = "png"<br>; wks = gsn_open_wks(type,"plt_PressureLevel1")<br><br>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br><br>; What times and how many time steps are in the data set?<br>; get time information and strip out the day and hour<br> times_in_file = files_all[:]->Times<br><br> dims = dimsizes (times_in_file)<br> ntimes = dims(0)<br><br> times_to_use = new(dims(0),string) ;create empty array<br><br> do i=0,dims(0)-1<br> times_to_use(i) = chartostring(times_in_file(i,8:12))<br> print(times_to_use(i))<br> end do<br>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br><br>; Set some Basic Plot options<br> res = True<br> ;res@NoHeaderFooter = True<br><br> res@MainTitle = "WRF Surface Pressure, Winds and Temperatures ~C~ Valid at Valid_time(i)Z on Valid_date(i) From Init_time Z on Init_date"<br> res@tiMainOffsetXF = 6.0<br> res@InitTime = False<br> res@Footer = False<br><br> pltres = True<br> mpres = True<br> mpres@mpFillOn = False ; turn off gray fill<br> mpres@mpOutlineBoundarySets = "National" ; turn on country boundaries<br> mpres@mpGeophysicalLineColor = "Navy" ; color of cont. outlines<br> mpres@mpGeophysicalLineThicknessF = 1.5 ; thickness of outlines<br> mpres@mpNationalLineColor = "Black"<br> mpres@mpNationalLineThicknessF = 2.5 ; turn on country boundaries<br><br> mpres@mpDataBaseVersion = "MediumRes" ; choose higher resolution<br> mpres@mpDataSetName = "Earth..4" ; choose most recent boundaries<br><br> mpres@mpMaxLatF = -4 ; choose subregion<br> mpres@mpMinLatF = -21<br> mpres@mpMaxLonF = 37<br> mpres@mpMinLonF = 21<br><br>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br><br>; The specific pressure levels that we want the data interpolated to.<br> pressure_levels = (/ 850., 700., 500., 300./) ; pressure levels to plot<br> nlevels = dimsizes(pressure_levels) ; number of pressure levels<br><br>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br><br>; VTlab = (/ "T+00", T+00", "T+06", "T+12", "T+18", "T+24", "T+30", "T+36", "T+42", "T+48"/) ; Validity for file name <br><br> do it = 0,ntimes(0)-1,2 ; TIME LOOP<br><br> print("Working on time: " + times_to_use(it) )<br> ;res@TimeLabel = times_to_use(it) ; Set Valid time to use on plots<br><br>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br>; First get the variables we will need <br><br> tc = wrf_user_getvar(files_all,"tc",it) ; T in C<br> u = wrf_user_getvar(files_all,"ua",it) ; u averaged to mass points<br> v = wrf_user_getvar(files_all,"va",it) ; v averaged to mass points<br> p = wrf_user_getvar(files_all, "pressure",it) ; pressure is our vertical coordinate<br> z = wrf_user_getvar(files_all, "z",it) ; grid point height<br> rh = wrf_user_getvar(files_all,"rh",it) ; relative humidity<br><br> tc@units = ""<br> u@units = ""<br> v@units = ""<br> p@units = ""<br> z@units = ""<br> rh@units = ""<br>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br><br> do level = 0,nlevels-1 ; LOOP OVER LEVELS<br><br> pressure = pressure_levels(level)<br><br> tc_plane = wrf_user_intrp3d(tc,p,"h",pressure,0.,False)<br> z_plane = wrf_user_intrp3d( z,p,"h",pressure,0.,False)<br> rh_plane = wrf_user_intrp3d(rh,p,"h",pressure,0.,False)<br> u_plane = wrf_user_intrp3d( u,p,"h",pressure,0.,False)<br> v_plane = wrf_user_intrp3d( v,p,"h",pressure,0.,False)<br><br> spd = (u_plane*u_plane + v_plane*v_plane)^(0.5) ; m/sec<br> spd@description = "Wind Speed"<br> ;spd@units = "m/s"<br> spd@units = ""<br> u_plane = u_plane*1.94386 ; kts<br> v_plane = v_plane*1.94386 ; kts<br> ;u_plane@units = "kts"<br> ;v_plane@units = "kts"<br> u_plane@units = ""<br> v_plane@units = ""<br><br> wks = gsn_open_wks(type,"Plots00-" + "P" + pressure_levels(level) + "_" + times_to_use(it) + "Z") <br> <br> ; Plotting options for T <br> opts = res<br><br> opts@cnLineColor = "Red"<br> opts@ContourParameters = (/ 5.0 /)<br> opts@cnInfoLabelOrthogonalPosF = 0.07 ; offset second label information<br> opts@gsnContourLineThicknessesScale = 2.0<br> opts@FieldTitle = "" ; overwrite Field Title<br> opts@PlotLevelID = ""<br> opts@cnInfoLabelString = ""<br> contour_tc = wrf_contour(files_all[it],wks,tc_plane,opts)<br> delete(opts)<br><br> ; Plotting options for RH <br> opts = res <br> opts@cnFillOn = True <br> opts@pmLabelBarOrthogonalPosF = -0.1<br> opts@ContourParameters = (/ 10., 90., 10./)<br> opts@FieldTitle = "" ; overwrite Field Title<br> opts@PlotLevelID = ""<br> opts@cnInfoLabelString = ""<br> opts@cnFillColors = (/"White","White","White", \<br> "White","Chartreuse","Green",\<br> "Green3","Green4", \<br> "ForestGreen","PaleGreen4"/)<br> contour_rh = wrf_contour(files_all[it],wks,rh_plane,opts)<br> delete(opts)<br><br> ; Plotting options for Wind Speed <br> opts = res <br> opts@cnLineColor = "MediumSeaGreen"<br> opts@ContourParameters = (/ 10. /)<br> opts@cnInfoLabelOrthogonalPosF = 0.07 ; offset second label information<br> opts@FieldTitle = "" ; overwrite Field Title<br> opts@PlotLevelID = ""<br> opts@cnInfoLabelString = ""<br> opts@gsnContourLineThicknessesScale = 3.0<br> contour_spd = wrf_contour(files_all[it],wks,spd,opts)<br> delete(opts)<br><br> ; Plotting options for Wind Vectors <br> opts = res <br> ;opts@FieldTitle = "Wind" ; overwrite Field Title<br> opts@FieldTitle = "" ; overwrite Field Title<br> opts@PlotLevelID = ""<br> ;opts@cnInfoLabelString = ""<br> opts@NumVectors = 47 ; wind barb density<br> vector = wrf_vector(files_all[it],wks,u_plane,v_plane,opts)<br> delete(opts)<br><br><br> ; Plotting options for Geopotential Heigh<br> opts_z = res <br> opts_z@cnLineColor = "Blue"<br> opts_z@FieldTitle = "" ; overwrite Field Title<br> opts_z@PlotLevelID = ""<br> ;opts@cnInfoLabelString = ""<br> opts_z@gsnContourLineThicknessesScale = 3.0<br><br><br> ; MAKE PLOTS <br> <br>; wks = gsn_open_wks(type,"plt_PressureLevel1"+level+it)<br><br> if ( pressure .eq. 850 ) then ; plot temp, rh, height, wind barbs<br> opts_z@ContourParameters = (/ 20.0 /)<br> contour_height = wrf_contour(files_all[it],wks,z_plane,opts_z)<br> plot = wrf_map_overlays(files_all[it],wks,(/contour_rh,contour_tc,contour_height, \<br> vector/),pltres,mpres)<br> end if<br><br> if ( pressure .eq. 700 ) then ; plot temp, height, wind barbs<br> opts_z@ContourParameters = (/ 30.0 /)<br> contour_height = wrf_contour(files_all[it],wks, z_plane,opts_z)<br> plot = wrf_map_overlays(files_all[it],wks,(/contour_tc,contour_height, \<br> vector/),pltres,mpres)<br> end if<br><br> if ( pressure .eq. 500 ) then ; plot temp, height, wind barbs<br> opts_z@ContourParameters = (/ 60.0 /)<br> contour_height = wrf_contour(files_all[it],wks, z_plane,opts_z)<br> plot = wrf_map_overlays(files_all[it],wks,(/contour_tc,contour_height, \<br> vector/),pltres,mpres)<br> end if<br><br> if ( pressure .eq. 300 ) then ; plot windspeed, height, wind barbs<br> opts_z@ContourParameters = (/ 60.0 /)<br> contour_height = wrf_contour(files_all[it],wks, z_plane,opts_z)<br> plot = wrf_map_overlays(files_all[it],wks,(/contour_spd,contour_height, \<br> vector/),pltres,mpres)<br> end if<br> delete(opts_z)<br>; delete(wks)<br><br> end do ; END OF LEVEL LOOP<br><br>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br><br> end do ; END OF TIME LOOP<br><br>end<br></div></div><div id="DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br>
<table style="border-top:1px solid #d3d4de">
<tr>
<td style="width:55px;padding-top:13px"><a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail" target="_blank"><img src="https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif" alt="" width="46" height="29" style="width: 46px; height: 29px;"></a></td>
<td style="width:470px;padding-top:12px;color:#41424e;font-size:13px;font-family:Arial,Helvetica,sans-serif;line-height:18px">Virus-free. <a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail" target="_blank" style="color:#4453ea">www.avast.com</a>
</td>
</tr>
</table><a href="#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1"></a></div>