Skip to content

Improving mesh in flip#100

Open
corentinravoux wants to merge 24 commits intomainfrom
mesh
Open

Improving mesh in flip#100
corentinravoux wants to merge 24 commits intomainfrom
mesh

Conversation

@corentinravoux
Copy link
Copy Markdown
Owner

Mesh improvements.
The idea is to

  • separate the pypower module for meshing
  • improve meshing integration so that it can be called inside a data_vector instance

Copilot AI review requested due to automatic review settings March 4, 2026 14:13
@corentinravoux corentinravoux linked an issue Mar 4, 2026 that may be closed by this pull request
@corentinravoux
Copy link
Copy Markdown
Owner Author

Might take this opportunity to remove Hankel transform dependency

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@corentinravoux
Copy link
Copy Markdown
Owner Author

New features added:

  • broken-alpha and gamma terms in the peculiar velocity estimator
  • GW density mapping
  • Module for density comparison

Copy link
Copy Markdown

Copilot AI left a comment

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 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.

Comment on lines +311 to +329
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)
Comment on lines +262 to +266
pm = ParticleMesh(
BoxSize=boxsize,
Nmesh=nmesh,
dtype="f8",
)
Comment on lines +120 to +132
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"]

Comment on lines +245 to +276
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
Comment on lines +623 to +631
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
corentinravoux and others added 12 commits March 16, 2026 15:12
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>
@corentinravoux
Copy link
Copy Markdown
Owner Author

cosmoprimo and pypower are no longer required.
pmesh is still needed for the gridding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deployment to Pypi is stuck due to external library (cosmoprimo) Idea: H0 from missplacement between two fields Remove some dependencies

2 participants