feat(shape): add e<->g ellipticity converters#69
Merged
Conversation
New cs_util.shape module, parallel to cs_util.size, as the single home for the distortion (e-type) <-> reduced-shear (g-type) conversion used across the UNIONS / ShapePipe stack: g = e / (1 + sqrt(1 - e^2)) (e_to_g) e = 2 g / (1 + g^2) (g_to_e) Component-wise (the WL-native two-component form): both ellipticity components are scaled by the magnitude ratio, preserving orientation. Producers (ShapePipe HSM e-type vs ngmix g-type) and consumers (sp_validation) import from here rather than re-deriving the factors. No version bump: downstream (shapepipe) tracks cs_util @ develop rather than pinning a release, so new helpers are available without a ship. Closes the converter half of Sacha Guerrini's review point on CosmoStat/shapepipe#761. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BXY93SBtDvLLrxWX8Vh4KW
…use the components directly instead
Collaborator
|
Apparently I do not have write access to the repo. I have a commit related to this PR. @martinkilbinger can you check if I do have write access and I made a mistake when pushing and if not could you add me? |
Collaborator
Author
|
gave you maintainer access @sachaguer |
Collaborator
|
Thanks, the PR meets its goals. As for me, it can be merged if all the CD/CI's pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
cs_util.shape, a small module parallel tocs_util.size, as the single home for the distortion (e-type) ↔ reduced-shear (g-type) ellipticity conversion used across the UNIONS / ShapePipe stack:Both functions are component-wise (the WL-native two-component form): the two ellipticity components are scaled by the magnitude ratio, so orientation is preserved. Round objects map to round objects; the small-ellipticity limit reduces to
e ≈ 2g.No version bump. Downstream (shapepipe) will track
cs_util @ developrather than pinning a release, so new helpers like this are available without shipping a new version each time.Why
ShapePipe's HSM moments store the distortion
ewhile ngmix stores the reduced shearg; downstream (sp_validation) sometimes needs one given the other. Centralising the conversion here means producers and consumers import a single source of truth rather than re-deriving the factors locally — the same move that motivatedcs_util.size.This closes the converter half of Sacha Guerrini's review point on CosmoStat/shapepipe#761 (HSM is e-type, ngmix g-type — name consistently and add a converter).
Tests
cs_util/tests/test_shape.py— known q=1/3 pair (|e|=0.8 ↔ |g|=0.5), axis-ratio closed forms, component-wise round-trips, orientation preservation, zero handling, small-ellipticity limit, array shapes. All pass.— Claude on behalf of Cail
Closes #73 — the e↔g converter single-source-of-truth (a sub-issue of the ngmix v2.0 epic CosmoStat/shapepipe#762). Linked here via the Development sidebar so the issue tracks this PR and closes when it merges.