{"id":50468023,"url":"https://github.com/simonsobs/coberus","last_synced_at":"2026-06-01T08:32:48.527Z","repository":{"id":360112879,"uuid":"836329252","full_name":"simonsobs/coberus","owner":"simonsobs","description":"A library for exploring ways to quickly coadd our maps","archived":false,"fork":false,"pushed_at":"2026-05-25T02:56:21.000Z","size":5406,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":6,"default_branch":"main","last_synced_at":"2026-05-25T04:29:17.737Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simonsobs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-07-31T16:04:50.000Z","updated_at":"2026-04-09T20:29:56.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/simonsobs/coberus","commit_stats":null,"previous_names":["simonsobs/coberus"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/simonsobs/coberus","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonsobs%2Fcoberus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonsobs%2Fcoberus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonsobs%2Fcoberus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonsobs%2Fcoberus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simonsobs","download_url":"https://codeload.github.com/simonsobs/coberus/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonsobs%2Fcoberus/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33767435,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-01T02:00:06.963Z","response_time":115,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-01T08:32:45.644Z","updated_at":"2026-06-01T08:32:48.522Z","avatar_url":"https://github.com/simonsobs.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Coberus\n\nA python library for co-adding maps in parallel. Coberus works by splitting your\nmap up into chunks (by default of 400x400 pixels). Each thread is handed one\nchunk, and it goes to read the constituent chunks of the underlying maps from\ndisk. Co-addition then happens on a pixel-by-pixel level, with the chunking used\nto reduce file access overhead.\n\n### Setup\n\nYou can install this repository using `uv` or `pip`.\n\n```\n{uv} pip install git+https://github.com/simonsobs/map-coaddition\n```\n\nYou can then use the library in your code as `coberus`.\n\n### Example usage\n\nThere are multiple ways to use coberus.\n\n#### Simple - CLI\n\nThis relies on you having a pre-prepared directory with all of your maps\nhaving the correct names, with the following format:\n\n1. `map{N}.fits` for maps with index 1-N.\n2. `map{N}_mask.fits` for masks for maps.\n3. `cov_map{N}_map{M}.fits` for covariance maps between N and M.\n4. `responses.json` which is a list of floats (e.g. just `[1.0, 1.0, 1.0, ...]`)\n   giving the responses of the maps in order.\n\nYou can then run, assuming there are 5 maps and they live in `maps`:\n\n```\ncoberus --input=./maps --number=5 --output=coadded.fits\n```\n\n#### Advanced - Creating your own Coadder\n\nThis is useful if you have non-conforming filenames or you are trying to\nconnect to an existing dask cluster.\n\n`coberus` is made up of one core object, `Coadder`, and one main\nfunction `coadd`.\n\n```python\nfrom coberus import Coadder, coadd\nfrom dask.distributed import Client\n\nmaps = [\"mymap_a.fits\", \"mymapb.fits\"]\nmasks = [\"ma_a.fits\", \"ma-b.fits\"]\ncovariance_maps = [\n    [\"a_a.fits\", \"a_b.fits\"],\n    [\"a_b.fits\", \"b_b.fits\"],\n]\nrepsonses = [0.1, 0.9]\n\ncoadder = Coadd(\n    maps=maps,\n    masks=masks,\n    covariance_maps=covariance_maps,\n    responses=responses\n)\n\nclient = Client()\n\n# Result is a dask array\nresult = coadd(client, coadder)\n\n# This is now a numpy array\narr = result.compute()\n```\n\nThere are utility functions in `coberus.fits` to write the dask array to file.\n\n\n#### Needlet ILC Pipeline - `needlet_coadd`\n\nFor Needlet Internal Linear Combination (NILC) map coaddition, we recommend\nusing the `pipeline.needlet_coadd` function. It will wavelet-decompose\na set of input maps, empirically estimate the covariance and co-add\nthe maps using Dask-distributed parallelism.\n\n```python\nfrom coberus import pipeline\nimport numpy as np\n\n# Tags identify each input dataset\ntags = ['a', 'b']\nbase_tag = 'a'  # the map tag corresponding to the final geometry\n\n# Functions that return file paths given a tag\nmap_fname_func  = lambda tag: f'maps/imap_{tag}.fits'\nmask_fname_func = lambda tag: f'masks/mask_{tag}.fits'\n\n# Beam: returns the harmonic-space beam for a tag at multipoles ells\n# e.g. all maps have fwhm = 5.0 arcmin\nfwhm = 5.0\nbeam_func = lambda tag, ells: np.exp(-0.5 * ells * (ells + 1) * (fwhm * np.pi / 180 / 60) ** 2 / (8 * np.log(2)))\n\n# Response: SED of the component to preserve (1 for CMB) evaluated\n# for each input tag (corresponding to that frequency or passband)\nresponse_func = lambda tag: 1.0\n\n# Cosine needlet peaks define the wavelet basis\nlpeaks = [0, 500, 750, 1000, 1250, 1500]\n\n# Multipole range each tag contributes to\nlmins = [0, 0]\nlmaxs = [1500, 1500]\n\n# Output beam FWHM in arcminutes\nout_beam_fwhm = 5.0\n\n# Directory for intermediate wavelet/covariance files (use RAMdisk if possible)\n# and index with your simulation number\nout_root = '/dev/shm/my_job_0_'\n\nresult = pipeline.needlet_coadd(\n    map_fname_func, mask_fname_func, tags, base_tag,\n    lpeaks, lmins, lmaxs, response_func, beam_func,\n    out_beam_fwhm, out_root,\n    cov_smooth_type='gaussian',  # 'block', 'gaussian', or 'tophat'\n    n_workers=10, # For Dask parallelization\n)\ncoadd_map = result['coadd']\n```\n\n**Key inputs:**\n- **`map_fname_func(tag)`** — path to the input map (pre-masked and apodized for stable wavelet transforms).\n- **`mask_fname_func(tag)`** — path to a *binary* mask indicating which pixels to include.\n- **`beam_func(tag, ells)`** — harmonic-space beam profile; maps are reconvolved to `out_beam_fwhm`.\n- **`response_func(tag)`** — SED response of the preserved component (1 for CMB).\n- **`lpeaks`** — peak multipoles defining the cosine needlet basis.\n- **`lmins` / `lmaxs`** — per-tag multipole limits controlling which needlet scales each tag enters.\n- **`out_root`** — path prefix for intermediate files; `/dev/shm/` is recommended for speed.\n\n**Optional features:**\n- **`deproj_response_funcs`** — list of response functions for constrained ILC deprojection (e.g. tSZ removal).\n- **`cov_smooth_type`** — covariance smoothing method: `'block'` (default), `'gaussian'` ([2307.01043](https://arxiv.org/abs/2307.01043)), or `'tophat'` ([2307.01258](https://arxiv.org/abs/2307.01258)).\n- **`nmap_labels` / `nmap_label_fname_func`** — coadd additional maps (e.g. simulations) using weights derived from the data maps; results returned as `result['\u003clabel\u003e_coadd']`.\n- **`delete_intermediate=True`** — clean up wavelet/covariance files after completion.\n\nSee `examples/example_notebook.ipynb` for a complete worked example with simulated CMB maps.\n\n\n#### Naming\n\nThe name `coberus` is a play on `coadder`. 'Adders' are a common species of\n[snake in Europe](https://en.wikipedia.org/wiki/Adder), and have the species\ndesignation of _Vipera berus_.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonsobs%2Fcoberus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimonsobs%2Fcoberus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonsobs%2Fcoberus/lists"}