Re: natgrid function error

From: Fred Clare <fredclare_at_nyahnyahspammersnyahnyah>
Date: Sat Nov 03 2012 - 01:02:49 MDT

Natgrid assumes you are trying to interpolate a mathematical function, disallowing the possibility that a single input coordinate can have two or more distinct assigned values.  From the Natgrid documentation: If two x/y coordinate pairs are duplicates, but the z values are distinct, then a fatal error is issued. The user needs to figure out how to handle such data. The easiest way to avoid this error is to eliminate all superfluous values.  These have been listed for your convenience in locating the offending data. Fred Clare On Nov 02, 2012, at 10:09 PM, Alexander Semenov <asemenov_at_alaska.edu> wrote: Hello, I have an error using natgrid function.   Natgrid - two input triples have the same x/y coordinates             but different data values:                  First triple:  152.000000 -1.356700 33.523701                 Second triple: 152.000000 -1.356700 33.481499 Could you please tell what I need to modify in the code to get rid of it? I attached the code and the data file -- regards ******************************************************* Alex Semenov PhD Student - Research Assistant International Arctic Research Center Department of atmospheric sciences University of Alaska Fairbanks 930 Koyukuk dr, 408c3 Fairbanks, AK, USA, 99775 work phone +19074742672 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" begin ; ascii_filename = "$NCARG_ROOT/lib/ncarg/data/asc/seismic.asc" seismic = asciiread("ITP63.dat",(/10974,5/),"float") x = seismic(:,2) ; time - Column 1 of file contains X values. y = seismic(:,3) ; depth - Column 2 of file contains Y values. z = seismic(:,4) ; temp - Column 3 of file contains Z values. numxout = 20 ; Define output grid for call to "natgrids". numyout = 20 xmin = min(x) ymin = min(y) xmax = max(x) ymax = max(y) xc = (xmax-xmin)/(numxout-1) yc = (ymax-ymin)/(numyout-1) xo = xmin + ispan(0,numxout-1,1)*xc yo = ymin + ispan(0,numyout-1,1)*yc zo = natgrids(x, y, z, xo, yo) ; Interpolate. xo_at_long_name = "x values" ; Define some attributes. yo_at_long_name = "y values" zo_at_long_name = "Depth of a subsurface stratum" xwks = gsn_open_wks( "x11","gsun08n") ; Open an X11 workstation. ; cgmwks = gsn_open_wks("ncgm","gsun08n") ; Open an NCGM workstation. ; pswks = gsn_open_wks( "ps","gsun08n") ; Open a PS workstation. ; pdfwks = gsn_open_wks( "pdf","gsun08n") ; Open a PDF workstation. cmap = (/(/1., 1., 1./), (/0., 0., 0./), (/1., 0., 0./), (/1., 0., .4/), \ (/1., 0., .8/), (/1., .2, 1./), (/1., .6, 1./), (/.6, .8, 1./), \ (/.2, .8, 1./), (/.2, .8, .6/), (/.2, .8, 0./), (/.2, .4, .0/), \ (/.2, .4, .4/), (/.2, .4, .8/), (/.6, .4, .8/), (/.6, .8, .8/), \ (/.6, .8, .4/), (/1., .6, .8/)/) gsn_define_colormap( xwks,cmap) ; Define a color map for each of ; gsn_define_colormap(cgmwks,cmap) ; the four workstations you ; gsn_define_colormap( pswks,cmap) ; just opened. ; gsn_define_colormap(pdfwks,cmap) ;----------- Begin first plot ----------------------------------------- resources = True resources_at_sfXArray = xo ; X axes data points resources_at_sfYArray = yo ; Y axes data points resources_at_tiMainString = zo_at_long_name ; Main title resources_at_tiMainFont = "Times-Bold" resources_at_tiXAxisString = "x values" ; X axis label. resources_at_tiYAxisString = "y values" ; Y axis label. resources_at_cnFillOn = True ; Turn on contour fill. resources_at_cnInfoLabelOn = False ; Turn off info label. resources_at_cnLineLabelsOn = False ; Turn off line labels. resources_at_lbOrientation = "Horizontal" ; Draw it horizontally. resources_at_lbPerimOn = False ; Turn off perimeter. resources_at_pmLabelBarDisplayMode = "Always" ; Turn on a label bar. resources_at_pmLabelBarSide = "Bottom" ; Change location of ; label bar. resources_at_vpYF = 0.9 ; Change Y location of plot. zo!0 = "i" ; Name the dimensions of "zo". zo!1 = "j" contour = gsn_contour(xwks,zo(j|:,i|:),resources) ; Draw a contour plot. ;----------- Begin second plot ----------------------------------------- delete(resources) ; Start with a new list of resources. resources = True resources_at_tiMainString = ":F26:slices" ; Define a title. resources_at_xyLineColors = (/2,8,10,14/) ; Define line colors. resources_at_xyLineThicknessF = 3.0 ; Define line thickness. resources_at_pmLegendDisplayMode = "Always" ; Turn on the drawing ; of a legend. resources_at_pmLegendZone = 0 ; Change the location resources_at_pmLegendOrthogonalPosF = 0.31 ; of the legend resources_at_lgJustification = "BottomRight" resources_at_pmLegendWidthF = 0.4 ; Change width and resources_at_pmLegendHeightF = 0.12 ; height of legend. resources_at_pmLegendSide = "Top" ; Change location of resources_at_lgPerimOn = False ; legend and turn off ; the perimeter. resources_at_xyExplicitLegendLabels = (/"zo(i,2)","zo(i,4)","zo(i,6)","zo(i,8)"/) resources_at_vpYF = 0.90 ; Change size and location of plot. resources_at_vpXF = 0.18 resources_at_vpWidthF = 0.74 resources_at_vpHeightF = 0.74 resources_at_trYMaxF = 980 ; Set the maximum value for the Y axes. xy = gsn_xy(xwks,xo,zo(j|2:8:2,i|:),resources) ; Draw an XY plot. ;----------- Draw to other workstations ------------------------------ NhlChangeWorkstation(contour,cgmwks) ; Change the workstation that the NhlChangeWorkstation(xy,cgmwks) ; contour and XY plot is drawn to. draw(contour) ; Draw the contour plot to the new frame(cgmwks) ; workstation and advance the frame. draw(xy) ; Draw the XY plot to the new frame(cgmwks) ; workstation and advance the frame. ; NhlChangeWorkstation(xy,pswks) ; Do the same for the PostScript ; NhlChangeWorkstation(contour,pswks) ; workstation. ; draw(contour) ; frame(pswks) ; draw(xy) ; frame(pswks) ; ; NhlChangeWorkstation(xy,pdfwks) ; And for the PDF workstation... ; NhlChangeWorkstation(contour,pdfwks) ; draw(contour) ; frame(pdfwks) ; draw(xy) ; frame(pdfwks) delete(xy) ; Clean up. delete(contour) end _______________________________________________ ncl-talk mailing list List instructions, subscriber options, unsubscribe: http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Sat Nov 3 01:03:07 2012

This archive was generated by hypermail 2.1.8 : Tue Nov 06 2012 - 15:05:49 MST