[ncl-talk] Solved: Biome sums

Jiang, Lifen lfjiang at ou.edu
Fri Feb 27 08:41:31 MST 2015


Sorry that this problem has been fixed. Please ignore my previous email.

Lifen
________________________________
From: ncl-talk-bounces at ucar.edu [ncl-talk-bounces at ucar.edu] on behalf of Jiang, Lifen [lfjiang at ou.edu]
Sent: Friday, February 27, 2015 9:21 AM
To: ncl-talk at ucar.edu
Subject: [ncl-talk] Biome sums

Hello,

I am computing the sums of variable “ESMF_sftlf_regrid” in the file “bcc” at each biome. Types of biomes was defined as “var2d” in the file “pft”.

I am expecting it will return ten different values (10 types of biomes). But it returned ten same values and with the error massage:

fatal:["NclVar.c":1376]:Assignment type mismatch, right hand side can't be coerced to type of left hand side
fatal:Execute: Error occurred at or near line 41 in file BiomeTotals_CMIP5.ncl

I have attached my code below and my data files.

I appreciate if someone can help figure out the problems in the code.

Thanks,

Lifen

***************

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 "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"


in1 = addfile("bcc.nc","r")
in2 = addfile("pft.nc","r")
t1 = in1->ESMF_sftlf_regrid
t0 = in2->var2d

t2 = t0(lat|:,lon|:) ; reorder

t1 = lonFlip(t1)
t2 = lonFlip(t2)
printVarSummary(t1)
printVarSummary(t2)

lat = in1->lat
lon = in1->lon

bc_density = new(dimsizes(t1),typeof(t1))
bc_sum = new(10,typeof(t2))
do i = 0, 9
bc_density = where(t2.eq. i, t1, bc_density at _FillValue) ; bc_density will be overwritten at each iteration of the loop
re   = 6.37122e06

rad  = 4.0 * atan(1.0) / 180.0
con  = re * rad
clat = cos(lat * rad)           ; cosine of latitude

dlon = (lon(2) - lon(1))        ; assume dlon is constant
dlat = (lat(2) - lat(1))        ; assume dlat is constant

dx   = con * dlon * clat        ; dx at each latitude
dy   = con * dlat               ; dy is constant
dxdy = dx * dy                  ; dxdy(nlat)
dydx = dy * dx                  ; dydx(nlat)

wgt  = new((/180, 360/), typeof(t1))
wgt  = conform(wgt, dxdy, 0)
bc_sum(i) = wgt_areasum2(bc_density, wgt, 0)
print(bc_sum(i))
end do

print(bc_sum)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150227/8cb3ae70/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bcc.nc
Type: application/octet-stream
Size: 264744 bytes
Desc: bcc.nc
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150227/8cb3ae70/attachment-0002.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pft.nc
Type: application/octet-stream
Size: 523012 bytes
Desc: pft.nc
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150227/8cb3ae70/attachment-0003.obj 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ATT00001.txt
Url: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150227/8cb3ae70/attachment-0001.txt 


More information about the ncl-talk mailing list