Skip to content

Commit c2d03c3

Browse files
authored
Merge pull request #761 from CosmoStat/refactor/psf-column-grammar
ngmix v2.0: one column grammar across estimators (PSF source-of-truth, single size, E↔G)
2 parents db61e5b + e9bfd53 commit c2d03c3

26 files changed

Lines changed: 2856 additions & 605 deletions

CLAUDE.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,30 @@ way to get all of that is the container.
3636
sandbox with a host clone of the repo bind-mounted in and `pip install -e`
3737
pointed at it, so edits on the host are live inside the container.
3838

39+
**Shadow a library build with `PYTHONPATH` (no image rebuild).** When you need
40+
the container to run a *different* build of a pure-Python library than the one
41+
baked into its venv — a feature worktree, an unreleased branch, this repo's own
42+
`src/` against a stale image — prepend the host checkout to `PYTHONPATH`. Python
43+
resolves the prepended path first, so the on-disk version shadows
44+
`/app/.venv/...` without touching the image. This is the local-testing
45+
counterpart of a git-ref dependency (e.g. `cs_util @ develop` in
46+
`pyproject.toml`): the dep change makes CI build the right version; the shadow
47+
lets you test that version *now*, before any rebuild. The recipe:
48+
49+
```bash
50+
apptainer exec --bind /n17data,/automnt <image.sif> bash -c \
51+
"cd <repo-worktree> && \
52+
PYTHONPATH=/path/to/libfoo-checkout:<repo-worktree>/src \
53+
python -m pytest <targets> -o addopts='' -q"
54+
```
55+
56+
Notes: the checkout path is the **parent** of the importable package dir (the
57+
dir containing `foo/`, not `foo/` itself); list several `:`-separated to stack
58+
shadows; `-o addopts=''` clears `pyproject.toml`'s pytest defaults when a plugin
59+
they reference (e.g. `pytest-cov`) isn't in the image. Use this for a quick
60+
verify; land the real fix as the `pyproject.toml` / `uv.lock` dep change so CI
61+
and the next image agree.
62+
3963
**Testing container changes: build remotely, pull locally.** Don't
4064
`apptainer build` images on a cluster — quotas are tight and the build is slow.
4165
The loop for any change to `Dockerfile` / `pyproject.toml` / `uv.lock` is: edit

example/cfis/final_cat.param

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ FLAGS
1111
IMAFLAGS_ISO
1212
NGMIX_MCAL_FLAGS
1313

14-
# PSF ellipticity
15-
NGMIX_ELL_PSFo_NOSHEAR
14+
# PSF ellipticity (original image PSF)
15+
NGMIX_G1_PSF_ORIG_NOSHEAR
16+
NGMIX_G2_PSF_ORIG_NOSHEAR
1617

1718
# spread class
1819
#SPREAD_CLASS
@@ -29,16 +30,26 @@ NGMIX_N_EPOCH
2930
## Ngmix: model fitting
3031

3132
# galaxy ellipticity
32-
NGMIX_ELL_1M
33-
NGMIX_ELL_1P
34-
NGMIX_ELL_2M
35-
NGMIX_ELL_2P
36-
NGMIX_ELL_NOSHEAR
37-
#NGMIX_ELL_ERR_1M
38-
#NGMIX_ELL_ERR_1P
39-
#NGMIX_ELL_ERR_2M
40-
#NGMIX_ELL_ERR_2P
41-
NGMIX_ELL_ERR_NOSHEAR
33+
NGMIX_G1_1M
34+
NGMIX_G2_1M
35+
NGMIX_G1_1P
36+
NGMIX_G2_1P
37+
NGMIX_G1_2M
38+
NGMIX_G2_2M
39+
NGMIX_G1_2P
40+
NGMIX_G2_2P
41+
NGMIX_G1_NOSHEAR
42+
NGMIX_G2_NOSHEAR
43+
#NGMIX_G1_ERR_1M
44+
#NGMIX_G2_ERR_1M
45+
#NGMIX_G1_ERR_1P
46+
#NGMIX_G2_ERR_1P
47+
#NGMIX_G1_ERR_2M
48+
#NGMIX_G2_ERR_2M
49+
#NGMIX_G1_ERR_2P
50+
#NGMIX_G2_ERR_2P
51+
NGMIX_G1_ERR_NOSHEAR
52+
NGMIX_G2_ERR_NOSHEAR
4253

4354
# flags
4455
NGMIX_FLAGS_1M
@@ -58,11 +69,11 @@ NGMIX_T_ERR_1P
5869
NGMIX_T_ERR_2M
5970
NGMIX_T_ERR_2P
6071
NGMIX_T_ERR_NOSHEAR
61-
NGMIX_Tpsf_1M
62-
NGMIX_Tpsf_1P
63-
NGMIX_Tpsf_2M
64-
NGMIX_Tpsf_2P
65-
NGMIX_Tpsf_NOSHEAR
72+
NGMIX_T_PSF_RECONV_1M
73+
NGMIX_T_PSF_RECONV_1P
74+
NGMIX_T_PSF_RECONV_2M
75+
NGMIX_T_PSF_RECONV_2P
76+
NGMIX_T_PSF_RECONV_NOSHEAR
6677

