Re: linint2_points for station data

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Thu, 09 Jul 2009 22:47:43 -0600

The returned array

        fo(time,pts) ==>fo(360,747)

        dim_fo = dimsizes(fo)
        ntim = dim_fo(0)
        npts = dim_fo(1)

At each time there are 747 values. This is like observations at a
specific time.

If you try 'dimension reordering

       ft = fo(pts|:,time|:) ; ft(pts,time) ==> ft(747,360)

ft can be considered to be a time series for each station.

I assume your are working with 30-daymonths since ntim=360

       nmos = 12
       fo_month = new( (/ npts,nmos/) , typeof(ft) )

       ndymo = 30

       ntStrt = 0
       ntLast = ndymo-1
                                       ; calculate 30-day monthly means
for each station
       do nmo=0,nmos-1
            fo_month(:,nmo) = dim_avg(ft(:,ntStrt:ntLast))

            ntStrt = ntStrt + ndymo
            ntLast = ntLast + ndymo
       end do

       fo_month!0 = "station"
       fo_month!1 = "month"

Good luck

yanling_1220 wrote:


I'm new in NCL language, so I'm having some difficulties
in doing things that seems to be easy!

I have used linint2_points_Wrap( )to interpolate a monthly
surface air temperature(tas) data projected by ECHAM5/MPI-OM
from one gussian grid ntim *nlat* mlon() (ntim=260, nlat=96,
mlon=192)to 747 stations in my research area.As explanation
of linint2_points_Wrap function on

the returned array is of Dimensions and sizes: [time | 360] x [pts | 747].
And I think the interpolate process succeed.

I consider that the returned arrays are 360D arrays of length 747
the interpolated values for each(x0,y0)coordinate pair, it is to say
that at each time?there are only 747 discrete points with values.
And the data is (360,747*747),not (360,747,747)as before. So can time
series analysis be done in NCL base on the returned array?such as
Computeing the long term monthly means ?seasonal means?annual values?
and so on. If these can come true, what are the corresponding functions?

The functions that process the data such as (360,747,747)
can process the data such as(360,747*747)? If it can?t ,what about
using onedtond( ndtooned(FO),(/ntim,N,M/))to reshape the returned
arrays FO ?

Above all, I wanted to contrast the interpolated project data with
my station observation. My station data is storaged in an ASCII file
as below frame?

Year month stid lat lon tas.

I want to obtain the time and spatial correlativity between the two data
or regress correlation between peojected and observerd data .
But I have no idea about how to do it in ncl. Can I read the sation data
into ncl according to some format that is convenient for analysis,
and how should I to do it?

Or If I have to put the interpolated project data out to carry out
the analysis, and how can I gain the data in the same frame as
the station observation. I have tried to put interpolated project
data out as .nc file, and define the content of the entire file as below:

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"


    stain= asciiread("station.asc",(/747,2/), "float")
    printVarSummary(stain )

    LAT = stain(:,0) ; (N,M)
    LON = stain(:,1)

    fo = linint2_points_Wrap(lon,lat,orig,True,LON,LAT,0) ; fo(ntim,747*747)

    ntim = dimsizes(time)
    tas = onedtond(ndtooned(fo),(/ntim,747,747/))

    tas!1 = "lat"
    tas!2 = "lon"

    lat = tas&lat
    lon = tas&lon

    nlat = dimsizes(lat)
    nlon = dimsizes(lon)

    cn_filename2 = ""

    system("/bin/rm -f " + cn_filename2)
    fout= addfile(cn_filename2,"c")


    fileAtt = True
    fileAtt_at_title = "data from linint2_points"
    fileAtt_at_conventions = "None"
    fileAtt_at_date = systemfunc("date")

    dimNames = (/"time","lat","lon"/)
    dimSizes = (/ntim,nlat,nlon/)
    dimUnlim = (/False,False,False/)

    filevardef(fout, "time" ,typeof(time),getvardims(time))

    filevardef(fout, "lat" ,typeof(lat),getvardims(lat))

    filevardef(fout, "lon" ,typeof(lon),getvardims(lon))
    filevardef(fout, "tas" ,typeof(tas),getvardims(tas))

    filevarattdef(fout,"time" ,time) ; copy T attributes
    filevarattdef(fout,"lat" ,lat) ; copy Y attributes
    filevarattdef(fout,"lon" ,lon) ; copy X attributes
    filevarattdef(fout,"tas" ,tas) ; copy tas attributes

    fout->time = (/time/)
    fout->lat = (/lat/)
    fout->lon = (/lon/)
    fout->tas =(/tas/)


I got an error massage:

fatal:No coordinate variable exists for dimension (lat) in variable (tas)

It means the named dimensions ?tas!1 = "lat", tas!2 = "lon"? isn?t
working.In the
  ?language_man_MINI.pdf ?, it said that ?Named dimensions should only
be used whe
n dimension reordering is required.? But if I want to put the
interpolated resul
t out, what should I define the latitude/longitude arrays?

Wish I have a clear show of my problems with my poor English.

If anybody knows how I should proceed the problem or finds the mistakes
that I ha
ve made whether in the process or about the comprehension, please let me
know, th

ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
Received on Thu Jul 09 2009 - 22:47:43 MDT

This archive was generated by hypermail 2.2.0 : Mon Jul 13 2009 - 20:56:19 MDT