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