<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Anne,<div class=""><br class=""></div><div class="">Unfortunately, NCL’s “$var$” notation is only valid when used to reference a variable on a file (“file->$vars(n)$”) or attributes/dimensions on a variable (“var@$atts(n)$”) and cannot be used as part of a variable’s name.</div><div class=""><br class=""></div><div class="">I think the idea you found about treating months as attributes of another variable might be the easiest way to proceed:</div><div class=""><font face="Menlo" class="">month = (/"nov", "dec", "jan”/)</font></div><div class=""><font face="Menlo" class="">var_nsidc = True</font></div><div class=""><font face="Menlo" class="">do m=0,dimsizes(month)-1</font></div><div class=""><font face="Menlo" class=""> var_nsidc@$month(m)$ = var_dtrend_nsidc(0::12,:,:)</font></div><div class=""><font face="Menlo" class="">end do</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><div class=""><font face="Menlo" class="">print(var_nsidc@nov)</font></div></div><div class=""><div class=""><font face="Menlo" class="">print(var_nsidc@dec)</font></div></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class="">I hope this helps,</div><div class="">Kevin</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Feb 27, 2018, at 4:18 AM, Anne <<a href="mailto:anne.seidenglanz@unive.it" class="">anne.seidenglanz@unive.it</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hello,<div class=""><br class=""></div><div class="">I am trying to loop through a number of months (like <i class="">month = (/"nov", "dec", "jan"/)</i>) to compute some climatologies (I know there are functions but I need to do it manually here). Because I am reading in and plotting 4 different data sets I am looking for way to loop over the months, <i class="">in order to become part of the new variable name</i>, so as to make the script shorter and better readable.<br class=""></div><div class="">My "$" syntax doesn't seem to work here (see below). There was an ncl talk a few years ago saying that one needs to treat the months as attributes of another variable in order to be able to use the "$" syntax, is that still the case?</div><div class=""><br class=""></div><div class=""><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline" class="">month = (/"nov", "dec", "jan"/)</span><br class=""></div><div class=""><br class=""></div><div class=""><div class=""> do m=0,dimsizes(month)-1</div><div class=""> var_$month(m)$_nsidc = var_dtrend_nsidc(0::12,:,:)<br class=""></div><div class=""> end do</div></div><div class=""><br class=""></div><div class=""><i class="">I want to end up with:</i></div><div class="">var_nov_nsidc</div><div class="">var_dec_nsidc</div><div class="">var_jan_nsidc</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">What am I doing wrong here?</div><div class=""><br class=""></div><div class="">Any help appreciated,</div><div class="">thanks</div><div class="">Anne</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""><div class="gmail_extra"><br class=""><div class="gmail_quote"><br class=""></div></div></div></div>
<br class="">
<div class=""><font style="font-family:Arial,Helvetica,sans-serif" size="2" class="">Nota automatica aggiunta dal sistema di posta.</font></div><div class=""><img src="https://www.unive.it/media/banner_150.jpg" class=""></div>_______________________________________________<br class="">ncl-talk mailing list<br class=""><a href="mailto:ncl-talk@ucar.edu" class="">ncl-talk@ucar.edu</a><br class="">List instructions, subscriber options, unsubscribe:<br class="">http://mailman.ucar.edu/mailman/listinfo/ncl-talk<br class=""></div></blockquote></div><br class=""></div></body></html>