Re: correlation between data from txt file and gridded sst data

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Thu Oct 31 2013 - 07:57:00 MDT

The error message told you the issue.

fatal:Argument type mismatch on argument (0) of (esccr) can not coerce

Argument 0 is the 1st argument to esccr: 'rr_obs'

The message tells you the there is a mismatch in the variable type.

If you did a

    printVarSummary(rr_obs)

You would see it is type "string" as you specify in your comment

> ;---Read in file as array of strings so we can parse each line.
> lines = asciiread(fili,-1,"string")
> nlines = dimsizes(lines)-1 ; First line is a header
> delim = ","
> rr_obs = str_get_field(lines(1:),3,delim)
> rr_obs@_FillValue = -999

---
http://www.ncl.ucar.edu/Document/Functions/Built-in/esccr.shtml
The function arguments are prototyped as *numeric*
function esccr (
		x         : numeric,  <====
		y         : numeric,  <====
		mxlag [1] : integer
	)
----
You must convert from string ==> numeric
    rr_obs     = tofloat( str_get_field(lines(1:),3,delim))
On 10/31/13 4:59 AM, Mohamad Ibrahim OMAR wrote:
> Hi all,
> I want to plot a spatial distribution of the correlation between the sst data and my station data. I try by the following code;
>
>    load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
>
>
> begin
>
> fili = "Jeddah_Rain_1982_2013.txt"
>
> f1  = addfile("sst.mnmean.anom_1982-2013.cdf","r")
>
> sst = f1->ssta
> lat = f1->Y
> lon = f1->X
>
> ; initialize site and year count
> ; note, set to work for six years of data only
> mncnt   = 0
> yrcnt   = 0
> sitecnt = 0
> ntime = 380
> ;---Read in file as array of strings so we can parse each line.
>    lines  = asciiread(fili,-1,"string")
>    nlines = dimsizes(lines)-1   ; First line is a header
>    delim     = ","
>    rr_obs     = str_get_field(lines(1:),3,delim)
>    rr_obs@_FillValue = -999
> copy_VarCoords(sst,rr_obs)
> printVarSummary(rr_obs)
> ;print(rr_obs+"  ")
>
> ssta = sst(Y|:,X|:,time|:)
>
>    corel  = esccr(rr_obs,ssta,1)
>
> ;  copy_VarCoords(sst(0,:,:), corel)
>
> print(corel+"  ")
>
> end
>   and I had got the error;
>
> fatal:Argument type mismatch on argument (0) of (esccr) can not coerce
> fatal:["Execute.c":8128]:Execute: Error occurred at or near line 34 in file statistics_tmp.ncl
>
>
> the ascii file has three columns year, month and the rainfall.
>
> So, can anyone help me? Thanks
> Regards
>
>
>
> Mohamed Ibrahim El-Sayed OMAR
> Egyptian Meteorological Authority
> Scientific Research Department
> Climate Studies Centre
> Kobry El-Quobba, P.O.Box. 11784
> Cairo, EGYPT
> Mobil phone  : 002 01060802805
> Home Phone : 002 0482370261
>
>
>
> _______________________________________________
> 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 Thu Oct 31 07:57:03 2013

This archive was generated by hypermail 2.1.8 : Fri Nov 01 2013 - 08:58:14 MDT