Clean up cosmo_inference folder#236
Conversation
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
🔴 ruff found lint / format issues@LisaGoh — these block the merge into
|
|
Wow I love to see -17k lines :) and i think this is the first time we've seen the new ruff auto-check. Will review in a bit! I think we can leave inference.smk un-tested and fix any bugs when we start running chains on the GLASS mocks |
|
hmm, @martinkilbinger could you please add Lisa as a maintainer to sp_validation so that the workflows run automatically and don't have to be approved manually each time? or you can make me an owner and i can do it :) |
cailmdaley
left a comment
There was a problem hiding this comment.
Thanks Lisa — this is a great cleanup, and the structure of it is exactly right: the templates/ + output/ split, the .gitignore, inference.smk, and cosmosis_fitting.py changes are all internally consistent, and −17k lines speaks for itself. 🎉
We did the light testing pass discussed in the thread (no full inference.smk run): py_compile on all 12 changed .py files passes, and we checked the new cs_util.cosmo calls against the cs_util source. That turned up two real bugs in the new chain_postprocessing.py logic (inline comments below) — both quick fixes — plus a few smaller things:
Deletion fallout (worth fixing in this PR):
workflow/rules/covariance.smk:256still invokes the deletedscripts/cosmocov_process.py, andpapers/bmodes/scripts/run_cov_sweep.sh:68calls the deletedworkflow/scripts/run_cosmocov_chain.sh. Since CosmoCov is being retired for OneCovariance anyway, I'd say drop/update those callers here so nothing dangles. (We checked the2pt_like_xi_sys.py/xi_sys_psf.pyreferences too — those resolve via%(COSMOSIS_DIR)sinto the CosmoSIS install, so they're fine.)
Dependency note (not this PR's fault, but it bites here first):
get_cosmo/c_ell_to_xionly exist on cs_util's development branch — released cs_util 0.2.1 (what the container has and what sp_validation pins) doesn't have them, so the import fails until a new cs_util release is cut. Worth coordinating with Martin on a release before merging, or at least noting it.
Optional / non-blocking:
- The converted
papers/realspace/*.pyscripts still carry some notebook artifacts — liveget_ipython()/display()calls (glass_mock_hist.py,get_chi2.py:562,unblinding_party_plots.py), twoplt.savefig("/Plots/…")paths incontours.py(632, 745) that would try to write to the filesystem root, and hardcoded/home/guerrinipaths throughout. Since these are archival figure scripts that's fine — maybe just a one-line header note that they document the 2D analysis rather than being re-runnable as-is. cosmosis_fitting.py's module docstring still says products land incosmosis_config/; they now go tooutput/.
Once the two inline fixes are in, this looks good to us — and per the thread, we'll shake out any remaining inference.smk wiring when we start running chains on the GLASS mocks.
— Claude (Fable) on behalf of Cail
| theta_deg = np.rad2deg(theta_rad) | ||
| xi_p = ccl.correlation(cosmo, ell=ell, C_ell=shear_cl, theta=theta_deg, type="GG+") | ||
| xi_m = ccl.correlation(cosmo, ell=ell, C_ell=shear_cl, theta=theta_deg, type="GG-") | ||
| xi_p, xi_m = cs_cosmo.c_ell_to_xi(cosmo, theta_rad, ell, shear_cl) |
There was a problem hiding this comment.
Units bug: c_ell_to_xi expects theta in arcminutes (it converts with theta / 60 internally), but theta_rad here is in radians — so the correlation functions get evaluated at angles ~3438× too small. The previously-deleted code did the np.rad2deg conversion explicitly.
xi_p, xi_m = cs_cosmo.c_ell_to_xi(cosmo, np.rad2deg(theta_rad) * 60, ell, shear_cl)Keep saving theta_rad to theta.txt as you do below — the reader at L627 multiplies by 180/π·60, i.e. it expects radians there.
|
Regarding Note also that the API of |
|
Thank you for the review! I've updated this branch to match develop, so I'll keep referencing the develop branch of I've also added the |
|
Thanks Lisa! One more ruff pass and I think this is good to go |
Addresses #235. So far I have:
papers/subfolder and converted them to.pyscripts to save spacecosmosis_fitting.pyandchain_postprocessing.pyscripts since they were overlapping/obsolete.cosmosis_configsubfolder to only include the template ini files (and separated the ini files intotemplatesandouput, whereby the contents ofoutputare only generated per user and not included in the repo to keep things lean)cosmocov_configsubfolder (in preparation for our switch to OneCovariance adoption instead)chain_postprocessing.pyscript to use thecs_util.cosmofunctionalities when computing the bestfitI have not yet run the
inference.smkworkflow myself, but per Claude the logic should not have been broken with these changes. I hope this helps!