[ncl-talk] index lists in assignment
Axel Seifert
Axel.Seifert at dwd.de
Thu Nov 29 10:37:22 MST 2018
Maybe I should add that the output of my little script is
(0) 0 0
(1) 3 4
(2) 2 2
This is with NCAR Command Language Version 6.3.0
The variables x and y are
Variable: x
Type: float
Total Size: 12 bytes
3 values
Number of Dimensions: 1
Dimensions and sizes: [3]
Coordinates:
Number Of Attributes: 1
_FillValue : 9.96921e+36
(0) 0
(1) 3
(2) 2
Variable: y
Type: float
Total Size: 12 bytes
3 values
Number of Dimensions: 1
Dimensions and sizes: [3]
Coordinates:
Number Of Attributes: 1
_FillValue : 9.96921e+36
(0) 0
(1) 4
(2) 2
Am 24.11.2018 um 15:16 schrieb Seifert Axel:
>
>
> Hi,
>
>
> I have a somewhat unexpected behavior when using index lists. Here a
> simplified example:
>
>
> x = new( 3, float)
> x = 0.0
> y = x
> z = (/1.,2.,3./)
> idx = (/1,2,1/)
> x(idx) = x(idx) + z
>
> do i=0,dimsizes(idx)-1
> y(idx(i)) = y(idx(i)) + z(i)
> end do
>
> print(" "+x+" "+y)
>
> I would have expected that x and y end up being the same, but they are
> not. The double assignment to index 1 does not work for the vector
> assignment. Is this the intended behavior for arrays in ncl?
>
> How can I get the 2nd behavior and still avoid the do-loop?
>
> In my case I am assigning measured values from satellite overpasses to
> a global grid and it can of course happen that I have multiple
> overpasses for a grid point in an observation vector. Hence, in
> addition to the sum of the values I would count the number of overpasses
>
> cnt = (/0,0,0/)
> cnt(idx) = cnt(idx) + 1
> print(" "+cnt)
>
> and then xavg = x/cnt should give me the proper average for, for
> example, one hour of data. What I need in the end is the correct
> average for xavg and the number of measurements used at each grid point.
>
> Thanks in advance for any helpful comments and suggestions.
>
> Axel
>
>
>
>
>
>
>
> _______________________________________________
> 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/20181129/9175f26b/attachment-0001.html>
More information about the ncl-talk
mailing list