Skip to content

GEOPY-2108: Support 3D vector property group for orientation of rotated gradients#123

Merged
domfournier merged 7 commits intodevelopfrom
GEOPY-2108
May 2, 2025
Merged

GEOPY-2108: Support 3D vector property group for orientation of rotated gradients#123
domfournier merged 7 commits intodevelopfrom
GEOPY-2108

Conversation

@benk-mira
Copy link
Copy Markdown
Contributor

@benk-mira benk-mira commented Apr 18, 2025

GEOPY-2108 - Support 3D vector property group for orientation of rotated gradients
…wrap inside a cartesian_to_direction_and_dip.

…wrap inside a cartesian_to_direction_and_dip.
@github-actions github-actions Bot changed the title GEOPY-2108 GEOPY-2108: Support 3D vector property group for orientation of rotated gradients Apr 18, 2025
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.50%. Comparing base (6e21320) to head (487c215).
Report is 8 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #123      +/-   ##
===========================================
+ Coverage    81.01%   82.50%   +1.48%     
===========================================
  Files           13       13              
  Lines          669      720      +51     
  Branches        94       94              
===========================================
+ Hits           542      594      +52     
  Misses         105      105              
+ Partials        22       21       -1     
Files with missing lines Coverage Δ
geoapps_utils/utils/transformations.py 100.00% <100.00%> (+5.00%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

@domfournier domfournier left a comment

Choose a reason for hiding this comment

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

Here's a simple test to check against

from geoh5py.objects import Points
from geoh5py import Workspace
from geoh5py.groups.property_group import GroupTypeEnum

def test_spherical_values(tmp_path):
    theta, phi = np.meshgrid(np.arange(0, 360, 10), np.arange(-90, 90, 10))
    theta = theta.flatten()
    phi = phi.flatten()

    rad = 100.0
    x = rad * np.cos(np.radians(theta)) * np.cos(np.radians(phi))
    y = rad * np.sin(np.radians(theta)) * np.cos(np.radians(phi))
    z = rad * np.sin(np.radians(phi))

    angles = np.rad2deg(cartesian_to_spherical(np.c_[x, y, z]))

    with Workspace.create(tmp_path / f"{__name__}.geoh5") as workspace:
        points = Points.create(
            workspace,
            name="spherical_points",
            vertices=np.c_[x, y, z],
        )
        unit_xyz = points.add_data({
            "x": {"values": x / rad},
            "y": {"values": y / rad},
            "z": {"values": z / rad},
        })
        prop_group = points.create_property_group(
            name="direction_xyz",
            properties=unit_xyz,
            property_group_type=GroupTypeEnum.VECTOR,
        )
        dip_azm = points.add_data({
            "dip": {"values": angles[:, 1]},
            "azimuth": {"values": angles[:, 0]},
        }
        )
        prop_group = points.create_property_group(
            name="direction_dip_azm",
            properties=dip_azm,
            property_group_type=GroupTypeEnum.DIPDIR,
        )

We should expect the orientation VECTOR and DIPDIR to be perpendicular arrows everywhere, which is currently not the case.

VECTOR
image

DIPDIR
image

Also, the current dip is positive upward, which is opposite of the convention (positive down).

You could tackle this by
1- converting the normalized xyz vector to its corresponding theta and phi
2- rotate a unit y vector [0, 1, 0] with the same angles
2- convert that new rotated vector to [theta, phi] -> [azimuth dip]

Comment thread geoapps_utils/utils/transformations.py Outdated
Comment thread geoapps_utils/utils/transformations.py Outdated
Comment thread geoapps_utils/utils/transformations.py Outdated
Comment thread tests/transformations_test.py Outdated
@qlty-cloud-legacy
Copy link
Copy Markdown

Code Climate has analyzed commit 487c215 and detected 0 issues on this pull request.

View more on Code Climate.

@domfournier domfournier merged commit 7b76c81 into develop May 2, 2025
15 checks passed
@domfournier domfournier deleted the GEOPY-2108 branch May 2, 2025 20:55
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.

2 participants