6778
# flux and error
6879
NGMIX_FLUX_1M
@@ -94,10 +105,10 @@ FWHM_IMAGE
94105
FWHM_WORLD
95106

96107
# PSF size measured on original image
97-
NGMIX_T_PSFo_NOSHEAR
108+
NGMIX_T_PSF_ORIG_NOSHEAR
98109

99110
# PSF size measured on reconvolved image
100-
# NGMIX_Tpsf_NOSHEAR
111+
# NGMIX_T_PSF_RECONV_NOSHEAR
101112

102113
# ngmix moment failure flag
103114
NGMIX_MOM_FAIL

example/unions_800/cat_matched.param

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ FLAGS
1111
IMAFLAGS_ISO
1212
NGMIX_MCAL_FLAGS
1313

14-
# PSF ellipticity
15-
NGMIX_ELL_PSFo_NOSHEAR
14+
# PSF ellipticity (original image PSF)
15+
NGMIX_G1_PSF_ORIG_NOSHEAR
16+
NGMIX_G2_PSF_ORIG_NOSHEAR
1617

1718
# spread class
1819
SPREAD_CLASS
@@ -29,16 +30,26 @@ NGMIX_N_EPOCH
2930
## Ngmix: model fitting
3031

3132
# galaxy ellipticity
32-
NGMIX_ELL_1M
33-
NGMIX_ELL_1P
34-
NGMIX_ELL_2M
35-
NGMIX_ELL_2P
36-
NGMIX_ELL_NOSHEAR
37-
#NGMIX_ELL_ERR_1M
38-
#NGMIX_ELL_ERR_1P
39-
#NGMIX_ELL_ERR_2M
40-
#NGMIX_ELL_ERR_2P
41-
NGMIX_ELL_ERR_NOSHEAR
33+
NGMIX_G1_1M
34+
NGMIX_G2_1M
35+
NGMIX_G1_1P
36+
NGMIX_G2_1P
37+
NGMIX_G1_2M
38+
NGMIX_G2_2M
39+
NGMIX_G1_2P
40+
NGMIX_G2_2P
41+
NGMIX_G1_NOSHEAR
42+
NGMIX_G2_NOSHEAR
43+
#NGMIX_G1_ERR_1M
44+
#NGMIX_G2_ERR_1M
45+
#NGMIX_G1_ERR_1P
46+
#NGMIX_G2_ERR_1P
47+
#NGMIX_G1_ERR_2M
48+
#NGMIX_G2_ERR_2M
49+
#NGMIX_G1_ERR_2P
50+
#NGMIX_G2_ERR_2P
51+
NGMIX_G1_ERR_NOSHEAR
52+
NGMIX_G2_ERR_NOSHEAR
4253

4354
# flags
4455
NGMIX_FLAGS_1M
@@ -58,11 +69,11 @@ NGMIX_T_ERR_1P
5869
NGMIX_T_ERR_2M
5970
NGMIX_T_ERR_2P
6071
NGMIX_T_ERR_NOSHEAR
61-
NGMIX_Tpsf_1M
62-
NGMIX_Tpsf_1P
63-
NGMIX_Tpsf_2M
64-
NGMIX_Tpsf_2P
65-
NGMIX_Tpsf_NOSHEAR
72+
NGMIX_T_PSF_RECONV_1M
73+
NGMIX_T_PSF_RECONV_1P
74+
NGMIX_T_PSF_RECONV_2M
75+
NGMIX_T_PSF_RECONV_2P
76+
NGMIX_T_PSF_RECONV_NOSHEAR
6677

6778
# flux and error
6879
NGMIX_FLUX_1M
@@ -87,10 +98,10 @@ MAG_AUTO
8798
SNR_WIN
8899

89100
# PSF size measured on original image
90-
NGMIX_T_PSFo_NOSHEAR
101+
NGMIX_T_PSF_ORIG_NOSHEAR
91102

92103
# PSF size measured on reconvolved image
93-
# NGMIX_Tpsf_NOSHEAR
104+
# NGMIX_T_PSF_RECONV_NOSHEAR
94105

95106
# ngmix moment failure flag
96107
NGMIX_MOM_FAIL

pyproject.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ dependencies = [
2020
"astropy>=7.0", # major 6 → 7
2121
"astroquery",
2222
"canfar",
23-
"cs_util>=0.1.9",
23+
"cs_util>=0.2.1",
2424
"galsim>=2.8",
2525
"h5py",
2626
"joblib>=1.4",
@@ -90,6 +90,11 @@ environments = ["sys_platform == 'linux'"]
9090

9191
[tool.uv.sources]
9292
ngmix = { git = "https://github.com/esheldon/ngmix", tag = "v2.4.0" }
93+
# Track cs_util's develop branch (a git ref, not a pinned release) so new
94+
# cs_util.size / cs_util.shape helpers are available without shipping a release
95+
# and rebuilding the image each time. shapepipe's column grammar sources size
96+
# (T = 2*sigma^2) and ellipticity conversions from cs_util.
97+
cs_util = { git = "https://github.com/CosmoStat/cs_util", branch = "develop" }
9398

9499
[build-system]
95100
# Declaring a build backend makes shapepipe an installed package (not a uv

0 commit comments

Comments
 (0)