-
Notifications
You must be signed in to change notification settings - Fork 43
Add class functions to simplify kGrid creation #597
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
base: master
Are you sure you want to change the base?
Conversation
- Implemented `from_geometry` method to create a kWaveGrid based on domain size and minimum element width. - Implemented `from_domain` method to create a kWaveGrid using physical dimensions and acoustic properties. - Added input validation for parameters in both methods to ensure positive values.
- Updated the grid creation process to utilize the new `from_domain` method for better clarity and efficiency. - Adjusted sensor mask and data reshaping to align with the new grid structure. - Ensured consistent usage of grid properties throughout the example for improved readability and maintainability.
- Updated the grid creation to use the new `from_domain` method for improved clarity and efficiency. - Adjusted sensor mask and data reshaping to utilize properties from the kWaveGrid instance. - Enhanced consistency in grid property usage throughout the example for better readability and maintainability.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #597 +/- ##
==========================================
- Coverage 73.61% 73.35% -0.27%
==========================================
Files 50 50
Lines 6929 6970 +41
Branches 1315 1323 +8
==========================================
+ Hits 5101 5113 +12
- Misses 1283 1312 +29
Partials 545 545
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request enhances the kWaveGrid class by adding two new factory methods and utility properties, and refactoring example scripts to simplify grid creation and improve code consistency.
- Introduces factory methods: from_geometry and from_domain in kWaveGrid
- Adds utility properties: x_max, y_max, and z_max
- Refactors grid initialization in at_circular_piston_3D.py and at_focused_bowl_3D.py to use the new factory methods
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| kwave/kgrid.py | Adds new factory methods and utility properties; broadcasts spacing if single-element |
| examples/at_focused_bowl_3D/at_focused_bowl_3D.py | Replaces manual grid creation with kWaveGrid.from_domain and updates sensor mask and data reshaping |
| examples/at_circular_piston_3D/at_circular_piston_3D.py | Refactors grid initialization to use kWaveGrid.from_domain and updates grid-based indices |
Co-authored-by: Copilot <[email protected]>
- Removed redundant properties for x_max, y_max, and z_max from kWaveGrid to streamline the class. - Updated the at_focused_bowl_3D example to define position vectors more clearly, improving readability and maintainability. - Introduced a new x_ref calculation for better accuracy in grid representation.
This pull request introduces enhancements to the
kWaveGridclass, including new factory methods and utility properties. It also refactors grid initialization and usage in theat_circular_piston_3Dandat_focused_bowl_3Dexamples, improving code readability and reusability by leveraging new factory methods in thekWaveGridclass. It alsoEnhancements to
kWaveGridClass:New Factory Methods:
from_geometryandfrom_domainclass methods to simplify the creation ofkWaveGridinstances based on physical domain dimensions, acoustic properties, and resolution requirements. These methods encapsulate grid spacing and size calculations.Utility Properties:
x_max,y_max, andz_maxproperties to provide easy access to the maximum extents of the grid in each dimension.Refactoring in Example Scripts:
Simplified Grid Initialization:
kWaveGrid.from_domainfactory method inat_circular_piston_3D.pyandat_focused_bowl_3D.py. This reduces redundant code and ensures consistency in grid creation. [1] [2]Improved Input Handling:
__init__method to handle single-element spacing inputs more gracefully by broadcasting them to match the grid dimensionality.