<div dir="ltr">Lyndz,<div><br></div><div>Try this to find the problem with your counting method.  Below this line:</div><div><br></div><div><div>    valavg(jl,il) = valavg(jl,il) + cval(n)</div><div><br></div><div>Add these code lines:</div><div><br></div><div>    test_lat =  20.0</div><div>    test_lon = 130.0</div><div>    jtest    = toint((test_lat-latS)/dlat)</div><div>    itest    = toint((test_lon-lonW)/dlon)</div><div>         </div><div>    if (il .eq. itest .and. jl .eq. jtest) then</div><div>      print (count(jl,il) + "  " + lines(n))</div><div>    end if</div></div><div><br></div><div>In the code above, change test_lat and test_lon to the coordinates of any single grid box that you want to check.  Then run the program.  This will print every input record that gets counted for that one grid box.</div><div><br></div><div>For example, I get 86 counts for the grid box example above, i..e. 20N, 130E.</div><div><br></div><div>--Dave</div><div><br><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Apr 8, 2018 at 9:04 PM, Lyndz <span dir="ltr"><<a href="mailto:olagueralyndonmark429@gmail.com" target="_blank">olagueralyndonmark429@gmail.<wbr>com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi Sir Dennis,<div><br></div><div>I tried your suggestion. I was able to run the script but I'm getting a very large count. When I counted it manually, the count does not exceed 10. But I'm getting around 88.</div><div>Attached are the output image, csv input file, and modified script.</div><div><br></div><div>I only wanted to count the TC with Vmax greater than 35knts. So I tried masking first the data.</div><div><br></div><div>I might be missing one important step here.</div><div><br></div><div>Many thanks for the help.</div><div><br></div><div>Sincerely,</div><div><br></div><div>Lyndz</div><div><br></div><div><br></div><div><div class="gmail_extra"><div class="gmail_quote">On Mon, Apr 9, 2018 at 3:17 AM, Dennis Shea <span dir="ltr"><<a href="mailto:shea@ucar.edu" target="_blank">shea@ucar.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><a href="http://www.ncl.ucar.edu/Applications/binning.shtml" target="_blank">http://www.ncl.ucar.edu/Applic<wbr>ations/binning.shtml</a><br><br></div>See Example 2:<br><br><pre>  freq  = count
  freq  = (count/npts)*100   ; comment this 
