Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Update GalaxySDShape naming scheme and create support for sigma fitting with shapeHSM products#242

Open
caioolivv wants to merge 70 commits into
masterfrom
shape_hsm
Open

Update GalaxySDShape naming scheme and create support for sigma fitting with shapeHSM products#242
caioolivv wants to merge 70 commits into
masterfrom
shape_hsm

Conversation

@caioolivv

Copy link
Copy Markdown
Member

Update GalaxySDShape naming scheme and create support for sigma fitting with shapeHSM products

caioolivv and others added 22 commits April 22, 2026 12:08
…rectory structure, remove unused sigma conversion test and fix coordinate conversion tests

Co-authored-by: Copilot <[email protected]>
@caioolivv caioolivv requested a review from vitenti May 21, 2026 17:30
@caioolivv

Copy link
Copy Markdown
Member Author

@vitenti this is ready for review!

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated 5 comments.

Comments suppressed due to low confidence (5)

numcosmo/galaxy/nc_galaxy_sd_shape_hsm_gauss.c:179

  • The model name/nick still refers to "HSC data", but this class was renamed to NcGalaxySDShapeHSMGauss and the header comment says it uses shapeHSM products (not HSC-specific). Update the user-visible name/nick strings to match the new semantics.
    numcosmo/galaxy/nc_galaxy_sd_shape_hsm_gauss.c:621
  • In the TRACE_DET branch, gt/sigma_t are scaled by the responsivity R but gx/sigma_x are not. Since R is scalar and the estimator is applied to both components, this asymmetry will bias gx and mis-scale its uncertainty.
    numcosmo/galaxy/nc_galaxy_sd_shape_hsm_gauss.c:628
  • In the TRACE branch, gt/sigma_t include the expected 0.5 and responsivity scaling, but gx/sigma_x do not. The TRACE convention (distortion χ) applies the same scaling to both components, so gx/sigma_x should be treated consistently.
    numcosmo/galaxy/nc_galaxy_sd_shape_hsm_gauss_global.c:645
  • In the TRACE_DET branch, gt/sigma_t are scaled by the responsivity R but gx/sigma_x are not. Since R is scalar, both components should be scaled consistently to avoid bias/mis-scaled uncertainties.
    numcosmo/galaxy/nc_galaxy_sd_shape_hsm_gauss_global.c:653
  • In the TRACE branch, gt/sigma_t include the expected 0.5 and responsivity scaling, but gx/sigma_x do not. The TRACE convention (distortion χ) should apply the same scaling to both components.

{"sigma": -0.1},
{"std_noise": -0.01},
]
case _: # pragma: no cover
Comment on lines +313 to 320
def gen_shape(self, mset: Ncm.MSet, shape_data: Nc.GalaxySDShapeData, rng: Ncm.RNG):
"""Generate the galaxy shape source distribution data observations."""
std_shape = min(np.sqrt(rng.gamma_gen(self._k_shape, self._theta_shape)), 0.45)
std_noise = min(np.sqrt(rng.gamma_gen(self._k_noise, self._theta_noise)), 0.5)
c1 = rng.gaussian_gen(0.0, self.c1_sigma)
c2 = rng.gaussian_gen(0.0, self.c2_sigma)
m = np.exp(rng.gaussian_gen(0.0, self.m_sigma))
coord = self.ellip_coord.genum
Comment on lines +388 to 395
def model_post_init(self, _: Any, /) -> None:
"""Check that sigma is less than std_noise."""
self._gauss_hsc = Nc.GalaxySDShapeGaussHSC.new(self.ellip_conv.genum)
self._k_shape = ((self.std_shape**2) / self.std_sigma) ** 2
self._theta_shape = self.std_sigma**2 / self.std_shape**2
self._hsm_gauss_global = Nc.GalaxySDShapeHSMGaussGlobal.new(
self.ellip_conv.genum
)
self._hsm_gauss_global["sigma"] = self.sigma
self._k_noise = ((self.std_noise**2) / self.std_sigma) ** 2
self._theta_noise = self.std_sigma**2 / self.std_noise**2
Comment on lines +145 to +148
c1 = rng.gaussian_gen(0.0, 0.01)
c2 = rng.gaussian_gen(0.0, 0.01)
m = np.exp(rng.gaussian_gen(0.0, 0.08))
std_noise = galaxy_shape_std_noise
Comment on lines 401 to +406
std_noise = min(np.sqrt(rng.gamma_gen(self._k_noise, self._theta_noise)), 0.5)
c1 = rng.gaussian_gen(0.0, self.c1_sigma)
c2 = rng.gaussian_gen(0.0, self.c2_sigma)
m = np.exp(rng.gaussian_gen(0.0, self.m_sigma))
coord = self.ellip_coord.genum
self._gauss_hsc.gen(
mset, shape_data, std_shape, std_noise, c1, c2, m, coord, rng
)
self._hsm_gauss_global.gen(mset, shape_data, std_noise, c1, c2, m, coord, rng)

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated 9 comments.

