<div dir="ltr">I tried experimenting with frame() but nothing worked. It's still interpolating data outside shapefile. </div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Dec 7, 2019 at 9:01 PM Rick Brownrigg <<a href="mailto:brownrig@ucar.edu">brownrig@ucar.edu</a>> wrote:<br></div><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>Hi,</div><div><br></div><div>Regarding the second issue, the bad-float values, this little scriplet:</div><div><br></div><div><span style="font-family:monospace"><font size="1">   infile = "sample.csv"<br>   lines = asciiread(infile, -1, "string")<br> <br>   numLines = dimsizes(lines)<br>   do i=1,numLines-1<br>      rain = tofloat(str_get_field(lines(i), 7, ","))<br>      print(i + ": " + rain)<br>   end do</font></span></div><div><br></div><div>reveals that in some cases, there is a value of "NA" for rain.  For example, see lines 672, 1320, 1610 -- there are probably several dozen instances.  I'm not sure there's much harm in allowing those cases to be treated as missing values; they'll be ignored in the contouring.</div><div><br></div><div>I don't really know about the shapefile issue. You have:</div><div><br></div><div><div><span style="font-family:monospace"><font size="1">    <span style="color:rgb(255,0,0)">plot</span> = gsn_csm_contour_map(wks,rain,</font></span><span style="font-family:monospace"><font size="1">res)<br>    var_mask = shapefile_mask_data(rain,shp_</font></span><span style="font-family:monospace"><font size="1">filename,True)<br>    <span style="color:rgb(255,0,0)">plot_mask</span> = gsn_csm_contour_map(wks,var_</font></span><span style="font-family:monospace"><font size="1">mask,res)<br>     ...<br>     draw(<span style="color:rgb(255,0,0)">plot_mask</span>)</font></span></div><div><span style="font-family:monospace"><font size="1">     frame(wks)</font></span></div></div><div><br></div><div>Even though you explicitly "draw" plot_mask, the fact that "plot" was generated against the workstation "wks", I'm wondering if its getting drawn when the call to frame() is made (I don't know for certain how that works under the hood). Perhaps experiment with that. If that does not resolve the issue, please repost to the group.</div><div><br></div><div>Rick</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Dec 7, 2019 at 2:26 AM Ajay Bankar via ncl-talk <<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a>> wrote:<br></div><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>Dear NCL Users,</div><div>                       I'm trying to make spatial plot of rainfall from station data available in csv file. I wrote the following script but data is not masking with shapefile. Also I'm getting the warning as:</div><div><b>warning:tofloat: A bad value was passed to (string) tofloat, input strings must contain numeric digits, replacing with missing value.</b></div><div>I have attached plot and sample data file for reference. </div><div><br></div><div>Thanks for any help!</div><div><br></div><div>load "$NCARG_ROOT/lib/ncarg/nclex/gsun/gsn_code.ncl"</div><div>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"<br>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"<br>load "/scratch/rakesh/WRF-AJAY/WRFV3/RUN_14AUG/NCL_PROGRAM/shp.ncl"<br> </div><div>begin <br> ;-- shapefile name<br> shp_filename = "/scratch/Administrative_Boundary_Headquarters/District_Boundary.shp" <br> infile = "/scratch/rakesh/WRF-AJAY/DATASETS/STATION/station_data_final.csv"<br> lines = asciiread(infile, -1, "string")<br>;print(lines)<br>;delim = ","<br><br>rain = tofloat( str_get_field(lines(1:), 7, ","))<br>rain@lat1d  = tofloat( str_get_field(lines(1:), 5, ","))<br>rain@lon1d  = tofloat( str_get_field(lines(1:), 6, ","))<br>;print(rain)<br> </div><div>;-- define sub-region, here for Karnataka<br>     minlat =  11<br>     maxlat =  19<br>     minlon =  73.5<br>     maxlon =  79.1<br> <br>;-- open workstation<br>     wks_type          = "pdf"<br>     wks  = gsn_open_wks(wks_type,"1_station_plot") <br><div> ;-- resource settings<br>     res                        =  True<br>     res@gsnDraw                =  False                       ;-- don't draw plot yet<br>     res@gsnFrame               =  False                       ;-- don't advance frame yet<br>     res@gsnMaximize            =  True                        ;-- maximize plot in frame<br> <br>  ;  res@tfDoNDCOverlay        = True<br><br>    cmap     := read_colormap_file("BlAqGrYeOrReVi200")<br>    cmap(0,:) = (/0,0,0,0/)    ; make first color fully transparent</div><div>    res@cnFillOn               =  True<br>    res@cnLinesOn              =  False<br>    res@cnLineLabelsOn         =  False<br>    res@cnFillPalette          = cmap                         ;"BlueYellowRed"<br>    res@cnLevelSelectionMode   = "ManualLevels"               ;-- manually set contour levels<br>    res@cnMinLevelValF         = 5                            ; 260.0                       ;-- contour min lev<br>    res@cnMaxLevelValF         = 95                           ; 280.0                       ;-- contour max lev<br>    res@cnLevelSpacingF        = 10                           ;   0.5                       ;-- contour spacing<br>    res@gsnAddCyclic           = False<br>  <br>    res@mpGridLineColor        =  0                          ;"grey40" </div><div>    res@mpFillOn               =  False<br>    res@mpOutlineOn            =  False<br>    res@mpGeophysicalLineColor = "black"<br>    res@mpLimitMode            = "LatLon"<br>    res@mpMinLatF              = minlat<br>    res@mpMaxLatF              = maxlat<br>    res@mpMinLonF              = minlon<br>    res@mpMaxLonF              = maxlon<br>    ;res@mpAreaMaskingOn        = True<br><br>   res@lbBoxMinorExtentF      =  0.1                         ;-- decrease height of labelbar boxes<br>   res@pmLabelBarOrthogonalPosF = 0.08                      ;-- move labelbar to the left side of plot<br></div><div>   res@lbBoxMinorExtentF      =  0.2                         ;-- decrease height of labelbar boxes<br><br>   res@pmTickMarkDisplayMode  = "Always"<br>   res@tmXTOn                 =  False<br>   res@tiMainString           = "STATION DATA PLOT"<br>  <br> ;-- create plot<br>    plot = gsn_csm_contour_map(wks,rain,res)<br>    var_mask = shapefile_mask_data(rain,shp_filename,True)<br> <br> ;-- create contours of masked data<br>    plot_mask = gsn_csm_contour_map(wks,var_mask,res)<br> <br> ;-- add plot_mask to plot<br>     lnres                    =  True<br>     lnres@gsLineColor        = "black"<br>     lnres@gsLineThicknessF   =  1.0<br> <br>     plot@lines = gsn_add_shapefile_polylines(wks, plot_mask, shp_filename, lnres)<br><br>  ;-- draw the plot and advance the frame<br>     draw(plot_mask)</div><div>     frame(wks)<br> end<br></div>-- <br><div dir="ltr"><div dir="ltr"><div><div><b>Thanks & Regards,<br></b></div><b>Ajay Bankar.<br></b></div><b><br></b></div></div></div></div>
_______________________________________________<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/mailman/listinfo/ncl-talk</a></blockquote></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div><b>Thanks & Regards,<br></b></div><b>Ajay Bankar.<br></b></div><b><br></b></div></div>