[ncl-talk] unable to plot correlation
Ipshita Majhi
ipmajhi at alaska.edu
Tue Feb 23 15:27:32 MST 2016
Dear NCL,
I used escorc to calculate correlation. The lat and lon dimension of the
two variables are different so the correlation output had four dimension.
How can i resolve it. Thank you, listed below is the code:-
;********************************************
;Reading in monthly mean and original weekly data
;for sce
;********************************************
a=addfile("~/Documents/NCL_files/Snow_cover_IMS/NCL_codes/sce_mon_mean.nc","r")
; open output netCDF file
b=addfile("~/Documents/NCL_files/Sea_ice/nhsce_v01r01_19661004_20140602.nc
","r")
;Extracting time and snow cover extent (sce) from respective data files
sce=byte2flt(a->sce)
sce at _FillValue = 0
sce!1="lat"
sce!2="lon"
lat=b->latitude
lon=b->longitude
sce at lat2d=lat
sce at lon2d=lon
;*********************************************
;*********************************************
;Reading in Sea ice data
;*********************************************
c=addfile("~/Documents/NCL_files/Sea_ice/HadISST_ice.nc","r")
lat_sic=c->latitude
lon_sic=c->longitude
sic=c->sic
;Extracting 1967-2012
sic_1967_2012=sic(1164:1715,:,:)
copy_VarAtts(sic,sic_1967_2012)
copy_VarCoords_1(sic,sic_1967_2012)
;*******************************************
;*******************************************
;Detrending and reording both the datasets
;*******************************************
jan_sce = new((/46,88,88/),float)
jan_sic=new((/46,180,360/),float)
jan_sce at _FillValue = -0.99
jan_sic at _FillValue= -1e+30
jan_sce at lat2d=lat
jan_sce at lon2d=lon
;*****************************************
;*****************************************
;Extracting monthly data for sce
;*****************************************
do nyr=0,551,12
jan_sce(nyr/12,:,:) =sce(nyr,:,:)
jan_sic(nyr/12,:,:)=sic_1967_2012(nyr,:,:)
end do
;****************************************
;****************************************
;Reordering
jan_reorder_sce=jan_sce(lat|:,lon|:,time|:); Dimension is (88,88,:)
jan_reorder_sic=jan_sic(latitude|:,longitude|:,time|:); Dimension is
(180,360,:)
;****************************************
;****************************************
;Detrending now
;****************************************
jan_sce_dt=dtrend(jan_reorder_sce,False)
jan_sic_dt=dtrend(jan_reorder_sic,False)
;****************************************
;****************************************
;Correlation coefficient
jan_ccr = escorc(jan_sce_dt,jan_sic_dt)
print(jan_ccr)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160223/bde7dec7/attachment.html
More information about the ncl-talk
mailing list