Skip to content
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

Proposal: allow arbitrary dimensions #77

Closed
MuellerSeb opened this issue Apr 13, 2020 · 1 comment
Closed

Proposal: allow arbitrary dimensions #77

MuellerSeb opened this issue Apr 13, 2020 · 1 comment
Assignees
Labels
enhancement New feature or request Refactoring Code-Refactoring needed here
Milestone

Comments

@MuellerSeb
Copy link
Member

MuellerSeb commented Apr 13, 2020

Since we are planing to allow arbitrary dimensions in PyKrige, we need to prepare GSTools for that as well.

There are just a few modifications needed. The foundation for rotation and anisotropy in N-D, as discussed in issue GeoStat-Framework/PyKrige#138, could be implemented in GSTools.

The covariance model needs some updates:

  1. it could simply provide the respective transformation matrices rot_mat, derot_mat, iso_mat and aniso_mat depending on the given angles and anisotropy-ratios (as described in the PyKrige issue)
  2. we have to update the workflow for checking dimensionality. The fix_dim could be a check_dim routine, that takes the wanted dimension and state if it is valid.
  3. anis and angles need to be treated based on the dimension. for anis this already works and for angles we need to consider, that there are (dim * (dim - 1)) // 2 rotation angles in N-D (15e2d80)
  4. The associated rotation planes are [(i, j) for i in range(angles_no) for j in range(i + 1, angles_no)] (15e2d80)
  5. everything else should be already working (SFT and so on).

The SRF would need some special treatment:

  1. We need samples of the unit-sphere in N-D. Following this, we could modify RNG.sample_sphere for dim>3 with: (a856ea2)
    coord = self.random.normal(size=coord.shape)
    while True:  # loop until all norms are non-zero
        norm = np.linalg.norm(coord, axis=0)
        # check for zero norms
        zero_norms = np.isclose(norm, 0)
        # exit the loop if all norms are non-zero
        if not np.any(zero_norms):
            break
        # transpose, since the next transpose reverses axis order
        zero_samples = zero_norms.T.nonzero()
        # need to transpose to have dim-axis last
        new_shape = coord.T[zero_samples].shape
        # resample the zero norm samples
        coord.T[zero_samples] = self.random.normal(size=new_shape)
    # project onto sphere
    coord = coord / norm
  2. The generators for unstructured meshes are already prepared for arbitrary dimensions.
  3. For structured meshes, we could simply drop handling structured meshes separately and convert them always to unstructured (which is done already, if anisotropy is present) or we could keep this procedures for 1,2 and 3 dimensions.
  4. we need to get rid of this cumbersome pos=(x,y,z) handling. We could simply handle it as an array and the spatial dimension is first array dimension.
@MuellerSeb MuellerSeb added this to the 1.3 milestone Apr 13, 2020
@MuellerSeb MuellerSeb self-assigned this Apr 17, 2020
@MuellerSeb MuellerSeb added enhancement New feature or request Refactoring Code-Refactoring needed here labels Apr 17, 2020
@MuellerSeb MuellerSeb modified the milestones: 1.3, 2.0 Aug 20, 2020
@LSchueler
Copy link
Member

Implemented with #112

@MuellerSeb MuellerSeb modified the milestones: 2.0, 1.3 Jan 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Refactoring Code-Refactoring needed here
Projects
None yet
Development

No branches or pull requests

2 participants