<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 12px; font-family: Helvetica, sans-serif;">
<div>
<div>Good afternoon,</div>
<div><br>
</div>
<div>Thank you very much for the suggestion! I have used the function that you recommended, but now I am receiving the following error:</div>
<div><br>
</div>
<div>Number of subscripts do not match number of dimensions of variable,(1) Subscripts used, (2) Subscripts expected</div>
<div><br>
</div>
<div>It occurs at the line where I actually create the plot:</div>
<div><br>
</div>
<div>plot(0) = gsn_csm_xy (wks,years,var0(:,ll_ind(0),ll_ind(1)),res)</div>
<div><br>
</div>
<div>I have checked that var0 is three dimensional, and I have specified three subscripts required…</div>
<div><br>
</div>
<div>Have I missed something?</div>
<div><br>
</div>
<div>Taylor M Hughlett, Ph.D.<br>
UTA Earth and Environmental Sciences<br>
500 Yates St.<br>
Geoscience Bldg Rm 117<br>
Arlington, TX 76013-0049</div>
</div>
<div><br>
</div>
<div>The Full Code:</div>
<div><br>
</div>
<div>
<div>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"</div>
<div>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"</div>
<div>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"</div>
<div><br>
</div>
<div>begin</div>
<div><br>
</div>
<div>;**************************************************</div>
<div>; Set file paths and plot specifics</div>
<div>;**************************************************</div>
<div><br>
</div>
<div>print("Setting File Paths")</div>
<div><br>
</div>
<div>;***** File Paths and Names *****</div>
<div><br>
</div>
<div>case = "b.e12.B1850C5CN.f09_g16.YD13ka.003"</div>
<div>filen = "b.e12.B1850C5CN.f09_g16.YD13ka.003.pop.SFWF.1_cat_840.nc"</div>
<div>file_loc = "/glade/scratch/hughlett/csm/b.e12.B1850C5CN.f09_g16.YD13ka.003/ocn/tseries/cat/"</div>
<div>grid = "b.e12.B1850C5CN.f09_g16.YD13ka.003.pop.h.0810.nc"</div>
<div>grid_loc = "/glade/scratch/hughlett/csm/b.e12.B1850C5CN.f09_g16.YD13ka.003/ocn/hist/"</div>
<div>plot_loc = "/glade/scratch/hughlett/plots/b.e12.B1850C5CN.f09_g16.YD13ka.003/timeseries"</div>
<div><br>
</div>
<div>;***** Variable to Plot *****</div>
<div><br>
</div>
<div>var = "SFWF"</div>
<div><br>
</div>
<div>;***** Text for Plot *****</div>
<div><br>
</div>
<div>CenterString = "Surface Freshwater Flux"</div>
<div>YAxisString = "SFWF (Sverdrups)"</div>
<div>XAxisString = "Years"</div>
<div><br>
</div>
<div>;***** Start and End Time for Plot *****</div>
<div><br>
</div>
<div>plot_begin = 0001</div>
<div>plot_end = 840</div>
<div><br>
</div>
<div>;***** Data Options (0 = no, 1 = yes) *****</div>
<div><br>
</div>
<div>smooth = 0</div>
<div>dtrd = 0</div>
<div>ncwrite = 0</div>
<div><br>
</div>
<div>;**************************************************</div>
<div>; Read In and Process Data</div>
<div>;**************************************************</div>
<div><br>
</div>
<div>print("Reading in and processing data")</div>
</div>
<div>
<div>;***** Read in All Variables *****</div>
<div><br>
</div>
<div>fvar = addfile(file_loc+filen,"r")</div>
<div>fgrid = addfile(grid_loc+grid,"r")</div>
<div><br>
</div>
<div>var0 = fvar->SFWF(:,:,:)</div>
<div>lat2d = fgrid->TLAT</div>
<div>lon2d = fgrid->TLONG</div>
<div><br>
</div>
<div>lat = 50</div>
<div>lon = 28</div>
<div><br>
</div>
<div>;***** Create a More Plottable Timeline *****</div>
<div><br>
</div>
<div>years = ispan(plot_begin,plot_end,1)</div>
<div>nyrs = dimsizes(years)</div>
<div><br>
</div>
<div>;***** Get indicies of the point to plot *****</div>
<div><br>
</div>
<div>ll_ind = getind_latlon2d( lat2d, lon2d, lat, lon)</div>
<div><br>
</div>
<div>;**************************************************</div>
<div>; Open workstation, set plot resources, and plot</div>
<div>;**************************************************</div>
<div><br>
</div>
<div>print("Creating Plot")</div>
<div><br>
</div>
<div>;***** Create Plot Name *****</div>
<div><br>
</div>
<div>pname = var + "." + case + "_" + "timeseries_0m" + plot_begin + "-" + plot_end</div>
<div><br>
</div>
<div>;***** Open workstation *****</div>
<div><br>
</div>
<div>wks = gsn_open_wks("ps",plot_loc+pname)</div>
<div><br>
</div>
<div>;***** Set Resources *****</div>
<div><br>
</div>
<div>res = True</div>
<div>res@gsnMaximize = True</div>
<div>res@gsnFrame = False</div>
<div>res@gsnDraw = False</div>
<div>res@vpHeightF = .23</div>
<div>res@vpWidthF = .783</div>
<div>res@tiXAxisFontHeightF = .015</div>
<div>res@tiYAxisFontHeightF = .015</div>
<div>res@tmYLLabelFontHeightF = .015</div>
<div>res@tmXBLabelFontHeightF = .015</div>
<div>res@gsnLeftString = " "</div>
<div>res@gsnRightString = " "</div>
<div>res@xyLineColor = (/"black"/)</div>
<div>res@gsnCenterString = CenterString</div>
<div>res@tiYAxisString = YAxisString</div>
<div>res@tiXAxisString = XAxisString</div>
<div>res@trYMinF = 15</div>
<div>res@trYMaxF = 19</div>
<div><br>
</div>
<div>;***** Create New Plot *****</div>
</div>
<div>
<div><br>
</div>
<div>plot = new(1,graphic)</div>
<div>plot(0) = gsn_csm_xy (wks,years,var0(:,ll_ind(0),ll_ind(1)),res)</div>
<div><br>
</div>
<div>print("Plot Created")</div>
<div><br>
</div>
<div>end</div>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<span id="OLK_SRC_BODY_SECTION">
<div style="font-family:Calibri; font-size:11pt; text-align:left; color:black; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt">
<span style="font-weight:bold">From: </span>Alan Brammer <<a href="mailto:abrammer@albany.edu">abrammer@albany.edu</a>><br>
<span style="font-weight:bold">Date: </span>Wednesday, February 1, 2017 at 2:15 PM<br>
<span style="font-weight:bold">To: </span>"Hughlett, Taylor M" <<a href="mailto:taylor.hughlett@uta.edu">taylor.hughlett@uta.edu</a>><br>
<span style="font-weight:bold">Cc: </span>"<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a>" <<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a>><br>
<span style="font-weight:bold">Subject: </span>Re: [ncl-talk] Dimension (nlon) of (var0) does not have an associated coordinate variable<br>
</div>
<div><br>
</div>
<div>
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
If you were plotting a map, like Barry Lynn's similar question today also on ncl-talk, you would want to do:
<div class=""><br class="">
</div>
<div class=""><span style="font-family: Helvetica, sans-serif;" class="">var0@lon2d = </span><span style="font-family: Helvetica, sans-serif;" class="">lon2d</span>
<div class="" style="font-family: Helvetica, sans-serif;">var0@lat2d = lat2d</div>
</div>
<div class="" style="font-family: Helvetica, sans-serif;"><br class="">
</div>
<div class="" style="font-family: Helvetica, sans-serif;">The below lines are not needed. </div>
<div class=""><font face="Helvetica,sans-serif" class=""> ; LON2D = lon2d(::1,::1) ;; I don’t think (::1,::1) does anything, </font><span style="font-family: Helvetica, sans-serif;" class=""> it will take all values with an increment of 1, i.e. the whole array. </span></div>
<div class="">
<div class="" style="font-family: Helvetica, sans-serif;"> ; LAT2D = lat2d(::1,::1)<span class="Apple-tab-span" style="white-space:pre"></span> ; so this is just redundant characters which aren’t needed. </div>
</div>
<div class="">You don’t need to replicate a variable that already exists. </div>
<div class=""><br class="">
</div>
<div class="">
<div class="" style="font-family: Helvetica, sans-serif;">To set coordinate variables named nlon and nlat, you want to use the & syntax not the @ syntax, but coordinate subscripting won’t work with 2d coordinates anyway. </div>
<div class="" style="font-family: Helvetica, sans-serif;"><br class="">
</div>
<div class="" style="font-family: Helvetica, sans-serif;">So instead get the index of the point you want using:</div>
<div class=""><font face="Helvetica,sans-serif" class=""><a href="https://www.ncl.ucar.edu/Document/Functions/Contributed/getind_latlon2d.shtml" class="">https://www.ncl.ucar.edu/Document/Functions/Contributed/getind_latlon2d.shtml</a></font></div>
<div class="">e.g.</div>
<div class=""><br class="">
</div>
<div class=""><font face="Helvetica,sans-serif" class="">ll_ind = getind_latlon2d( lat2d, lon2d, </font><span style="font-family: Helvetica, sans-serif;" class="">28,50)</span></div>
<div class=""><font face="Helvetica,sans-serif" class="">…</font></div>
<div class=""><font face="Helvetica,sans-serif" class="">… </font></div>
<div class=""><span style="font-family: Helvetica, sans-serif;" class="">plot(0) = gsn_csm_xy (wks, years, var0(:, ll_ind(0), ll_ind(1) ), res)</span></div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">Good luck, </div>
<div class=""><br class="">
</div>
<div class="">Alan</div>
<div class=""><br class="">
</div>
<br class="">
<div class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div style="color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px;">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
##############################<br class="">
Alan Brammer,
<div class="">Post-Doc Researcher</div>
<div class=""><br class="">
</div>
<div class="">Department of Atmospheric and Environmental Sciences,<br class="">
University at Albany, State University of New York, Albany, NY, 12222
<div class=""><a href="mailto:abrammer@albany.edu" class="">abrammer@albany.edu</a><br class="">
##############################</div>
</div>
</div>
</span></div>
</div>
</div>
</div>
</div>
</div>
</span>
</body>
</html>