Add boundary conditions to an array before overlapping See Also -------- periodic constant
(x, depth=None, kind=None)
| 299 | |
| 300 | |
| 301 | def boundaries(x, depth=None, kind=None): |
| 302 | """Add boundary conditions to an array before overlapping |
| 303 | |
| 304 | See Also |
| 305 | -------- |
| 306 | periodic |
| 307 | constant |
| 308 | """ |
| 309 | if not isinstance(kind, dict): |
| 310 | kind = dict.fromkeys(range(x.ndim), kind) |
| 311 | if not isinstance(depth, dict): |
| 312 | depth = dict.fromkeys(range(x.ndim), depth) |
| 313 | |
| 314 | for i in range(x.ndim): |
| 315 | d = depth.get(i, 0) |
| 316 | if d == 0: |
| 317 | continue |
| 318 | |
| 319 | this_kind = kind.get(i, "none") |
| 320 | if this_kind == "none": |
| 321 | continue |
| 322 | elif this_kind == "periodic": |
| 323 | x = periodic(x, i, d) |
| 324 | elif this_kind == "reflect": |
| 325 | x = reflect(x, i, d) |
| 326 | elif this_kind == "nearest": |
| 327 | x = nearest(x, i, d) |
| 328 | elif i in kind: |
| 329 | x = constant(x, i, d, kind[i]) |
| 330 | |
| 331 | return x |
| 332 | |
| 333 | |
| 334 | def ensure_minimum_chunksize(size, chunks): |