Index
BBox
dataclass
Utility class for managing tile bounds.
We follow shapely convention to store the bounds. The bounds should also be interpreted similar to python's indexing - i.e, left edge inclusive. See https://shapely.readthedocs.io/en/stable/manual.html#object.bounds for details on shapely convention.
Source code in src/spurt/utils/_tiling.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |
count
property
Number of pixels in tile.
space
property
Slice notation for use with NumPy arrays.
from_shapely_bounds(bounds)
classmethod
Create using any sequence in shapely convention.
Source code in src/spurt/utils/_tiling.py
34 35 36 37 38 39 40 | |
intersects(box)
Check if two boxes intersect.
Source code in src/spurt/utils/_tiling.py
42 43 44 45 46 47 48 49 | |
tolist()
List of integers in shapely convention.
Source code in src/spurt/utils/_tiling.py
51 52 53 | |
TileSet
Utility class for managing collection of tiles.
Source code in src/spurt/utils/_tiling.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | |
dilate(factor)
Dilate current tile set.
Source code in src/spurt/utils/_tiling.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | |
from_json(fname)
classmethod
Load tiles from a JSON file.
Source code in src/spurt/utils/_tiling.py
89 90 91 92 93 94 95 96 97 98 99 100 | |
get_overlaps()
Return list of pairs of overlapping tiles.
Source code in src/spurt/utils/_tiling.py
120 121 122 123 124 125 126 127 128 129 130 131 | |
single_tile(shape)
classmethod
Return tileset with single tile corresponding to shape.
Source code in src/spurt/utils/_tiling.py
115 116 117 118 | |
to_json(fname)
Write tiles to a JSON file.
Source code in src/spurt/utils/_tiling.py
102 103 104 105 106 107 108 109 110 111 112 113 | |
create_tiles_density(points, shape, max_tiles)
Tile set with non-overlapping tiles based on density of points.
This is based on the nice implementation found here: https://mathoverflow.net/questions/412127/partitioning-unit-square-with-equal-frequency-rectangles
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
ndarray
|
2D array with point coordinates within the shape. |
required |
shape
|
tuple[int, int]
|
Shape of rectangle to tile up. |
required |
max_tiles
|
int
|
Maximum number of tiles. Actual number of tiles is perfect square '<= max_tiles'. |
required |
Source code in src/spurt/utils/_tiling.py
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | |
create_tiles_regular(shape, max_tiles)
Tile set with approximately regularly sized non-overlapping tiles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shape
|
tuple[int, int]
|
Shape of rectangle to tile up. |
required |
max_tiles
|
int
|
Maximum number of tiles. Actual number of tiles is perfect square '<= max_tiles'. |
required |
Source code in src/spurt/utils/_tiling.py
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | |
get_cpu_count()
Get the number of CPUs available to the current process.
This function accounts for the possibility of a Docker container with
limited CPU resources on a larger machine (which is ignored by
multiprocessing.cpu_count()). This is derived from
isce-framework/dolphin.
Returns:
| Type | Description |
|---|---|
int
|
The number of CPUs available to the current process. |
Source code in src/spurt/utils/_cpu.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | |