;======================================================================= ; name: ; xyanim.ncl ; ; category: ; NCL script ; ; description: ; This script creates a postscript file of 12-monthly figures. ; The "ps" file can be converted to "gif" by ; "convert [file name].ps [file name].gif" on LINUX environment. ; ; author: ; m.yoshimori ;======================================================================= begin ; specify years year0 = 1979 ; start year of the dataset syear = 1991 ; start year of the analysis eyear = 2020 ; end year of the analysis ; specify file names fin = "./GPCP/precip.mon.mean.nc" ; input file name (netCDF) fout = "./out/xyanim_pr" ; output file name (png/eps etc.) ; get data in = addfile(fin,"r") ; open a file tmp = in->precip ; read the data printVarSummary(tmp) ; check the data ; montly climatology y1 = (syear - year0)*12 y2 = (eyear - year0 + 1)*12 - 1 var = clmMonTLL(tmp(y1:y2,:,:)) delete(tmp) ;----- ; plot ;----- wks = gsn_open_wks("png",fout) ; open a png/eps file gsn_define_colormap(wks,"precip_11lev") ; choose a color map ; basic settings res = True ; plot mods desired res@gsnDraw = False ; draw plot res@gsnFrame = False ; advance frame res@cnFillOn = True ; turn on color fill res@cnLinesOn = False ; turn off contour lines res@cnLineLabelsOn = False ; turn off contour labels ; contour levels res@cnLevelSelectionMode = "ManualLevels" res@cnMinLevelValF = 1.0 res@cnMaxLevelValF = 12.0 res@cnLevelSpacingF = 1.0 ; adjust aspect ratio res@mpShapeMode = "FreeAspect" res@vpWidthF = 0.80 res@vpHeightF = 0.45 ; map res@mpFillOn = False ; turn off gray continents res@mpCenterLonF = 180 ; set centers the plot at 180 res@gsnMajorLonSpacing = 60 ; tick mark interval for longitude ; font size res@tiMainFontHeightF = 0.022 ; fontsize of the main title res@txFontHeightF = 0.02 ; fontsize of the subtitles res@tmXBLabelFontHeightF = 0.018 ; fontsize of tickmark labels (x-axis) res@tmYLLabelFontHeightF = 0.018 ; fontsize of tickmark labels (x-axis) ; titles ; res@tiMainString = "GPCP 1991-2020 monthly climatology" ; title res@gsnCenterString = "" ; subtitle res@gsnLeftString = "Precipitation" ; upper-left subtitle res@gsnRightString = "" ; upper-right subtitle ; subtitle attributes ; res@txFontHeightF = 0.02 ; resize the text ; res@amOrthogonalPosF = 0.05 ; move text up ; color table res@gsnSpreadColors = True ; spread out color table ; reshape color bar res@lbTitleOn = True res@lbOrientation = "horizontal" res@lbBoxEndCapStyle = "TriangleBothEnds" ; triangle edges res@lbBoxMinorExtentF = 0.2 ; slim width res@lbLabelStride = 1 ; label interval res@pmLabelBarOrthogonalPosF = 0.1 ; shift up&down ; reshape color title res@lbTitleString = "mm/day" res@lbTitleFontHeightF = 0.018 res@lbTitlePosition = "Right" res@lbTitleDirection = "Across" map = gsn_csm_contour_map(wks,var(0,:,:),res) res@sfXarray = var&lon res@sfYarray = var&lat ntim = 12 do m = 0, ntim-1 month = m+1 if (month.lt.10) then mm = "0"+tostring(month) else mm = tostring(month) end if setvalues map@contour ; Change the title for the contour plot. "tiMainString" : "GPCP 1991-2020 Climatology: Month = " + mm end setvalues setvalues map@data ; Change the data for the contour plot. "sfDataArray" : var(m,:,:) end setvalues draw(map) frame(wks) end do delete(map) end