<div dir="ltr"><div>Or a more clear way could be:</div><div><br></div><div>
<div><span class="gmail-im"><div>do t=0,35</div><div><span style="white-space:pre-wrap"> </span>z=0</div><div><span style="white-space:pre-wrap"> </span>nw=0.</div><div><span style="white-space:pre-wrap"> </span>do i=0,30</div><div><span style="white-space:pre-wrap"> </span>z=z+1</div></span><div><span style="white-space:pre-wrap"> </span>nva=where(veg.eq.z, <span style="color:rgb(255,0,0)"><b>nwp(t,:,:)</b></span>, 0.)</div><span class="gmail-im"><div><span style="white-space:pre-wrap"></span></div><div><span style="white-space:pre-wrap"> nv = tofloat(sum(nva))</span></div><div><span style="white-space:pre-wrap"> delete(nva)
<span class="gmail-im"><div> ;nwpveg(t,i)=nv</div><div><span style="white-space:pre-wrap"> </span>print(z+" "+nv)</div></span> </span>end do</div><div>end do</div></span></div>
</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, May 11, 2020 at 8:47 AM Rashed Mahmood <<a href="mailto:rashidcomsis@gmail.com">rashidcomsis@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hi Abdullah,</div><div>I think the following may work, make sure that is what you want?:</div><div>See the red colour since nwp is 3D so you may want to assign "t" in first argument...double check.<br></div><div>
<div><div>do t=0,35</div><div><span style="white-space:pre-wrap"> </span>z=0</div><div><span style="white-space:pre-wrap"> </span>nw=0.</div><div><span style="white-space:pre-wrap"> </span>do i=0,30</div><div><span style="white-space:pre-wrap"> </span>z=z+1</div><div><span style="white-space:pre-wrap"> </span>nv=where(veg.eq.z, doubletofloat(dim_sum_n(<span style="color:rgb(255,0,0)"><b>nwp(t,:,:)</b></span>,(/1,2/))), 0.)</div><div><span style="white-space:pre-wrap"> </span>;nwpveg(t,i)=nv</div><div><span style="white-space:pre-wrap"> </span>;print(z+" "+nv)</div><div><span style="white-space:pre-wrap"> </span>end do</div><div>end do</div></div>
</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, May 11, 2020 at 6:06 AM ABDULLA SAKALLI via ncl-talk <<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>Dear Lists,<div>I’ve two arrays that I should compare them and add the value of the second array where the first array match some conditions. </div><div>The array one is:</div><blockquote style="margin:0px 0px 0px 40px;border:medium none;padding:0px"><div><div><span style="font-size:9px">Variable: veg</span></div><div><span style="font-size:9px">Type: integer</span></div><div><span style="font-size:9px">Total Size: 1036800 bytes</span></div><div><span style="font-size:9px"> 259200 values</span></div><div><span style="font-size:9px">Number of Dimensions: 2</span></div><div><span style="font-size:9px">Dimensions and sizes:<span style="white-space:pre-wrap"> </span>[360] x [720]</span></div><div><span style="font-size:9px">Coordinates:</span></div><div><span style="font-size:9px">Number Of Attributes: 1</span></div><div><span style="font-size:9px"> _FillValue :<span style="white-space:pre-wrap"> </span>-2147483647</span></div></div></blockquote><div><br></div><div>The array two is:</div><blockquote style="margin:0px 0px 0px 40px;border:medium none;padding:0px"><div><div><i style="font-size:9px">Variable: nwp</i></div></div><div><div><i style="font-size:9px">Type: double</i></div></div><div><div><i style="font-size:9px">Total Size: 74649600 bytes</i></div></div><div><div><i style="font-size:9px"> 9331200 values</i></div></div><div><div><i style="font-size:9px">Number of Dimensions: 3</i></div></div><div><div><i style="font-size:9px">Dimensions and sizes:<span style="white-space:pre-wrap"> </span>[time | 36] x [lat | 360] x [lon | 720]</i></div></div><div><div><i style="font-size:9px">Coordinates:</i></div></div><div><div><i style="font-size:9px"> time: [183.5..12967]</i></div></div><div><div><i style="font-size:9px"> lat: [-89.5..90]</i></div></div><div><div><i style="font-size:9px"> lon: [-179.5..180]</i></div></div><div><div><i style="font-size:9px">Number Of Attributes: 4</i></div></div><div><div><i style="font-size:9px"> units :<span style="white-space:pre-wrap"> </span>mm</i></div></div><div><div><i style="font-size:9px"> _FillValue :<span style="white-space:pre-wrap"> </span>-9999</i></div></div><div><div><i style="font-size:9px"> missing_value :<span style="white-space:pre-wrap"> </span>-9999</i></div></div></blockquote><div><br></div><div>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.</div><div><br></div><div>My loop looks like:</div><div><br></div><div><div>do t=0,35</div><div><span style="white-space:pre-wrap"> </span>z=0</div><div><span style="white-space:pre-wrap"> </span>nw=0.</div><div><span style="white-space:pre-wrap"> </span>do i=0,30</div><div><span style="white-space:pre-wrap"> </span>z=z+1</div><div><span style="white-space:pre-wrap"> </span>nv=where(veg.eq.z, doubletofloat(dim_sum_n(nwp,(/1,2/))), 0.)</div><div><span style="white-space:pre-wrap"> </span>;nwpveg(t,i)=nv</div><div><span style="white-space:pre-wrap"> </span>;print(z+" "+nv)</div><div><span style="white-space:pre-wrap"> </span>end do</div><div>end do</div></div><div><br></div><div>by running the code I got the error messages</div><div><div><font size="1"><i>fatal:where: condition variable (parameter 0) dimension mismatch with parameter 1</i></font></div><div><font size="1"><i>fatal:["Execute.c":8637]:Execute: Error occurred at or near line 77 in file ReadNcFiles-VegNr-0p5deg.ncl</i></font></div></div><div><br></div><div>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.</div><div><br></div><div>Best wishes,</div><div>Abdulla</div><div><br><div>
<div dir="auto" style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><div dir="auto" style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><div><font color="#585858">---------------------------------------------------------------------------<br>Assoc. Prof. Abdulla Sakalli<br><br>Iskenderun Technical University<br>Faculty of Engineering and Natural Sciences<br>Dept. Industrial Engineering<br>Merkez Kampus<br>Iskenderun-Hatay-Turkey<br><a href="mailto:as@abdulla-sakalli.com" target="_blank">as@abdulla-sakalli.com</a><br><a href="mailto:abdulla.sakalli@iste.edu.tr" target="_blank">abdulla.sakalli@iste.edu.tr</a><br>+90 326 613 5600/4313<br>+90 536 506 9191<br></font><br></div></div></div>
</div>
<br></div></div>_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a></blockquote></div>
</blockquote></div>