-
Notifications
You must be signed in to change notification settings - Fork 12
GEOPY-2697: Implement Airborne Apparent Conductivity survey type #838
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
81e37e3
Add classes
domfournier e2461a8
Remove class attributes
domfournier 4b97e1f
Add unit test
domfournier 6f95d2d
Add return type
domfournier 367dbc8
Fix test
domfournier 210d15e
Mute pylint
domfournier 5bde603
Merge branch 'develop' into GEOPY-2697
domfournier File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
235 changes: 235 additions & 0 deletions
235
geoh5py/objects/surveys/electromagnetics/airborne_app_con.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,235 @@ | ||
| # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' | ||
| # Copyright (c) 2020-2026 Mira Geoscience Ltd. ' | ||
| # ' | ||
| # This file is part of geoh5py. ' | ||
| # ' | ||
| # geoh5py is free software: you can redistribute it and/or modify ' | ||
| # it under the terms of the GNU Lesser General Public License as published by ' | ||
| # the Free Software Foundation, either version 3 of the License, or ' | ||
| # (at your option) any later version. ' | ||
| # ' | ||
| # geoh5py is distributed in the hope that it will be useful, ' | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of ' | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ' | ||
| # GNU Lesser General Public License for more details. ' | ||
| # ' | ||
| # You should have received a copy of the GNU Lesser General Public License ' | ||
| # along with geoh5py. If not, see <https://www.gnu.org/licenses/>. ' | ||
| # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' | ||
|
|
||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import uuid | ||
|
|
||
| import numpy as np | ||
|
|
||
| from geoh5py.data import IntegerData, ReferencedData | ||
| from geoh5py.objects.curve import Curve | ||
| from geoh5py.objects.points import Points | ||
|
|
||
| from .base import FEMSurvey | ||
|
|
||
|
|
||
| # pylint: disable=too-many-ancestors, duplicate-code | ||
|
|
||
|
|
||
| class AirborneAppConSurvey(FEMSurvey): | ||
| """ | ||
| Base tipper survey class. | ||
| """ | ||
|
|
||
| __INPUT_TYPE = ["Rx and base stations"] | ||
|
|
||
| def __init__( | ||
| self, | ||
| base_stations: AirborneAppConBaseStations | None = None, | ||
| **kwargs, | ||
| ): | ||
| self._base_stations = base_stations | ||
|
|
||
| super().__init__( | ||
| **kwargs, | ||
| ) | ||
|
|
||
| @property | ||
| def base_stations(self) -> AirborneAppConBaseStations | None: | ||
| """The base station entity""" | ||
| if isinstance(self, AirborneAppConBaseStations): | ||
| return self | ||
|
|
||
| if getattr(self, "_base_stations", None) is None: | ||
| if ( | ||
| self.metadata is not None | ||
| and "Base stations" in self.metadata["EM Dataset"] | ||
| ): | ||
| base_station = self.metadata["EM Dataset"]["Base stations"] | ||
| base_station_entity = self.workspace.get_entity(base_station)[0] | ||
|
|
||
| if isinstance(base_station_entity, AirborneAppConBaseStations): | ||
| self._base_stations = base_station_entity | ||
|
|
||
| return self._base_stations | ||
|
|
||
| @base_stations.setter | ||
| def base_stations(self, base: AirborneAppConBaseStations): | ||
| if not isinstance(base, (AirborneAppConBaseStations, type(None))): | ||
| raise TypeError( | ||
| f"Input `base_stations` must be of type '{AirborneAppConBaseStations}' or None" | ||
| ) | ||
|
|
||
| if isinstance(self, AirborneAppConBaseStations): | ||
| raise AttributeError( | ||
| f"The 'base_station' attribute cannot be set on class {AirborneAppConBaseStations}." | ||
| ) | ||
|
|
||
| if base.tx_id_property is not None: | ||
| self.edit_em_metadata({"Tx ID tx property": base.tx_id_property.uid}) | ||
|
|
||
| if isinstance( | ||
| self.tx_id_property, ReferencedData | IntegerData | ||
| ) and isinstance(base.tx_id_property, ReferencedData | IntegerData): | ||
| self.tx_id_property.entity_type = base.tx_id_property.entity_type | ||
|
|
||
| self._base_stations = base | ||
| self.edit_em_metadata({"Base stations": base.uid}) | ||
|
|
||
| def copy_from_extent( | ||
| self, | ||
| extent: np.ndarray, | ||
| parent=None, | ||
| *, | ||
| copy_children: bool = True, | ||
| clear_cache: bool = False, | ||
| inverse: bool = False, | ||
| **kwargs, | ||
| ) -> AirborneAppConReceivers | AirborneAppConBaseStations | None: | ||
| """ | ||
| Sub-class extension of :func:`~geoh5py.shared.entity.Entity.copy_from_extent`. | ||
| """ | ||
| indices = self.mask_by_extent(extent, inverse=inverse) | ||
|
|
||
| if indices is None: | ||
| return None | ||
|
|
||
| new_entity = self.copy( | ||
| parent=parent, | ||
| copy_children=copy_children, | ||
| clear_cache=clear_cache, | ||
| mask=indices, | ||
| **kwargs, | ||
| ) | ||
|
|
||
| return new_entity | ||
|
|
||
| @property | ||
| def default_input_types(self) -> list[str]: | ||
| """Choice of survey creation types.""" | ||
| return self.__INPUT_TYPE | ||
|
|
||
| @property | ||
| def default_receiver_type(self) -> type: | ||
| """ | ||
| :return: Transmitter class | ||
| """ | ||
| return AirborneAppConReceivers | ||
|
|
||
| @property | ||
| def default_transmitter_type(self) -> type: | ||
| """ | ||
| :return: Transmitter class | ||
|
domfournier marked this conversation as resolved.
|
||
| """ | ||
| return type(None) | ||
|
|
||
| @property | ||
| def base_receiver_type(self) -> type: | ||
| return Curve | ||
|
domfournier marked this conversation as resolved.
|
||
|
|
||
| @property | ||
| def base_transmitter_type(self) -> type: | ||
| return Points | ||
|
|
||
| @property | ||
| def default_metadata(self) -> dict: | ||
| """ | ||
| :return: Default unique identifier | ||
| """ | ||
| return { | ||
| "EM Dataset": { | ||
| "Base stations": None, | ||
| "Channels": [], | ||
| "Input type": "Rx and base stations", | ||
| "Property groups": [], | ||
| "Receivers": None, | ||
| "Survey type": "Airborne Apparent Conductivity", | ||
| "Unit": "Hertz (Hz)", | ||
| } | ||
| } | ||
|
|
||
| @property | ||
| def default_units(self) -> list[str]: | ||
| """Accepted time units. Must be one of "Seconds (s)", | ||
| "Milliseconds (ms)", "Microseconds (us)" or "Nanoseconds (ns)" | ||
| """ | ||
| return self.__UNITS | ||
|
|
||
| def _format_transmitter_ids(self, values, attributes): | ||
| """ | ||
| Format transmitter ids. | ||
|
|
||
| :param values: Array of transmitter ids. | ||
| :param attributes: Attributes dictionary for the new Data. | ||
| """ | ||
| if self.complement is not None and self.complement.tx_id_property is not None: | ||
| attributes["entity_type"] = self.complement.tx_id_property.entity_type | ||
| else: | ||
| value_map = { | ||
| ind: f"Base station {ind}" for ind in np.unique(values.astype(np.int32)) | ||
| } | ||
| value_map[0] = "Unknown" | ||
| attributes.update( | ||
| { | ||
| "primitive_type": "REFERENCED", | ||
| "value_map": value_map, | ||
| "association": "VERTEX", | ||
| } | ||
| ) | ||
|
|
||
|
|
||
| class AirborneAppConReceivers(AirborneAppConSurvey, Curve): # pylint: disable=too-many-ancestors | ||
| """ | ||
| An airborne apparent conductivity survey object. | ||
| """ | ||
|
|
||
| _TYPE_UID = uuid.UUID("{9f4772d3-92e7-4601-a3c7-23042c2a76ca}") | ||
| __TYPE = "Receivers" | ||
| _default_name = "Airborne Apparent Conductivity rx" | ||
|
|
||
| @property | ||
| def complement(self): | ||
| return self.base_stations | ||
|
|
||
| @property | ||
| def type(self): | ||
| """Survey element type""" | ||
| return self.__TYPE | ||
|
|
||
|
|
||
| class AirborneAppConBaseStations(AirborneAppConSurvey, Points): | ||
| """ | ||
| An airborne apparent conductivity survey object. | ||
| """ | ||
|
|
||
| _TYPE_UID = uuid.UUID("{b389d178-97eb-4ba1-b378-b8b1e8ab35ff}") | ||
| __TYPE = "Base stations" | ||
| _default_name = "Airborne Apparent Conductivity base" | ||
| _minimum_vertices = 1 | ||
|
|
||
| @property | ||
| def complement(self): | ||
| return self.receivers | ||
|
|
||
| @property | ||
| def type(self): | ||
| """Survey element type""" | ||
| return self.__TYPE | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.