Copy a slice of an array around to its other side Useful to create periodic boundary conditions for overlap
(x, axis, depth)
| 192 | |
| 193 | |
| 194 | def periodic(x, axis, depth): |
| 195 | """Copy a slice of an array around to its other side |
| 196 | |
| 197 | Useful to create periodic boundary conditions for overlap |
| 198 | """ |
| 199 | |
| 200 | left = ( |
| 201 | (slice(None, None, None),) * axis |
| 202 | + (slice(0, depth),) |
| 203 | + (slice(None, None, None),) * (x.ndim - axis - 1) |
| 204 | ) |
| 205 | right = ( |
| 206 | (slice(None, None, None),) * axis |
| 207 | + (slice(-depth, None),) |
| 208 | + (slice(None, None, None),) * (x.ndim - axis - 1) |
| 209 | ) |
| 210 | l = x[left] |
| 211 | r = x[right] |
| 212 | |
| 213 | l, r = _remove_overlap_boundaries(l, r, axis, depth) |
| 214 | |
| 215 | return concatenate([r, x, l], axis=axis) |
| 216 | |
| 217 | |
| 218 | def reflect(x, axis, depth): |
searching dependent graphs…