Skip to content

Instantly share code, notes, and snippets.

@uturuncoglu
Last active March 22, 2024 14:55
Show Gist options
  • Save uturuncoglu/149e0530730b380ac483f2eaf9aafdf4 to your computer and use it in GitHub Desktop.
Save uturuncoglu/149e0530730b380ac483f2eaf9aafdf4 to your computer and use it in GitHub Desktop.
WW3 NCL script
begin
;--- arguments ---
vname = "zeta"
vname = "uwind_speed"
vname = "vwind_speed"
tindx = 71
;--- open file ---
nc = addfile("sci_0001.nc", "r")
;--- read variable and coordinate dimensions ---
lon1d = nc->lonc ;lon
lat1d = nc->latc ;lat
var = nc->$vname$
var@lon1d = lon1d
var@lat1d = lat1d
;--- plot variable ---
wks_type = "pdf"
wks = gsn_open_wks(wks_type, "plot_fvcom_"+vname)
res = True
res@gsnDraw = False
res@gsnFrame = False
res@gsnAddCyclic = False
res@cnFillOn = True
res@cnLinesOn = False
res@cnLineLabelsOn = False
res@gsnLeftString = ""
res@gsnRightString = ""
size = 0.60
res@vpWidthF = size
res@vpHeightF = size
res@cnInfoLabelOn = False
res@lbLabelBarOn = False
res@cnFillMode = "RasterFill"
res@sfFirstNodeIndex = 1
res@pmTickMarkDisplayMode = True
res@mpDataBaseVersion = "HighRes"
res@mpLimitMode = "LatLon"
res@mpMinLonF = min(var@lon1d)
res@mpMaxLonF = max(var@lon1d)
res@mpMinLatF = min(var@lat1d)
res@mpMaxLatF = max(var@lat1d)
plot = gsn_csm_contour_map(wks, var(tindx,:), res)
draw(plot)
frame(wks)
end
begin
;--- arguments ---
vname = "air_pressure"
vname = "wind_speed"
vname = "rsxx"
vname = "rsyy"
vname = "rsxy"
tindx = 47
;--- open file ---
nc = addfile("schout_1.nc", "r")
;--- read variable and coordinate dimensions ---
lon1d = nc->SCHISM_hgrid_node_x
lat1d = nc->SCHISM_hgrid_node_y
if (vname .eq. "wind_speed") then
var = nc->$vname$(:,:,0)
else
var = nc->$vname$
end if
var@lon1d = lon1d
var@lat1d = lat1d
;--- plot variable ---
wks_type = "pdf"
wks = gsn_open_wks(wks_type, "plot_sch_"+vname)
res = True
res@gsnDraw = False
res@gsnFrame = False
res@gsnAddCyclic = False
res@cnFillOn = True
res@cnLinesOn = False
res@cnLineLabelsOn = False
res@gsnLeftString = ""
res@gsnRightString = ""
size = 0.60
res@vpWidthF = size
res@vpHeightF = size
res@cnInfoLabelOn = False
res@lbLabelBarOn = False
res@cnFillMode = "RasterFill"
res@sfFirstNodeIndex = 1
res@pmTickMarkDisplayMode = True
;res@mpDataBaseVersion = "HighRes"
res@mpLimitMode = "LatLon"
res@mpMinLonF = min(var@lon1d)
res@mpMaxLonF = max(var@lon1d)
res@mpMinLatF = min(var@lat1d)
res@mpMaxLatF = max(var@lat1d)
plot = gsn_csm_contour_map(wks, var(tindx,:), res)
draw(plot)
frame(wks)
end
begin
;--- arguments ---
vname = "SXX"
vname = "SYY"
vname = "SXY"
vname = "CX"
vname = "CY"
vname = "HS"
vname = "WLV"
tindx = 120
;--- open files ---
files = systemfunc("ls *.out_grd.ww3.nc")
nc = addfiles(files, "r")
;--- read variable and coordinate dimensions ---
lon1d = nc[0]->lon(0,:)
lat1d = nc[0]->lat(0,:)
nconn = nc[0]->nconn
var = nc[:]->$vname$
var@lon1d = lon1d
var@lat1d = lat1d
;--- generate cell coordnates ---
dims = dimsizes(nconn)
ne = dims(0)
nn = dims(1)
elon = new((/ ne /), typeof(lon1d))
elat = new((/ ne /), typeof(lat1d))
do i = 0, ne-1
elon(i) = sum(lon1d(nconn(i,:)-1))/tofloat(nn)
elat(i) = sum(lat1d(nconn(i,:)-1))/tofloat(nn)
end do
;--- plot variable ---
wks_type = "pdf"
wks = gsn_open_wks(wks_type, "plot_ww3_"+vname)
res = True
res@gsnDraw = False
res@gsnFrame = False
res@gsnAddCyclic = False
res@cnFillOn = True
res@cnLinesOn = False
res@cnLineLabelsOn = False
res@gsnLeftString = ""
res@gsnRightString = ""
size = 0.60
res@vpWidthF = size
res@vpHeightF = size
res@cnInfoLabelOn = False
res@lbLabelBarOn = False
res@cnFillMode = "RasterFill"
res@sfElementNodes = nc[0]->nconn
res@sfFirstNodeIndex = 1
res@pmTickMarkDisplayMode = True
res@mpDataBaseVersion = "HighRes"
res@mpLimitMode = "LatLon"
res@mpMinLonF = min(var@lon1d)
res@mpMaxLonF = max(var@lon1d)
res@mpMinLatF = min(var@lat1d)
res@mpMaxLatF = max(var@lat1d)
plot = gsn_csm_contour_map(wks, var(tindx,0,:), res)
draw(plot)
frame(wks)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment