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

Rashed Mahmood rashidcomsis at gmail.com
Mon May 11 09:47:19 MDT 2020


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> 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
> abdulla.sakalli at iste.edu.tr
> +90 326 613 5600/4313
> +90 536 506 9191
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20200511/d0e2c66b/attachment.html>


More information about the ncl-talk mailing list