Skip to content

Fourier filtering, covariance fixes and masks#70

Merged
adrien-laposta merged 35 commits into
mainfrom
ML_maps
May 26, 2026
Merged

Fourier filtering, covariance fixes and masks#70
adrien-laposta merged 35 commits into
mainfrom
ML_maps

Conversation

@adrien-laposta
Copy link
Copy Markdown
Collaborator

This PR merges three different branches

  • ML_maps: allows for an additional Fourier filtering step on maps (can be either F+B or ML maps). Applying the Fourier filter might require being careful about sharp features in our maps. This new feature is therefore coupled to the mask refactoring recent changes.
  • mask-validation: This branch (see Mask validation #60) merges changes from the refactor_mask branch as it is complementary to the validation script introduced. Fourier filtering step requires the cropped version of the binary mask generated with this new mask definition script.
  • covfix: This was just a branch started mostly to fix an issue with the binning of beam window functions when using compute_Dl: True in the parameter file. It has been merged and tested on ML maps, with changes introduced in this branch.

commit ac76d04
Author: kwolz <kevin.wolz93@gmail.com>
Date:   Sat Mar 14 19:59:24 2026 -0400

    remove unnecessary line

commit 50c011f
Author: kwolz <kevin.wolz93@gmail.com>
Date:   Sat Mar 14 19:56:58 2026 -0400

    removed unused script

commit ffefc79
Author: kwolz <kevin.wolz93@gmail.com>
Date:   Sat Mar 14 19:45:43 2026 -0400

    lint

commit b9e9116
Merge: 3cd5550 6596179
Author: kwolz <kevin.wolz93@gmail.com>
Date:   Sat Mar 14 19:42:10 2026 -0400

    merging from remote

commit 3cd5550
Author: kwolz <kevin.wolz93@gmail.com>
Date:   Sat Mar 14 19:34:14 2026 -0400

    add mask validation script, small refactoring of map_utils

commit b17450d
Author: kwolz <kevin.wolz93@gmail.com>
Date:   Sat Mar 14 19:31:50 2026 -0400

    refactor & doc get_analysis_mask

commit 7248903
Merge: 0ce6c85 329a7bc
Author: kwolz <kevin.wolz93@gmail.com>
Date:   Thu Feb 19 13:19:03 2026 -0500

    resolve merger conflicts

commit 329a7bc
Author: Adrien La Posta <adrien.la.posta@gmail.com>
Date:   Wed Feb 18 17:44:46 2026 +0000

    first commit, clean smooth mask

commit 6596179
Author: kwolz <kevin.wolz93@gmail.com>
Date:   Sun Sep 28 14:41:24 2025 +0100

    improve plot transfer function

commit da91814
Author: kwolz <kevin.wolz93@gmail.com>
Date:   Sun Sep 28 14:40:46 2025 +0100

    mask spin derivatives

commit 5c49012
Author: Jason Leung <leung@astro.utoronto.ca>
Date:   Wed Aug 6 10:00:00 2025 +0100

    Improve plots for mask validation

commit 874ee89
Author: Jason Leung <leung@astro.utoronto.ca>
Date:   Tue Aug 5 12:00:00 2025 +0100

    Change argument name from 'puretype' to 'simtype'

    since 'puretype' refers to power-law Gaussian sims whereas mask
    validation uses CMB sims as input.

commit 83ad1d8
Author: Jason Leung <leung@astro.utoronto.ca>
Date:   Mon Aug 4 16:00:00 2025 +0100

    Default to validate only the mask listed in config

    Only if that mask is not found, look for masks in the mask directory.
    Print plot directory on screen.

commit 0ce6c85
Author: kwolz <kevin.wolz93@gmail.com>
Date:   Thu Jul 24 04:29:13 2025 -0400

    changed car apodization

commit f3b8c86
Author: kwolz <kevin.wolz93@gmail.com>
Date:   Wed Jul 16 18:25:38 2025 -0400

    mostly naming conventions

commit 4f2b68a
Author: kwolz <kevin.wolz93@gmail.com>
Date:   Wed Jul 16 18:24:27 2025 -0400

    script to coadd signal and noise sims

commit a29bcc4
Author: kwolz <kevin.wolz93@gmail.com>
Date:   Wed Jul 16 18:23:53 2025 -0400

    noise curve fitting and plotting

commit 4af8558
Author: kwolz <kevin.wolz93@gmail.com>
Date:   Wed Jul 16 18:23:26 2025 -0400

    add approximate Gaussian ISO beams

commit 927febe
Author: kwolz <kevin.wolz93@gmail.com>
Date:   Wed Jul 16 18:22:39 2025 -0400

    plotting improvements and car apodzation

commit 4010704
Author: kwolz <kevin.wolz93@gmail.com>
Date:   Wed Jul 16 18:16:13 2025 -0400

    mask: added weights option; shifted smoothing before apodization

commit 354efe2
Author: kwolz <kevin.wolz93@gmail.com>
Date:   Fri Jul 11 11:06:08 2025 -0400

    update N_ell fitting routine

commit d884836
Author: kwolz <kevin.wolz93@gmail.com>
Date:   Fri Jul 11 11:03:35 2025 -0400

    lmax management

commit b94cb53
Author: kwolz <kevin.wolz93@gmail.com>
Date:   Thu Jul 24 04:36:09 2025 -0400

    change car apodization

commit 0ea3700
Author: kwolz <kevin.wolz93@gmail.com>
Date:   Fri Jul 11 10:58:21 2025 -0400

    modernized mpi_utils

commit 199b38e
Author: kwolz <kevin.wolz93@gmail.com>
Date:   Fri Jul 11 10:55:21 2025 -0400

    add alternative (temporary) mask generation

commit 18fd459
Author: kwolz <kevin.wolz93@gmail.com>
Date:   Fri Jul 11 10:54:02 2025 -0400

    lmax management in MCM computation

commit c8f532c
Author: Jason Leung <leung@astro.utoronto.ca>
Date:   Mon Jun 23 09:00:00 2025 +0100

    Fix plot units

    Cls have units temp^2

commit 3e1b791
Author: Jason Leung <leung@astro.utoronto.ca>
Date:   Fri Jun 20 14:00:00 2025 +0100

    Add mask validation script

    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
…rders are not sharp and within the footprint
Comment thread pipeline/misc/validate_mask.py
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.

A few comments. Looks good overall.

Comment thread pipeline/kspace/filter_sims_kspace.py
Comment thread pipeline/misc/validate_mask.py
out_unf = f"{pcls_tf_est_dir}/pcls_mat_tf_est_{ftag1}_x_{ftag2}_unfiltered_{id_sim:04d}.npz" # noqa
preproc_ftag1, kspace_tag1 = ftag1
preproc_ftag2, kspace_tag2 = ftag2

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.

These names are getting long! Can we add a (...) around each lab to help identifying their content from the file name?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Not sure I fully understood this, you want to explicitely separate them in the fname string using brackets ? (Overall I agree with you on file name length - that's the price to pay to stay explicit)

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.

Yes, something like {ftag1}_x_{ftag2} --> ({ftag1})_x_({ftag2})

print(f"{tf_dir}/transfer_function_{ftag1}_x_{ftag2}.npz")
lab1 = f"{ftag1[0]}_{ftag1[1]}"
lab2 = f"{ftag2[0]}_{ftag2[1]}"
print(f"{tf_dir}/transfer_function_{lab1}_x_{lab2}.npz")
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.

Same suggestion as above to put brackets around lab1 and lab2 in the file names

tf = np.load(f"{tf_dir}/transfer_function_{ftag1}_x_{ftag2}.npz")
ktag1 = meta.kspace_tag_from_map_set(ms1)
ktag2 = meta.kspace_tag_from_map_set(ms2)
tf = np.load(f"{tf_dir}/transfer_function_{ftag1}_{ktag1}_x_{ftag2}_{ktag2}.npz") # noqa
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.

see above

Comment thread pipeline/create_sacc_file_analytic.py Outdated
Comment thread pipeline/create_sacc_file_analytic.py Outdated
Comment thread pipeline/create_sacc_file_analytic.py
Comment thread pipeline/compute_pseudo_cells.py
Comment thread pipeline/compute_sims_pseudo_cells.py
@adrien-laposta
Copy link
Copy Markdown
Collaborator Author

Regarding all comments related to the naming convention length.

  • A quick grep looking for occurrences of ftag gives a lot of results: it feel unsafe to propagate all changes there.
  • This naming convention length issue will also occur for spectra (if map_sets are quite long and descriptive), covariances (pairs of map_set pairs) and other products such as coupling matrices.
  • I'd rather open an issue on this, to see if we find any elegant way of compressing these labels to make pipeline output more human-readable and apply it to all outputs all at once.

@adrien-laposta
Copy link
Copy Markdown
Collaborator Author

Regarding all comments related to the naming convention length.

* A quick grep looking for occurrences of `ftag` gives a lot of results: it feel unsafe to propagate all changes there.

* This naming convention length issue will also occur for spectra (if map_sets are quite long and descriptive), covariances (pairs of `map_set` pairs) and other products such as coupling matrices.

* I'd rather open an issue on this, to see if we find any elegant way of compressing these labels to make pipeline output more human-readable and apply it to all outputs all at once.

An issue has been opened there #75

@chervias
Copy link
Copy Markdown
Member

This PR is missing applyting the k-space filter to the signflip spectra estimation that happens on pipeline/compute_signflip_sims_pseudo_cells.py

Comment thread soopercool/map_utils.py Outdated

def almtomap(alm):
return alm2map(alm, pix_type=pix_type, nside=nside,
car_map_template=temp)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this is a bug, alm2map has parameter car_template, not car_map_template

Comment thread soopercool/utils.py


def plot_transfer_function(lb, tf_dict, lmin, lmax, field_pairs, file_name):
def plot_transfer_function(lb, tf_dict, lmin, lmax, field_pairs,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Here tf_dict is assumed to be a dictionary, but the way it is used you actually pass a npz file here, which is not the same, so this function is broken as is. I'm not sure how you want to handle it, I will deactivate plots for now for me.

@adrien-laposta adrien-laposta merged commit 2428c7a into main May 26, 2026
1 check passed
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.

4 participants