GithubHelp home page GithubHelp logo

Comments (8)

damonge avatar damonge commented on August 30, 2024

Hi @YutoMinami

I'm slightly confused by the notation you're using. Let's see if this clarifies things:
Let's say you want to compute the covariance between power spectrum cl_A1A2 and power spectrum cl_B1B2. Say that power spectrum cl_A1A2 is the cross-correlation between two fields (fA1,fA2) and cl_B1B2 is the cross-correlation between (fB1,fB2). Then, you should use:

wA=nmt.NmtWorkspace()
wA=nmt.compute_coupling_matrix(fA1,fA2,b)
wB=nmt.NmtWorkspace()
wB=nmt.compute_coupling_matrix(fB1,fB2,b)
cwAB=nmt.NmtCovarianceWorkspace()
cwAB.compute_coupling_coefficients(fA1,fA2,fB1,fB2)

covariance = nmt.covariance_gaussian_covariance(cwAB, spin_A1, spin_A2, spin_B1, spin_B2,
                                                cl_A1B1, cl_A1B2, cl_A2B1, cl_A2B2, wA, wB)

Does this make sense?

from namaster.

YutoMinami avatar YutoMinami commented on August 30, 2024

Hi @damonge

With such expression, I'd like to compute the covariance between power spectrum cl_A1A2 cl_A1A2.

fA1_0, fA1_2 = nmt.NmtField(mask, [inmap1[0] ],  nmt.nmtField(mask, inmap1[1:]) )
fA2_0, fA2_2 = nmt.NmtField(mask, [inmap2[0]],  nmt.nmtField(mask, inmap2[1:]) )
wA=nmt.NmtWorkspace()
wA=nmt.compute_coupling_matrix(fA1_2,fA2_2,b)
cw = nmt.NmtCovarianceWorkspace()
#cw.compute_coupling_coefficients(fA1_0,fA2_0,fA1_0,fA2_0) # This results in wrong covariance
cw.compute_coupling_coefficients(fA1_0,fA1_0,fA1_0,fA1_0) # This works well
covariance = nmt.covariance_gaussian_covariance(cw, 2,2,2,2,
                                                cl_A1_2A2_2, cl_A1_2A2_2, cl_A1_2A2_2, cl_A1_2A2_2, wA, wA)

from namaster.

damonge avatar damonge commented on August 30, 2024

Hmmmh, that's surprising.
The call to compute_coupling_coefficients should only depend on the masks of the different fields being passed. Since all of your fields have the same mask, this is very strange. Am I interpreting this correctly?

Also, note that if you just want power spectra and covariances for two spin-2 fields, you don't really need to generate any spin-0 fields at all (e.g. you could just pass fA1_2 instead of fA1_0 to compute_coupling_coefficents).

from namaster.

YutoMinami avatar YutoMinami commented on August 30, 2024

The call to compute_coupling_coefficients should only depend on the masks of the different fields being passed. Since all of your fields have the same mask, this is very strange. Am I interpreting this correctly?

Yes. I checked again whether the same mask is passed to the different field and it is. Therefore I wondered what coefficients are intended to be calculated in the function.

Also, note that if you just want power spectra and covariances for two spin-2 fields, you don't really need to generate any spin-0 fields at all (e.g. you could just pass fA1_2 instead of fA1_0 to compute_coupling_coefficents).

Thanks.

from namaster.

YutoMinami avatar YutoMinami commented on August 30, 2024

Hi @damonge

I'm sorry I checked and re-run my program and found there is an incorrect explanation.
Though I said only
#cw.compute_coupling_coefficients(fA1_0,fA2_0,fA1_0,fA2_0) solved the problem,
actually I also changed from
wA=nmt.compute_coupling_matrix(fA1_2,fA2_2,b)
to wA=nmt.compute_coupling_matrix(fA1_2,fA1_2,b) when I got correct covariance matrix.

This means even for the calculation of variance of cross correlation, the same field is needed as an input.

I reproduced the small variance problem as the following:
I created one CMB sky map with some beam smoothing and two different noise map.
From them I created two CMB sky maps with different noise map (fA_1 and fA_2).
Then I calculate pseudo cl from fA_1 and fA_2 and use them as an input to gaussian_covariance().
For the workspace wA=nmt.compute_coupling_matrix(fA1_2,fA2_2,b) is used.
Then I compared the variance of 'EB' from NaMaster and sample variance.
It shows that in low ell where CMB is dominant and CMB is auto correlated, NaMaster variance agrees to sample variance and in high ell where noise is dominant and noise is cross correlated, NaMaster variance becomes too small compared to sample variance as if there is no noise.

So, my question should be "How can I calculate correct variance from different realization?"

from namaster.

damonge avatar damonge commented on August 30, 2024

Hi @YutoMinami
I'm very sorry it's taken me so long to respond. The covariance for the EB power spectrum is very inaccurate in the approximation used by namaster (we show this here: https://arxiv.org/abs/1906.11765), so I'm not completely surprised that this doesn't work well. I this case I think the best way forward is actually using simulations.

I'm still suprised that the resulting covariance depends on the fields you pass to compute_coupling_coefficients if all of them have the same mask... Is that still the case?

from namaster.

damonge avatar damonge commented on August 30, 2024

I'll close this for now, but feel free to reopen

from namaster.

YutoMinami avatar YutoMinami commented on August 30, 2024

Hi @damonge
As I explained in
#61 (comment) ,
I changed both compute_coupling_matrix and compute_coupling_coefficients.
Therefore, I think compute_coupling_coefficients itself doesn't make change.
Thank you.

from namaster.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.