[ncl-talk] ncl-talk Digest, Vol 180, Issue 52

Baughcum (US), Steven L steven.l.baughcum at boeing.com
Fri Nov 30 14:36:05 MST 2018


Filezilla does not appear to be on software express


-----Original Message-----
From: ncl-talk [mailto:ncl-talk-bounces at ucar.edu] On Behalf Of ncl-talk-request at ucar.edu
Sent: Friday, November 30, 2018 1:10 PM
To: ncl-talk at ucar.edu
Subject: ncl-talk Digest, Vol 180, Issue 52

Send ncl-talk mailing list submissions to
	ncl-talk at ucar.edu

To subscribe or unsubscribe via the World Wide Web, visit
	http://mailman.ucar.edu/mailman/listinfo/ncl-talk
or, via email, send a message with subject or body 'help' to
	ncl-talk-request at ucar.edu

You can reach the person managing the list at
	ncl-talk-owner at ucar.edu

When replying, please edit your Subject line so it is more specific than "Re: Contents of ncl-talk digest..."


Today's Topics:

   1. Re: index lists in assignment (Dennis Shea)
   2. Re: write netcdf (Dennis Shea)
   3. Re: write netcdf (Debasish Hazra)
   4. Re: index lists in assignment (Seifert Axel)


----------------------------------------------------------------------

Message: 1
Date: Fri, 30 Nov 2018 12:21:38 -0700
From: Dennis Shea <shea at ucar.edu>
To: Rick Brownrigg <brownrig at ucar.edu>
Cc: Ncl-talk <ncl-talk at ucar.edu>
Subject: Re: [ncl-talk] index lists in assignment
Message-ID:
	<CAOF1d_7g9jt56i5Gf4+bReP-26e=fNwMGTbuUYyuY6_W+DXd2g at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

My recollection is that the way fortran and NCL handled 'indirect subscripting' (my words) yielded different results.
Hence, the 'expected results' are colored by past expeerience in fortran.

Unfortunately, I can not find my NCL/fortran   example. Sorry.

D


On Fri, Nov 30, 2018 at 11:27 AM Rick Brownrigg <brownrig at ucar.edu> wrote:

> Hi Axel,
>
> Apologies in delay in getting back to you on this.  As far as I can 
> tell, the behavior ox "x(idx) = x(idx) + z" is the intended behavior 
> (perhaps not the same as "desired" behavior in your case), in the 
> sense that the right-hand side is completely evaluated before the 
> (re)assignment to the variable "x": is performed.
>
> The do-loop approach does work -- it it just unbearably slow?  Without 
> knowing more about your data, I don't have a suggestion for how to 
> avoid looping.
>
> Rick
>
>
> On Thu, Nov 29, 2018 at 10:37 AM Axel Seifert <Axel.Seifert at dwd.de> wrote:
>
>>
>> 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 listncl-talk at ucar.edu List instructions, subscriber 
>> options, 
>> unsubscribe:http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
> _______________________________________________
> 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/20181130/6262459e/attachment-0001.html>

------------------------------

Message: 2
Date: Fri, 30 Nov 2018 12:45:23 -0700
From: Dennis Shea <shea at ucar.edu>
To: Toni Klemm <toni-klemm at tamu.edu>
Cc: Ncl-talk <ncl-talk at ucar.edu>
Subject: Re: [ncl-talk] write netcdf
Message-ID:
	<CAOF1d_7gdirqdkd0HiSgNcoSi2h3Z5EZKawdO6zyCcQKRE+0aw at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

