Add overlay of ascii data from CSV file with missing values?

From: Katrina Bennett <kebennett_at_nyahnyahspammersnyahnyah>
Date: Mon Apr 07 2014 - 18:18:01 MDT

Hi there, I am working on a map where I want to add an overlay of points to
indicate significance of the underlying data.

However, I'm stumped on how to do this best in NCL. My data are in a csv
file that contains missing values where the data is not significant.

I played around and looked at the options for overlay, and it seems like
adding the dum1=gsn_add_polymarker(wks, plot(0), lon, lat, pmres) is the
best option.

What I'm struggling with is how I can assign the values for the
gsn_add_polymarkers to each column in my ascii file that has no missing
values?

Thank you in advance!

Here is my code:

;************************************
; panel_6.ncl
;
; Concepts illustrated:
; - Paneling four plots on a page
; - Adding white space around paneled plots
;
;************************************
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
;************************************
undef ("new_shape")
function new_shape(x[*]:numeric, lat[*]:numeric, lon[*]:numeric \
                  ,long_name[1]:string,units[1]:string)
; **** This is a rectilinear grid ****
begin
   x2d = onedtond(x,(/dimsizes(lat),dimsizes(lon)/))
   x2d@long_name = long_name ; assign attributes
   x2d@units = units
   x2d!0 = "lat" ; assign coordinate var
   x2d!1 = "lon"
   x2d&lat = lat
   x2d&lon = lon
   return( x2d )
end

;===

begin
   nlat = 13
   nlon = 96

   diri = "/import/c/w/kbennett/WAGNER/orig/"
   fili = "all_precfn2.csv"
   filj = "sig05.csv"
   asciif = asciiread(diri+fili, -1,"float") ; will ignore letters
   ncol = 6 ; # of columns
   nval = dimsizes(asciif) ; # of total values
   npts = nval/ncol ; # of points (rows)

   print ("Number of npts " + npts) ; nrow

   if (npts.ne.(nlat*nlon)) then
       print("size mismatch")
       exit
   end if

   data = onedtond(asciif,(/npts,ncol/)) ; npts x ncol

   lon = data(0:nlon-1,0)
   lon!0 = "lon"
   lon@units = "degrees_east"

   lat = data(::nlon,1)
   lat!0 = "lat"
   lat@units = "degrees_north"
   ;print(lon)
   ;print(lat)

;;read sig file and ???
   asciij = asciiread(diri+filj, -1,"float") ; will ignore letters
   dataj = onedtond(asciij,(/npts,ncol/)) ; npts x ncol
   dataj@_FillValue = -9999

   :how can I extract the lat/long values for each column that have no
missing data
   lonj = dataj(0:nlon-1,0)
   latj = dataj(::nlon,1)

   precDJF = new_shape(data(:,2),lat,lon,"DJF" ,"mm/ka")
   precMAM = new_shape(data(:,3),lat,lon,"MAM" ,"mm/ka")
   precJJA = new_shape(data(:,4),lat,lon,"JJA" ,"mm/ka")
   precSON = new_shape(data(:,5),lat,lon,"SON" ,"mm/ka")

   ;printVarSummary(precDJF)

   ;************************************
   ;create plot
   ;************************************
    wks = gsn_open_wks("png","panel") ; open a png file
    gsn_define_colormap(wks,"gui_default") ; choose colormap
    plot = new(4,graphic) ; create graphic array

    res = True
    res@cnFillOn = True ; turn on color fill
    res@gsnDraw = False ; do not draw picture
    res@gsnFrame = False ; do not advance frame
    res@gsnPolar = "NH" ; select northern hemisphere
    res@lbLabelBarOn = False ; turn off individual lb's
   ;res@gsnAddCyclic = False
    res@mpMinLatF = min(lat)
    res@mpGeophysicalLineThicknessF = 2.0 ; thickness of outlines

    pmres = True
    pmres@gsMarkerIndex = 17 ; Filled circle
    pmres@gsMarkerSizeF = 0.0125

    plot(0)=gsn_csm_contour_map_polar(wks,precDJF,res)
    dum1=gsn_add_polymarker(wks, plot(0), lonj, latj, pmres)
    plot(1)=gsn_csm_contour_map_polar(wks,precMAM,res)
    plot(2)=gsn_csm_contour_map_polar(wks,precSON,res)
    plot(3)=gsn_csm_contour_map_polar(wks,precJJA,res)

    resP = True
    resP@txString = "Precipitation"
    resP@gsnMaximize = True
    resP@gsnPanelLabelBar = True ; add common colorbar
   ;resP@lbLabelFontHeightF = 0.007 ; make labels smaller

   ; draw panel with a vertical label bar and white space
    resP@lbOrientation = "Vertical" ; default is horizontal
    resP@gsnPanelYWhiteSpacePercent = 5
    resP@gsnPanelXWhiteSpacePercent = 5
    gsn_panel(wks,plot,(/2,2/),resP)
end

~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Katrina E. Bennett
PhD Candidate
University of Alaska Fairbanks
International Arctic Research Center
907-474-1939 kebennett@alaska.edu

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Apr 07 18:18:13 2014

This archive was generated by hypermail 2.1.8 : Tue Apr 15 2014 - 10:45:19 MDT