;======================================================================= ; name: ; xy.ncl ; ; purpose: ; to plot lon-lat map ; ; 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/xy_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 ; annual means from "syear" to "eyear" y1 = (syear - year0)*12 y2 = (eyear - year0 + 1)*12 - 1 yyyymm = yyyymm_time(syear, eyear, "integer") tmp2 = month_to_annual_weighted(yyyymm, tmp(y1:y2,:,:), 1) delete(tmp) ; long-term average var = dim_avg_n_Wrap(tmp2, 0) delete(tmp2) ;----- ; 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 = True ; draw plot res@gsnFrame = True ; 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 = "ERA5 1991-2020 annual mean 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" ; plot plot=gsn_csm_contour_map_ce(wks,var,res) end