GEUS-Glaciology-and-Climate / ice_discharge

Greenland Ice Sheet solid ice discharge from 1986 through last month
https://doi.org/10.5194/essd-12-1367-2020
GNU Lesser General Public License v3.0
8 stars 4 forks source link

Automatic monitoring #25

Open mankoff opened 3 years ago

mankoff commented 3 years ago

To support auto-updating with minimal human interaction, we should implement some level of automatic monitoring.

mankoff commented 3 years ago

Example algorithm: If the changes in the most recent update are more than 20 % over the max historical (last 3 year) change, flag it.

import xarray as xr
import numpy as np

ds = xr.open_dataset('./out/gate.nc')
df = ds['discharge'].T.to_dataframe().unstack()

past = df[df.index > df.index[-1] - pd.DateOffset(years=3)]

flag = np.abs(past.diff().iloc[-1]) > np.abs(past.diff().iloc[:-1].max()*1.20)
flag = flag[flag == True]

if flag.size == 0:
    print("No flags")
else:
    df[flag.index].loc['2016':].plot(drawstyle='steps-post')