Comments suppressed due to low confidence (3)

numcosmo/galaxy/nc_galaxy_sd_shape_hsm_gauss.c:180

  • The model class name/nick still mentions HSC, but this implementation is now for shapeHSM products (and the file/class names have been updated accordingly). This string is user-visible (logs/serialization), so it should match the new model semantics.
    numcosmo/galaxy/nc_galaxy_sd_shape_hsm_gauss_global.c:862
  • The warning message refers to ..._new but the failure is occurring inside nc_galaxy_sd_shape_hsm_gauss_global_sigma_from_std_shape(). Using the correct function name makes the warning actionable.
    numcosmo/galaxy/nc_galaxy_sd_shape_hsm_gauss_global.c:868
  • Same warning-message issue as above: the function name in the warning should match nc_galaxy_sd_shape_hsm_gauss_global_sigma_from_std_shape() to help debugging.

std_noise = min(np.sqrt(rng.gamma_gen(self._k_noise, self._theta_noise)), 0.5)
c1 = rng.gaussian_gen(0.0, self.c1_sigma)
c2 = rng.gaussian_gen(0.0, self.c2_sigma)
m = np.exp(rng.gaussian_gen(0.0, self.m_sigma))
std_noise = min(np.sqrt(rng.gamma_gen(self._k_noise, self._theta_noise)), 0.5)
c1 = rng.gaussian_gen(0.0, self.c1_sigma)
c2 = rng.gaussian_gen(0.0, self.c2_sigma)
m = np.exp(rng.gaussian_gen(0.0, self.m_sigma))

