;************************************************* ; regress_2.ncl ; ; Concepts illustrated: ; - Calculating the regression coefficient (slope) at each grid point ; - Copying attributes from one variable to another ; - Drawing color-filled contours over a cylindrical equidistant map ; ;************************************************* ; ; 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/csm/contributed.ncl" load "/media/hilory/Transcend/AL/r45/shapefile_utils.ncl" ; shp_filename = "/home/vincent/Desktop/mask/NGA_adm_shp/NGA_adm0.shp" ; shp_filename = "/Volumes/climdata/mask/NGA_adm_shp/NIR_outline_SHP-2/NIR_outline.shp" shp_filename = "/media/hilory/Transcend/AL/r45/gadm36_NGA_shp/gadm36_NGA_0.shp" print("======================================================================") print("Masking data against " + shp_filename) optm = True optm@keep = True ; Keep values inside this shape begin ;************************************************ ; create pointer to file and read in indices ;************************************************ in1f = addfile("rx1day_ANN_ensmean_rcp45_2020-2099_mask-mask.nc","r") in1h = addfile("rx1day_ANN_ensmean_historical_1961-2000_mask-mask.nc", "r") in2f = addfile("rx5day_ANN_ensmean_rcp45_2020-2099_mask-mask.nc","r") in2h = addfile("rx5day_ANN_ensmean_historical_1961-2000_mask-mask.nc", "r") in3f = addfile("sdii_ANN_ensmean_rcp45_2020-2099_mask-mask.nc","r") in3h = addfile("sdii_ANN_ensmean_historical_1961-2000_mask-mask.nc", "r") in4f = addfile("r10mm_ANN_ensmean_rcp45_2020-2099_mask-mask.nc","r") in4h = addfile("r10mm_ANN_ensmean_historical_1961-2000_mask-mask.nc", "r") in5f = addfile("r20mm_ANN_ensmean_rcp45_2020-2099_mask-mask.nc","r") in5h = addfile("r20mm_ANN_ensmean_historical_1961-2000_mask-mask.nc", "r") in6f = addfile("cdd_ANN_ensmean_rcp45_2020-2099_mask-mask.nc","r") in6h = addfile("cdd_ANN_ensmean_historical_1961-2000_mask-mask.nc", "r") in7f = addfile("cwd_ANN_ensmean_rcp45_2020-2099_mask-mask.nc","r") in7h = addfile("cwd_ANN_ensmean_historical_1961-2000_mask-mask.nc", "r") in8f = addfile("prcptot_ANN_ensmean_rcp45_2020-2099_mask-mask.nc","r") in8h = addfile("prcptot_ANN_ensmean_historical_1961-2000_mask-mask.nc", "r") rx1dayh0 = in1h->rx1day rx1dayf0 = in1f->rx1day rx5dayh0 = in2h->rx5day rx5dayf0 = in2f->rx5day sdiih0 = in3h->sdii sdiif0 = in3f->sdii r10mmh0 = in4h->r10mm r10mmf0 = in4f->r10mm r20mmh0 = in5h->r20mm r20mmf0 = in5f->r20mm cddh0 = in6h->cdd cddf0 = in6f->cdd cwdh0 = in7h->cwd cwdf0 = in7f->cwd prcptoth0 = in8h->prcptot prcptotf0 = in8f->prcptot ;--Time definition ;Baseline Period (1961-2000) ;Near future (2020-2059) ;far future (2060-2099) yyyymm = cd_calendar(rx1dayh0&time, -1) yyyymm2 = cd_calendar(rx1dayf0&time, -1) yyyy = yyyymm/100 yyyy2 = yyyymm2/100 biyr = ind(yyyy .ge. 1961 .and. yyyy .le. 2000) nfiyr = ind(yyyy2 .ge. 2020 .and. yyyy2 .le. 2059) ffiyr = ind(yyyy2 .ge. 2060 .and. yyyy2 .le. 2099) ffiyr2 = ind(yyyy2 .ge. 2060 .and. yyyy2 .le. 2099) fyr = ind(yyyy2 .ge. 2020 .and. yyyy2 .le. 2099) rx1dayh = rx1dayh0(biyr,:,:) rx1daynf = rx1dayf0(nfiyr,:,:) rx1dayff = rx1dayf0(ffiyr,:,:) rx5dayh = rx5dayh0(biyr,:,:) rx5daynf = rx5dayf0(nfiyr,:,:) rx5dayff = rx5dayf0(ffiyr,:,:) sdiih = sdiih0(biyr,:,:) sdiinf = sdiif0(nfiyr,:,:) sdiiff = sdiif0(ffiyr,:,:) r10mmh = r10mmh0(biyr,:,:) r10mmnf = r10mmf0(nfiyr,:,:) r10mmff = r10mmf0(ffiyr,:,:) r20mmh = r20mmh0(biyr,:,:) r20mmnf = r20mmf0(nfiyr,:,:) r20mmff = r20mmf0(ffiyr,:,:) cddh = cddh0(biyr,:,:) cddnf = cddf0(nfiyr,:,:) cddff = cddf0(ffiyr,:,:) cwdh = cwdh0(biyr,:,:) cwdnf = cwdf0(nfiyr,:,:) cwdff = cwdf0(ffiyr,:,:) prcptoth = cddh0(biyr,:,:) prcptotnf = cddf0(nfiyr,:,:) prcptotff = cddf0(ffiyr,:,:) ; t1=ut_calendar(rx1dayh&time, -1) ; t2=ut_calendar(rx1daynf&time, -1) ; t3=ut_calendar(rx1dayff&time, -1) ; print(t1) ; print(t2) ; print(t3) ;--Difference between periods ;--RX1DAY rx1daynfA = dim_avg_n_Wrap(rx1dayf0(nfiyr,:,:),0)-dim_avg_n_Wrap(rx1dayh0(biyr,:,:),0) rx1dayffA = dim_avg_n_Wrap(rx1dayf0(ffiyr,:,:),0)-dim_avg_n_Wrap(rx1dayh0(biyr,:,:),0) copy_VarCoords(rx1dayh0(0,:,:),rx1daynfA) copy_VarCoords(rx1dayh0(0,:,:),rx1dayffA) ; delete([/rx1dayh0,rx1dayf0/]) ;--RX5DAY rx5daynfA = dim_avg_n_Wrap(rx5dayf0(nfiyr,:,:),0)-dim_avg_n_Wrap(rx5dayh0(biyr,:,:),0) rx5dayffA = dim_avg_n_Wrap(rx5dayf0(ffiyr,:,:),0)-dim_avg_n_Wrap(rx5dayh0(biyr,:,:),0) copy_VarCoords(rx5dayh0(0,:,:),rx5daynfA) copy_VarCoords(rx5dayh0(0,:,:),rx5dayffA) ; delete([/rx5dayh0,rx5dayf0/] ;--SDII sdiinfA = dim_avg_n_Wrap(sdiif0(nfiyr,:,:),0)-dim_avg_n_Wrap(sdiih0(biyr,:,:),0) sdiiffA = dim_avg_n_Wrap(sdiif0(ffiyr,:,:),0)-dim_avg_n_Wrap(sdiih0(biyr,:,:),0) copy_VarCoords(sdiih0(0,:,:),sdiinfA) copy_VarCoords(sdiih0(0,:,:),sdiiffA) ; delete([/sdiih0,sdiif0/] ;--R10MM r10mmnfA = dim_avg_n_Wrap(r10mmf0(nfiyr,:,:),0)-dim_avg_n_Wrap(r10mmh0(biyr,:,:),0) r10mmffA = dim_avg_n_Wrap(r10mmf0(ffiyr,:,:),0)-dim_avg_n_Wrap(r10mmh0(biyr,:,:),0) copy_VarCoords(r10mmh0(0,:,:),r10mmnfA) copy_VarCoords(r10mmh0(0,:,:),r10mmffA) ; delete([/r10mmh0,r10mmf0/] ;--R20MM r20mmnfA = dim_avg_n_Wrap(r20mmf0(nfiyr,:,:),0)-dim_avg_n_Wrap(r20mmh0(biyr,:,:),0) r20mmffA = dim_avg_n_Wrap(r20mmf0(ffiyr,:,:),0)-dim_avg_n_Wrap(r20mmh0(biyr,:,:),0) copy_VarCoords(r20mmh0(0,:,:),r20mmnfA) copy_VarCoords(r20mmh0(0,:,:),r20mmffA) ; delete([/r20mmh0,r20mmf0/] ;--CDD cddnfA = dim_avg_n_Wrap(cddf0(nfiyr,:,:),0)-dim_avg_n_Wrap(cddh0(biyr,:,:),0) cddffA = dim_avg_n_Wrap(cddf0(ffiyr,:,:),0)-dim_avg_n_Wrap(cddh0(biyr,:,:),0) copy_VarCoords(cddh0(0,:,:),cddnfA) copy_VarCoords(cddh0(0,:,:),cddffA) ; delete([/cddh0,cddf0/] ;--CWD cwdnfA = dim_avg_n_Wrap(cwdf0(nfiyr,:,:),0)-dim_avg_n_Wrap(cwdh0(biyr,:,:),0) cwdffA = dim_avg_n_Wrap(cwdf0(ffiyr,:,:),0)-dim_avg_n_Wrap(cwdh0(biyr,:,:),0) copy_VarCoords(cwdh0(0,:,:),cwdnfA) copy_VarCoords(cwdh0(0,:,:),cwdffA) ; delete([/cwdh0,cwdf0/] ;--PRCPTOT prcptotnfA = dim_avg_n_Wrap(prcptotf0(nfiyr,:,:),0)-dim_avg_n_Wrap(prcptoth0(biyr,:,:),0) prcptotffA = dim_avg_n_Wrap(prcptotf0(ffiyr,:,:),0)-dim_avg_n_Wrap(prcptoth0(biyr,:,:),0) copy_VarCoords(prcptoth0(0,:,:),prcptotnfA) copy_VarCoords(prcptoth0(0,:,:),prcptotffA) ; delete([/prcptoth0,prcptotf0/] dimh = dimsizes(rx1dayh) ntim = dimh(0) ; all years and months nlat = dimh(1) mlon = dimh(2) year = ispan(yyyy(0), yyyy(ntim-1), 1) nyrs = dimsizes(year) dimf = dimsizes(rx1daynf) ntim = dimf(0) ; all years and months nlat = dimf(1) mlon = dimf(2) year2 = ispan(yyyy2(0), yyyy2(ntim-1), 1) nyrs2 = dimsizes(year2) ;print(yyyymm) ;;=============================================== ;;Kendall trend significance test ;;=============================================== ; opt = False ;opt@return_trend = False ;--RX1DAY ; rx1dayhK = trend_manken(rx1dayh, opt, 0) ; rx1dayhK!1 = "lat" ; copy lat,lon coords ; rx1dayhK!2 = "lon" dimf = dimsizes(rx1daynf) ntim = dimf(0) ; all years and months nlat = dimf(1) mlon = dimf(2) year2 = ispan(yyyy2(0), yyyy2(ntim-1), 1) nyrs2 = dimsizes(year2) ;;=============================================== ;;Kendall trend significance test ;;=============================================== opt = False ;opt@return_trend = False ;--RX1DAY ;--hist rx1dayhK = trend_manken(rx1dayh, opt, 0) rx1dayhK!1 = "lat" ; copy lat,lon coords rx1dayhK!2 = "lon" rx1dayhK&lat = rx1dayh&lat ; copy lat,lon coords rx1dayhK&lon = rx1dayh&lon ; copy lat,lon coords ;--future rx1dayp = array_append_record (rx1daynf, rx1dayff, 0) rx1daypK = trend_manken(rx1dayp, opt, 0) rx1daypK!1 = "lat" ; copy lat,lon coords rx1daypK!2 = "lon" rx1daypK&lat = rx1dayp&lat ; copy lat,lon coords rx1daypK&lon = rx1dayp&lon ; copy lat,lon coords delete(rx1dayp) ; printVarSummary(rx1daypK) ; printVarSummary(rx1dayhK) ; print(rx1dayhK(0,{7},{7})) ; print(rx1dayhK(1,{7},{7})) ;--RX5DAY ;--hist rx5dayhK = trend_manken(rx5dayh, opt, 0) rx5dayhK!1 = "lat" ; copy lat,lon coords rx5dayhK!2 = "lon" rx5dayhK&lat = rx5dayh&lat ; copy lat,lon coords rx5dayhK&lon = rx5dayh&lon ; copy lat,lon coords ;--future rx5dayp = array_append_record (rx5daynf, rx5dayff, 0) rx5daypK = trend_manken(rx5dayp, opt, 0) rx5daypK!1 = "lat" ; copy lat,lon coords rx5daypK!2 = "lon" rx5daypK&lat = rx5dayp&lat ; copy lat,lon coords rx5daypK&lon = rx5dayp&lon ; copy lat,lon coords delete(rx5dayp) ;--SDII ;--hist sdiihK = trend_manken(sdiih, opt, 0) sdiihK!1 = "lat" ; copy lat,lon coords sdiihK!2 = "lon" sdiihK&lat = sdiih&lat ; copy lat,lon coords sdiihK&lon = sdiih&lon ; copy lat,lon coords ;--future sdiip = array_append_record (sdiinf, sdiiff, 0) sdiipK = trend_manken(sdiip, opt, 0) sdiipK!1 = "lat" ; copy lat,lon coords sdiipK!2 = "lon" sdiipK&lat = sdiip&lat ; copy lat,lon coords rx1daypK&lon = sdiip&lon ; copy lat,lon coords delete(sdiip) ;--R10MM ;--hist r10mmhK = trend_manken(r10mmh, opt, 0) r10mmhK!1 = "lat" ; copy lat,lon coords r10mmhK!2 = "lon" r10mmhK&lat = r10mmh&lat ; copy lat,lon coords r10mmhK&lon = r10mmh&lon ; copy lat,lon coords ;--future r10mmp = array_append_record (r10mmnf, r10mmff, 0) r10mmpK = trend_manken(r10mmp, opt, 0) r10mmpK!1 = "lat" ; copy lat,lon coords r10mmpK!2 = "lon" r10mmpK&lat = r10mmp&lat ; copy lat,lon coords r10mmpK&lon = r10mmp&lon ; copy lat,lon coords delete(r10mmp) ;--R20MM ;--hist r20mmhK = trend_manken(r20mmh, opt, 0) r20mmhK!1 = "lat" ; copy lat,lon coords r20mmhK!2 = "lon" r20mmhK&lat = r20mmh&lat ; copy lat,lon coords r20mmhK&lon = r20mmh&lon ; copy lat,lon coords ;--future r20mmp = array_append_record (r20mmnf, r20mmff, 0) r20mmpK = trend_manken(r20mmp, opt, 0) r20mmpK!1 = "lat" ; copy lat,lon coords r20mmpK!2 = "lon" r20mmpK&lat = r20mmp&lat ; copy lat,lon coords r20mmpK&lon = r20mmp&lon ; copy lat,lon coords delete(r20mmp) ;--CDD ;--hist cddhK = trend_manken(cddh, opt, 0) cddhK!1 = "lat" ; copy lat,lon coords cddhK!2 = "lon" cddhK&lat = cddh&lat ; copy lat,lon coords cddhK&lon = cddh&lon ; copy lat,lon coords ;--future cddp = array_append_record (cddnf, cddff, 0) cddpK = trend_manken(cddp, opt, 0) cddpK!1 = "lat" ; copy lat,lon coords cddpK!2 = "lon" cddpK&lat = cddp&lat ; copy lat,lon coords cddpK&lon = cddp&lon ; copy lat,lon coords delete(cddp) ;--CWD ;--hist cwdhK = trend_manken(cwdh, opt, 0) cwdhK!1 = "lat" ; copy lat,lon coords cwdhK!2 = "lon" cwdhK&lat = cwdh&lat ; copy lat,lon coords cwdhK&lon = cwdh&lon ; copy lat,lon coords ;--future cwdp = array_append_record (cwdnf, cwdff, 0) cwdpK = trend_manken(cwdp, opt, 0) cwdpK!1 = "lat" ; copy lat,lon coords cwdpK!2 = "lon" cwdpK&lat = cwdp&lat ; copy lat,lon coords cwdpK&lon = cwdp&lon ; copy lat,lon coords delete(cwdp) ;--PRCPTOT ;--hist prcptothK = trend_manken(prcptoth, opt, 0) prcptothK!1 = "lat" ; copy lat,lon coords prcptothK!2 = "lon" prcptothK&lat = prcptoth&lat ; copy lat,lon coords prcptothK&lon = prcptoth&lon ; copy lat,lon coords ;--future prcptotp = array_append_record (prcptotnf, prcptotff, 0) prcptotpK = trend_manken(prcptotp, opt, 0) prcptotpK!1 = "lat" ; copy lat,lon coords prcptotpK!2 = "lon" prcptotpK&lat = prcptotp&lat ; copy lat,lon coords prcptotpK&lon = prcptotp&lon ; copy lat,lon coords delete(prcptotp) ;************************************************ ; Calculate the regression coefficients (slopes) ;************************************************ ;--RX1DAY ;--hist rx1dayhrc_mask = shapefile_mask_data(rx1dayhK(1,:,:),shp_filename,optm) rx1dayhrc_mask@_FillValue = 1e27 rx1dayhprob = rx1dayhK(0,:,:)*100. ;== To compare with Kendall in R copy_VarCoords(rx1dayhK(0,:,:),rx1dayhprob) rx1dayhprob_mask = shapefile_mask_data(rx1dayhprob,shp_filename,optm) rx1dayh_sig = where(rx1dayhprob_mask.gt.95,rx1dayhrc_mask,rx1dayhrc_mask@_FillValue) copy_VarCoords(rx1dayhprob,rx1dayh_sig) ;--near and far future projection rx1dayprc_mask = shapefile_mask_data(rx1daypK(1,:,:),shp_filename,optm) rx1dayprc_mask@_FillValue = 1e27 rx1daypprob = rx1daypK(0,:,:)*100. ;== To compare with Kendall in R copy_VarCoords(rx1daypK(0,:,:),rx1daypprob) rx1daypprob_mask = shapefile_mask_data(rx1daypprob,shp_filename,optm) rx1dayp_sig = where(rx1daypprob_mask.gt.95,rx1dayprc_mask,rx1dayprc_mask@_FillValue) copy_VarCoords(rx1daypprob,rx1dayp_sig) ;-- rx1dayffA_mask = shapefile_mask_data(rx1dayffA,shp_filename,optm) rx1daynfA_mask = shapefile_mask_data(rx1daynfA,shp_filename,optm) ; rx1dayhrc_mask@long_name = "RX1DAY Trend" ; rx1dayhrc_mask@units = rx1dayh@units+"/year" delete([/rx1dayh, rx1dayhK, rx1dayhprob , rx1dayffA, rx1daynfA, rx1dayhprob, rx1dayhprob_mask/]) ;--RX5DAY ;--hist rx5dayhrc_mask = shapefile_mask_data(rx5dayhK(1,:,:),shp_filename,optm) rx5dayhrc_mask@_FillValue = 1e27 rx5dayhprob = rx5dayhK(0,:,:)*100. ;== To compare with Kendall in R copy_VarCoords(rx5dayhK(0,:,:),rx5dayhprob) rx5dayhprob_mask = shapefile_mask_data(rx5dayhprob,shp_filename,optm) rx5dayh_sig = where(rx5dayhprob_mask.gt.95,rx5dayhrc_mask,rx5dayhrc_mask@_FillValue) copy_VarCoords(rx5dayhprob,rx5dayh_sig) ;--near and far future projection rx5dayprc_mask = shapefile_mask_data(rx5daypK(1,:,:),shp_filename,optm) rx5dayprc_mask@_FillValue = 1e27 rx5daypprob = rx1daypK(0,:,:)*100. ;== To compare with Kendall in R copy_VarCoords(rx5daypK(0,:,:),rx5daypprob) rx5daypprob_mask = shapefile_mask_data(rx5daypprob,shp_filename,optm) rx5dayp_sig = where(rx5daypprob_mask.gt.95,rx5dayprc_mask,rx5dayprc_mask@_FillValue) copy_VarCoords(rx5daypprob,rx5dayp_sig) ;-- rx5dayffA_mask = shapefile_mask_data(rx5dayffA,shp_filename,optm) rx5daynfA_mask = shapefile_mask_data(rx5daynfA,shp_filename,optm) ; rx5dayhrc_mask@long_name = "RX5DAY Trend" ; rx5dayhrc_mask@units = rx5dayh@units+"/year" delete([/rx5dayh, rx5dayhK, rx5dayhprob , rx5dayffA, rx5daynfA, rx5dayhprob, rx5dayhprob_mask/]) ;--SDII ;--hist sdiihrc_mask = shapefile_mask_data(sdiihK(1,:,:),shp_filename,optm) sdiihrc_mask@_FillValue = 1e27 sdiihprob = sdiihK(0,:,:)*100. ;== To compare with Kendall in R copy_VarCoords(sdiihK(0,:,:),sdiihprob) sdiihprob_mask = shapefile_mask_data(sdiihprob,shp_filename,optm) sdiih_sig = where(sdiihprob_mask.gt.95,sdiihrc_mask,sdiihrc_mask@_FillValue) copy_VarCoords(sdiihprob,sdiih_sig) ;--near and far future projection sdiiprc_mask = shapefile_mask_data(sdiipK(1,:,:),shp_filename,optm) sdiiprc_mask@_FillValue = 1e27 sdiipprob = sdiipK(0,:,:)*100. ;== To compare with Kendall in R copy_VarCoords(sdiipK(0,:,:),sdiipprob) sdiipprob_mask = shapefile_mask_data(sdiipprob,shp_filename,optm) sdiip_sig = where(sdiipprob_mask.gt.95,sdiiprc_mask,sdiiprc_mask@_FillValue) copy_VarCoords(sdiipprob,sdiip_sig) ;-- sdiiffA_mask = shapefile_mask_data(sdiiffA,shp_filename,optm) sdiinfA_mask = shapefile_mask_data(sdiinfA,shp_filename,optm) ; sdiihrc_mask@long_name = "SDII Trend" ; sdiihrc_mask@units = sdiih@units+"/year" delete([/sdiih, sdiihK, sdiihprob , sdiiffA, sdiinfA, sdiihprob, sdiihprob_mask/]) ;--R10MM ;--hist r10mmhrc_mask = shapefile_mask_data(r10mmhK(1,:,:),shp_filename,optm) r10mmhrc_mask@_FillValue = 1e27 r10mmhprob = r10mmhK(0,:,:)*100. ;== To compare with Kendall in R copy_VarCoords(r10mmhK(0,:,:),r10mmhprob) r10mmhprob_mask = shapefile_mask_data(r10mmhprob,shp_filename,optm) r10mmh_sig = where(r10mmhprob_mask.gt.95,r10mmhrc_mask,r10mmhrc_mask@_FillValue) copy_VarCoords(r10mmhprob,r10mmh_sig) ;--near and far future projection r10mmprc_mask = shapefile_mask_data(r10mmpK(1,:,:),shp_filename,optm) r10mmprc_mask@_FillValue = 1e27 r10mmpprob = r10mmpK(0,:,:)*100. ;== To compare with Kendall in R copy_VarCoords(r10mmpK(0,:,:),r10mmpprob) r10mmpprob_mask = shapefile_mask_data(r10mmpprob,shp_filename,optm) r10mmp_sig = where(r10mmpprob_mask.gt.95,r10mmprc_mask,r10mmprc_mask@_FillValue) copy_VarCoords(r10mmpprob,r10mmp_sig) ;-- r10mmffA_mask = shapefile_mask_data(r10mmffA,shp_filename,optm) r10mmnfA_mask = shapefile_mask_data(r10mmnfA,shp_filename,optm) ; r10mmhrc_mask@long_name = "R10MM Trend" ; r10mmhrc_mask@units = r10mmh@units+"/year" delete([/r10mmh, r10mmhK, r10mmhprob , r10mmffA, r10mmnfA, r10mmhprob, r10mmhprob_mask/]) ;--R20MM ;--hist r20mmhrc_mask = shapefile_mask_data(r20mmhK(1,:,:),shp_filename,optm) r20mmhrc_mask@_FillValue = 1e27 r20mmhprob = r20mmhK(0,:,:)*100. ;== To compare with Kendall in R copy_VarCoords(r20mmhK(0,:,:),r20mmhprob) r20mmhprob_mask = shapefile_mask_data(r20mmhprob,shp_filename,optm) r20mmh_sig = where(r20mmhprob_mask.gt.95,r20mmhrc_mask,r20mmhrc_mask@_FillValue) copy_VarCoords(r20mmhprob,r20mmh_sig) ;--near and far future projection r20mmprc_mask = shapefile_mask_data(r20mmpK(1,:,:),shp_filename,optm) r20mmprc_mask@_FillValue = 1e27 r20mmpprob = r20mmpK(0,:,:)*100. ;== To compare with Kendall in R copy_VarCoords(r20mmpK(0,:,:),r20mmpprob) r20mmpprob_mask = shapefile_mask_data(r20mmpprob,shp_filename,optm) r20mmp_sig = where(r20mmpprob_mask.gt.95,r20mmprc_mask,r20mmprc_mask@_FillValue) copy_VarCoords(r20mmpprob,r20mmp_sig) ;-- r20mmffA_mask = shapefile_mask_data(r20mmffA,shp_filename,optm) r20mmnfA_mask = shapefile_mask_data(r20mmnfA,shp_filename,optm) ; r20mmhrc_mask@long_name = "R20MM Trend" ; r20mmhrc_mask@units = r10mmh@units+"/year" delete([/r20mmh, r20mmhK, r20mmhprob , r20mmffA, r20mmnfA, r20mmhprob, r20mmhprob_mask/]) ;--CDD ;--hist cddhrc_mask = shapefile_mask_data(cddhK(1,:,:),shp_filename,optm) cddhrc_mask@_FillValue = 1e27 cddhprob = cddhK(0,:,:)*100. ;== To compare with Kendall in R copy_VarCoords(cddhK(0,:,:),cddhprob) cddhprob_mask = shapefile_mask_data(cddhprob,shp_filename,optm) cddh_sig = where(cddhprob_mask.gt.95,cddhrc_mask,cddhrc_mask@_FillValue) copy_VarCoords(cddhprob,cddh_sig) ;--near and far future projection cddprc_mask = shapefile_mask_data(cddpK(1,:,:),shp_filename,optm) cddprc_mask@_FillValue = 1e27 cddpprob = cddpK(0,:,:)*100. ;== To compare with Kendall in R copy_VarCoords(cddpK(0,:,:),cddpprob) cddpprob_mask = shapefile_mask_data(cddpprob,shp_filename,optm) cddp_sig = where(cddpprob_mask.gt.95,cddprc_mask,cddprc_mask@_FillValue) copy_VarCoords(cddpprob,cddp_sig) ;-- cddffA_mask = shapefile_mask_data(cddffA,shp_filename,optm) cddnfA_mask = shapefile_mask_data(cddnfA,shp_filename,optm) ; cddhrc_mask@long_name = "CDD Trend" ; cddhrc_mask@units = cddh@units+"/year" delete([/cddh, cddhK, cddhprob , cddffA, cddnfA, cddhprob, cddhprob_mask/]) ;--CWD ;--hist cwdhrc_mask = shapefile_mask_data(cwdhK(1,:,:),shp_filename,optm) cwdhrc_mask@_FillValue = 1e27 cwdhprob = cwdhK(0,:,:)*100. ;== To compare with Kendall in R copy_VarCoords(cwdhK(0,:,:),cwdhprob) cwdhprob_mask = shapefile_mask_data(cwdhprob,shp_filename,optm) cwdh_sig = where(cwdhprob_mask.gt.95,cwdhrc_mask,cwdhrc_mask@_FillValue) copy_VarCoords(cwdhprob,cwdh_sig) ;--near and far future projection cwdprc_mask = shapefile_mask_data(cwdpK(1,:,:),shp_filename,optm) cwdprc_mask@_FillValue = 1e27 cwdpprob = cwdpK(0,:,:)*100. ;== To compare with Kendall in R copy_VarCoords(cwdpK(0,:,:),cwdpprob) cwdpprob_mask = shapefile_mask_data(cwdpprob,shp_filename,optm) cwdp_sig = where(cwdpprob_mask.gt.95,cwdprc_mask,cwdprc_mask@_FillValue) copy_VarCoords(cwdpprob,cwdp_sig) ;-- cwdffA_mask = shapefile_mask_data(cwdffA,shp_filename,optm) cwdnfA_mask = shapefile_mask_data(cwdnfA,shp_filename,optm) ; cwdhrc_mask@long_name = "CWD Trend" ; cwdhrc_mask@units = cwdh@units+"/year" delete([/cwdh, cwdhK, cwdhprob , cwdffA, cwdnfA, cwdhprob, cwdhprob_mask/]) ;--PRCPTOT ;--hist prcptothrc_mask = shapefile_mask_data(prcptothK(1,:,:),shp_filename,optm) prcptothrc_mask@_FillValue = 1e27 prcptothprob = prcptothK(0,:,:)*100. ;== To compare with Kendall in R copy_VarCoords(prcptothK(0,:,:),cwdhprob) prcptothprob_mask = shapefile_mask_data(prcptothprob,shp_filename,optm) prcptoth_sig = where(prcptothprob_mask.gt.95,prcptothrc_mask,prcptothrc_mask@_FillValue) copy_VarCoords(prcptothprob,prcptoth_sig) ;--near and far future projection prcptotprc_mask = shapefile_mask_data(prcptotpK(1,:,:),shp_filename,optm) prcptotprc_mask@_FillValue = 1e27 prcptotpprob = prcptotpK(0,:,:)*100. ;== To compare with Kendall in R copy_VarCoords(prcptotpK(0,:,:),prcptotpprob) prcppprob_mask = shapefile_mask_data(prcptotpprob,shp_filename,optm) prcptotp_sig = where(prcptotpprob_mask.gt.95,prcptotprc_mask,prcptotprc_mask@_FillValue) copy_VarCoords(prcptotpprob,prcptotp_sig) ;-- prcptotffA_mask = shapefile_mask_data(prcptotffA,shp_filename,optm) prcptotnfA_mask = shapefile_mask_data(prcptotnfA,shp_filename,optm) ; prcptothrc_mask@long_name = "PRCPTOT Trend" ; prcptothrc_mask@units = PRCPTOTh@units+"/year" delete([/prcptoth, prcptothK, prcptothprob , prcptotffA, prcptotnfA, prcptothprob, prcptothprob_mask/]) wks = gsn_open_wks("png","TR_trends") ; send graphics to PNG file res = True res@gsnFrame = False res@gsnDraw = False res@gsnMaximize = True ; make large res@gsnAddCyclic = False res@cnFillOn = True ; turn on color res@cnLinesOn = False ; turn off contour lines res@cnLineLabelsOn = False ; turn off contour line labels res@cnConstFLabelOn = False res@cnInfoLabelOn = False res@pmTickMarkDisplayMode = "Always" res@tiMainFont = 22 res@tiXAxisFont = 22 res@tiYAxisFont = 22 res@tmXBLabelFont = 22 res@tmYLLabelFont = 22 res@tmYRLabelFont = 22 res@cnLevelSelectionMode = "ManualLevels" ; set manual contour levels res@cnMinLevelValF = 0. ; set min contour level res@cnMaxLevelValF = 3. ; set max contour level res@cnLevelSpacingF = 0.2 ; set contour interval res3=res res@mpFillOn = False ; turn off default background gray res@mpOutlineOn = False res@mpMinLonF = 2 res@mpMaxLonF = 15 res@mpMinLatF = 4 res@mpMaxLatF = 15 res@lbLabelBarOn = False res3@cnFillColor = "black" ; res@gsnCenterString = year(0)+"-"+year(nyrs-1) res3@cnFillPattern = 17 res3@cnMonoFillColor = True res3@cnFillDotSizeF = .005 res3@cnFillColor = "black" plot =new(8, graphic) res@tiMainString = "RX1DAY" plot(0) = gsn_csm_contour_map_overlay(wks,rx1dayhrc_mask,rx1dayh_sig,res,res3) res@tiMainString = "RX5DAY" plot(1) = gsn_csm_contour_map_overlay(wks,rx5dayhrc_mask,rx5dayh_sig,res,res3) res@tiMainString = "SDII" plot(2) = gsn_csm_contour_map_overlay(wks,sdihrc_mask,sdiih_sig,res,res3) res@tiMainString = "R10MM" plot(3) = gsn_csm_contour_map_overlay(wks,r10mmhrc_mask,r10mmh_sig,res,res3) res@tiMainString = "R20MM" plot(4) = gsn_csm_contour_map_overlay(wks,r20mmhrc_mask,r20mmh_sig,res,res3) res@tiMainString = "CDD" plot(5) = gsn_csm_contour_map_overlay(wks,cddhrc_mask,cddh_sig,res,res3) res@tiMainString = "CWD" plot(6) = gsn_csm_contour_map_overlay(wks,cwdhrc_mask,cwdh_sig,res,res3) res@tiMainString = "PRCPTOT" plot(7) = gsn_csm_contour_map_overlay(wks,prcptothrc_mask,prcptoth_sig,res,res3) ;res@tiMainString = "NOAA" ; plot(8) = gsn_csm_contour_map_overlay(wks,trnoaahrc_mask,trnoaah_sig,res,res3) plot1 =new(8, graphic) res@cnLevelSelectionMode = "ManualLevels" ; set manual contour levels res@cnMinLevelValF = 0. ; set min contour level res@cnMaxLevelValF = 2. ; set max contour level res@cnLevelSpacingF = 0.2 ; set contour interval res@tiMainString = "RX1DAY" plot1(0) = gsn_csm_contour_map_overlay(wks,rx1dayprc_mask,rx1dayp_sig,res,res3) res@tiMainString = "RX5DAY" plot1(1) = gsn_csm_contour_map_overlay(wks,rx5dayprc_mask,rx5dayp_sig,res,res3) res@tiMainString = "SDII" plot1(2) = gsn_csm_contour_map_overlay(wks,sdiprc_mask,sdiip_sig,res,res3) res@tiMainString = "R10MM" plot1(3) = gsn_csm_contour_map_overlay(wks,r10mmprc_mask,r10mmp_sig,res,res3) res@tiMainString = "R20MM" plot1(4) = gsn_csm_contour_map_overlay(wks,r20mmprc_mask,r20mmp_sig,res,res3) res@tiMainString = "CDD" plot1(5) = gsn_csm_contour_map_overlay(wks,cddprc_mask,cddp_sig,res,res3) res@tiMainString = "CWD" plot1(6) = gsn_csm_contour_map_overlay(wks,cwdprc_mask,cwdp_sig,res,res3) res@tiMainString = "PRCPTOT" plot1(7) = gsn_csm_contour_map_overlay(wks,prcptotprc_mask,prcptotp_sig,res,res3) ;res@tiMainString = "NOAA" ; plot1(8) = gsn_csm_contour_map_overlay(wks,trnoaaprc_mask,trnoaap_sig,res,res3) ;---Add Nigeria shapefile outlines to the plot. lnres = True lnres@gsLineColor = "gray25" lnres@gsLineThicknessF = 2.0 id_mask=new(8,graphic) id_mask1=new(8,graphic) do i=0,7 id_mask(i) = gsn_add_shapefile_polylines(wks,plot(i),shp_filename,lnres) id_mask1(i) = gsn_add_shapefile_polylines(wks,plot1(i),shp_filename,lnres) end do ;--Panel res pres = True pres@gsnMaximize = True pres@gsnPanelLabelBar = True pres@gsnPanelMainString = "Historical Precip Indices" gsn_panel(wks,plot,(/3,3/),pres) pres@gsnPanelMainString = "Projected Precip Indices" gsn_panel(wks,plot1,(/3,3/),pres) res@cnLevelSelectionMode = "ManualLevels" ; set manual contour levels res@cnMinLevelValF = 0. ; set min contour level res@cnMaxLevelValF = 100. ; set max contour level res@cnLevelSpacingF = 10 ; set contour interval res@cnFillPalette = "spread_15lev" plot2 = new(8,graphic) plot3 = new(8,graphic) res@tiMainString = "RX1DAY" plot2(0) =gsn_csm_contour_map_ce(wks,rx1daynfA_mask,res) res@tiMainString = "RX5DAY" plot2(1) =gsn_csm_contour_map_ce(wks,rx5daynfA_mask,res) res@tiMainString = "SDII" plot2(2) =gsn_csm_contour_map_ce(wks,sdiinfA_mask,res) res@tiMainString = "R10MM" plot2(3) =gsn_csm_contour_map_ce(wks,r10mmnfA_mask,res) res@tiMainString = "R20MM" plot2(4) =gsn_csm_contour_map_ce(wks,r20mmnfA_mask,res) res@tiMainString = "CDD" plot2(5) =gsn_csm_contour_map_ce(wks,cddnfA_mask,res) res@tiMainString = "CWD" plot2(6) =gsn_csm_contour_map_ce(wks,cwdnfA_mask,res) res@tiMainString = "PRCPTOT" plot2(7) =gsn_csm_contour_map_ce(wks,trnccnfA_mask,res) ;res@tiMainString = "NOAA" ;plot2(8) =gsn_csm_contour_map_ce(wks,trnoaanfA_mask,res) ;====== res@tiMainString = "RX1DAY" plot3(0) =gsn_csm_contour_map_ce(wks,rx1dayffA_mask,res) res@tiMainString = "RX5DAY" plot3(1) =gsn_csm_contour_map_ce(wks,rx5dayffA_mask,res) res@tiMainString = "SDII" plot3(2) =gsn_csm_contour_map_ce(wks,sdiiffA_mask,res) res@tiMainString = "R10MM" plot3(3) =gsn_csm_contour_map_ce(wks,r10mmffA_mask,res) res@tiMainString = "R20MM" plot3(4) =gsn_csm_contour_map_ce(wks,r20mmffA_mask,res) res@tiMainString = "CDD" plot3(5) =gsn_csm_contour_map_ce(wks,cddffA_mask,res) res@tiMainString = "CWD" plot3(6) =gsn_csm_contour_map_ce(wks,cwdffA_mask,res) res@tiMainString = "PRCPTOT" plot3(7) =gsn_csm_contour_map_ce(wks,trnccffA_mask,res) ;res@tiMainString = "NOAA" ;plot2(8) =gsn_csm_contour_map_ce(wks,trnoaanfA_mask,res) id_mask2=new(8,graphic) id_mask3=new(8,graphic) do i=0,7 id_mask2(i) = gsn_add_shapefile_polylines(wks,plot2(i),shp_filename,lnres) id_mask3(i) = gsn_add_shapefile_polylines(wks,plot3(i),shp_filename,lnres) end do ;--Panel res pres = True pres@gsnMaximize = True pres@gsnPanelLabelBar = True pres@gsnPanelMainString = "RCP45 Near Future - Hist Precip Indices" gsn_panel(wks,plot2,(/3,3/),pres) pres@gsnPanelMainString = "RCP45 Far Future - Hist Precip Indices" gsn_panel(wks,plot3,(/3,3/),pres) end