Add boundary conditions to an array before overlapping See Also -------- periodic constant
(x, depth=None, kind=None)
| 285 | |
| 286 | |
| 287 | def boundaries(x, depth=None, kind=None): |
| 288 | """Add boundary conditions to an array before overlapping |
| 289 | |
| 290 | See Also |
| 291 | -------- |
| 292 | periodic |
| 293 | constant |
| 294 | """ |
| 295 | if not isinstance(kind, dict): |
| 296 | kind = dict.fromkeys(range(x.ndim), kind) |
| 297 | if not isinstance(depth, dict): |
| 298 | depth = dict.fromkeys(range(x.ndim), depth) |
| 299 | |
| 300 | for i in range(x.ndim): |
| 301 | d = depth.get(i, 0) |
| 302 | if d == 0: |
| 303 | continue |
| 304 | |
| 305 | this_kind = kind.get(i, "none") |
| 306 | if this_kind == "none": |
| 307 | continue |
| 308 | elif this_kind == "periodic": |
| 309 | x = periodic(x, i, d) |
| 310 | elif this_kind == "reflect": |
| 311 | x = reflect(x, i, d) |
| 312 | elif this_kind == "nearest": |
| 313 | x = nearest(x, i, d) |
| 314 | elif i in kind: |
| 315 | x = constant(x, i, d, kind[i]) |
| 316 | |
| 317 | return x |
| 318 | |
| 319 | |
| 320 | def ensure_minimum_chunksize(size, chunks): |