<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
{mso-style-name:msonormal;
mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
font-size:12.0pt;
font-family:"Times New Roman",serif;}
span.hoenzb
{mso-style-name:hoenzb;}
span.EmailStyle19
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'>Mary,<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'>Thank you for your assistance. I had no idea so much information was missing. I have been looking at the dimensions and sizes (ex. [ncl_join | 4017] x [north_south | 29] x [east_west | 45]) along with the total size values (Total Size: 20968740 bytes; 5242185 values) as a method to confirm that my model was simulating the correct extent and that it was outputting data, but this was not sufficient. <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'>Thank you so much for teaching me another method to confirm how many valid values I have, and how many I am missing. This tells me that there is a wrong input in my model simulation. If you have any other preliminary data checks that you would recommend please let me know. Thank you for yours and Dennis’s time.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'>Regards,<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'>-Stuart <o:p></o:p></span></p><p class=MsoNormal><b><span style='font-size:11.0pt;font-family:"Calibri",sans-serif'>From:</span></b><span style='font-size:11.0pt;font-family:"Calibri",sans-serif'> Mary Haley <haley@ucar.edu> <br><b>Sent:</b> Wednesday, May 2, 2018 10:19 AM<br><b>To:</b> Smith, Stuart <smit1770@purdue.edu><br><b>Cc:</b> Ncl-talk <ncl-talk@ucar.edu><br><b>Subject:</b> Re: [ncl-talk] Extracting Output Results from Specific Grid Cells<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><div><div><p class=MsoNormal>Stuart,<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Sorry for the delay.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>The answer follows, but I want to point out that almost half of your lat/lon values on the file are missing. I'll discuss this in a little bit.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>If you look at one of your data files using ncl_filedump, you will see that the lat/lon arrays are two-dimensional (I edited the output for clarity):<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><div><p class=MsoNormal><span style='font-family:"Courier New"'> Variable: lat</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> Type: float</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> Number of Dimensions: 2</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> Dimensions and sizes: [ 29 <north_south> x 45 <east_west> ]</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> Coordinates:</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> Number of Attributes: 9</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> units : degree_north</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> standard_name : latitude</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> long_name : latitude</span><o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> Variable: lon</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> Type: float</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> Number of Dimensions: 2</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> Dimensions and sizes: [ 29 <north_south> x 45 <east_west> ]</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> Coordinates:</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> Number of Attributes: 9</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> units : degree_east</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> standard_name : longitude</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> long_name : longitude</span><o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Data that is defined by two-dimensional lat/lon arrays is said to be on a "curvilinear" grid. In order to sub-select regions from curvilinear data, you need to use either getind_latlon2d or region_ind.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Also, you don't want to use the [:] syntax to read the lat/lon arrays off the file, because then you will get back 2 x 29 x 45 arrays, which is unnecessary if your lat/lon arrays don't change with each time step.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Instead, simply read off one timestep of the lat / lon using [0]:<span style='font-family:"Courier New"'> </span><o:p></o:p></p></div><div><div><p class=MsoNormal><span style='font-family:"Courier New"'> a = addfiles(fils,"r")</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> ListSetType (a, "join")</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> data = a[:]->Tair_f_tavg</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> data@time = a[:]->time</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> lon2d = a[0]->lon</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> lat2d = a[0]->lat</span><o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>You can then get the index locations into lat2d and lon2d that are equal to LAT and LON as follows:<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> LAT = (/ 48.5625/)</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> LON = (/-98.9375/)</span><o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> nm = getind_latlon2d (lat2d,lon2d, LAT, LON)</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> n = nm(0,0)</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> m = nm(0,1)</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> print("==================================================")</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> print("Original lat/lon : " + LAT +" "+LON)</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> print("Actual lat/lon : " + lat2d(n,m)+" "+lon2d(n,m))</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> print("==================================================")</span><o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>To slice the data at that particular location:<o:p></o:p></p></div><div><p class=MsoNormal> <o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> data_slice = data(:,n,m)</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> printVarSummary(data)</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> printVarSummary(data_slice)</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> printMinMax(data_slice,0)</span><o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>We have some examples of using these functions. Please see:<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal><a href="http://www.ncl.ucar.edu/Applications/latlon_subset.shtml" target="_blank">http://www.ncl.ucar.edu/Applications/latlon_subset.shtml</a><o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>These examples show the difference between region_ind and getind_latlon2d, which is important if you want to grab a sub-region of data, rather than just a single slice.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Back to the lat/lon values being missing. It's always incredibly important to look at your data and understand it before you start doing calculations on it, or try to plot it. Dennis Shea mentioned to me offline that your lat/lon arrays had a high number of missing values, so I simply added the following two lines to check this:<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><div><p class=MsoNormal><span style='font-family:"Courier New"'> print("==================================================")</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> print("# of valid latitude values = " + num(.not.ismissing(lat2d)))</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> print("# of missing latitude values = " + num(ismissing(lat2d)))</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> print("==================================================")</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> print("# of valid longitude values = " + num(.not.ismissing(lon2d)))</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> print("# of missing longitude values = " + num(ismissing(lon2d)))</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'> print("==================================================")</span><o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>which gave me the following output:<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><div><p class=MsoNormal><span style='font-family:"Courier New"'>==================================================</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'># of valid latitude values = 703</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'># of missing latitude values = 602</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'>==================================================</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'># of valid longitude values = 703</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'># of missing longitude values = 602</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'>==================================================</span><o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>It's likely that the lat/lon arrays have missing values in the same location.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Now maybe this is perfectly valid for your data, but it's something we wanted to be sure you were aware of. It's somewhat unusual to see this many missing values in lat / lon arrays.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div></div></div><div><p class=MsoNormal>--Mary<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div></div><div><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>On Sat, Apr 28, 2018 at 12:32 PM, Smith, Stuart <<a href="mailto:smit1770@purdue.edu" target="_blank">smit1770@purdue.edu</a>> wrote:<o:p></o:p></p><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in'><div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Hello,<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Attached is a NCL script I have been using to output model simulation results. My goal is to enhance this script to plot outputs from specific grid cells. <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>The plotting script was originally designed to read in netCDF files, which were outputted from the model simulation in a daily time step as a netCDF file (ex. <a href="http://200903180000.d01.nc" target="_blank">200903180000.d01.nc</a>). In order to create a timeseries, the script joins the files into an array and plots the total average data. I would like to enhance the NCL script to plot a time series of the raw outputted data from a defined grid cell.<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>I have been able to do this successfully looking at individual files, but when I try joining the data into an array for time series analysis of the grid cell I get the following error “fatal:Dimension (east_west) of (data) does not have an associated coordinate variable fatal" on line 28. Could I please have assistance on understanding the error and correcting this issue? Attached are example output results from a model simulation as well. Thank you for your time.<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Regards,<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='color:#888888'> <o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='color:#888888'>-Stuart <o:p></o:p></span></p></div></div><p class=MsoNormal style='margin-bottom:12.0pt'><br>_______________________________________________<br>ncl-talk mailing list<br><a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a><br>List instructions, subscriber options, unsubscribe:<br><a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><o:p></o:p></p></blockquote></div><p class=MsoNormal><o:p> </o:p></p></div></div></body></html>