Re: Cross correlation between two zonally averaged variables

From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>
Date: Fri Apr 06 2012 - 15:11:21 MDT

Hi Noel,
Responses below..

On 04/06/2012 09:45 AM, Noel Aloysius wrote:
> Hi Adam,
>
> Thanks for the reply.
>
> A) Zonal average
>
> I checked the output summary of the cross correlations. The zonal
> averge output dimentions are [lat | 35] x [month | 12] wheras the
> cross-corr dimensions are [35]. Does escorc computes the correlations
> across 12-months and gives a single value for each lat?

Yes, in this case, escorc computes the correlations across 12-months and
gives a single value for each lat.

> If this is the case, how can I get the cross correlations for each lat
> by month, ie with the same dimension as [lat | 35] x [month | 12].

You calculated the monthly climatology before you calculate the zonal
averages, thereby reducing the number of timesteps from 600 (as you have
10yrs of data) to 12. Instead of calculating and operating on the
monthly climatology, do you really want to remove the monthly annual
cycle (via say rmMonAnnCycTLL), and then operate on the anomalous data
that has 600 timesteps? From there you could code a do loop that
calculates the cross correlation on every January, February, etc.. For
instance:

Panom = rmMonAnnCycTLL(P(t1:t2,ilt1:ilt2,iln1:iln2))
Pzone1 = dim_avg_Wrap(Panom(lat|:,time|:,lon|:))

(repeat for Pzone2)

ccr = Pzone1(:,:11) ; preallocate array with correct
meta-data/coordinate variables
do gg = 0,11
      ccr(:,gg) = (/ escorc(Pzone1(:,gg::12),Pzone2(:,gg::12)) /) ;
gg::12 means start at gg and go to the end of the index by 12
end do

>
> B) Max values of a variable along lat
>
> From the zonal average, Pzone1 and 2, I want to get the max value
> along the latitudes for each month, identify the latitiude at which
> the max occurs and create an xy plot that shows the magnitude and
> location.
> i) The max value can be computed using dim_max, but how can I get
> the lat value index.
> ii) How can I combine these two and create a single xy plot, with
> month on x axis and lat on y axis.
>
> The script I developed so far is attached. Lines 56-58 and 90-93 shows
> I how compute climatology, zonal average and max values.
>

You can use the ind function to get at the latitudes:
; (untested)
; Operates on each timestep and identifies latitude of max value

mlat = new(dimsizes(PZone1&time),typeof(PZone1&lat))
lat1 = PZone1&lat
do gg = 0,dimsizes(PZone1&time)-1
      arr = Pzone1(:,gg)
      temp = dim_max(arr)
      i = ind(arr.eq.temp)
      mlat(gg) = lat1(i)
      delete([/arr,temp/])
end do

Then you can plot mlat via gsn_csm_xy...
Adam

> Thank you again for the assistance,
>
> Noel
>
>
> On Thu, Apr 5, 2012 at 7:40 PM, Adam Phillips <asphilli@ucar.edu
> <mailto:asphilli@ucar.edu>> wrote:
>
> Hi Noel,
> Striping out some lines from your code:
> Pzone1 = dim_avg_Wrap(Pclm(lat|:,month|:,lon|:))
> Pzone2 = dim_avg_Wrap(Pclm(lat|:,month|:,lon|:))
> ..... (So both Pzone1 and Pzone2 are dimensioned lat x month
> ccr = escorc(Pzone1,Pzone2)
> .....
> plot(0) = gsn_csm_lat_time(wks, ccr, res)
>
> The output array (ccr) from escorc will be a 1D array of size
> dimsizes(Pzone1&lat). ccr will also not contain any associated
> coordinate variables. gsn_csm_lat_time expects a 2D array
> dimensioned lat x time, and that is why you are getting that error
> message. Try using printVarSummary after the lines above to see
> what I mean.
>
> I'm not 100% sure that this is what you want, but if you want to
> correlate the corresponding time series (at each latitude) and
> then plot the correlation coefficients at each latitude, you can
> do that with a line plot. gsn_csm_xy should do the trick.
>
> Hope that helps. If not, or if you have further queries, please
> let ncl-talk know.
> Adam
>
>
> On 04/05/2012 12:44 PM, Noel Aloysius wrote:
>> Hello NCL-talk,
>>
>> I want to create a plot of cross-correlation between two zonally
>> averaged variables. I used clmMonTLL and dim_avg_Wrap to create
>> the zonal averages and then used escorc function to compute the
>> correlation. When I tried to plot results I get the following
>> error. I will appreciate any help to resolve this,
>>
>> (0) check_for_y_lat_coord: Warning: Data either does not
>> contain a valid latitude coordinate array or doesn't contain one
>> at all.
>> (0) A valid latitude coordinate array should have a 'units'
>> attribute equal to one of the following values:
>> (0) 'degrees_north' 'degrees-north' 'degree_north'
>> 'degrees north' 'degrees_N' 'Degrees_north' 'degree_N' 'degreeN'
>> 'degreesN' 'deg north'
>>
>> The script is attached. Thank you in advance,
>> Noel
>>
>>
>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
> --
> ______________________________________________________________
> Adam Phillipsasphilli@ucar.edu <mailto:asphilli@ucar.edu>
> NCAR/Climate and Global Dynamics Division(303) 497-1726 <tel:%28303%29%20497-1726>
> P.O. Box 3000
> Boulder, CO 80307-3000http://www.cgd.ucar.edu/cas/asphilli
>
>
> _______________________________________________
> 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

-- 
______________________________________________________________
Adam Phillips                                asphilli@ucar.edu
NCAR/Climate and Global Dynamics Division       (303) 497-1726
P.O. Box 3000				
Boulder, CO 80307-3000    http://www.cgd.ucar.edu/cas/asphilli

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Apr 6 15:11:32 2012

This archive was generated by hypermail 2.1.8 : Mon Apr 09 2012 - 13:43:03 MDT