PyHydroGeophysX.Hydro_modular package#
Submodules#
PyHydroGeophysX.Hydro_modular.hydro_to_ert module#
Module for converting hydrologic model output to ERT apparent resistivity.
- PyHydroGeophysX.Hydro_modular.hydro_to_ert.hydro_to_ert(water_content: ndarray, porosity: ndarray, mesh: pygimli.Mesh, profile_interpolator: ProfileInterpolator, layer_idx: int | List[int], structure: ndarray, marker_labels: List[int], rho_parameters: Dict[str, Any], electrode_spacing: float = 1.0, electrode_start: float = 0.0, num_electrodes: int = 72, scheme_name: str = 'wa', noise_level: float = 0.05, abs_error: float = 0.0, rel_error: float = 0.05, save_path: str | None = None, mesh_markers: ndarray | None = None, verbose: bool = False, seed: int | None = None) Tuple[pygimli.DataContainer, ndarray][source]#
Convert hydrologic model output to ERT apparent resistivity.
This function performs the complete workflow from water content to synthetic ERT data: 1. Interpolates water content to mesh 2. Calculates saturation 3. Converts saturation to resistivity using petrophysical models 4. Creates electrode array along surface profile 5. Performs forward modeling to generate synthetic ERT data
- Parameters:
water_content – Water content array (nlay, ny, nx) or mesh values
porosity – Porosity array (nlay, ny, nx) or mesh values
mesh – PyGIMLI mesh
profile_interpolator – ProfileInterpolator for surface interpolation
marker_labels – Layer marker labels [top, middle, bottom]
rho_parameters –
Dictionary of resistivity parameters: {
’rho_sat’: [100, 500, 2400], # Saturated resistivity values ‘n’: [2.2, 1.8, 2.5], # Cementation exponents ‘sigma_s’: [1/500, 0, 0] # Surface conductivity values
}
electrode_spacing – Spacing between electrodes
electrode_start – Starting position of electrode array
num_electrodes – Number of electrodes
scheme_name – ERT scheme name (‘wa’, ‘dd’, etc.)
noise_level – Relative noise level for synthetic data
abs_error – Absolute error for data estimation
rel_error – Relative error for data estimation
save_path – Path to save synthetic data (None = don’t save)
mesh_markers – Mesh cell markers (None = get from mesh)
verbose – Whether to display verbose information
seed – Random seed for noise generation
- Returns:
Tuple of (synthetic ERT data container, resistivity model)
PyHydroGeophysX.Hydro_modular.hydro_to_fdem module#
Hydrologic-to-FDEM conversion helpers for 2D profile workflows.
- PyHydroGeophysX.Hydro_modular.hydro_to_fdem.hydro_to_fdem(water_content: ndarray, porosity: ndarray, layer_boundaries: ndarray, frequencies: ndarray | None = None, sigma_w: float = 0.05, m: float = 1.5, n: float = 2.0, sigma_s: float = 0.0, source_location: ndarray | None = None, receiver_location: ndarray | None = None, source_radius: float = 10.0, receiver_orientation: str = 'z', receiver_component: str = 'secondary', waveform_type: str = 'dipole', noise_level: float = 0.03, seed: int | None = None, min_thickness: float = 0.1, verbose: bool = False) Tuple[ndarray, ndarray, ndarray, ndarray][source]#
Simulate pseudo-2D FDEM response from one hydrologic profile.
A 1D FDEM sounding is simulated at each profile station and stacked into a response matrix.
- Parameters:
water_content – Water content matrix, shape (n_layers, n_stations).
porosity – Porosity matrix, same shape as water_content.
layer_boundaries – Elevation matrix for layer interfaces, shape (n_layers + 1, n_stations), or 1D (n_layers + 1).
frequencies – FDEM frequencies.
sigma_w – Pore-water conductivity (S/m).
m – Cementation exponent.
n – Saturation exponent.
sigma_s – Surface conductivity (S/m).
source_location – Source location [x, y, z].
receiver_location – Receiver location [x, y, z].
source_radius – Source loop radius (m).
receiver_orientation – Receiver orientation.
receiver_component – ‘secondary’, ‘total’, or ‘both’.
waveform_type – ‘dipole’ or ‘loop’.
noise_level – Relative noise level.
seed – Random seed.
min_thickness – Lower bound for finite layer thicknesses (m).
verbose – Print progress.
- Returns:
Shape (n_stations, n_frequencies), complex. clean_data: Shape (n_stations, n_frequencies), complex. uncertainty: Shape (n_stations, n_frequencies), float. conductivity: Shape (n_layers, n_stations), float.
- Return type:
noisy_data
PyHydroGeophysX.Hydro_modular.hydro_to_geophysics module#
Hydro -> multi-geophysics forward pipeline for the desktop studio.
This module is a thin, parameterized re-use of
examples/Ex_hydro_to_multigeophys.py. It is deliberately Qt-free so it can run
inside a worker thread (or be unit-tested) without a QApplication.
Two layers:
extract_profile/build_survey_config– numpy + scipy only. These work even when pygimli is not installed, so “Generate profile” and “Export survey config” never depend on the heavy backend.run_hydro_forward– the real forward run. It imports pygimli and thehydro_to_*wrappers lazily; if anything is missing or fails it raisesBackendUnavailableso the caller can fall back to config export.
- PyHydroGeophysX.Hydro_modular.hydro_to_geophysics.assign_three_layer_markers(mesh: Any, line1: ndarray, line2: ndarray, top_marker: int = 0, mid_marker: int = 3, bot_marker: int = 2) ndarray[source]#
Assign top/middle/bottom markers from two interface lines.
- PyHydroGeophysX.Hydro_modular.hydro_to_geophysics.build_survey_config(context: Dict[str, Any], params: Dict[str, Any], methods: Sequence[str], point1: Sequence[float], point2: Sequence[float], profile: Dict[str, Any] | None = None) Dict[str, Any][source]#
Build a complete, JSON-serializable survey configuration.
If a previously extracted
profiledict is supplied, a downsampled copy of the sampled profile is embedded so the config is useful even without a forward run.
- PyHydroGeophysX.Hydro_modular.hydro_to_geophysics.extract_profile(context: ~typing.Dict[str, ~typing.Any], params: ~typing.Dict[str, ~typing.Any], point1: ~typing.Sequence[float], point2: ~typing.Sequence[float], log: ~typing.Callable[[str], None] = <function noop>) Dict[str, Any][source]#
Extract the 2D hydro profile between two clicked points.
Returns a dict with
L_profile,structure(layer boundaries),water_content_profileandporosity_profileplus bookkeeping. This only needs numpy + scipy viaProfileInterpolatorand works without pygimli.
- PyHydroGeophysX.Hydro_modular.hydro_to_geophysics.fill_profile_nans(values: Any) ndarray[source]#
Fill NaNs along the profile direction for each layer.
- PyHydroGeophysX.Hydro_modular.hydro_to_geophysics.find_hydro_files(data_dir: Path) Dict[str, Path | None][source]#
Return the resolved path for each expected hydro file (or None).
- PyHydroGeophysX.Hydro_modular.hydro_to_geophysics.get_mesh_xy(mesh: Any) Tuple[ndarray, ndarray][source]#
Return mesh cell-center x/y arrays.
- PyHydroGeophysX.Hydro_modular.hydro_to_geophysics.interpolate_profile_to_mesh(profile_values: Any, layer_boundaries: Any, x_profile: Any, mesh: Any) ndarray[source]#
Interpolate a (layers x distance) profile matrix onto mesh cells.
- PyHydroGeophysX.Hydro_modular.hydro_to_geophysics.run_hydro_forward(context: ~typing.Dict[str, ~typing.Any], params: ~typing.Dict[str, ~typing.Any], methods: ~typing.Sequence[str], point1: ~typing.Sequence[float], point2: ~typing.Sequence[float], log: ~typing.Callable[[str], None] = <function noop>) Dict[str, Any][source]#
Run the real hydro->geophysics forward pipeline.
Raises
BackendUnavailableif pygimli / the hydro_to_* wrappers cannot be imported, and propagates any other exception from the forward run so the caller can fall back to config export.
PyHydroGeophysX.Hydro_modular.hydro_to_gravity module#
Hydrologic-to-gravity conversion helpers for 2D profile workflows.
- PyHydroGeophysX.Hydro_modular.hydro_to_gravity.hydro_to_gravity(water_content: ndarray, porosity: ndarray, layer_boundaries: ndarray, station_positions: ndarray | None = None, rho_matrix: float = 2650.0, rho_water: float = 1000.0, rho_air: float = 1.225, sensor_height: float = 0.5, noise_level: float = 0.01, seed: int | None = None, mesh_nx: int = 80, mesh_nz: int = 60, model_width_y: float = 12.0, verbose: bool = False) Tuple[ndarray, ndarray, ndarray, ndarray][source]#
Simulate gravity response from a 2D hydrologic profile using SimPEG.
The 2D profile is interpolated to a thin 3D TensorMesh (single y strip), then
Simulation3DIntegralis used to computegz.- Parameters:
water_content – Water content matrix, shape (n_layers, n_stations).
porosity – Porosity matrix, same shape as water_content.
layer_boundaries – Elevation matrix for layer interfaces, shape (n_layers + 1, n_stations), or 1D (n_layers + 1).
station_positions – Profile x coordinates.
rho_matrix – Grain density (kg/m^3).
rho_water – Water density (kg/m^3).
rho_air – Air density (kg/m^3).
sensor_height – Sensor height above ground (m).
noise_level – Relative noise level.
seed – Random seed.
mesh_nx – Number of mesh cells in x.
mesh_nz – Number of mesh cells in z.
model_width_y – Width of the single y strip (m).
verbose – Print progress.
- Returns:
Gravity anomaly with noise (mGal), shape (n_stations,). clean_data: Noise-free gravity anomaly (mGal), shape (n_stations,). uncertainty: Data uncertainty (mGal), shape (n_stations,). density_contrast: Profile density contrast model (kg/m^3),
shape (n_layers, n_stations).
- Return type:
noisy_data
PyHydroGeophysX.Hydro_modular.hydro_to_srt module#
Module for converting hydrologic model output to seismic travel times.
- PyHydroGeophysX.Hydro_modular.hydro_to_srt.hydro_to_srt(water_content: ndarray, porosity: ndarray, mesh: pygimli.Mesh, profile_interpolator: ProfileInterpolator, layer_idx: int | List[int], structure: ndarray, marker_labels: List[int], vel_parameters: Dict[str, Any], sensor_spacing: float = 1.0, sensor_start: float = 0.0, num_sensors: int = 72, shot_distance: float = 5, noise_level: float = 0.05, noise_abs: float = 1e-05, save_path: str | None = None, mesh_markers: ndarray | None = None, verbose: bool = False, seed: int | None = None) Tuple[pygimli.DataContainer, ndarray][source]#
Convert hydrologic model output to seismic travel times.
This function performs the complete workflow from water content to synthetic SRT data:
Interpolates water content to mesh
Calculates saturation
Converts saturation to seismic velocities using petrophysical models
Creates sensor array along surface profile
Performs forward modeling to generate synthetic travel time data
- Parameters:
water_content – Water content array (nlay, ny, nx) or mesh values
porosity – Porosity array (nlay, ny, nx) or mesh values
mesh – PyGIMLI mesh
profile_interpolator – ProfileInterpolator for surface interpolation
marker_labels – Layer marker labels [top, middle, bottom]
vel_parameters – Dictionary of velocity parameters containing ‘top’: {‘bulk_modulus’: 30.0, ‘shear_modulus’: 20.0, ‘mineral_density’: 2650, ‘depth’: 1.0}, ‘mid’: {‘bulk_modulus’: 50.0, ‘shear_modulus’: 35.0, ‘mineral_density’: 2670, ‘aspect_ratio’: 0.05}, ‘bot’: {‘bulk_modulus’: 55.0, ‘shear_modulus’: 50.0, ‘mineral_density’: 2680, ‘aspect_ratio’: 0.03}
sensor_spacing – Spacing between sensors
sensor_start – Starting position of sensor array
num_sensors – Number of sensors
shot_distance – Distance between shot points
noise_level – Relative noise level for synthetic data
noise_abs – Absolute noise level for synthetic data
save_path – Path to save synthetic data (None = don’t save)
mesh_markers – Mesh cell markers (None = get from mesh)
verbose – Whether to display verbose information
seed – Random seed for noise generation
- Returns:
Tuple of (synthetic SRT data container, velocity model)
PyHydroGeophysX.Hydro_modular.hydro_to_tdem module#
Hydrologic-to-TDEM conversion helpers for 2D profile workflows.
- PyHydroGeophysX.Hydro_modular.hydro_to_tdem.hydro_to_tdem(water_content: ndarray, porosity: ndarray, layer_boundaries: ndarray, times: ndarray | None = None, sigma_w: float = 0.05, m: float = 1.5, n: float = 2.0, sigma_s: float = 0.0, source_radius: float = 10.0, noise_level: float = 0.03, seed: int | None = None, min_thickness: float = 0.1, verbose: bool = False) Tuple[ndarray, ndarray, ndarray, ndarray][source]#
Simulate pseudo-2D TDEM response from one hydrologic profile.
The input is a 2D section (layers x profile stations). A 1D TDEM sounding is simulated at each profile station and stacked into a response matrix.
- Parameters:
water_content – Water content matrix, shape (n_layers, n_stations).
porosity – Porosity matrix, same shape as water_content.
layer_boundaries – Elevation matrix for layer interfaces, shape (n_layers + 1, n_stations), or 1D (n_layers + 1).
times – TDEM time channels.
sigma_w – Pore-water conductivity (S/m).
m – Cementation exponent.
n – Saturation exponent.
sigma_s – Surface conductivity (S/m).
source_radius – Source loop radius (m).
noise_level – Relative noise level.
seed – Random seed.
min_thickness – Lower bound for finite layer thicknesses (m).
verbose – Print progress.
- Returns:
Shape (n_stations, n_times). clean_data: Shape (n_stations, n_times). uncertainty: Shape (n_stations, n_times). conductivity: Shape (n_layers, n_stations).
- Return type:
noisy_data
Module contents#
Hydro_modular package for hydrologic to geophysical conversion utilities.
- PyHydroGeophysX.Hydro_modular.hydro_to_ert(water_content: ndarray, porosity: ndarray, mesh: pygimli.Mesh, profile_interpolator: ProfileInterpolator, layer_idx: int | List[int], structure: ndarray, marker_labels: List[int], rho_parameters: Dict[str, Any], electrode_spacing: float = 1.0, electrode_start: float = 0.0, num_electrodes: int = 72, scheme_name: str = 'wa', noise_level: float = 0.05, abs_error: float = 0.0, rel_error: float = 0.05, save_path: str | None = None, mesh_markers: ndarray | None = None, verbose: bool = False, seed: int | None = None) Tuple[pygimli.DataContainer, ndarray][source]#
Convert hydrologic model output to ERT apparent resistivity.
This function performs the complete workflow from water content to synthetic ERT data: 1. Interpolates water content to mesh 2. Calculates saturation 3. Converts saturation to resistivity using petrophysical models 4. Creates electrode array along surface profile 5. Performs forward modeling to generate synthetic ERT data
- Parameters:
water_content – Water content array (nlay, ny, nx) or mesh values
porosity – Porosity array (nlay, ny, nx) or mesh values
mesh – PyGIMLI mesh
profile_interpolator – ProfileInterpolator for surface interpolation
marker_labels – Layer marker labels [top, middle, bottom]
rho_parameters –
Dictionary of resistivity parameters: {
’rho_sat’: [100, 500, 2400], # Saturated resistivity values ‘n’: [2.2, 1.8, 2.5], # Cementation exponents ‘sigma_s’: [1/500, 0, 0] # Surface conductivity values
}
electrode_spacing – Spacing between electrodes
electrode_start – Starting position of electrode array
num_electrodes – Number of electrodes
scheme_name – ERT scheme name (‘wa’, ‘dd’, etc.)
noise_level – Relative noise level for synthetic data
abs_error – Absolute error for data estimation
rel_error – Relative error for data estimation
save_path – Path to save synthetic data (None = don’t save)
mesh_markers – Mesh cell markers (None = get from mesh)
verbose – Whether to display verbose information
seed – Random seed for noise generation
- Returns:
Tuple of (synthetic ERT data container, resistivity model)
- PyHydroGeophysX.Hydro_modular.hydro_to_fdem(water_content: ndarray, porosity: ndarray, layer_boundaries: ndarray, frequencies: ndarray | None = None, sigma_w: float = 0.05, m: float = 1.5, n: float = 2.0, sigma_s: float = 0.0, source_location: ndarray | None = None, receiver_location: ndarray | None = None, source_radius: float = 10.0, receiver_orientation: str = 'z', receiver_component: str = 'secondary', waveform_type: str = 'dipole', noise_level: float = 0.03, seed: int | None = None, min_thickness: float = 0.1, verbose: bool = False) Tuple[ndarray, ndarray, ndarray, ndarray][source]#
Simulate pseudo-2D FDEM response from one hydrologic profile.
A 1D FDEM sounding is simulated at each profile station and stacked into a response matrix.
- Parameters:
water_content – Water content matrix, shape (n_layers, n_stations).
porosity – Porosity matrix, same shape as water_content.
layer_boundaries – Elevation matrix for layer interfaces, shape (n_layers + 1, n_stations), or 1D (n_layers + 1).
frequencies – FDEM frequencies.
sigma_w – Pore-water conductivity (S/m).
m – Cementation exponent.
n – Saturation exponent.
sigma_s – Surface conductivity (S/m).
source_location – Source location [x, y, z].
receiver_location – Receiver location [x, y, z].
source_radius – Source loop radius (m).
receiver_orientation – Receiver orientation.
receiver_component – ‘secondary’, ‘total’, or ‘both’.
waveform_type – ‘dipole’ or ‘loop’.
noise_level – Relative noise level.
seed – Random seed.
min_thickness – Lower bound for finite layer thicknesses (m).
verbose – Print progress.
- Returns:
Shape (n_stations, n_frequencies), complex. clean_data: Shape (n_stations, n_frequencies), complex. uncertainty: Shape (n_stations, n_frequencies), float. conductivity: Shape (n_layers, n_stations), float.
- Return type:
noisy_data
- PyHydroGeophysX.Hydro_modular.hydro_to_gravity(water_content: ndarray, porosity: ndarray, layer_boundaries: ndarray, station_positions: ndarray | None = None, rho_matrix: float = 2650.0, rho_water: float = 1000.0, rho_air: float = 1.225, sensor_height: float = 0.5, noise_level: float = 0.01, seed: int | None = None, mesh_nx: int = 80, mesh_nz: int = 60, model_width_y: float = 12.0, verbose: bool = False) Tuple[ndarray, ndarray, ndarray, ndarray][source]#
Simulate gravity response from a 2D hydrologic profile using SimPEG.
The 2D profile is interpolated to a thin 3D TensorMesh (single y strip), then
Simulation3DIntegralis used to computegz.- Parameters:
water_content – Water content matrix, shape (n_layers, n_stations).
porosity – Porosity matrix, same shape as water_content.
layer_boundaries – Elevation matrix for layer interfaces, shape (n_layers + 1, n_stations), or 1D (n_layers + 1).
station_positions – Profile x coordinates.
rho_matrix – Grain density (kg/m^3).
rho_water – Water density (kg/m^3).
rho_air – Air density (kg/m^3).
sensor_height – Sensor height above ground (m).
noise_level – Relative noise level.
seed – Random seed.
mesh_nx – Number of mesh cells in x.
mesh_nz – Number of mesh cells in z.
model_width_y – Width of the single y strip (m).
verbose – Print progress.
- Returns:
Gravity anomaly with noise (mGal), shape (n_stations,). clean_data: Noise-free gravity anomaly (mGal), shape (n_stations,). uncertainty: Data uncertainty (mGal), shape (n_stations,). density_contrast: Profile density contrast model (kg/m^3),
shape (n_layers, n_stations).
- Return type:
noisy_data
- PyHydroGeophysX.Hydro_modular.hydro_to_srt(water_content: ndarray, porosity: ndarray, mesh: pygimli.Mesh, profile_interpolator: ProfileInterpolator, layer_idx: int | List[int], structure: ndarray, marker_labels: List[int], vel_parameters: Dict[str, Any], sensor_spacing: float = 1.0, sensor_start: float = 0.0, num_sensors: int = 72, shot_distance: float = 5, noise_level: float = 0.05, noise_abs: float = 1e-05, save_path: str | None = None, mesh_markers: ndarray | None = None, verbose: bool = False, seed: int | None = None) Tuple[pygimli.DataContainer, ndarray][source]#
Convert hydrologic model output to seismic travel times.
This function performs the complete workflow from water content to synthetic SRT data:
Interpolates water content to mesh
Calculates saturation
Converts saturation to seismic velocities using petrophysical models
Creates sensor array along surface profile
Performs forward modeling to generate synthetic travel time data
- Parameters:
water_content – Water content array (nlay, ny, nx) or mesh values
porosity – Porosity array (nlay, ny, nx) or mesh values
mesh – PyGIMLI mesh
profile_interpolator – ProfileInterpolator for surface interpolation
marker_labels – Layer marker labels [top, middle, bottom]
vel_parameters – Dictionary of velocity parameters containing ‘top’: {‘bulk_modulus’: 30.0, ‘shear_modulus’: 20.0, ‘mineral_density’: 2650, ‘depth’: 1.0}, ‘mid’: {‘bulk_modulus’: 50.0, ‘shear_modulus’: 35.0, ‘mineral_density’: 2670, ‘aspect_ratio’: 0.05}, ‘bot’: {‘bulk_modulus’: 55.0, ‘shear_modulus’: 50.0, ‘mineral_density’: 2680, ‘aspect_ratio’: 0.03}
sensor_spacing – Spacing between sensors
sensor_start – Starting position of sensor array
num_sensors – Number of sensors
shot_distance – Distance between shot points
noise_level – Relative noise level for synthetic data
noise_abs – Absolute noise level for synthetic data
save_path – Path to save synthetic data (None = don’t save)
mesh_markers – Mesh cell markers (None = get from mesh)
verbose – Whether to display verbose information
seed – Random seed for noise generation
- Returns:
Tuple of (synthetic SRT data container, velocity model)
- PyHydroGeophysX.Hydro_modular.hydro_to_tdem(water_content: ndarray, porosity: ndarray, layer_boundaries: ndarray, times: ndarray | None = None, sigma_w: float = 0.05, m: float = 1.5, n: float = 2.0, sigma_s: float = 0.0, source_radius: float = 10.0, noise_level: float = 0.03, seed: int | None = None, min_thickness: float = 0.1, verbose: bool = False) Tuple[ndarray, ndarray, ndarray, ndarray][source]#
Simulate pseudo-2D TDEM response from one hydrologic profile.
The input is a 2D section (layers x profile stations). A 1D TDEM sounding is simulated at each profile station and stacked into a response matrix.
- Parameters:
water_content – Water content matrix, shape (n_layers, n_stations).
porosity – Porosity matrix, same shape as water_content.
layer_boundaries – Elevation matrix for layer interfaces, shape (n_layers + 1, n_stations), or 1D (n_layers + 1).
times – TDEM time channels.
sigma_w – Pore-water conductivity (S/m).
m – Cementation exponent.
n – Saturation exponent.
sigma_s – Surface conductivity (S/m).
source_radius – Source loop radius (m).
noise_level – Relative noise level.
seed – Random seed.
min_thickness – Lower bound for finite layer thicknesses (m).
verbose – Print progress.
- Returns:
Shape (n_stations, n_times). clean_data: Shape (n_stations, n_times). uncertainty: Shape (n_stations, n_times). conductivity: Shape (n_layers, n_stations).
- Return type:
noisy_data