From: Erika Folova <e.folova_at_nyahnyahspammersnyahnyah>

Date: Wed Aug 14 2013 - 10:25:45 MDT

Date: Wed Aug 14 2013 - 10:25:45 MDT

Thanks, but that's not what I meant. I can handle the above case easily..,

My problem is : I just wonder how to *create a series* where Y shifts

according to the lag in each year dataset. then hold them together to be

one series. X is kept fixed 90 days (only in JFM) for each year (i.e only Y

is moving back and forward, meaning that Y time series start on 17 December

and 15 January in analysis for each year)

The illustration is as follow:

lag 0 :

X =

1Jan1980---------------31mar1980||1Jan1981--------------31mar1981--------------

Y =

1Jan1980---------------31mar1980||1Jan1981--------------31mar1981--------------

lag +1 :

X =

1Jan1980---------------31mar1980||1Jan1981--------------31mar1981--------------

Y =

2Jan1980---------------1Apr1980||2Jan1981------------------1Apr1981--------------

lag -1 :

X =

1Jan1980---------------31mar1980||1Jan1981--------------31mar1981---------------

Y =

31Dec1979---------------30mar1980||31Dec1980-------------30mar1980--------------

surely each segment for one year is 90 days, so if have 20 years data, the

total length of series will be 20 x 90 =1800 time.

FOR X is quite EASY to handle, but FOR Y is quite hard to hande by shift

the date accordingly for each year and combine them. That's actually my

problem.

Thank you.

Erika

On Wed, Aug 14, 2013 at 5:33 PM, Dennis Shea <shea@ucar.edu> wrote:

*> Please do not send me direct emails. I have my own job to do. THX.
*

*>
*

*> ===
*

*>
*

*> Alessandra's response was "appropriate". However, another approach
*

*> may be the following where *you* 'manually' do the lag operation.
*

*>
*

*> Note: escorc requires that the number of time steps be the same.
*

*>
*

*> Something like the following.
*

*>
*

*> X = (time,lat,lon)
*

*> Y = (time,lat,lon)
*

*>
*

*> undef("erika_lag")
*

*> function erika_lag(X[*][*][*], Y[*][*][*], mxlag[1]:integer)
*

*> begin
*

*> x = X(lat|:,lon|:,time|:)
*

*> y = Y(lat|:,lon|:,time|:)
*

*>
*

*> dimx = dimsizes(x)
*

*> nlat = dimx(0)
*

*> mlon = dimx(1)
*

*> ntim = dimx(2)
*

*> ntim1 = ntim-1 ; convenience
*

*>
*

*> mxlag = 15
*

*> r = new ( (/2*mxlag+1,nlat,mlon/), typeof(x), getFillValue(x))
*

*>
*

*> r(mxlag+1,:,:) = escorc(x,y) ; correlation at lag 0
*

*>
*

*> do m=1,mxlag ; x lead y
*

*> myStrt = m
*

*> myLast = ntim1
*

*> r(mxlag+1+m,:,:) = escorc(x(:,:,0:ntim1-m),y(:,:,**myStrt:myLast))
*

*> end do
*

*>
*

*> do m=1,mxlag ; y lead x
*

*> myStrt = ?
*

*> myLast = ?
*

*> r(m-mxlag-1,:,:) = escorc(y(:,:,myStrt:myLast)), x(:,:,0:ntim1-m))
*

*> end do
*

*>
*

*> r!0 = "lag"
*

*> r&lag = ispan(-mxlag,mxlag,1) ; -15 to 15
*

*> copy_VarCoords(x(:,:,0), r(0,:,:))
*

*> printVarSummary(r)
*

*>
*

*> return(r)
*

*> end
*

*>
*

*>
*

*>
*

*>
*

*>
*

*> On 8/14/13 6:01 AM, Erika Folova wrote:
*

*>
*

*>> Dear NCL Team,
*

*>>
*

