Scheduled Downtime
On Friday 21 April 2023 @ 5pm MT, this website will be down for maintenance and expected to return online the morning of 24 April 2023 at the latest

NCL script for PM2.5 and PM10

This post was from a previous version of the WRF&MPAS-A Support Forum. New replies have been disabled and if you have follow up questions related to this post, then please start a new thread from the forum home page.

rasaqdayo

New member
Hello, I tried checking for the right section to post this since I couldn't find Post Processing section for WRF-Chem support. Please can I get a sample of an NCL script (showing PM2.5 and PM10) for a single wrfout file?
 
Hi,

Use this script as an example. You will want to replace HGT_M with your PM2.5 variable name that is output from WRF-Chem.

http://www2.mmm.ucar.edu/wrf/OnLineTutorial/Graphics/NCL/Examples/BASIC/wrf_wps_ter4.ncl

This page has a number of examples of ways to plot WRF data using NCL. Also, the NCL website has a great examples page which has anything you might want.

http://www.ncl.ucar.edu/Applications/
 
Thank you abjaye. The terrain height script is a very good basic script for NCL tutorial. In my case, wrf.out file for PM2.5 and PM10 has time step, level and coordinates attributes. I have preference for gsn_csm scripts. This is a sample of the script I finally used in case anyone is interested. The script has two plots - data on native and non-native grid.

;----------------------------------------------------------------------
; - Plotting WRF data on native grid
; - Plotting WRF data on non-native grid
;----------------------------------------------------------------------
; These files are loaded by default in NCL V6.2.0 and newer
; load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
; load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
; load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRF_contributed.ncl"
;----------------------------------------------------------------------

begin

;---Add data file and read variables
; f = addfile("wrfout_d01_2003-07-15_00_00_00.nc","r")
dirp = "/root/Build_WRF/WRFV3/test/em_real/"
filp = "wrfout_d01_2012-09-10_00:00:00.nc"

pthp = dirp + filp

f = addfile(pthp,"r") ; new input file
PM25 = f->PM2_5_DRY ; (Time, level, south_north, west_east )
printVarSummary(PM25)

level = 1
;---Open workstation and set resources for first contour plot
wks = gsn_open_wks("x11" ,"dataonmap") ; ps,pdf,x11,ncgm,eps

res1 = True
res1@gsnMaximize = True ; maximize size

res1@cnFillOn = True ; color plot desired
res1@cnFillPalette = "WhiteBlueGreenYellowRed"
res1@cnLinesOn = False ; turn off contour lines
res1@cnLineLabelsOn = False ; turn off contour labels
res1@cnLevelSpacingF = 1.

res1@gsnAddCyclic = False ; turn off longitude cyclic point

res1@lbOrientation = "Vertical"
res1@lbLabelFontHeightF = 0.015

res1@tiMainString = "WRF data on native grid"

res1@mpDataBaseVersion = "MediumRes"

;---Set map projection based on global attributes on file
res1 = wrf_map_resources(f, res1)

; res1@tfDoNDCOverlay = True ; old method
res1@tfDoNDCOverlay = "NDCViewport"

;---Draw first contour plot
plot = gsn_csm_contour_map(wks,PM25(24,level,:,:),res1)

;---Set resources for second contour plot
PM25@lat2d = f->XLAT(0,:,:) ; need for map limits
PM25@lon2d = f->XLONG(0,:,:)

res2 = True
res2@gsnMaximize = True ; maximize size

res2@cnFillOn = True ; color plot desired
res2@cnFillPalette = "WhiteBlueGreenYellowRed"
res2@cnLinesOn = False ; turn off contour lines
res2@cnLineLabelsOn = False ; turn off contour labels
res2@cnLevelSpacingF = 1.

res2@gsnAddCyclic = False ; turn off longitude cyclic point

res2@lbOrientation = "Vertical"
res2@lbLabelFontHeightF = 0.015

res2@mpMinLatF = min(PM25@lat2d)
res2@mpMaxLatF = max(PM25@lat2d)
res2@mpMinLonF = min(PM25@lon2d)
res2@mpMaxLonF = max(PM25@lon2d)

res2@tiMainString = "WRF data on C.E. grid"
res2@pmTitleZone = 4

res2@mpDataBaseVersion = "MediumRes"
res2@pmTickMarkDisplayMode = "Always" ; nicer tickmarks

;---Draw second contour plot
plot = gsn_csm_contour_map(wks,PM25(24,level,:,:),res2)

end
 
Top