<div dir="ltr">Hi Mary,<div><br></div><div>This is in relation to my previous post with the subject: "<span style="color:rgb(34,34,34);font-family:arial,sans-serif;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">convert polyline shapefile to netcdf via ncl_convert2nc" where I only wanted to count unique TC's within a 5x5degree drid box.</span></div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;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">It was suggested to sort the input based on the "SN" column first before counting and updating a column whenever a different "SN" value is read for every lat-lon points. </span></div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;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"><br></span></div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;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">I combined some lines from your script and the binning script from the NCL example page (<a href="https://www.ncl.ucar.edu/Applications/binning.shtml">https://www.ncl.ucar.edu/Applications/binning.shtml</a>). I attached in this email the script that I am using. </span></div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;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"><br></span></div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;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">I added the following lines but resulted to some errors: </span></div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;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"><br></span></div><div><span style="text-align:start;text-indent:0px;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline;background-color:rgb(255,0,0)"><div><font color="#ff0000">  sn_unique = get_unique_values(sn)</font></div><div><font color="#ff0000">  snpts       = dimsizes(sn_unique)</font></div><div><font color="#ff0000"><br></font></div><div><font color="#ff0000">  do a=0,snpts-1</font></div><div><font color="#ff0000">         ii := ind(sn.eq.sn_unique(a))</font></div><div><font color="#ff0000">  end do</font></div><div><br></div><div><font color="#ff0000">  npts = dimsizes(ii)</font></div><div><font color="#ff0000">  nlat=lat(ii)</font></div><div><font color="#ff0000">  nlon=lon(ii)</font></div><div><font color="#ff0000">  nvmax=vmax(ii)</font></div><div><font color="#ff0000"><br></font></div><div><font color="#ff0000">  do n=0,npts-1</font></div><div><font color="#ff0000">           if (nlat(n).ge.latS .and. nlat(n).le.latN .and.  \</font></div><div><font color="#ff0000">                 nlon(n).ge.lonW .and. nlon(n).le.lonE .and.  \</font></div><div><font color="#ff0000">                .not.ismissing(nvmax(n)) ) then</font></div><div><font color="#ff0000"><br></font></div><div><font color="#ff0000">                 jl = toint((nlat(n)-latS)/dlat)</font></div><div><font color="#ff0000">                 il = toint((nlon(n)-lonW)/dlon)</font></div><div><font color="#ff0000">                 count(jl,il)  = count(jl,il)  + 1</font></div><div><font color="#ff0000">                 valavg(jl,il) = valavg(jl,il) + nvmax(n)</font></div><div><font color="#ff0000">              end if</font></div><div><font color="#ff0000">  end do</font></div><div><font color="#ff0000"><br></font></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-transform:none;white-space:normal;word-spacing:0px">[Errors]</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-transform:none;white-space:normal;word-spacing:0px"><div>warning:ContourPlotInitialize: no valid values in scalar field; ContourPlot not possible:[errno=1101]</div><div>warning:ContourPlotSetValues: cnLevelSpacingF value exceeds or equals data range: defaulting</div><div>warning:ContourPlotInitialize: no valid values in scalar field; ContourPlot not possible:[errno=1101]</div><div>warning:ContourPlotSetValues: cnLevelSpacingF value exceeds or equals data range: defaulting</div><div>warning:ContourPlotInitialize: no valid values in scalar field; ContourPlot not possible:[errno=1101]</div><div>warning:ContourPlotSetValues: cnLevelSpacingF value exceeds or equals data range: defaulting</div><div><br></div><div>Many thanks for the help.</div><div>Sincerely, </div><div><br></div><div>Lyndz</div></div></span></div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;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"><br></span></div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;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"><br></span></div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;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"><br></span></div><div class="gmail_extra"><div><div class="gmail-m_956314357828514775gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><br></div></div></div></div></div></div></div></div></div></div></div></div></div></div>
<br><div class="gmail_quote">On Thu, Apr 12, 2018 at 12:05 PM, Mary Haley <span dir="ltr"><<a href="mailto:haley@ucar.edu" target="_blank">haley@ucar.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div style="font-size:small">Dear Lyndz,</div><div style="font-size:small"><br></div><div style="font-size:small">I wrote an email answering your question about how to access rows and columns of data, but then I realized that I'm not sure this is what you really wanted.</div><div style="font-size:small"><br></div><div style="font-size:small">It might be easier for you to read each column of data from the file individually, and then sort the array(s) that you need.  </div><div style="font-size:small"><br></div><div style="font-size:small">Since it's not clear what you want to do with the sorted values, I created an example that creates a sort vector for the "sn" column, and then it prints both "sn" and "year" using this sort vector.</div><div style="font-size:small"><br></div><div style="font-size:small">Since I was curious, I also plotted your data with different colored dots for each of the unique categories, and different dots for each set of years.</div><div style="font-size:small"><br></div><div style="font-size:small">If you are still not sure how to get the sorting you need, please reply back to ncl-talk with more information about what you are trying to do.</div><div style="font-size:small"><br></div><div style="font-size:small">Thanks</div><div style="font-size:small"><br></div><div style="font-size:small">--Mary</div><div style="font-size:small"><br></div><div><span style="font-size:12.8px"><br></span></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="gmail-m_956314357828514775h5">On Tue, Apr 10, 2018 at 8:49 PM, Lyndz <span dir="ltr"><<a href="mailto:olagueralyndonmark429@gmail.com" target="_blank">olagueralyndonmark429@gmail.c<wbr>om</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div class="gmail-m_956314357828514775h5"><div dir="ltr"><br clear="all"><div><div class="gmail-m_956314357828514775m_2639543927944879954m_-6536766144831156985gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Dear NCL experts, </div><div><br></div><div>I am trying to get a field in a 2D array after sorting. Is there a way to extract the "fourth column" (<b 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;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">(0,4)<span style="white-space:pre-wrap">       </span>198920 in the sample below)</b>, for example in the 2D array. I tried using the <b>str_get_field </b>function, but it does not work for this case.</div><div><br></div><div>Any suggestion on how to do this correctly?</div><div><br></div><div><br></div><div>These are the commands that I am using:</div><div><br></div><div><div>filename="test.txt"</div><div>test=readAsciiTable(filename,9<wbr>,"float",1)</div><div>i=dim_pqsort_n(test(:,0),1,0)</div><div>Aout=test(i,:)</div><div>print(Aout)</div></div><div><br></div><div><div>Variable: Aout</div><div>Type: float</div><div>Total Size: 39528 bytes</div><div>            9882 values</div><div>Number of Dimensions: 2</div><div>Dimensions and sizes:<span style="white-space:pre-wrap">      </span>[1098] x [9]</div><div>Coordinates: </div><div>Number Of Attributes: 1</div><div>  _FillValue :<span style="white-space:pre-wrap">   </span>9.96921e+36</div><div>(0,0)<span style="white-space:pre-wrap"> </span> 0</div><div>(0,1)<span style="white-space:pre-wrap">  </span>26.1</div><div>(0,2)<span style="white-space:pre-wrap">        </span>130</div><div>(0,3)<span style="white-space:pre-wrap"> </span>40</div><div><b>(0,4)<span style="white-space:pre-wrap"> </span>198920</b></div><div>(0,5)<span style="white-space:pre-wrap">    </span>20</div><div>(0,6)<span style="white-space:pre-wrap">  </span>1989</div><div>(0,7)<span style="white-space:pre-wrap">        </span> 8</div><div>(0,8)<span style="white-space:pre-wrap">  </span>26</div><div>(1,0)<span style="white-space:pre-wrap">  </span> 0</div><div>(1,1)<span style="white-space:pre-wrap">  </span>28.7</div><div>(1,2)<span style="white-space:pre-wrap">        </span>122.9</div></div><div><br></div><div><br></div><div>I'll appreciate any help.</div><div><br></div><div><br></div><div>Sincerely,</div><div><br></div><div>Lyndz</div></div></div></div></div></div></div></div></div></div></div></div></div></div>
</div>
<br></div></div>______________________________<wbr>_________________<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/mailma<wbr>n/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div></div>