*>> It was posted a week ago but haven’t got any appropriate response yet -(
*

*>> I am begging a suggestion for this tricky problem.
*

*>>
*

*>> Actually the question is how can I* control the date* for Y. For X is OK
*

*>> to
*

*>> keep it *fixed 90 days* for each year from 1 January to 30 March. But for
*

*>> Y
*

*>>
*

*>> is quite hard for me to understand how can I shift it by -15 to 15 days
*

*>> relative to X, meaning that Y time series start on 17 December and 15
*

*>> January for the first and the last analysis.
*

*>>
*

*>> Here is the illustration of the setting of time series :
*

*>>
*

*>> lag 0: X: 1 Jan |----------------------| 31 Mar 1
*

*>> Jan|----------------------|31 Mar .....
*

*>> Y: 1 Jan |----------------------| 31 Mar 1
*

*>> Jan|----------------------|31 Mar .....
*

*>>
*

*>> lag -1 X: 1 Jan |----------------------| 31 Mar 1
*

*>> Jan|----------------------|31 Mar ....
*

*>> Y: 31 Dec |----------------------| 30 Mar 31
*

*>> Dec|----------------------|30 Mar ....
*

*>>
*

*>> lag +1 X: 1 Jan |----------------------| 31 Mar 1
*

*>> Jan|----------------------|31 Mar ....
*

*>> 2 Jan |----------------------| 1 Apr 2
*

*>> Jan|----------------------| 1 Apr ....
*

*>>
*

*>>
*

*>> Thank you so much for your kind suggestion,
*

*>> It means a lot for me to figure out this matter.
*

*>> Thank you
*

*>>
*

*>> Best,
*

*>> Erika
*

*>>
*

*>>
*

*>>
*

*>>
*

*>>
*

*>>
*

*>> On Fri, Aug 9, 2013 at 8:54 PM, Erika Folova <e.folova@gmail.com> wrote:
*

*>>
*

*>>> I meant as I described earlier, I want to keep 90-day time period for X
*

*>>> "fixed" from1 January to 31 March while the time series of the Y is
*

*>>>
*

*>> shifted
*

*>>
*

*>>> by -15 to 15 days (nlag= +/- 15 ). That meansthe Y time series start on
*

*>>> 17
*

*>>> December and 15 January for the first and the last analysis. I still do
*

*>>>
*

*>> not
*

*>>
*

*>>> have an idea how to make it easily. Any help will be really appreciated.
*

*>>>
*

*>>> Thank you,..
*

*>>>
*

*>>>
*

*>>>
*

*>>>
*

*>>> On Fri, Aug 9, 2013 at 2:42 AM, Alessandra Giannini
*

*>>> <alesall@iri.columbia.edu> wrote:
*

*>>>
*

*>>>>
*

*>>>>
*

*>>>> Hi Erika,
*

*>>>>
*

*>>>> NCL has a correlation function that allows for lags:
*

*>>>>
*

*>>>> <http://www.ncl.ucar.edu/**Document/Functions/Built-in/**esccr.shtml<http://www.ncl.ucar.edu/Document/Functions/Built-in/esccr.shtml>
*

*>>>> >
*

*>>>>
*

*>>>> cheers, alessandra
*

*>>>>
*

*>>>>
*

*>>>>
*

*>>>>
*

*>>>>
*

*>>>> On Aug 8, 2013, at 1:38 PM, Erika Folova <e.folova@gmail.com> wrote:
*

*>>>>
*

*>>>> So.. no suggestion for my case :-(
*

*>>>>
*

*>>>>
*

*>>>> On Sat, Jul 27, 2013 at 5:58 AM, Erika Folova <e.folova@gmail.com>
*

*>>>> wrote:
*

*>>>>
*

*>>>>>
*

*>>>>> Hallo NCL,
*

*>>>>>
*

*>>>>> Lately I am quite confused to set my code to do a cross correlation,
*

*>>>>> The role is as follows: I have daily datasets lets say X and Y
*

*>>>>> extending for 5 years. The role is, I want to keep 90-day time period
*

*>>>>>
*

*>>>> for
*

*>>
*

*>>> X "fixed" from
*

*>>>>> 1 January to 31 March while the time series of the Y is shifted by -15
*

*>>>>>
*

*>>>> to
*

*>>
*

*>>> 15 days (nlag= +/- 15 ). That means
*

*>>>>> the Y time series start on 17 December and 15 January for the first and
*

*>>>>> the last analysis.
*

*>>>>>
*

*>>>>> What I think is something like this:
*

*>>>>>
*

*>>>>> mxlag = 15
*

*>>>>> lag = ispan(-mxlag,mxlag,1)
*

*>>>>>
*

*>>>>> do l = -mxlag,mxlag
*

*>>>>> CC (l+mxlag,:) = escorc( X(time), Y(time|time+l))
*

*>>>>> end do
*

*>>>>>
*

*>>>>> But I guess this is a wrong approach because I just want to concern on
*

*>>>>> JFM fixed on X but shifted for Y as I mentioned previously,
*

*>>>>> Any help would be really appreciated.
*

*>>>>>
*

*>>>>> Thank you
*

*>>>>>
*

*>>>>> Erika,
*

*>>>>>
*

*>>>>
*

*>>>>
*

*>>>> ______________________________**_________________
*

*>>>> ncl-talk mailing list
*

*>>>> List instructions, subscriber options, unsubscribe:
*

*>>>> http://mailman.ucar.edu/**mailman/listinfo/ncl-talk<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 Wed Aug 14 10:25:59 2013

*
This archive was generated by hypermail 2.1.8
: Wed Aug 14 2013 - 18:35:09 MDT
*