API Reference

Model Building

Model Building Module

This module provides tools and classes for building and setting up seismic velocity models. It focuses on model construction and parameterization, not forward modeling or inversion.

Key components: - Basic geometry elements (Point2d, ZNode2d) - Model cell definitions (TrapezoidCell2d) - Zelt format velocity model construction (ZeltVelocityModel2d) - Enhanced model building capabilities (EnhancedZeltModel)

class pyAOBS.model_building.EnhancedZeltModel(base_model: ZeltVelocityModel2d)[source]

Bases: ZeltVelocityModel2d

增强型 Zelt 速度模型类,提供额外的处理功能。

compare_with_base() dict[source]

比较当前模型与基础模型的差异。

Returns:

包含比较结果的字典,包括:
  • ’velocity_changes’: 每层速度变化的列表,每个元素是一个元组 ((base_top, base_bottom), (current_top, current_bottom))

  • ’depth_changes’: 每层深度变化的列表,每个元素是一个元组 (base_depth, current_depth)

  • ’boundary_changes’: 模型边界的变化 {‘xmin’: (base, current), ‘xmax’: (base, current),

    ’zmin’: (base, current), ‘zmax’: (base, current)}

Return type:

dict

process_velocity_model(process_type: str)[source]

处理速度模型并更新模型属性。

参数:
process_type: 处理类型,可选值包括:
  • ‘average_velocity’: 计算并更新为平均速度

  • ‘interval_velocity’: 计算并更新为层间速度

  • ‘two_way_time’: 计算并更新为双程走时

返回:

根据处理类型返回相应的结果,同时更新模型属性

class pyAOBS.model_building.Point2d(x: float, z: float)[source]

Bases: object

A 2D point representation.

x

X-coordinate

Type:

float

z

Z-coordinate (depth)

Type:

float

x: float
z: float
class pyAOBS.model_building.TrapezoidCell2d(x1: float, x2: float, z1: float, z2: float, z3: float, z4: float, v1: float, v2: float, v3: float, v4: float)[source]

Bases: object

A trapezoid cell in the velocity model.

This class represents a trapezoid-shaped cell in the velocity model, defined by four corners with their respective velocities. The cell provides methods for point-in-cell testing and velocity interpolation.

x1

Left x-coordinate

Type:

float

x2

Right x-coordinate

Type:

float

s1

Upper boundary slope

Type:

float

b1

Upper boundary intercept

Type:

float

s2

Lower boundary slope

Type:

float

b2

Lower boundary intercept

Type:

float

__repr__() str[source]

Return string representation of the cell.

at(p: Point2d) float[source]

Calculate velocity at a point within the cell.

Parameters:

p (Point2d) – Point to calculate velocity at

Returns:

Interpolated velocity value

Return type:

float

Raises:

ValueError – If point is outside the cell

is_in(p: Point2d) bool[source]

Check if a point is inside the cell.

Parameters:

p (Point2d) – Point to test

Returns:

True if point is inside the cell, False otherwise

Return type:

bool

class pyAOBS.model_building.ZNode2d(x: ~typing.List[float] = <factory>, val: ~typing.List[float] = <factory>, flags: ~typing.List[int] = <factory>)[source]

Bases: object

A velocity node in the ZELT model.

This class represents a node in the velocity model, containing x-coordinates, corresponding values (velocity or depth), and flags for inversion control.

x

X-coordinates of the node points

Type:

List[float]

val

Values (velocity or depth) at each x-coordinate

Type:

List[float]

flags

Inversion flags for each point (0: fixed, 1: free)

Type:

List[int]

__post_init__()[source]

Validate node data after initialization.

add_point(x: float, val: float, flag: int = 0) None[source]

Add a new point to the node.

Parameters:
  • x (float) – X-coordinate

  • val (float) – Value at the point (velocity or depth)

  • flag (int, optional) – Inversion flag. Defaults to 0 (fixed).

flags: List[int]
get_value_at(x: float) float[source]

Get interpolated value at given x-coordinate.

Parameters:

x (float) – X-coordinate to interpolate at

Returns:

Interpolated value

Return type:

float

Raises:

ValueError – If x is outside the node’s range

get_values() List[float][source]

Get list of values.

Returns:

List of values (velocity or depth)

Return type:

List[float]

get_x_coords() List[float][source]

Get list of x-coordinates.

Returns:

List of x-coordinates

Return type:

List[float]

val: List[float]
x: List[float]
class pyAOBS.model_building.ZeltVelocityModel2d(model_file: str | None = None)[source]

Bases: object

Base class for 2D velocity models in Zelt format.

This class provides basic functionality for handling 2D velocity models in Zelt format, including velocity calculations and model manipulation.

depth_nodes

Depth nodes for each layer

Type:

List[ZNode2d]

vupper_nodes

Upper velocity nodes for each layer

Type:

List[ZNode2d]

vlower_nodes

Lower velocity nodes for each layer

Type:

List[ZNode2d]

cells

Trapezoid cells for velocity interpolation

Type:

List[TrapezoidCell2d]

bottom_boundary

Bottom boundary nodes of the model

Type:

ZNode2d

at(x: float, z: float) float[source]

获取指定位置的速度值。

Parameters:
  • x (float) – x 坐标。

  • z (float) – z 坐标。

Returns:

速度值。

Return type:

float

Raises:

ValueError – 如果点超出模型边界。

get_layer_geometry(layer_idx: int) Tuple[List[float], List[float]][source]

Get the geometry of a layer.

Parameters:

layer_idx (int) – Layer index

Returns:

X-coordinates and depths of layer nodes

Return type:

Tuple[List[float], List[float]]

get_model_bounds() Tuple[float, float, float, float][source]

Get model boundaries.

Returns:

(x_min, x_max, z_min, z_max)

Return type:

Tuple[float, float, float, float]

read_model(model_file: str) None[source]

从文件中读取速度模型。

Parameters:

model_file (str) – 速度模型文件路径。

to_xarray(dx: float = 10.0, dz: float = 3.0) Dataset[source]

将模型转换为 xarray 数据集。

Parameters:
  • dx (float) – x方向的采样间隔(km),默认1.0 km

  • dz (float) – z方向的采样间隔(km),默认0.25 km

Returns:

包含速度场的数据集。

Return type:

xr.Dataset

Visualization

Visualization module for seismic processing.

This module provides visualization tools for seismic data and models. It includes: - ZeltModelVisualizer: For visualizing Zelt velocity models - GridModelVisualizer: For visualizing grid format velocity models - GridModelProcessor: For processing and converting grid format velocity models

Rock Classification

Utilities

Utility functions for the seismic_processing package.