[ncl-talk] sum of some dimension of an array

ABDULLA SAKALLI abdulla.sakalli at iste.edu.tr
Mon May 11 10:04:15 MDT 2020


Thank you very much (Shukran) Rashed,
I’m trying the first suggestion. And then, I’ll try the second one. 

I’ll let you know about the results.

Best wishes,
Abdulla

> On 11 May 2020, at 19:00, Rashed Mahmood <rashidcomsis at gmail.com> wrote:
> 
> Or a more clear way could be:
> 
> do t=0,35
> 	z=0
> 	nw=0.
> 	do i=0,30
> 		z=z+1
> 		nva=where(veg.eq.z, nwp(t,:,:), 0.)
>                 nv  = tofloat(sum(nva))
>                 delete(nva)
>         ;nwpveg(t,i)=nv
> 	print(z+" "+nv)
>  end do
> end do
> 
> 
> On Mon, May 11, 2020 at 8:47 AM Rashed Mahmood <rashidcomsis at gmail.com <mailto:rashidcomsis at gmail.com>> wrote:
> Hi Abdullah,
> I think the following may work, make sure that is what you want?:
> See the red colour since nwp is 3D so you may want to assign "t" in first argument...double check.
> do t=0,35
> 	z=0
> 	nw=0.
> 	do i=0,30
> 		z=z+1
> 		nv=where(veg.eq.z, doubletofloat(dim_sum_n(nwp(t,:,:),(/1,2/))), 0.)
> 		;nwpveg(t,i)=nv
> 		;print(z+" "+nv)
> 	end do
> end do
> 
> On Mon, May 11, 2020 at 6:06 AM ABDULLA SAKALLI via ncl-talk <ncl-talk at ucar.edu <mailto:ncl-talk at ucar.edu>> wrote:
> Dear Lists,
> I’ve two arrays that I should compare them and add the value of the second array where the first array match some conditions. 
> The array one is:
> Variable: veg
> Type: integer
> Total Size: 1036800 bytes
>             259200 values
> Number of Dimensions: 2
> Dimensions and sizes:	[360] x [720]
> Coordinates:
> Number Of Attributes: 1
>   _FillValue :	-2147483647
> 
> The array two is:
> Variable: nwp
> Type: double
> Total Size: 74649600 bytes
>             9331200 values
> Number of Dimensions: 3
> Dimensions and sizes:	[time | 36] x [lat | 360] x [lon | 720]
> Coordinates:
>             time: [183.5..12967]
>             lat: [-89.5..90]
>             lon: [-179.5..180]
> Number Of Attributes: 4
>   units :	mm
>   _FillValue :	-9999
>   missing_value :	-9999
> 
> The first array contains 31 vegetation types. I’d like to get the sum of the all nwp points classified according to the veg array.
> 
> My loop looks like:
> 
> do t=0,35
> 	z=0
> 	nw=0.
> 	do i=0,30
> 		z=z+1
> 		nv=where(veg.eq.z, doubletofloat(dim_sum_n(nwp,(/1,2/))), 0.)
> 		;nwpveg(t,i)=nv
> 		;print(z+" "+nv)
> 	end do
> end do
> 
> by running the code I got the error messages
> fatal:where: condition variable (parameter 0) dimension mismatch with parameter 1
> fatal:["Execute.c":8637]:Execute: Error occurred at or near line 77 in file ReadNcFiles-VegNr-0p5deg.ncl
> 
> Does anyone of you have an idea, how can I solve this problem? or better to say, how can I get the increment of the nwp array when the veg array equal to 1 to 31 one.
> 
> Best wishes,
> Abdulla
> 
> ---------------------------------------------------------------------------
> Assoc. Prof. Abdulla Sakalli
> 
> Iskenderun Technical University
> Faculty of Engineering and Natural Sciences
> Dept. Industrial Engineering
> Merkez Kampus
> Iskenderun-Hatay-Turkey
> as at abdulla-sakalli.com <mailto:as at abdulla-sakalli.com>
> abdulla.sakalli at iste.edu.tr <mailto:abdulla.sakalli at iste.edu.tr>
> +90 326 613 5600/4313
> +90 536 506 9191
> 
> 
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu <mailto:ncl-talk at ucar.edu>
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk <http://mailman.ucar.edu/mailman/listinfo/ncl-talk>
---------------------------------------------------------------------------
Assoc. Prof. Abdulla Sakalli

Iskenderun Technical University
Faculty of Engineering and Natural Sciences
Dept. Industrial Engineering
Merkez Kampus
Iskenderun-Hatay-Turkey
as at abdulla-sakalli.com
abdulla.sakalli at iste.edu.tr
+90 326 613 5600/4313
+90 536 506 9191


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20200511/1a48e3e9/attachment-0001.html>


More information about the ncl-talk mailing list