<div dir="ltr"><div>Hi Tabish,</div><div>Your variable S is essentially a new string variable so it is not going to represent your level variable names.</div><div><br></div><div>One way to do this is to use ListPush and ListPop : <a href="https://www.ncl.ucar.edu/Document/Functions/Built-in/ListPush.shtml">https://www.ncl.ucar.edu/Document/Functions/Built-in/ListPush.shtml</a></div><div>e.g. after defining levels:<br></div><div><br></div><div>lev_list = NewList("fifo")</div><div><br></div><div>ListPush(lev_list, lev21)</div><div>ListPush(lev_list, lev22)</div><div></div><div>...</div><div>ListPush(lev_list, lev31)</div><div><br></div><div>levels := ListPop(lev_list)</div><div>res@cnLevels := levels<br></div><div><br></div><div>I guess there are other methods for listing variables, but I think this should work.</div><div><br></div><div>Cheers,</div><div>Rashed<br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Nov 6, 2021 at 3:19 PM Tabish Ansari via ncl-talk <<a href="mailto:ncl-talk@mailman.ucar.edu">ncl-talk@mailman.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 dir="ltr"><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">Hi</div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif"><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">I'm using an NCL script to create contour plots for different days where everything but the contour levels remain the same. I have already defined the contour levels explicitly for all the days but I don't want to comment/uncomment them each time I run the script for different days. So, I'm looking for a more efficient way to do it.</div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif"><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">Here's the code snippet:</div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">=======================================================================</div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif"> lev21 = (/ 5,10,15,20,25,30,35/) ; set levels for 21Oct<br> lev22 = (/ 25,30,35,40,45,50,55,60,65,70,75,80,85/) ; set levels for 22Oct<br> lev23 = (/ 25,50,75,100,125,150,175,200/) ; set levels for 23Oct<br> lev24 = (/ 75,100,125,150,175,200,225,250,275,300/) ; set levels for 24Oct<br> lev25 = (/ 75,100,125,150,175,200,225,250,275/) ; set levels for 25Oct<br> lev26 = (/ 5,10,15,20,25,30,35/) ; set levels for 26Oct<br> lev27 = (/ 5,10,15,20,25,30,35,40,45,50/) ; set levels for 27Oct<br> lev28 = (/ 25,30,35,40,45,50,55,60,65,70,75,80,85/) ; set levels for 28Oct<br> lev29 = (/ 25,50,75,100,125,150,175/) ; set levels for 29Oct<br> lev30 = (/ 75,100,125,150,175,200,225,250,275/) ; set levels for 30Oct<br> lev31 = (/ 25,50,75,100,125,150,175,200/) ; set levels for 31Oct<br><br> N = day + 21<br> S = "lev"+N<br> print(S)<br> res@cnLevels = $S$<br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">==========================================================================</div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif"><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">Here, I'm just setting the value for "day" between 0 and 10 and I'm able to create a string S with exactly the same name as those arrays that I have defined, which contain the contour levels. But NCL won't accept a string as a variable name. Is there anyway around this?</div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif"><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">Thank you</div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif"><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">Tabish</div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif"><br></div><div><div dir="ltr"><div dir="ltr"><div><i><span style="color:rgb(68,68,68)"><font face="tahoma, sans-serif">----------------------------------------------------------<br><span style="background-color:rgb(255,255,255)">Dr <a href="https://www.rug.nl/staff/t.u.ansari/" target="_blank">Tabish U Ansari</a></span></font></span></i></div><div><i><span style="color:rgb(68,68,68)"><span style="background-color:rgb(255,255,255)"><font face="tahoma, sans-serif">Assistant Professor - Earth & Energy</font></span></span></i></div><div><i><span style="color:rgb(68,68,68)"><span style="background-color:rgb(255,255,255)"><font face="tahoma, sans-serif">University of Groningen - <span style="font-weight:normal"><a href="https://www.rug.nl/cf/?lang=en" target="_blank">Campus Fryslân</a><br></span></font></span></span></i></div><div><i><span style="color:rgb(68,68,68)"><span style="background-color:rgb(255,255,255)"><span style="font-weight:normal"><font face="tahoma, sans-serif">Leeuwarden, the Netherlands<br></font></span></span></span></i></div><i><span style="color:rgb(68,68,68)"><span style="font-weight:normal"><span style="background-color:rgb(255,255,255)"><font face="tahoma, sans-serif"><a href="https://www.researchgate.net/profile/Tabish_Ansari" target="_blank">ResearchGate</a> | <a href="https://scholar.google.com/citations?user=E94r-mwAAAAJ&hl=en&oi=ao" target="_blank">Google Scholar</a> | <a href="https://twitter.com/tabishbiet" target="_blank">Twitter</a> </font><font face="comic sans ms, sans-serif"><span></span></font></span></span></span></i></div></div></div></div>
_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@mailman.ucar.edu" target="_blank">ncl-talk@mailman.ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="https://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">https://mailman.ucar.edu/mailman/listinfo/ncl-talk</a></blockquote></div>