ajdawson / eofs

EOF analysis in Python
http://ajdawson.github.io/eofs/
GNU General Public License v3.0
199 stars 60 forks source link

about the difference between .pcs() and .projectField() #135

Open AndreaVitoVacca opened 1 year ago

AndreaVitoVacca commented 1 year ago

dear @ajdawson , thank you very much for this package. I am using eofs.xarray.Eof() to reduce the space dimensionality on which to compute a clustering algorithm to extract atmospheric circulation pattern. In particular, I am applying the clustering on the PCS of a field of daily geopotential height anomalies. I am having unexpected wrong results when using .pcs(), but right results if I use instead the .projectField(). In this framework my doubt is the following: My theoretical understanding of the topic leads me expect that If i project the field on the EOF space obtained from the field itself (.projectField()), the resulting pseudo-pcs should be exactly the same as the pcs (or at least pretty similar). I tried this with different datasets and saw that this is not the case (the pseudo-pcs are different from pcs). I also tried to dive into the souce code, without clarifying my ideas. Could you please give me a rationale for this behavior?

this could help to interpret my results and understand when to use .projectField() and .pcs() for my purposes. For completeness, I attach some line of the code I am using. Thank you for the attention, I apologies for the issue not strictly related to errors in the code but more on the understanding of the outputs. Kind regards, Andrea Vito Vacca

eof = eofs.xarray.Eof(field,weights=wgts) pcs = eof.pcs(npcs=4) pseudo_pcs=eof.projectField(field,neofs=4) clus1 = KMeans(n_clusters=4,random_state=100).fit(pcs) # wrong results clus2 = KMeans(n_clusters=4,random_state=100).fit(pseudo_pcs) # right results