</pre></div><div class="gmail-m_-3240558432705581867m_-7759596318575725727gmail-HOEnZb"><div class="gmail-m_-3240558432705581867m_-7759596318575725727gmail-h5"><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Apr 7, 2018 at 9:05 PM, Lyndz <span dir="ltr"><<a href="mailto:olagueralyndonmark429@gmail.com" target="_blank">olagueralyndonmark429@gmail.c<wbr>om</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra">Hi Sir Rick,</div><div class="gmail_extra"><br></div><div class="gmail_extra">Thank you for the fast response.</div><div class="gmail_extra">I wanted to create a 5degree by 5degree grid NetCDF file from the shapefile, where each grid box contains the "count"(frequency) of unique TC tracks per category.</div><div class="gmail_extra">I'm just wondering if this is possible to do in NCL.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Sincerely,</div><div class="gmail_extra"><br></div><div class="gmail_extra">Lyndz</div><div><div class="gmail-m_-3240558432705581867m_-7759596318575725727gmail-m_-8049274986959429232h5"><div class="gmail_extra"><br></div><div class="gmail_extra"><div><div class="gmail-m_-3240558432705581867m_-7759596318575725727gmail-m_-8049274986959429232m_-6417443193172863545gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr"><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 class="gmail_quote">On Sun, Apr 8, 2018 at 3:34 AM, Rick Brownrigg <span dir="ltr"><<a href="mailto:brownrig@ucar.edu" target="_blank">brownrig@ucar.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div><div>Hi Lyndz,<br><br></div>I'm not sure there is a "correct" way to do this. NetCDF is really good at representing regular arrays of data, whereas polylines/polygons tend to have varying numbers of coordinate pairs -- what would lat and lon variables look like in that case, and what would be the meaning of lat/lon dimensions?  NCL makes a shapefile *look* like a NetCDF file by packing the coordinate information for all features into the x/y variables, but then one has to utilize the geometry and segments variables to unpack coordinates for each feature. The shapefiles examples page show many examples of doing this:<br><br>    <a href="http://ncl.ucar.edu/Applications/shapefiles.shtml" target="_blank">http://ncl.ucar.edu/Applicatio<wbr>ns/shapefiles.shtml</a><br><br></div>If you are working with NCL, you are probably better off leaving your data as a shapefile<i>. </i>I take it however that you have other reasons for wanting a NetCDF file?<br><br></div><div>Finally, I might comment that the conversion result may not be correct -- its suspect to me that the "num_points" value is exactly twice the value of "num_features" -- I wonder if maybe just the end-points of the tracks where what got captured in the conversion?<br></div><div><br></div>Rick<br></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="gmail-m_-3240558432705581867m_-7759596318575725727gmail-m_-8049274986959429232m_-6417443193172863545h5">On Fri, Apr 6, 2018 at 11:30 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-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div><div class="gmail-m_-3240558432705581867m_-7759596318575725727gmail-m_-8049274986959429232m_-6417443193172863545h5"><div dir="ltr"><div><div class="gmail-m_-3240558432705581867m_-7759596318575725727gmail-m_-8049274986959429232m_-6417443193172863545m_8432888801720720690m_-2027423418176086207gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr"><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 would like to convert the following shapefile to a netcdf file.</div><div>I created the shapefile from a csv file containing jtwc tc tracks (see attached csv2shp.py)<br></div><div>Also attached is the csv file.</div><div><br></div><div>When I used the ncl_convert2nc the netcdf file has no lat-lon dimension. Here's the output of the ncdump. Is it also possible to divide the TC categories by dividing the Vmax values? </div><div><br></div><div>I'll appreciate any suggestion on how to do this correctly.</div><div><br></div><div><div>netcdf par_jtwc_above_ts_1979-1993 {</div><div>dimensions:</div><div><span style="white-space:pre-wrap">   </span>geometry = 2 ;</div><div><span style="white-space:pre-wrap">   </span>segments = 2 ;</div><div><span style="white-space:pre-wrap">   </span>num_features = 1050 ;</div><div><span style="white-space:pre-wrap">    </span>num_segments = 1050 ;</div><div><span style="white-space:pre-wrap">    </span>num_points = 2100 ;</div><div>variables:</div><div><span style="white-space:pre-wrap">     </span>int geometry(num_features, geometry) ;</div><div><span style="white-space:pre-wrap">   </span>int segments(num_segments, segments) ;</div><div><span style="white-space:pre-wrap">   </span>double x(num_points) ;</div><div><span style="white-space:pre-wrap">   </span>double y(num_points) ;</div><div><span style="white-space:pre-wrap">   </span>int SN(num_features) ;</div><div><span style="white-space:pre-wrap">   </span>int CY(num_features) ;</div><div><span style="white-space:pre-wrap">   </span>int Y1(num_features) ;</div><div><span style="white-space:pre-wrap">   </span>int M1(num_features) ;</div><div><span style="white-space:pre-wrap">   </span>int D1(num_features) ;</div><div><span style="white-space:pre-wrap">   </span>int H1(num_features) ;</div><div><span style="white-space:pre-wrap">   </span>int VMax1(num_features) ;</div><div><span style="white-space:pre-wrap">        </span>int Y2(num_features) ;</div><div><span style="white-space:pre-wrap">   </span>int M2(num_features) ;</div><div><span style="white-space:pre-wrap">   </span>int D2(num_features) ;</div><div><span style="white-space:pre-wrap">   </span>int H2(num_features) ;</div><div><span style="white-space:pre-wrap">   </span>int VMax2(num_features) ;</div><div><br></div><div>// global attributes:</div><div><span style="white-space:pre-wrap">           </span>:segs_numPnts = 1 ;</div><div><span style="white-space:pre-wrap">              </span>:segs_xyzIndex = 0 ;</div><div><span style="white-space:pre-wrap">             </span>:geom_numSegs = 1 ;</div><div><span style="white-space:pre-wrap">              </span>:geom_segIndex = 0 ;</div><div><span style="white-space:pre-wrap">             </span>:geometry_type = "polyline" ;</div><div><span style="white-space:pre-wrap">          </span>:layer_name = "par_jtwc_above_ts_1979-1993" ;</div><div><span style="white-space:pre-wrap">          </span>:creation_date = "Sat Apr  7 14:11:24 JST 2018" ;</div><div><span style="white-space:pre-wrap">             </span>:NCL_Version = "6.4.0" ;</div><div><span style="white-space:pre-wrap">               </span>:system = "Linux localhost.localdomain 3.10.0-327.36.3.el7.x86_64 #1 SMP Mon Oct 24 16:09:20 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux" ;</div><div><span style="white-space:pre-wrap">                </span>:Conventions = "None" ;</div><div><span style="white-space:pre-wrap">                </span>:title = "NCL: convert-OGR-to-netCDF" ;</div><div>}</div></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></blockquote></div></div></blockquote></div></div></div></div></div></blockquote></div></div></div></div></blockquote></div></div></div></div></blockquote></div></div></div></div>