MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

spatial coherence

  • To: mathgroup at smc.vnet.net
  • Subject: [mg94275] spatial coherence
  • From: jasch at crustal.ucsb.edu
  • Date: Tue, 9 Dec 2008 07:01:43 -0500 (EST)

Dear group,

I want to compute the 2D spatial coherence between 2 random fields. I want
to not only compute if there is a correlation between the two fields at 0
offset (Correlation[Flatten@field1,Flatten@field2]), but i am interested
in the correlation between the points of field1 and the points at field2
that have an offset of dx and dy (dx and dy can be positive or negative).
Here is what I have tried so far: i create a submask of one field and then
shift this submask over the other field and compute the correlation at
each position (both fields have no periodic boundary conditions).

get2DCorr[f1_, f2_, n1_, n2_, m1_, m2_] :=
  Module[{dn, dm, field1, corrs},
   dn = n2 - n1;
   dm = m2 - m1;
(*submask*)
   field1 =
    f1[[Range[m1 + Floor[dm/4], m1 + 3*Floor[dm/4]],
      Range[n1 + Floor[dn/4], n1 + 3*Floor[dn/4]]]];
(*correlate this submask with submasks of field2*)
corrs = Table[
     Correlation[Flatten@field1,
      Flatten@f2[[Range[m1 + j, m1 + 2*Floor[dm/4] + j],
         Range[n1 + i, n1 + 2*Floor[dn/4] + i]]]], {j, 1,
      Floor[dm/2]}, {i, 1, Floor[dn/2]}];
   Return[{corrs,
     ReliefPlot[corrs, FrameTicks -> Automatic,
      DataRange -> {{-Floor[dn/2]*0.06,
         Floor[dn/2]*0.06}, {-Floor[dm/2]*0.06, Floor[dm/2]*0.06}},
      ColorFunction -> ColorData["ThermometerColors"]]}];
   ];
f1 and f2 are random fields, both have the same dimensions {nx,ny}
n1 and n2 can for example be 1 and nx, respectively
m1 and m2 can for example 1 and ny, respectively

I am wondering if there is a faster and more appropriate way of doing
this. I know there must be a way using the cross spectrum of the two
fields, but i am not sure how to do it correctly (especially to get a
resulting 2D map that has units of a correlation coefficient between -1..1
like the one I create with the module above)

Thank you very much!

Jan




  • Prev by Date: Re: Re: Clever Tricky Solutions
  • Next by Date: Re: Clever Tricky Solutions
  • Previous by thread: proxy / firewall problem
  • Next by thread: Re: spatial coherence