Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 27 additions & 19 deletions TOATS.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"# Date format test\n",
Expand Down Expand Up @@ -224,7 +226,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"def decimal_month(years, months, days):\n",
Expand Down Expand Up @@ -275,7 +279,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"# calculate and display monthly and annual statistics\n",
Expand Down Expand Up @@ -451,7 +457,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"# create series of dates adjusted to start at 0 for use in the regression model \n",
Expand Down Expand Up @@ -481,7 +489,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"# calculate and plot trend \n",
Expand Down Expand Up @@ -516,21 +526,17 @@
"outputs": [],
"source": [
"TDTi_dict = {} # time of detection\n",
"\n",
"# autocorrelation at lag 1 of the time series noise\n",
"for k, v in wls_model_dict.items():\n",
" model = v['model']\n",
" ts_mean = var_trends[k]['ts_mean']\n",
" decimal_year_zero = v['decimal_year_zero']\n",
" ts_variable_deseasoned = v['ts_variable_deseasoned']\n",
" \n",
" # Detrended monthly anomalies\n",
" trend_to_remove_TDT = model.predict(decimal_year_zero)\n",
" detrended_TDT = [ts_variable_deseasoned[i]-trend_to_remove_TDT[i] for i in range(0, len(ts_mean[k]['datetime_mean']))]\n",
" \n",
" # autocorrelation at lag 1 of the time series noise (i.e. detrended monthly anomalies) \n",
" autocorr = sm.tsa.stattools.acf(detrended_TDT,fft=False,nlags=1)[1:]\n",
" decimal_year_zero = v['decimal_year_zero']\n",
" autocorr = sm.tsa.stattools.acf(ts_variable_deseasoned,fft=False,nlags=1)[1:]\n",
" ts_mean = var_trends[k]['ts_mean']\n",
"\n",
" # standard deviation of detrended monthly anomalies\n",
" model = v['model']\n",
" trend_to_remove_TDT = model.predict(decimal_year_zero)\n",
" detrended_TDT = [ts_variable_deseasoned[i]-trend_to_remove_TDT[i] for i in range(0, len(ts_mean[k]['datetime_mean']))]\n",
" std_dev = np.std(detrended_TDT)\n",
"\n",
" # time of detection \n",
Expand Down Expand Up @@ -611,7 +617,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"# summary of OLS Regression Results\n",
Expand Down Expand Up @@ -759,9 +767,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.5"
"version": "3.10.6"
}
},
"nbformat": 4,
"nbformat_minor": 4
"nbformat_minor": 2
}