torchbp.grid module
- class torchbp.grid.CartesianGrid(x_range, y_range, nx, ny)[source]
Bases:
GridCartesian grid.
- Parameters:
x_range (Tuple[float, float]) – X extent (x0, x1) in meters. x1 must be > x0.
y_range (Tuple[float, float]) – Y extent (y0, y1) in meters. y1 must be > y0.
nx (int) – Number of X samples. Must be positive.
ny (int) – Number of Y samples. Must be positive.
Examples
>>> grid = CartesianGrid(x_range=(-50, 50), y_range=(-50, 50), nx=100, ny=100) >>> grid.dx 1.0 >>> grid.dy 1.0 >>> grid.shape() (100, 100)
- property dx: float
X spacing in meters (cached).
- property dy: float
Y spacing in meters (cached).
- classmethod from_dict(d)[source]
Create CartesianGrid from dict format.
- Parameters:
d (dict) – Dict with keys: “x”, “y”, “nx”, “ny”
- Returns:
Grid object
- Return type:
- resize(nx=None, ny=None)[source]
Return new grid with different resolution.
- Parameters:
nx (int, optional) – New number of X samples. If None, keep current nx.
ny (int, optional) – New number of Y samples. If None, keep current ny.
- Returns:
New grid with updated resolution
- Return type:
- to_dict()[source]
Convert to dict format.
- Returns:
Grid dict with keys: “x”, “y”, “nx”, “ny”
- Return type:
dict
- property x0: float
Minimum X coordinate in meters.
- property x1: float
Maximum X coordinate in meters.
- property y0: float
Minimum Y coordinate in meters.
- property y1: float
Maximum Y coordinate in meters.
- class torchbp.grid.PolarGrid(r_range, theta_range, nr, ntheta)[source]
Bases:
GridPseudo-polar grid (theta stored as sin(angle)).
- Parameters:
r_range (Tuple[float, float]) – Range extent (r0, r1) in meters. r1 must be > r0.
theta_range (Tuple[float, float]) – Azimuth extent (theta0, theta1) as sin(angle). Must be in [-1, 1].
nr (int) – Number of range bins. Must be positive.
ntheta (int) – Number of azimuth bins. Must be positive.
Examples
>>> grid = PolarGrid(r_range=(50, 100), theta_range=(-1, 1), nr=100, ntheta=200) >>> grid.dr # Range spacing (cached) 0.5 >>> grid.dtheta # Azimuth spacing (cached) 0.01 >>> grid.shape() (100, 200)
- property dr: float
Range spacing in meters (cached).
- property dtheta: float
Azimuth spacing (cached).
- classmethod from_dict(d)[source]
Create PolarGrid from dict format.
- Parameters:
d (dict) – Dict with keys: “r”, “theta”, “nr”, “ntheta”
- Returns:
Grid object
- Return type:
- property r0: float
Minimum range in meters.
- property r1: float
Maximum range in meters.
- resize(nr=None, ntheta=None)[source]
Return new grid with different resolution.
- Parameters:
nr (int, optional) – New number of range bins. If None, keep current nr.
ntheta (int, optional) – New number of azimuth bins. If None, keep current ntheta.
- Returns:
New grid with updated resolution
- Return type:
- property theta0: float
Minimum azimuth (sin of angle).
- property theta1: float
Maximum azimuth (sin of angle).
- torchbp.grid.unpack_cartesian_grid(grid)[source]
Unpack cartesian grid to (x0, x1, y0, y1, nx, ny, dx, dy).
Accepts both CartesianGrid objects and dicts.
- Parameters:
grid (CartesianGrid or dict) – Cartesian grid specification
- Returns:
(x0, x1, y0, y1, nx, ny, dx, dy)
- Return type:
tuple