Large improvements of flip: mesh, dependencies removal, forward modeling, field comparison likelihood#100
Large improvements of flip: mesh, dependencies removal, forward modeling, field comparison likelihood#100corentinravoux wants to merge 52 commits into
Conversation
|
Might take this opportunity to remove Hankel transform dependency |
|
New features added:
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 8 changed files in this pull request and generated 12 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def init_from_catalog( | ||
| cls, | ||
| data_position_sky, | ||
| rcom_max, | ||
| grid_size, | ||
| grid_type, | ||
| kind, | ||
| **kwargs, | ||
| ): | ||
| grid = mesh.grid_data_density( | ||
| data_position_sky, | ||
| rcom_max, | ||
| grid_size, | ||
| grid_type, | ||
| kind, | ||
| **kwargs, | ||
| ) | ||
|
|
||
| return cls(grid) |
| pm = ParticleMesh( | ||
| BoxSize=boxsize, | ||
| Nmesh=nmesh, | ||
| dtype="f8", | ||
| ) |
| if ( | ||
| "alpha_low" in parameter_values_dict | ||
| and "alpha_high" in parameter_values_dict | ||
| and "x1_treshold" in parameter_values_dict | ||
| ): | ||
| alpha = jnp.where( | ||
| self._data["x1"] < parameter_values_dict["x1_treshold"], | ||
| parameter_values_dict["alpha_low"], | ||
| parameter_values_dict["alpha_high"], | ||
| ) | ||
| else: | ||
| alpha = parameter_values_dict["alpha"] | ||
|
|
| def create_mesh( | ||
| positions, | ||
| boxsize, | ||
| cellsize, | ||
| assignement="ngp", | ||
| weights=None, | ||
| scaling=None, | ||
| ): | ||
|
|
||
| conversions = {"ngp": "nnb", "cic": "cic", "tsc": "tsc", "pcs": "pcs"} | ||
| resampler = conversions[assignement] | ||
|
|
||
| nmesh, boxsize, boxcenter = _get_mesh_attrs( | ||
| boxsize, | ||
| cellsize, | ||
| ) | ||
|
|
||
| pm = ParticleMesh( | ||
| BoxSize=boxsize, | ||
| Nmesh=nmesh, | ||
| dtype="f8", | ||
| ) | ||
| offset = boxcenter - boxsize / 2.0 | ||
| _slab_npoints_max = int(1024 * 1024 * 4) | ||
|
|
||
| def paint(positions, weights, scaling, out, transform=None): | ||
| positions = positions - offset | ||
| factor = 0.5 | ||
| if not np.isfinite(positions).all(): | ||
| raise ValueError("Some positions are NaN/inf") | ||
| if not np.isfinite(weights).all(): | ||
| raise ValueError("Some weights are NaN/inf") |
|
|
||
| data_position_sky_bandwidth = data_position_sky_bandwidth[mask, :, :] | ||
|
|
||
| data_position_bandwith = jacobian @ data_position_sky_bandwidth @ jacobian.T |
| for i in range(data_positions.shape[0]): | ||
| kernel_weights = multivariate_kernel_density_estimation( | ||
| data_positions[i], | ||
| data_position_bandwith[i], | ||
| grid_positions, | ||
| kernel=kernel, | ||
| cutoff_type=cutoff_type, | ||
| threshold=threshold, | ||
| ) |
| import numpy as np | ||
|
|
||
| from flip.covariance import CovMatrix | ||
| from flip.data_vector import mesh |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
merging main
|
This branch goes beyond the mesh part, it include new developments, in particular the creation of a forward modeling subpackage based on flox. |
merging main in mesh
|
@copilot Give me a complete review of the flip/forward new implementation, without the flip/forward/flox. Please point at potential bugs or search for unphysical implementation |
Here is a complete review of 1. Critical:
|
Mesh improvements.
The idea is to