utils
centroid_costs(points, cycles, dual_edges, scale=100.0)
Estimate edge costs based on centroid distance in dual graph.
Should probably relocate to a common area where cost functions are maintained at a later date.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
ndarray
|
Location of points on data/primal grid |
required |
cycles
|
ndarray | list[list[int]]
|
Cycles in the primal graph |
required |
dual_edges
|
ndarray
|
Array of size (nedges, 2) where each element represents the cycle in which a primal edge participates. 1-index to account for grounding node in the dual graph. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
cost |
ndarray
|
Nonnegative integer cost of the form 1 + distance / scale. Boundary edge costs are set to zero. |
Source code in src/spurt/mcf/utils.py
189 190 191 192 193 194 195 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 | |
distance_costs(points, edges, scale=100.0)
Estimate edge costs based on distance between points in primal graph.
Should probably relocate to a common area where cost functions are maintained at a later date.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
ndarray
|
Locations on points on data/primal grid |
required |
edges
|
ndarray
|
Array of size (nedges, 2) containing indices of connected points/nodes. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
cost |
ndarray
|
Nonnegative integer cost of the form 1 + distance / scale |
Source code in src/spurt/mcf/utils.py
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | |
flood_fill(indata, links, flows, mode)
Flood fill unwrapping.
Given input data and links for those links start at an arbitrary point and walk along links adding the gradient. When we encounter a cycle, make sure that walking either path around the cycle will result in the same answer. Return the point values. This version has a lot of debugging friendly features. This method assumes that the graph is connected.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indata
|
ndarray
|
Input wrapped phase/ gradient data as 1D array. Same size as number of points/ edges in graph. |
required |
links
|
ndarray
|
Links specifed as tuples of point indices. The links should represented a fully connected graph. |
required |
flows
|
ndarray
|
Integer cycles to be added to each link. |
required |
mode
|
str
|
Can be one of 'points' or 'gradients' |
required |
Returns:
| Name | Type | Description |
|---|---|---|
unwrapped |
ndarray
|
Unwrapped phase in radians. Same size as indata. |
Source code in src/spurt/mcf/utils.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 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 150 151 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 | |
phase_diff(z0, z1, model=0.0)
Compute the wrapped phase difference for between two numbers in radians.
If a model is provided, represents phase difference within +/-pi of the model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
z0
|
ndarray
|
Can be complex or real |
required |
z1
|
ndarray
|
Same type as z0 |
required |
model
|
float | ndarray
|
Real array with a model of the phase difference |
0.0
|
Source code in src/spurt/mcf/utils.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | |
sign_nonzero(x)
Return +1 if x > 0 and -1 for x < 0.
Non-zero value should not be passed in.
Source code in src/spurt/mcf/utils.py
31 32 33 34 35 36 37 38 | |