[1] Toni's initial comment was correct.
*An attribute can only be assigned to an existing variable.* [2] Your initial execution of

           fout  =* addfile (*"./2016/Regrid/
GPM_3IMERGDL_05_precipitationCal.20160601.nc",* "c")*
     created the netCDF file.

    The "c" creates a new file. If you want to rerun with the same destination name you must

*       system*
<http://www.ncl.ucar.edu/Document/Functions/Built-in/system.shtml>("/bin/rm
-f /2016/Regrid/GPM_3IMERGDL_05_precipitationCal.20160601.nc")   ;
remove any pre-existing file

              fout  =* addfile (*"./2016/Regrid/
GPM_3IMERGDL_05_precipitationCal.20160601.nc",* "c")*

On Fri, Nov 30, 2018 at 11:19 AM Toni Klemm <toni-klemm at tamu.edu> wrote:

> Hi Debasish,
>
> Try taking out the space between *systemfunc* and *(?date?) here:*
>
> fAtt at creation_date = systemfunc ("date")
>
>
> which changes it to this:
>
> fAtt at creation_date = systemfunc("date")
>
>
>
> If that doesn?t solve it, try taking the spaces out of:
>
>  fileattdef( fout, fAtt )
>
>
> to this
>
>  fileattdef(fout,fAtt )
>
>
>
> Good luck,
> Toni
>
>
>
> *Toni Klemm, Ph.D.*Postdoctoral Research Associate Department of 
> Ecosystem Science and Management College of Agriculture and Life 
> Sciences Texas A&M University, College Station, TX Contributor to the 
> Early Career Climate Forum <http://www.eccforum.org> www.toni-klemm.de 
> | @toniklemm <http://twitter.com/toniklemm>
>
>
>
>
>
>
>
>
> On Nov 30, 2018, at 12:09 PM, Debasish Hazra 
> <debasish.hazra5 at gmail.com>
> wrote:
>
> Thanks Toni. I switched the lines, but it still show error at  
> fileattdef( fout, fAtt ) and odes not create netcdf file. I think the 
> problem comes from this line
> :
> fAtt at creation_date = systemfunc ("date") Do I have to define date 
> before ?
> Debasish
>
> On Fri, Nov 30, 2018 at 12:55 PM Toni Klemm <toni-klemm at tamu.edu> wrote:
>
>> Hi Debasish,
>>
>> That?s because you create the variable fAtt *after* you assign it the 
>> creation date. You need to create it *before* you assign any 
>> attributes to it. Just switch these two lines:
>>
>> fAtt at creation_date = systemfunc ("date")
>>
>> fAtt               = True
>>
>>
>> to this
>>
>> fAtt               = True
>>
>> fAtt at creation_date = systemfunc ("date")
>>
>>
>> and it should work.
>>
>>
>> Best of luck,
>> Toni
>>
>>
>>
>> *Toni Klemm, Ph.D.*Postdoctoral Research Associate Department of 
>> Ecosystem Science and Management College of Agriculture and Life 
>> Sciences Texas A&M University, College Station, TX Contributor to the 
>> Early Career Climate Forum 
>> <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.eccforum.org
>> &d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=WsLJ5ywbW3XnTzqo_ETV62H6s1a5bcGg
>> nrpl7xPRfic&m=AhPAW_80wDzCMtnVlNa6lt6ob2Ry8twXpfcse-Zzyo0&s=dkIA-iN1G
>> iZcr9S2dVSIsYTWqjsxn3SBNsX76k0PMPM&e=>
>> www.toni-klemm.de
>> <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.toni-2Dklemm
>> .de&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=WsLJ5ywbW3XnTzqo_ETV62H6s1a5b
>> cGgnrpl7xPRfic&m=AhPAW_80wDzCMtnVlNa6lt6ob2Ry8twXpfcse-Zzyo0&s=VhxrGE
>> Icsx_bmsihHPNLUGS4bru6-0m_Prt036iyrzk&e=>
>>  | @toniklemm
>> <https://urldefense.proofpoint.com/v2/url?u=http-3A__twitter.com_toni
>> klemm&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=WsLJ5ywbW3XnTzqo_ETV62H6s1a
>> 5bcGgnrpl7xPRfic&m=AhPAW_80wDzCMtnVlNa6lt6ob2Ry8twXpfcse-Zzyo0&s=W2NJ
>> GiF2TmAEPo2hBAy4USeevwdcKTq_BjCPqYjQoMY&e=>
>>
>>
>>
>>
>>
>>
>>
>>
>> On Nov 30, 2018, at 11:47 AM, Debasish Hazra 
>> <debasish.hazra5 at gmail.com>
>> wrote:
>>
>> Hi,
>> I am regridding data and trying to write that in netcdf file but 
>> getting error :
>>
>>      data_regrid = ESMF_regrid(data2,opt)
>>       printVarSummary(data_regrid)
>>       printMinMax(data_regrid,0)
>>       ; write netCDF the 'simple' way
>>       start_write_time = get_cpu_time()
>>       fout  = addfile ("./2016/Regrid/ 
>> GPM_3IMERGDL_05_precipitationCal.20160601.nc
>> <https://urldefense.proofpoint.com/v2/url?u=http-3A__GPM-5F3IMERGDL-5
>> F05-5FprecipitationCal.20160601.nc&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&
>> r=WsLJ5ywbW3XnTzqo_ETV62H6s1a5bcGgnrpl7xPRfic&m=m6TpKEa7O0Cj3dUZmxrnP
>> vld1cZSrJU2iAFWlhkU_3c&s=s9u-rRMRy_zB-nNalwPJbIwsn969qj_oSze9O9jJcWE&
>> e=>",
>> "c")
>>       fAtt at creation_date = systemfunc ("date")
>>       fAtt               = True
>>       fAtt at Conventions   = "None"
>>       fAtt at title         = "Regrid: 0.1 to 0.25 grid via ESMF
>> interpolation"
>>       fAtt at source_file   =  "
>> g4.subsetted.GPM_3IMERGDL_05_precipitationCal.20160601.180W_90S_180E_
>> 90N.nc 
>> <https://urldefense.proofpoint.com/v2/url?u=http-3A__g4.subsetted.GPM
>> -5F3IMERGDL-5F05-5FprecipitationCal.20160601.180W-5F90S-5F180E-5F90N.
>> nc&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=WsLJ5ywbW3XnTzqo_ETV62H6s1a5bc
>> Ggnrpl7xPRfic&m=m6TpKEa7O0Cj3dUZmxrnPvld1cZSrJU2iAFWlhkU_3c&s=_wD-kFp
>> aARvGRdB7kAc3f76mIpQWtI5rrl7v1_kGXzI&e=>
>> "
>>       fileattdef( fout, fAtt )
>>       fout->data_regrid = precip
>>       end_write_time = get_cpu_time()
>>
>> But geting the following error : fatal:Variable (fAtt) is undefined, 
>> can not assign attribute (creation_date).Any help on how to fix fAtt error ?
>>
>> Thanks
>> Debasish
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>> <https://urldefense.proofpoint.com/v2/url?u=http-3A__mailman.ucar.edu
>> _mailman_listinfo_ncl-2Dtalk&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=WsLJ
>> 5ywbW3XnTzqo_ETV62H6s1a5bcGgnrpl7xPRfic&m=AhPAW_80wDzCMtnVlNa6lt6ob2R
>> y8twXpfcse-Zzyo0&s=29ChGHh36O1jDtQZPh_lATDDQDZhDZiwN098O0cqZMw&e=>
>>
>>
>>
> _______________________________________________
> 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/20181130/bfdfd8b0/attachment-0001.html>

------------------------------

Message: 3
Date: Fri, 30 Nov 2018 14:45:22 -0500
From: Debasish Hazra <debasish.hazra5 at gmail.com>
To: toni-klemm at tamu.edu
Cc: ncl-talk <ncl-talk at ucar.edu>
Subject: Re: [ncl-talk] write netcdf
Message-ID:
	<CAJ0V9jofXA00w+kRpwaTe0BG5kNjgML7yVrR-Y91G1rxegUaoA at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Thanks Toni. It is working fine now
Debasish

On Fri, Nov 30, 2018 at 1:19 PM Toni Klemm <toni-klemm at tamu.edu> wrote:

> Hi Debasish,
>
> Try taking out the space between *systemfunc* and *(?date?) here:*
>
> fAtt at creation_date = systemfunc ("date")
>
>
> which changes it to this:
>
> fAtt at creation_date = systemfunc("date")
>
>
>
> If that doesn?t solve it, try taking the spaces out of:
>
>  fileattdef( fout, fAtt )
>
>
> to this
>
>  fileattdef(fout,fAtt )
>
>
>
> Good luck,
> Toni
>
>
>
> *Toni Klemm, Ph.D.*Postdoctoral Research Associate Department of 
> Ecosystem Science and Management College of Agriculture and Life 
> Sciences Texas A&M University, College Station, TX Contributor to the 
> Early Career Climate Forum <http://www.eccforum.org> www.toni-klemm.de 
> | @toniklemm <http://twitter.com/toniklemm>
>
>
>
>
>
>
>
>
> On Nov 30, 2018, at 12:09 PM, Debasish Hazra 
> <debasish.hazra5 at gmail.com>
> wrote:
>
> Thanks Toni. I switched the lines, but it still show error at  
> fileattdef( fout, fAtt ) and odes not create netcdf file. I think the 
> problem comes from this line
> :
> fAtt at creation_date = systemfunc ("date") Do I have to define date 
> before ?
> Debasish
>
> On Fri, Nov 30, 2018 at 12:55 PM Toni Klemm <toni-klemm at tamu.edu> wrote:
>
>> Hi Debasish,
>>
>> That?s because you create the variable fAtt *after* you assign it the 
>> creation date. You need to create it *before* you assign any 
>> attributes to it. Just switch these two lines:
>>
>> fAtt at creation_date = systemfunc ("date")
>>
>> fAtt               = True
>>
>>
>> to this
>>
>> fAtt               = True
>>
>> fAtt at creation_date = systemfunc ("date")
>>
>>
>> and it should work.
>>
>>
>> Best of luck,
>> Toni
>>
>>
>>
>> *Toni Klemm, Ph.D.*Postdoctoral Research Associate Department of 
>> Ecosystem Science and Management College of Agriculture and Life 
>> Sciences Texas A&M University, College Station, TX Contributor to the 
>> Early Career Climate Forum 
>> <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.eccforum.org
>> &d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=WsLJ5ywbW3XnTzqo_ETV62H6s1a5bcGg
>> nrpl7xPRfic&m=AhPAW_80wDzCMtnVlNa6lt6ob2Ry8twXpfcse-Zzyo0&s=dkIA-iN1G
>> iZcr9S2dVSIsYTWqjsxn3SBNsX76k0PMPM&e=>
>> www.toni-klemm.de
>> <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.toni-2Dklemm
>> .de&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=WsLJ5ywbW3XnTzqo_ETV62H6s1a5b
>> cGgnrpl7xPRfic&m=AhPAW_80wDzCMtnVlNa6lt6ob2Ry8twXpfcse-Zzyo0&s=VhxrGE
>> Icsx_bmsihHPNLUGS4bru6-0m_Prt036iyrzk&e=>
>>  | @toniklemm
>> <https://urldefense.proofpoint.com/v2/url?u=http-3A__twitter.com_toni
>> klemm&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=WsLJ5ywbW3XnTzqo_ETV62H6s1a
>> 5bcGgnrpl7xPRfic&m=AhPAW_80wDzCMtnVlNa6lt6ob2Ry8twXpfcse-Zzyo0&s=W2NJ
>> GiF2TmAEPo2hBAy4USeevwdcKTq_BjCPqYjQoMY&e=>
>>
>>
>>
>>
>>
>>
>>
>>
>> On Nov 30, 2018, at 11:47 AM, Debasish Hazra 
>> <debasish.hazra5 at gmail.com>
>> wrote:
>>
>> Hi,
>> I am regridding data and trying to write that in netcdf file but 
>> getting error :
>>
>>      data_regrid = ESMF_regrid(data2,opt)
>>       printVarSummary(data_regrid)
>>       printMinMax(data_regrid,0)
>>       ; write netCDF the 'simple' way
>>       start_write_time = get_cpu_time()
>>       fout  = addfile ("./2016/Regrid/ 
>> GPM_3IMERGDL_05_precipitationCal.20160601.nc
>> <https://urldefense.proofpoint.com/v2/url?u=http-3A__GPM-5F3IMERGDL-5
>> F05-5FprecipitationCal.20160601.nc&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&
>> r=WsLJ5ywbW3XnTzqo_ETV62H6s1a5bcGgnrpl7xPRfic&m=m6TpKEa7O0Cj3dUZmxrnP
>> vld1cZSrJU2iAFWlhkU_3c&s=s9u-rRMRy_zB-nNalwPJbIwsn969qj_oSze9O9jJcWE&
>> e=>",
>> "c")
>>       fAtt at creation_date = systemfunc ("date")
>>       fAtt               = True
>>       fAtt at Conventions   = "None"
>>       fAtt at title         = "Regrid: 0.1 to 0.25 grid via ESMF
>> interpolation"
>>       fAtt at source_file   =  "
>> g4.subsetted.GPM_3IMERGDL_05_precipitationCal.20160601.180W_90S_180E_
>> 90N.nc 
>> <https://urldefense.proofpoint.com/v2/url?u=http-3A__g4.subsetted.GPM
>> -5F3IMERGDL-5F05-5FprecipitationCal.20160601.180W-5F90S-5F180E-5F90N.
>> nc&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=WsLJ5ywbW3XnTzqo_ETV62H6s1a5bc
>> Ggnrpl7xPRfic&m=m6TpKEa7O0Cj3dUZmxrnPvld1cZSrJU2iAFWlhkU_3c&s=_wD-kFp
>> aARvGRdB7kAc3f76mIpQWtI5rrl7v1_kGXzI&e=>
>> "
>>       fileattdef( fout, fAtt )
>>       fout->data_regrid = precip
>>       end_write_time = get_cpu_time()
>>
>> But geting the following error : fatal:Variable (fAtt) is undefined, 
>> can not assign attribute (creation_date).Any help on how to fix fAtt error ?
>>
>> Thanks
>> Debasish
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>> <https://urldefense.proofpoint.com/v2/url?u=http-3A__mailman.ucar.edu
>> _mailman_listinfo_ncl-2Dtalk&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=WsLJ
>> 5ywbW3XnTzqo_ETV62H6s1a5bcGgnrpl7xPRfic&m=AhPAW_80wDzCMtnVlNa6lt6ob2R
>> y8twXpfcse-Zzyo0&s=29ChGHh36O1jDtQZPh_lATDDQDZhDZiwN098O0cqZMw&e=>
>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20181130/2c365263/attachment-0001.html>

------------------------------

Message: 4
Date: Fri, 30 Nov 2018 21:09:40 +0000
From: Seifert Axel <Axel.Seifert at dwd.de>
To: Dennis Shea <shea at ucar.edu>, Rick Brownrigg <brownrig at ucar.edu>
Cc: Ncl-talk <ncl-talk at ucar.edu>
Subject: Re: [ncl-talk] index lists in assignment
Message-ID: <1543612189195.98086 at exch.dwd.de>
Content-Type: text/plain; charset="iso-8859-1"


Hi Dennis and Rick,


Thanks for your comments. Yes, the do-loop is kind of slow and would then be the most expensive part of that script. The length of an observation vector is of order 100000 for one hour of satellite data and I have several months of data, which have to be processed for multiple model simulations.


I can probably restructure my data to avoid double indices, or multiple overpasses, in one observation vector. Alternatively, I could simply ignore that slight loss of data. At least, it would always use the newer data and overwrite the older data. This is probably not a bad choice as well.


Axel




________________________________
Von: Dennis Shea <shea at ucar.edu>
Gesendet: Freitag, 30. November 2018 20:21
An: Rick Brownrigg
Cc: Axel.Seifert at dwd.de; Ncl-talk
Betreff: Re: [ncl-talk] index lists in assignment

My recollection is that the way fortran and NCL handled 'indirect subscripting' (my words) yielded different results.
Hence, the 'expected results' are colored by past expeerience in fortran.

Unfortunately, I can not find my NCL/fortran   example. Sorry.

D


On Fri, Nov 30, 2018 at 11:27 AM Rick Brownrigg <brownrig at ucar.edu<mailto:brownrig at ucar.edu>> wrote:
Hi Axel,

Apologies in delay in getting back to you on this.  As far as I can tell, the behavior ox "x(idx) = x(idx) + z" is the intended behavior (perhaps not the same as "desired" behavior in your case), in the sense that the right-hand side is completely evaluated before the (re)assignment to the variable "x": is performed.

The do-loop approach does work -- it it just unbearably slow?  Without knowing more about your data, I don't have a suggestion for how to avoid looping.

Rick


On Thu, Nov 29, 2018 at 10:37 AM Axel Seifert <Axel.Seifert at dwd.de<mailto:Axel.Seifert at dwd.de>> wrote:


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<mailto:ncl-talk at ucar.edu>
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk<https://ssi.dwd.de/mailman/listinfo/,DanaInfo=.ambkoqftG2lk2Lrr9+ncl-talk>


_______________________________________________
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<https://ssi.dwd.de/mailman/listinfo/,DanaInfo=.ambkoqftG2lk2Lrr9+ncl-talk>
_______________________________________________
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<https://ssi.dwd.de/mailman/listinfo/,DanaInfo=.ambkoqftG2lk2Lrr9+ncl-talk>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20181130/f2a7742f/attachment.html>

------------------------------

Subject: Digest Footer

_______________________________________________
ncl-talk mailing list
ncl-talk at ucar.edu
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk


------------------------------

End of ncl-talk Digest, Vol 180, Issue 52
*****************************************


More information about the ncl-talk mailing list