<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 Adam,<div class=""><br class=""></div><div class="">Before addressing the error, I wanted to verify that your version of NCL is actually 5.2. NCL <b class="">6.4.0</b> was released earlier this year, while NCL <b class="">5.2</b> was released in early 2010 and may not match behavior described in our up-to-date documentation. You may want to consider upgrading: <a href="http://ncl.ucar.edu/Download/" class="">http://ncl.ucar.edu/Download/</a></div><div class=""><br class=""></div><div class="">Regarding the error you observed, error messages generated by NCL can often contain useful information that is specific to your script. In this case, it looks like the script is trying to access a two dimensional variable as if it only had one dimension:</div><font face="Menlo" class="">val = new(<b class="">(/1,355/)</b>,float)<br class="">[…]<br class=""></font><div class=""><font face="Menlo" class="">plot = gsn_csm_xy(wks,x(r),<b class="">val(r)</b>,res)</font></div><div class=""><br class=""></div><div class="">There is a <a href="http://www.ncl.ucar.edu/Document/Language/error_messages.shtml" class="">list of common error messages</a> with generic examples on the NCL website; the second error message in that list seems relevant: <a href="http://www.ncl.ucar.edu/Document/Language/error_messages.shtml#NumSubRHS" class="">Number of subscripts on right-hand-side do not match number of dimensions of variable: (4), Subscripts used: (3)</a></div><div class=""><br class=""></div><div class="">I suspect that there may have been a second “fatal: …” error message indicating which line this error occurred on. In general, including as much error/debug output as possible in ncl-talk emails helps us to identify issues and respond more quickly.</div><div class=""><br class=""></div><div class="">Also, you can also try to identify what is causing an error by adding appropriate “print()” or “printVarSummary()” calls to your script immediately before where the error is occurring. For example, adding “printVarSummary(val)” in this case would show that val is a 1x355 array — technically two dimensional, although one dimension is of length 1 — while “printVarSummary(x)” would show a one-dimensional array of length 355.</div><div class=""><br class=""></div><div class=""><div class="">Finally, I’m not 100% certain what the goal of your script is, but it seems as though the x and y values for your plot are single scalar values “x(r)” and “val(r)”. Without knowing exactly what the script is trying to accomplish, I can’t be much more specific than that, but based on those x and y values I think that your script might not generate the plot that you’re expecting.</div></div><div class=""><br class=""></div><div class="">I hope this helps,</div><div class="">Kevin</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Nov 29, 2017, at 5:13 PM, Adam Hoefs <<a href="mailto:ajhoefs@wisc.edu" class="">ajhoefs@wisc.edu</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div id="divtagdefaultwrapper" dir="ltr" style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif;" class=""><div style="margin-top: 0px; margin-bottom: 0px;" class="">Hello,</div><div style="margin-top: 0px; margin-bottom: 0px;" class="">I am trying to make a basic xy plot in NCL 5.2, and am getting the following error:</div><div style="margin-top: 0px; margin-bottom: 0px;" class=""><span class="">fatal:Number of subscripts do not match number of dimensions of variable,(1) Subscripts used, (2) Subscripts expected</span><br class=""></div><div style="margin-top: 0px; margin-bottom: 0px;" class=""><span class=""><br class=""></span></div><div style="margin-top: 0px; margin-bottom: 0px;" class=""><span class="">I have looked at past questions that have the same error but cannot figure out how to apply their solutions to my script.</span></div><div style="margin-top: 0px; margin-bottom: 0px;" class=""><span class="">Any help would be much appreciated!</span></div><div style="margin-top: 0px; margin-bottom: 0px;" class=""><span class="">-Adam</span></div><div style="margin-top: 0px; margin-bottom: 0px;" class=""><span class=""><br class=""></span></div><p style="margin-top: 0px; margin-bottom: 0px;" class=""><span class=""></span></p><div class="">;*************************************************</div><div class="">; plot_csv_example.ncl</div><div class="">;</div><div class="">; this script will plot data from csv/txt output</div><div class="">; for the columns you specify.</div><div class="">; please read through the code before you use it. It is currently set up to read in the csv file</div><div class="">; but not make the plot--you'll have to add code to make a plot.</div><div class="">;</div><div class="">;*************************************************</div><div class="">; first need to tell NCL where the function libraries are. These next 3 lines have to be at the top </div><div class="">; of EVERY NCL script you write:</div><div class=""><br class=""></div><div class="">load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"</div><div class="">load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"</div><div class="">load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"</div><div class=""><br class=""></div><div class="">; after specifiying the paths you have to have a "begin script" statement:</div><div class="">begin</div><div class=""><br class=""></div><div class="">;************************************************************</div><div class="">; start user input</div><div class="">;************************************************************</div><div class="">; first designate the directory the directory where your csv file resides</div><div class="">filedir = "/users/hoefs/"</div><div class=""><br class=""></div><div class="">delim = ","</div><div class=""><br class=""></div><div class="">; specify filename</div><div class="">filename = "Houston2016.csv"</div><div class=""><br class=""></div><div class="">; specify column (number) of data to use on the x-axis of the plot</div><div class="">; note: though NCL usually starts counting at zero, when reading ascii/text/csv files</div><div class="">; the first column is numbered 1.</div><div class="">xcol = 1</div><div class=""><br class=""></div><div class="">; specify column (number) of data to use on the y-axis of the plot</div><div class="">ycol = 2</div><div class=""><br class=""></div><div class="">; specify the name of the output filename of the plot</div><div class="">; the script is currently set up to create a PDF plot. ".pdf" will be appended to the filename automatically</div><div class="">outfilename = "HoustonOzone2016"</div><div class="">; note that the output file is currently set up to be written to the same</div><div class="">; directory as the csv file</div><div class=""><br class=""></div><div class="">;************************************************************</div><div class="">; end user input</div><div class="">;************************************************************</div><div class=""><br class=""></div><div class="">file1 = ("/users/hoefs/Houston2016/")</div><div class="">; read in contents of file with "asciiread" function. Contents go into an array defined here as "values1d1"</div><div class="">values1d1 = asciiread("Houston2016.csv",-1,"string")</div><div class="">; use the str_split and dimsizes functions to get the number of columns</div><div class="">ncols = dimsizes(str_split(values1d1(1),","))</div><div class="">; use the dimsizes function to get the number of rows (includes header row(s) if there are any)</div><div class="">nrows = dimsizes(values1d1) ; this shouldn't change</div><div class=""><br class=""></div><div class="">; declare arrays to put data into. Adjust array size if there's a header row.</div><div class="">; for example, if there's a header row, xdata = new(nrows-1,float)</div><div class="">xdata = new(355,float)</div><div class="">ydata = new(355,float)</div><div class=""><br class=""></div><div class="">; note: if there is a header row (or rows) you'll need to change this loop</div><div class="">; for example, for a single header row change the length of the do loop to : do r = 1,nrows-2</div><div class="">; this loop reads in each row of values1d1 with the function "str_get_field" and then converts </div><div class="">; the string into a floating number with the "tofloat" function and stores the values in the xdata and ydata arrays.</div><div class="">do r = 0,nrows-1</div><div class=""> xdata(r) = tofloat(str_get_field(values1d1(r),xcol,","))</div><div class=""> ydata(r) = tofloat(str_get_field(values1d1(r),ycol,","))</div><div class="">end do</div><div class=""><br class=""></div><div class="">; here's an example of how to check that the data were read in correctly:</div><div class="">printVarSummary(ydata)</div><div class="">printMinMax(ydata,True)</div><div class="">print("the average is "+avg(ydata))</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">;**********************************************************</div><div class="">; now make the plot!</div><div class="">; a few basic things are included below but the bulk of the plotting commands you'll have to add.</div><div class="">; check the NCL example pages for how to make the kind of plot you want (xy scatter for example)</div><div class=""><br class=""></div><div class="">res = True</div><div class="">res@gsnFrame = False</div><div class="">res@xyLineThicknessF = 3</div><div class="">res@trYMinF = 0.0</div><div class="">res@trYMaxF = 0.1</div><div class="">res@trXMinF = 2016000</div><div class="">res@trXMaxF = 2016355</div><div class="">res@xyDashPattern = 0</div><div class="">res@xyLineColor = (/"NavyBlue"/)</div><div class="">res@tiXAxisString = "Date"</div><div class="">res@tiYAxisString = "Ozone Concentration (ppb)"</div><div class=""><br class=""></div><div class="">res@tiMainString = "8-Hr Max Daily Avg. Ozone Concentration in Houston 2016" ; title</div><div class=""><br class=""></div><div class="">outname = ("HoustonOzone") ; output filename</div><div class=""><br class=""></div><div class="">wks = gsn_open_wks("pdf","HoustonOzone")</div><div class=""><br class=""></div><div class="">res@gsnMaximize = True</div><div class="">res@gsnPaperOrientation = "Landscape"</div><div class="">val = new((/1,355/),float)</div><div class="">x = 2016000 + ispan(0,355,1)</div><div class=""><br class=""></div><div class=""><span style="font-size: 12pt;" class="">plot = gsn_csm_xy(wks,x(r),val(r),res)</span><br class=""></div><div class="">draw(plot)</div><div class="">frame(wks)</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">end ; obligatory "end of script" statement</div><div class=""><br class=""></div><br class=""><p style="margin-top: 0px; margin-bottom: 0px;" class=""></p></div><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">_______________________________________________</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">ncl-talk mailing list</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="mailto:ncl-talk@ucar.edu" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">ncl-talk@ucar.edu</a><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">List instructions, subscriber options, unsubscribe:</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a></div></blockquote></div><br class=""></div></body></html>