c1 = rng.gaussian_gen(0.0, 0.01)
c2 = rng.gaussian_gen(0.0, 0.01)
m = np.exp(rng.gaussian_gen(0.0, 0.08))
Comment thread tests/c/data/test_nc_data_cluster_wl.c Outdated
Comment on lines +472 to +474
g_assert_true (g_strv_contains ((const gchar * const *) nc_galaxy_wl_obs_peek_columns (obs), NC_GALAXY_SD_SHAPE_HSM_GAUSS_COL_C1));
g_assert_true (g_strv_contains ((const gchar * const *) nc_galaxy_wl_obs_peek_columns (obs), NC_GALAXY_SD_SHAPE_HSM_GAUSS_COL_C2));
g_assert_true (g_strv_contains ((const gchar * const *) nc_galaxy_wl_obs_peek_columns (obs), NC_GALAXY_SD_SHAPE_HSM_GAUSS_COL_M));
Comment thread tests/c/data/test_nc_data_cluster_wl.c Outdated
Comment on lines +741 to +746
const gdouble c1 = nc_galaxy_wl_obs_get (obs_copy, NC_GALAXY_SD_SHAPE_HSM_GAUSS_COL_C1, i);
const gdouble c2 = nc_galaxy_wl_obs_get (obs_copy, NC_GALAXY_SD_SHAPE_HSM_GAUSS_COL_C2, i);
const gdouble m = nc_galaxy_wl_obs_get (obs_copy, NC_GALAXY_SD_SHAPE_HSM_GAUSS_COL_M, i);
const gdouble c1_2 = nc_galaxy_wl_obs_get (obs2, NC_GALAXY_SD_SHAPE_HSM_GAUSS_COL_C1, i);
const gdouble c2_2 = nc_galaxy_wl_obs_get (obs2, NC_GALAXY_SD_SHAPE_HSM_GAUSS_COL_C2, i);
const gdouble m_2 = nc_galaxy_wl_obs_get (obs2, NC_GALAXY_SD_SHAPE_HSM_GAUSS_COL_M, i);
Comment thread tests/c/data/test_nc_data_cluster_wl.c Outdated
Comment on lines +842 to +847
const gdouble c1 = nc_galaxy_wl_obs_get (obs_copy, NC_GALAXY_SD_SHAPE_HSM_GAUSS_COL_C1, i);
const gdouble c2 = nc_galaxy_wl_obs_get (obs_copy, NC_GALAXY_SD_SHAPE_HSM_GAUSS_COL_C2, i);
const gdouble m = nc_galaxy_wl_obs_get (obs_copy, NC_GALAXY_SD_SHAPE_HSM_GAUSS_COL_M, i);
const gdouble c1_2 = nc_galaxy_wl_obs_get (obs2, NC_GALAXY_SD_SHAPE_HSM_GAUSS_COL_C1, i);
const gdouble c2_2 = nc_galaxy_wl_obs_get (obs2, NC_GALAXY_SD_SHAPE_HSM_GAUSS_COL_C2, i);
const gdouble m_2 = nc_galaxy_wl_obs_get (obs2, NC_GALAXY_SD_SHAPE_HSM_GAUSS_COL_M, i);
Comment thread tests/c/data/test_nc_data_cluster_wl.c Outdated
Comment on lines +1044 to +1049
const gdouble c1 = nc_galaxy_wl_obs_get (obs_copy, NC_GALAXY_SD_SHAPE_HSM_GAUSS_COL_C1, i);
const gdouble c2 = nc_galaxy_wl_obs_get (obs_copy, NC_GALAXY_SD_SHAPE_HSM_GAUSS_COL_C2, i);
const gdouble m = nc_galaxy_wl_obs_get (obs_copy, NC_GALAXY_SD_SHAPE_HSM_GAUSS_COL_M, i);
const gdouble c1_2 = nc_galaxy_wl_obs_get (obs2, NC_GALAXY_SD_SHAPE_HSM_GAUSS_COL_C1, i);
const gdouble c2_2 = nc_galaxy_wl_obs_get (obs2, NC_GALAXY_SD_SHAPE_HSM_GAUSS_COL_C2, i);
const gdouble m_2 = nc_galaxy_wl_obs_get (obs2, NC_GALAXY_SD_SHAPE_HSM_GAUSS_COL_M, i);
Comment thread tests/c/data/test_nc_data_cluster_wl.c Outdated
Comment on lines +941 to +948
if (NC_IS_GALAXY_SD_SHAPE_HSM_GAUSS (test->galaxy_shape))
{
const gdouble c1 = nc_galaxy_wl_obs_get (obs_copy, NC_GALAXY_SD_SHAPE_HSM_GAUSS_COL_C1, i);
const gdouble c2 = nc_galaxy_wl_obs_get (obs_copy, NC_GALAXY_SD_SHAPE_HSM_GAUSS_COL_C2, i);
const gdouble m = nc_galaxy_wl_obs_get (obs_copy, NC_GALAXY_SD_SHAPE_HSM_GAUSS_COL_M, i);
const gdouble c1_2 = nc_galaxy_wl_obs_get (obs2, NC_GALAXY_SD_SHAPE_HSM_GAUSS_COL_C1, i);
const gdouble c2_2 = nc_galaxy_wl_obs_get (obs2, NC_GALAXY_SD_SHAPE_HSM_GAUSS_COL_C2, i);
const gdouble m_2 = nc_galaxy_wl_obs_get (obs2, NC_GALAXY_SD_SHAPE_HSM_GAUSS_COL_M, i);
Comment thread numcosmo_py/experiments/cluster_wl.py Outdated
Comment on lines 388 to 389
def model_post_init(self, _: Any, /) -> None:
"""Check that sigma is less than std_noise."""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants