[ncl-talk] convert string to variable name
Adam Phillips
asphilli at ucar.edu
Fri Aug 28 10:13:57 MDT 2015
Hi Zhifeng,
The short (unfortunate) answer is no, you cannot use dynamical variable
names. This is a commonly requested feature. If you search for "dynamic
variable naming" on the NCL website you will see a few of the ncl-talk
queries on this subject and you can see if any of those responses can
assist.
Hope that helps.
Adam
On Fri, Aug 28, 2015 at 9:58 AM, Zhifeng Yang <yangzf01 at gmail.com> wrote:
> Hi
>
> I wanted to change variable names through strings. Since I use the similar
> property while I read variable from .nc file. For instance,
> a = "var"
> b = addfile(filename + ".nc", "r")
> c = b->$a$
> In this case, I can change a to change the variable names.
>
> Now I wanted to use the similar feature to modify variable names. For
> instance,
> a is a string,
> a = "var"
>
> b is a variable. I want to modify b by using
> b = $a + "a01"$
>
> Unfortunately, I got the error below.
>
> fatal:syntax error: line 1 before or near $
> b = $
>
> Do you know whether these is any way to change the variable name like what
> I want?
>
> Thank you
> Zhifeng
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
--
Adam Phillips
Associate Scientist, Climate and Global Dynamics Laboratory, NCAR
www.cgd.ucar.edu/staff/asphilli/ 303-497-1726
<http://www.cgd.ucar.edu/staff/asphilli>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150828/9106f9b8/attachment.html
More information about the ncl-talk
mailing list