[ncl-talk] Reading Ozone data with lat/lon

Guido Cioni guidocioni at gmail.com
Thu Nov 9 12:13:20 MST 2017


The error is telling you that the problem is in argument (1) of the function gsn_csm_contour_map, so data, and that the type is wrong. Quickly looking at your file it seems to me that you need to convert data to a numeric type (double or float) before plotting it.
String types of course can not be contoured :) 

Have a look here https://www.ncl.ucar.edu/Document/Language/error_messages.shtml <https://www.ncl.ucar.edu/Document/Language/error_messages.shtml>.

I think you may want to elaborate the data array a little bit before passing it to the contour function. I guess just reading from the text file will produce something that is not correctly dimensioned. 

Cheers 

> Il giorno 09 nov 2017, alle ore 18:53, Emma Nelson <enelson23 at wisc.edu> ha scritto:
> 
> Hi,
> 
> I've been trying to plot a file with data from an Ozone station with its lat/lon data from another file.  I've been following an example script but I keep getting an error that says, "fatal:Argument type mismatch on argument (1) of (gsn_csm_contour_map) can not coerce" when I try to plot.  Any help would be appreciated!  Here is my script:
> 
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> 
> diri = "/Users/EmmaNelson/Desktop/"
> fili = "Ozone SanAn2016.csv"
> data = asciiread(diri+fili, -1, "string")
> header = True
> delim = ","
> 
> data2 = asciiread(diri+"O3 Stationlatlon.csv", -1, "string")
> header = True
> delim = ","
> 
> sloc = str_get_field(data2, 1, ",")
> lat = tofloat(str_get_field(data2, 2, ",") )
> lon = tofloat(str_get_field(data2, 3, ",") )
> 
> pltDir = "/Users/EmmaNelson/Desktop/"
> pltNam = "Ozone"
> pltType = "x11"
> 
> wks = gsn_open_wks(pltType,pltDir+pltNam)
> gsn_define_colormap(wks,"WhViBlGrYeOrRe")
> 
> res = True
> res at gsnFrame = False
> res at gsnMaximize = True
> res at pmTickMarkDisplayMode = "Always"
> 
> res at mpOutlineBoundarySets = "USStates"
> 
> res at cnFillOn = True
> res at cnLinesOn = True
> res at cnLineLabelsOn = True
> res at sfXArray = lon
> res at sfYArray = lat
> 
> map = gsn_csm_contour_map(wks,data,res)
> 
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu <mailto:ncl-talk at ucar.edu>
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk <http://mailman.ucar.edu/mailman/listinfo/ncl-talk>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20171109/cf111411/attachment.html>


More information about the ncl-talk mailing list