API Documentation
Data access
Gas
Bases: object
Source code in src/aitana/whakaari.py
18 19 20 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 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 | |
so2(fuse=False, smooth=True)
Retrieve SO2 gas flux for Whakaari. If fuse is True, the returned values will be a fusion of airborne and scandoas SO2 gas flux measurements. Otherwise, the returned values will be the airborne SO2 gas flux measurements from cospec if available and contouring otherwise.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in src/aitana/whakaari.py
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 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 | |
Seismicity
Bases: object
Source code in src/aitana/whakaari.py
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 | |
rsam()
Load RSAM values NZ.WIZ.10.HHZ.The first time you call this it will download the data from Zenodo and store it locally.
Returns:
:param df: Dataframe with RSAM values.
:type df: :class:`pandas.DataFrame`
Source code in src/aitana/whakaari.py
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 | |
eruptions(min_size=0, dec_interval=None)
This function loads the eruption catalogue for White Island and declusters it.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in src/aitana/whakaari.py
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 231 232 233 234 235 236 237 238 | |
CraterLake
Bases: object
Source code in src/aitana/ruapehu.py
14 15 16 17 18 19 20 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 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 187 188 189 190 191 192 193 194 195 196 197 198 | |
temperature(resample='D', interpolate=None, exclude1995=True, dropna=True)
Read crater lake temperature from Tilde (https://tilde.geonet.org.nz).
Parameters:
:param resample: Average over resampling interval and
linearly interpolate in between. The
interval should be one of 'D', 'W',
or 'M'
:type resample: str
:param interpolate: Interpolate between resampled points.
Only takes effect if resample is not
None.
:type interpolate: str
Returns:
:param df: A dataframe with the temperature time series.
:type df: :class:`pandas.Dataframe`
Source code in src/aitana/ruapehu.py
20 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 | |
water_analyte(analyte, resample=None, interpolate=None, exclude1995=True, drop_duplicates=True)
Download water analyte data from Tilde (https://tilde.geonet.org.nz).
Parameters:
analyte : str
The analyte to download. This can be one of
'Al, 'As', 'B', 'Br', 'Ca', 'Cl', 'Cs', 'F',
'Fe', 'H2S', 'K', 'Li', 'Mg', 'NH3', 'NO3-N', 'Na',
'PO4-P', 'Rb', 'SO4', 'SiO2', 'd18O', 'd2H', 'ph'
resample : str
Resample the data to a given interval. This can be anything
allowed by :pandas.DataFrame.resample:.
interpolate : str
Interpolate between points. This can be anything allowed by
:pandas.DataFrame.interpolate:.
exclude1995 : bool
Exclude data from 1995 when there wasn't a lake.
Returns:
pandas.DataFrame
A dataframe with the water analyte time series.
Source code in src/aitana/ruapehu.py
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 | |
water_level(resample='D', interpolate=None, dropna=True)
Read crater lake water level from Tilde (https://tilde.geonet.org.nz).
Source code in src/aitana/ruapehu.py
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 | |
Seismicity
Bases: object
Source code in src/aitana/ruapehu.py
258 259 260 261 262 263 264 265 266 267 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 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 | |
cone()
Load an earthquake catalogue for an area of 7 km around the summit.
Source code in src/aitana/ruapehu.py
276 277 278 279 280 281 282 283 284 | |
daily_rsam(update=False)
Load RSAM values from DRZ, MAVZ and FWVZ combined by scaling MAVZ and FWVZ RSAM values with DRZ.
Returns:
:param df: Dataframe with RSAM values.
:type df: :class:`pandas.DataFrame`
Source code in src/aitana/ruapehu.py
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 | |
regional()
Load an earthquake catalogue for an area containing Waiouru and National Park.
Source code in src/aitana/ruapehu.py
264 265 266 267 268 269 270 271 272 273 274 | |
rm_duplicates(cat1, cat2)
Remove events from catalogue cat1 that are also in cat2 and return a new catalogue.
Parameters:
cat1 : pandas.DataFrame
The first catalogue.
cat2 : pandas.DataFrame
The second catalogue.
Returns:
pandas.DataFrame
A new catalogue with the events from cat1 that are not in cat2.
Source code in src/aitana/ruapehu.py
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | |
eruptions(min_size=0, dec_interval=None)
This function loads the eruption catalogue for Mt. Ruapehu and declusters it if required. The catalogue is based on Brad Scott's GNS Science Report. Declustering is turned on if dec_interval is greater than zero. This will also exclude magmatic eruption episodes between 9 January 1944 and 8 January 1946 as well as 6 January 1995 to 12 January 1997 as these aren't independent events.
Parameters:
min_size : int
The minimum eruption size to include in the catalogue.
dec_interval : str
The declustering interval in pandas complient time delta format.
Returns:
pandas.DataFrame
A dataframe with the (declustered) eruption catalogue.
Source code in src/aitana/ruapehu.py
362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 | |
lake_height_scaling(recompute=False)
Calculate the scaling factor between the lake height sensors 08 and 03.
Parameters:
recompute : bool
If True, recompute the scaling factor. If False, load the
scaling factor from the cache.
Returns:
tuple
A tuple containing the intercept and slope of the linear regression
between the two sensors.
Source code in src/aitana/ruapehu.py
487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 | |
tilde_request(start_date, end_date, domain, name, station, method='-', sensor='-', aspect='-')
Request data from the tilde API (https://tilde.geonet.org.nz/v3/api-docs/). See the tilde discovery tool for more information: https://tilde.geonet.org.nz/ui/data-discovery/
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in src/aitana/tilde.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 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 | |
wfs_request(start_date, end_date, polygon=None, radius=None, center_point=None, maxdepth=30)
Load volcano-tectonic earthquake catalogues from GeoNet's WFS service (http://wfs.geonet.org.nz).
Parameters:
polygon : str
A string with the polygon coordinates in the format
"lon1+lat1,lon2+lat2,...,lonN+latN,lon1+lat1"
radius : int
The radius around the volcano summit in meters.
center_point : str
The center point of the radius in the format "lon+lat".
maxdepth : int
The maximum depth of the earthquakes in kilometers.
Returns:
pandas.DataFrame
A dataframe with the earthquake catalogue.
Source code in src/aitana/wfs.py
9 10 11 12 13 14 15 16 17 18 19 20 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 | |
Utilities
cache_dataframe(cache_dir='')
Decorator to cache pandas DataFrames, handle date ranges, and persist the cache to disk.
| Parameters: |
|
|---|
Source code in src/aitana/util.py
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 | |
eqRate(cat, fixed_time=None, fixed_nevents=None, enddate=datetime.utcnow())
Compute earthquake rate.
| Parameters: |
|
|---|
Source code in src/aitana/util.py
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 231 232 233 234 235 236 237 238 239 240 | |
generate_cache_key(func_name, args, kwargs)
Generate a unique filename for caching based on function name and arguments.
Source code in src/aitana/util.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
get_color(idx, alpha=1.0, style='seaborn-v0_8-paper')
Return a color from the matplotlib color cycle by index.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in src/aitana/util.py
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 | |
get_defaults_with_names(func)
Get parameter names and their default values from a function object.
Source code in src/aitana/util.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | |
gradient(df, period='14D')
Compute gradient for time series by first smoothing the time series and then computing the first-order difference.
Parameters:
:param df: Dataframe
:type df: :class:`~pandas.DataFrame`
:param period: Period over which to compute a rolling mean.
:type period: str
Source code in src/aitana/util.py
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | |
hex_to_rgb(value, alpha=1.0)
Return (red, green, blue) for the color given as #rrggbb.
Source code in src/aitana/util.py
269 270 271 272 273 274 275 | |
reindex(df, dates, fill_method=None, ffill_interval=14)
Reindex and forward fill to generate a timeseries that can be used to set the evidence for a BN.
| Parameters: |
|
|---|
Source code in src/aitana/util.py
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | |
rgb_to_hex(red, green, blue)
Return color as #rrggbb for the given color values.
Source code in src/aitana/util.py
278 279 280 | |
test_signal(nsec=3600, sampling_rate=100.0, frequencies=[0.1, 3.0, 10.0], amplitudes=[0.1, 1.0, 0.7], phases=[0.0, np.pi * 0.25, np.pi], offsets=[0.0, 0.0, 0.0], starttime=UTCDateTime(1970, 1, 1), gaps=False, noise=True, noise_std=0.5, sinusoid=True, addchirp=True, network='NZ', station='BLUB', location='', channel='HHZ')
Produce a test signal for which we know where the peaks are in the spectrogram.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in src/aitana/util.py
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 | |
Evaluation and scoring
compute_rates(model, pew, debug=False)
Compute the forecasted rates for positive and negative windows.
Arguments:
model: pandas.DataFrame
The model probabilities.
pew: int
The pre-eruption window size.
debug: bool, optional
Whether to print debug information.
Returns:
dict: The forecasted rates for positive and negative windows as well as the overall rate.
Source code in src/aitana/scoring.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 | |
evaluate_threshold(thresh, model, debug=False, pew=90, return_windows=False)
Evaluate the number of true positives, false positives, true negatives and false negatives for a given threshold.
Arguments:
thresh: float
The threshold value.
model: pandas.DataFrame
The forecasted probabilities.
debug: bool, optional
Whether to print debug information.
pew: int, optional
The pre-eruption window size.
return_windows: bool, optional
Whether to return the positive and negative windows.
Returns:
dict: The evaluation results.
list: A list of dictionaries for the tp, fp, tn, fn windows.
Source code in src/aitana/scoring.py
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 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 227 228 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 258 259 260 | |
get_evaluation_windows(starttime, endtime, pew)
Get the evaluation windows for the forecasted rates.
Arguments:
starttime: pd.Timestamp
The start time of the forecast.
endtime: pd.Timestamp
The end time of the forecast.
pew: int
The pre-eruption window size.
Returns:
positive_windows: list
The pre-eruption windows.
negative_windows: list
Non pre-eruption windows.
Source code in src/aitana/scoring.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | |
get_roc_curve(model, thresholds, func, debug=False)
Compute the ROC curve for a given model and thresholds.
Arguments:
model: pandas.DataFrame
The model probabilities.
thresholds: list
The thresholds to evaluate.
func: function
The evaluation function.
debug: bool, optional
Whether to print debug information.
Source code in src/aitana/scoring.py
263 264 265 266 267 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 311 312 313 314 315 316 317 318 319 320 321 | |
make_strictly_increasing(sequence)
Make a sequence strictly increasing. Some of the ROC curves computed with our own metric are not strictly increasing due to the way tps, fps, tns and fns are defined. This function makes sure that the sequence is strictly increasing so that we can caluculate the AUC value.
Arguments:
sequence: Sequence
The sequence to make strictly increasing.
Returns:
Sequence: The strictly increasing sequence.
Source code in src/aitana/scoring.py
324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 | |
State-space models
LocalLinearTrend
Bases: MLEModel
Source code in src/aitana/assimilate.py
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 | |
__init__(endog, obs_cov=None)
Univariate Local Linear Trend Model
Source code in src/aitana/assimilate.py
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 | |
SemiLinearTrend
Bases: MLEModel
Source code in src/aitana/assimilate.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 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 | |
__init__(endog)
Univariate Local Linear Trend Model
Source code in src/aitana/assimilate.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | |
Visualisation
scoring_plot(forecast, threshold, scoring_function, debug=False, ax=None)
Plot the forecast probabilities and the evaluation windows.
Arguments:
forecast: pandas.Series
The forecast probabilities.
threshold: float
The threshold value.
scoring_function: Callable
Function that returns (stats, time_windows) given (threshold, trace).
debug: bool, optional
Whether to print debug information.
ax: matplotlib Axes, optional
The axes to plot on. If None, a new figure and axes are created.
Source code in src/aitana/visualise.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 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 | |
trellis_plot(models, data, plot_uncertainty=False, groups=['b', 'c', 'd', 'e'], q_min=0.15, q_max=0.85)
Create a trellis plot for the given models and data.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in src/aitana/visualise.py
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 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 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 227 228 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 258 259 260 261 262 263 264 265 | |
CLI and workflows
SnakemakeBackend
Source code in src/aitana/volcanobench.py
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 | |
clean(volcano, outdir)
Delete all workflow outputs for a volcano.
Source code in src/aitana/volcanobench.py
116 117 118 119 120 | |
list_workflows()
List all registered workflows.
Source code in src/aitana/volcanobench.py
123 124 125 126 127 128 129 130 131 | |
run(volcano, outdir, cores=1)
Run all registered benchmark workflows for a volcano.
Source code in src/aitana/volcanobench.py
109 110 111 112 113 | |
Logging configuration for the aitana package.
This module sets up logging to output to stdout/stderr without file handlers.
get_logger(name)
Get a logger for a specific module within aitana.
Parameters:
name : str
The name of the module (e.g., 'aitana.ruapehu')
Returns:
logging.Logger
A configured logger instance
Source code in src/aitana/logging_config.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |
setup_logging(level=logging.INFO)
Configure logging for the aitana package.
By default, INFO and DEBUG messages go to stdout, WARNING, ERROR, and CRITICAL go to stderr.
Parameters:
level : int
The logging level (e.g., logging.DEBUG, logging.INFO)
Source code in src/aitana/logging_config.py
10 11 12 13 14 15 16 17 18 19 20 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 | |