<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto">Hi Tabish,<div><br></div><div>Krishan is right but I want to add something about the use of script variables. </div><div>If you define </div><div><br></div><div><blockquote type="cite"><div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div dir="ltr"><div dir="ltr"><div class="gmail_default"><i style="caret-color: rgb(0, 0, 0); background-color: rgba(255, 255, 255, 0);"><font color="#000000">var = "E_PM25J"<br></font></i></div></div></div></blockquote></div></div></blockquote><div><br></div>you have to use var with $...$</div><div><br><blockquote type="cite"><div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div dir="ltr"><div dir="ltr"><div class="gmail_default"><i style="caret-color: rgb(0, 0, 0); background-color: rgba(255, 255, 255, 0);"><font color="#000000">pm25 = a->$var$(0,0,:,:)</font></i></div></div></div></blockquote></div></div></blockquote><br><div dir="ltr">Bye, Karin <div><br></div></div><div dir="ltr"><br>Am 25.10.2018 um 15:21 schrieb Krishnamoorthy Chandramouli <<a href="mailto:chandrakrishna.90@gmail.com">chandrakrishna.90@gmail.com</a>>:<br><br></div><blockquote type="cite"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hi,<div><br></div><div>You can use <strong style="color:rgb(0,0,0);font-family:courier;font-size:13.333333015441895px;margin:0px;padding:0px">getfilevarnames to read the variable names from nc file .</strong></div><div><strong style="color:rgb(0,0,0);font-family:courier;font-size:13.333333015441895px;margin:0px;padding:0px">Loop over the names and read them.</strong></div><div><strong style="color:rgb(0,0,0);font-family:courier;font-size:13.333333015441895px;margin:0px;padding:0px"><br></strong></div><div><font color="#000000" face="courier" size="2"><span style="caret-color: rgb(0, 0, 0);"><b><br></b></span></font><div><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><b>Warm regards,</b></div><div><b>krishna</b></div><div><br></div></div></div></div></div></div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Oct 25, 2018 at 6:46 AM Tabish Ansari <<a href="mailto:tabishumaransari@gmail.com">tabishumaransari@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><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 want to read in several variables, in my case emissions of chemical species, from a netcdf file.<br></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">There are too many variables in the file, eg- E_PM25I, E_PM25J, E_CO, E_NO2 etc</div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">Is it possible to store them in a string array and supply them one by one to the reading function?</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">Currently, I'm unable to do this due to datatype mismatch.</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 trying something like 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"><i>begin<br>a=addfile("/data3/tabish/vert-MEIC-emis/APEC-wrfchemi/<a href="http://wrfchemi_00z_d03_total_Oct_8lev_0.5BTHso2_so4_allnormal.nc" target="_blank">wrfchemi_00z_d03_total_Oct_8lev_0.5BTHso2_so4_allnormal.nc</a>","r")<br>pm25 = a->E_PM25J(0,0,:,:)<br>("var read in the normal way")<br>var = "E_PM25J"<br>pm25 = a->var(0,0,:,:)<br>print("var read in dynamic way")<br>end</i><br><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">however, the string variable var isn't used in the reading process.</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">Please let me know if there's a way in NCL to do this.</div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">This will make the algorithm much more efficient.</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">Cheers,</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<br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif"><br clear="all"></div><div><div dir="ltr" class="m_889863004448786313gmail_signature"><div dir="ltr"><div><div><font size="1"><span style="font-family:tahoma,sans-serif">Tabish U Ansari<br></span></font></div><font size="1"><span style="font-family:tahoma,sans-serif">PhD student, Lancaster Environment Center<br></span></font></div><font size="1"><span style="font-family:tahoma,sans-serif">Lancaster Univeristy<br> <span>Bailrigg</span>, <span>Lancaster</span>, <br><span>LA1 4YW</span>, <span>United Kingdom</span></span></font><br></div></div></div></div></div>
_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
</blockquote></div>
</div></blockquote><blockquote type="cite"><div dir="ltr"><span>_______________________________________________</span><br><span>ncl-talk mailing list</span><br><span><a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a></span><br><span>List instructions, subscriber options, unsubscribe:</span><br><span><a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a></span><br></div></blockquote></div></body></html>