plume_detection
This module deals with the detection of plumes in a TerraModel. Written by James Panton and Alistair Campbell.
AlgorithmError
Bases: Exception
Exception type raised when incorrect algorithm passed to plume_dbscan
Source code in terratools/plume_detection.py
11 12 13 14 15 16 17 18 |
|
deg2rad(indat)
convert degrees to radians
Parameters:
Name | Type | Description | Default |
---|---|---|---|
indat |
Input degrees |
required |
Returns:
Type | Description |
---|---|
Output radians |
Source code in terratools/plume_detection.py
324 325 326 327 328 329 330 331 332 |
|
get_centre(lons, lats)
Function to take in data lons and lats of a contour line and returns the centroid lon, lat
Parameters:
Name | Type | Description | Default |
---|---|---|---|
lons |
Input longitudes |
required | |
lats |
Input latitudes |
required |
Returns:
Type | Description |
---|---|
latitude of centroid |
Source code in terratools/plume_detection.py
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 |
|
kmeans_analysis(gridin, nclusts, n_init='auto')
perform kmeans clusters analysis on given grid using sklearn package for nclust clusters. Return grid filled with values 0 to nclust-1.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
gridin |
Input data for K-means analysis |
required | |
nclusts |
Number of clusters to search for |
required | |
n_init |
Numer of times to run K-means with different starting centroids |
'auto'
|
Returns:
Type | Description |
---|---|
Result of K-means analysis with clusters numerated |
Source code in terratools/plume_detection.py
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 |
|
plume_centroids(plumeID, plm_obj)
Returns the coordinates of the centroids of each depth layer within the plume
Parameters:
Name | Type | Description | Default |
---|---|---|---|
plumeID |
plumeID number for the plume in question |
required | |
plm_obj |
Plume object |
required |
Returns:
Type | Description |
---|---|
Centroid of plume at each radial layer that it was detected |
Source code in terratools/plume_detection.py
229 230 231 232 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 |
|
plume_dbscan(model, kmeans, algorithm='HDBSCAN', epsilon=150, minsamples=150, depth_range=(400, 2600))
Performs either DBSCAN or HDBSCAN on the output array from the K-means function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model |
Input TerraModel |
required | |
kmeans |
Result from the K-means analysis |
required | |
algorithm |
Spatial clustering algorithm - 'DBSCAN' and 'HDBSCAN' supported |
'HDBSCAN'
|
|
epsilon |
Threshold distance parameter for DBSCAN, min_cluster_size for HDBSCAN |
150
|
|
minsamples |
Minimum number of samples in a neighbourhood for DBSCAN and HDBSCAN |
150
|
|
depth_range |
(min_depth, max_depth) over which to look for plumes |
(400, 2600)
|
Returns:
Type | Description |
---|---|
Number of noise points |
Source code in terratools/plume_detection.py
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 187 188 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 |
|
plume_kmeans(model, depth_range=(400, 2600), n_init='auto')
Performs K-means clustering on the model at each depth containing a layer within the range specified Currently only works when nclust=2
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model |
TerraModel object |
required | |
depth_range |
(min_depth, max_depth) over which to look for plumes |
(400, 2600)
|
|
n_init |
number of times to run k-means with different starting centroids |
'auto'
|
Returns:
Type | Description |
---|---|
Corresponding depths of layers which were searched for plumes. |
Source code in terratools/plume_detection.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 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 |
|
rad2deg(indat)
convert radians to degrees
Parameters:
Name | Type | Description | Default |
---|---|---|---|
indat |
Input radians |
required |
Returns:
Type | Description |
---|---|
Output degress |
Source code in terratools/plume_detection.py
313 314 315 316 317 318 319 320 321 |
|