[ncl-talk] Creating variables automatically
Mateus da Silva Teixeira
mateusstex at gmail.com
Tue Oct 9 04:58:19 MDT 2018
Thank you Rick, I'll test it.
Best regards,
Mateus
Em seg, 8 de out de 2018 às 18:17, Rick Brownrigg <brownrig at ucar.edu>
escreveu:
> One can't create variables in that way. However, you can create
> attributes, so using your example, something like:
>
> res = True ; arbitrary value
> *do i = 1, 5*
> * varname = "cases_"+sprinti("%i",i)+"days"*
> * res@$varname$ = new( (/ nlat, nlon /), "float" )*
>
> * res@$varname$ = dim_avg_n( slp( idxCases, :, : ), 0 )*
> *end do*
>
> *Hope that helps...*
>
> *Rick*
>
> On Mon, Oct 8, 2018 at 3:08 PM Mateus da Silva Teixeira <
> mateusstex at gmail.com> wrote:
>
>> Hi,
>>
>> Can I use string reference to create different variables in NCL?
>>
>> I'm trying it
>>
>> *do i = 1, 5*
>> * varname = "cases_"+sprinti("%i",i)+"days"*
>> * $varname$ = new( (/ nlat, nlon /), "float" )*
>>
>> * $varname$ = dim_avg_n( slp( idxCases, :, : ), 0 )*
>> *end do*
>>
>> But NCL is giving syntax error. It seems that I can't use string
>> references that way. So, would there be a way to do this?
>>
>> Thanks.
>>
>> Mateus
>>
>> _______________________________________________
>> 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/20181009/af5bfb65/attachment.html>
More information about the ncl-talk
mailing list