Skip to content

Conversation

@cphyc
Copy link
Collaborator

@cphyc cphyc commented Nov 6, 2025

This finally adds splicing with multilevel.

It is, however, worth noting that the accuracy improves much more slowly when using the multi-level approach. Typically, you'd need hundreds of steps to reach ~1% accuracy.

splicing

Some details on the implementation

Splicing on a uniform grid

The equation to be solved is
$$\mathbf{\bar{M} C^{-1} \bar{M}} \alpha = \mathbf{\bar{M} C^{-1} M} (b - a),$$
where $a$ and $b$ are fields (in density space), $\mathbf{M}=1-\mathbf{\bar M}$ is a matrix that selects the region to be spliced.

Once $\alpha$ is obtained, one can obtain the spliced field as
$$f=b + \mathbf{M}(a-b) + \mathbf{\bar{M}}\alpha.$$

This is a WIP:

  • the order of operation isn't fixed yet - I suspect that pinning down exactly the order in which operations are supposed to happen will help with convergence,
  • the splicing now returns a spliced field in density space, but it is expected we're still operating on whitenoise. I have hacked the code so that it writes numpy grids, but this will have to go. The annoyance is that there is no way to go back to whitenoise from density (since the filters have non-null empty spaces).

@cphyc
Copy link
Collaborator Author

cphyc commented Nov 7, 2025

@apontzen do you know if there's a piece of code that implements the combination / uncombination operations ($T/T^+$ operators)?

In particular, splicing yields the solution $\alpha_Z$ such that $\mathbf{\bar{M}}\mathbf{C}^{-1}\mathbf{\bar{M}} \mathbf{T}\alpha_Z = \mathbf{\bar{M}}\mathbf{C}^{-1}\mathbf{MT}(b_Z - a_Z)$. The solution $f_Z$ then reads $\mathbf{T} f_Z = \mathbf{T}b_Z + \mathbf{M}\mathbf{T}(a_Z - b_Z) + \mathbf{\bar{M}}\mathbf{T}\alpha_Z$.

So I'd either have to let genetIC know that I have already combined the fields (i.e., store $\mathbf{T}f_Z$) or get back $f_Z$ from the combined field (i.e., apply $\mathbf{T}^+$, but this isn't the exact inverse of $\mathbf{T}$, so I don't know how accurate that'd be).

In the latter case, it'd be useful if there were a way to apply $\mathbf{T}$ and $\mathbf{T}^+$ already implemented.

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.

1 participant