Skip to content

Mask validation#60

Open
jsyleung wants to merge 28 commits into
mainfrom
mask-validation
Open

Mask validation#60
jsyleung wants to merge 28 commits into
mainfrom
mask-validation

Conversation

@jsyleung
Copy link
Copy Markdown
Collaborator

For a set of analysis masks (in the same directory), plot their effects on power spectra on the same plot for easy comparison.

Includes options for:

  • B-mode purification
  • Map unit conversion
  • Beam FWHM

Scans a directory for analysis masks, applies them to CMB sims, and
passes the masked maps into NaMaster to obtain the power spectra.
Outputs plots in directory specified in pipeline/get_analysis_mask.py
@jsyleung jsyleung requested a review from kwolz June 20, 2025 15:00
Cls have units temp^2
Copy link
Copy Markdown
Collaborator

@kwolz kwolz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! This will be super useful to be run alongside the mask generation script. Just a few comments.

Comment thread pipeline/misc/validate_mask_isohits.py Outdated
BBmeta.make_dir(plot_dir)

# Check mask directory for masks
mask_basename = "analysis_mask"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make the default option to analyze only the mask at meta.mask["analysis_mask"], and only if that is null, look for the masks in the mask directory? The reason is that soopercool will by default compute power spectra from the former, and in general {mask_dir}/analysis_mask.fits may differ from meta.mask["analysis_mask"].

Comment thread pipeline/misc/validate_mask_isohits.py Outdated
plt.plot(ells[tag], (means_bb[tag]-cbbb)/std_bb[tag], label=labels[tag])
plt.xlabel(r"Multipole $\ell$")
plt.ylabel(r"$(\^{C}_b - C_b^{\mathrm{th}})/\sigma(\^{C}_b)$")
plt.savefig(os.path.join(plot_dir, "mask_validation_sigmas.png"), bbox_inches='tight')
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add the same quantity for EE to the same plot? It would be useful to see if EE is biased too.

Comment thread pipeline/misc/validate_mask_isohits.py Outdated
parser = argparse.ArgumentParser()
parser.add_argument("--globals", required=True, help="Path to paramfile")
parser.add_argument("--fwhm", default=30, help="Beam size (arcmin). Default: 30")
parser.add_argument("--puretype", default='cmbTEB', help="Input sim pure type (T/E/B). Default: 'cmbTEB'")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit peaky comment: can we not call this puretype, but maybe something like simtype? The reason is that pure_type is being used for the transfer function estimation sims, which are not CMB sims (containing B, EB, or TEB, etc.) but power-law Gaussian sims that carry only one type of polarization.

Comment thread pipeline/misc/validate_mask_isohits.py Outdated
plt.plot(ells[tag], std_bb[tag]/std_bb_bonly[tag], label=labels[tag])
plt.xlabel(r"Multipole $\ell$")
plt.ylabel(r"$\sigma(C_b^{\mathrm{CMB}})/\sigma(C_b^{\mathrm{B\ only}})$")
plt.savefig(os.path.join(plot_dir, "mask_validation_compare_bonly.png"), bbox_inches='tight')
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here a log-scale for y could help seeing the deviation from 1 more clearly, especially if the variance ratio becomes very large for small ell.

@kwolz
Copy link
Copy Markdown
Collaborator

kwolz commented Mar 14, 2026

Completed substantial refactoring to mask-related code. Major changes are:

  • Rewrote mask validation script to accept minimal input, generate simulations on the fly, output chi2-based test diagnostics, and support efficient MPI parallelization.
  • Mask generator applies cropped mask edges.
  • Mask utilities (e.g. spin derivatives, fsky calculation) fully generalized.

Mask-related code elements have now improved documentation.

@kwolz kwolz requested a review from adrien-laposta March 14, 2026 23:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants