-
Notifications
You must be signed in to change notification settings - Fork 3
[bump minor] Change to the observation covariance matrix to work with NaCl outputs #95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR updates the SN Ia velocity data vector to correctly handle NaCl-style observation covariances that are 3N×3N over the SALT2 parameters (mb, x1, c), instead of an N×N distance-modulus covariance. It introduces a design-matrix–based propagation from the SALT2 parameter covariance to the distance-modulus covariance and then to the velocity covariance.
Changes:
- Replace the previous direct use of
self._covariance_observationwith a linear propagation via a design matrixA(andJ) so that a 3N×3N SALT2 parameter covariance is mapped into an N×N distance-modulus covariance, including intrinsic scatter viasigma_M. - Simplify the velocity covariance computation in
give_data_and_varianceto apply only the distance-modulus-to-velocity conversion matrix, given that the SALT2-to-distance-modulus propagation is now handled incompute_observed_distance_modulus_variance. - Introduce
self.number_datapointsto track N, use it consistently in shape checks and identity construction, and adjust_init_Aand covariance-shape validation accordingly.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
flip/data_vector/snia_vectors.py
Outdated
| A = jnp.ones((3, self.number_datapoints, 3 * self.number_datapoints)) | ||
| ij = jnp.ogrid[: self.number_datapoints, : 3 * self.number_datapoints] | ||
| for k in range(3): | ||
| A[k][ij[1] == 3 * ij[0] + k] = 1 | ||
| if jax_installed: | ||
| A = A.at[k, ij[1] == 3 * ij[0] + k].set(1) | ||
| else: | ||
| A[k][ij[1] == 3 * ij[0] + k] = 1 |
Copilot
AI
Jan 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_init_A initializes A with ones and then only ever assigns a subset of entries to 1 again, so the entire matrix stays filled with ones instead of having a single 1 per (SN, parameter) and zeros elsewhere. This makes the derived design matrix J effectively an all-ones matrix and causes the propagated distance-modulus covariance in compute_observed_distance_modulus_variance to be mathematically incorrect; A should be initialized to zeros and only the desired indices set to 1 so that each row selects the appropriate mb/x1/c element for that object.
NaCl outputs: covariance of 3N x 3N with full covariance for mb, x1 and c parameters (need to convert from x_0 to m_b)