Update GalaxySDShape naming scheme and create support for sigma fitting with shapeHSM products#242
Conversation
…M calibration products
…SDShapeHSMGauss in configuration files
…_shape_hsm_gauss_global_gen function
…rectory structure, remove unused sigma conversion test and fix coordinate conversion tests Co-authored-by: Copilot <[email protected]>
… SIGMA directly" This reverts commit 2d4a877.
…(not truncated)" This reverts commit 43d96e3.
… when there's no shear
…ention and remove R factor for cross components
…_stats for performance optimization
…parameters in gen_galaxies function
Member
Author
|
@vitenti this is ready for review! |
There was a problem hiding this comment.
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
NcGalaxySDShapeHSMGaussand 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_tare scaled by the responsivityRbutgx/sigma_xare not. SinceRis scalar and the estimator is applied to both components, this asymmetry will biasgxand mis-scale its uncertainty.
numcosmo/galaxy/nc_galaxy_sd_shape_hsm_gauss.c:628 - In the TRACE branch,
gt/sigma_tinclude the expected0.5and responsivity scaling, butgx/sigma_xdo not. The TRACE convention (distortion χ) applies the same scaling to both components, sogx/sigma_xshould be treated consistently.
numcosmo/galaxy/nc_galaxy_sd_shape_hsm_gauss_global.c:645 - In the TRACE_DET branch,
gt/sigma_tare scaled by the responsivityRbutgx/sigma_xare not. SinceRis 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_tinclude the expected0.5and responsivity scaling, butgx/sigma_xdo 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) |
There was a problem hiding this comment.
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
..._newbut the failure is occurring insidenc_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 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 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 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 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 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 on lines
388
to
389
| def model_post_init(self, _: Any, /) -> None: | ||
| """Check that sigma is less than std_noise.""" |
… gamma distribution
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.
Update GalaxySDShape naming scheme and create support for sigma fitting with shapeHSM products