;************************************************* ; regress_2.ncl ; ; Concepts illustrated: ; - Drawing color-filled contours over a cylindrical equidistant map ; - Calculating the regression coefficient ; - Copying attributes from one variable to another ; ;************************************************* 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" begin ;************************************************ ; create pointer to file and read in temperature ;************************************************ in = addfile("b003_TS_200-299.nc","r") tmp = in->TS ts = tmp(lat|:,lon|:,time|:) ; reorder variable ;************************************************ ; create x and calculate the regression coefficient ; note regline works on one dimensional arrays. ;************************************************ x = ispan(0,dimsizes(ts&time)-1,1)*1. rc = regCoef(x,ts) rc@long_name = "regression coefficient" rc@units = "unitless" copyatt(rc,ts) ; copy other atts and cv's ;************************************************ ; plotting parameters ;************************************************ wks = gsn_open_wks("ps","regress") ; specifies a ps plot gsn_define_colormap(wks,"ViBlGrWhYeOrRe") ; choose colormap res = True ; plot mods desired res@cnFillOn = True ; turn on color res@cnLinesOn = False ; turn off contour lines res@gsnSpreadColors = True ; use full range of color map res@lbLabelStride = 2 ; label bar stride res@cnLevelSelectionMode = "ManualLevels" ; set manual contour levels res@cnMinLevelValF = -0.04 ; set min contour level res@cnMaxLevelValF = 0.04 ; set max contour level res@cnLevelSpacingF = 0.005 ; set contour interval res@tiMainString = "Regress wrt 100 time steps" plot = gsn_csm_contour_map_ce(wks,rc,res) ; create a default plot end