dplPy
example using an entirely floating chronology¶
In [22]:
Copied!
import numpy as np
import scipy as sp
import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
# nicely render figures in the notebook
%config InlineBackend.figure_format = 'retina'
%matplotlib inline
# you can omit the line below if you'd like, but I really don't like the default fonts in Python, so I switch to Helvetica
plt.rcParams['font.family'] = 'Helvetica'
plt.rcParams['figure.figsize'] = (10, 5)
import numpy as np
import scipy as sp
import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
# nicely render figures in the notebook
%config InlineBackend.figure_format = 'retina'
%matplotlib inline
# you can omit the line below if you'd like, but I really don't like the default fonts in Python, so I switch to Helvetica
plt.rcParams['font.family'] = 'Helvetica'
plt.rcParams['figure.figsize'] = (10, 5)
Let's import dplpy
and check to make sure we've got the latest version and are using the Pypi installed version:
In [23]:
Copied!
import dplpy
# print out the version number of dplPy you are using - should be v0.1.2
print('Currently using the following version of dplPy:', dplpy.__version__)
# You should see the path to your local Python installation
print('Currently using the following directory for dplPy:', dplpy.__file__)
import dplpy
# print out the version number of dplPy you are using - should be v0.1.2
print('Currently using the following version of dplPy:', dplpy.__version__)
# You should see the path to your local Python installation
print('Currently using the following directory for dplPy:', dplpy.__file__)
Currently using the following version of dplPy: 0.1.2 Currently using the following directory for dplPy: /Users/kja/anaconda3/envs/dplpy/lib/python3.12/site-packages/dplpy/__init__.py
We'll use reader
to get the raw ring width and we'll plot the series using Pandas build-in plotting.
In [24]:
Copied!
df = dplpy.readers("wwr.rwl")
df.plot(legend=False);
df = dplpy.readers("wwr.rwl")
df.plot(legend=False);
Attempting to read input file: wwr.rwl as .rwl format SUCCESS! File read as: .rwl file Series names: ['WWRC501', 'WWRgq01', 'WWRa101', 'WWRa301', 'WWRgw01', 'WWRgw02', 'WWRl501', 'WWRgx01', 'WWRgy01', 'WWRbh01', 'WWRa601', 'WWRgs01', 'WWRc401', 'WWRc402', 'WWRst01a', 'WWRst01b', 'WWRst02a', 'WWRL601', 'WWRb201', 'WWRL801']
Get the series summary:
In [25]:
Copied!
dplpy.summary(df)
dplpy.summary(df)
Out[25]:
WWRC501 | WWRgq01 | WWRa101 | WWRa301 | WWRgw01 | WWRgw02 | WWRl501 | WWRgx01 | WWRgy01 | WWRbh01 | WWRa601 | WWRgs01 | WWRc401 | WWRc402 | WWRst01a | WWRst01b | WWRst02a | WWRL601 | WWRb201 | WWRL801 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
count | 184.000000 | 199.000000 | 113.000000 | 123.000000 | 226.000000 | 172.000000 | 107.000000 | 220.000000 | 235.000000 | 223.000000 | 69.000000 | 226.000000 | 164.000000 | 165.000000 | 121.000000 | 85.000000 | 90.000000 | 147.000000 | 140.000000 | 135.000000 |
mean | 1.417060 | 1.406482 | 2.523788 | 1.705341 | 1.146354 | 0.846506 | 2.167056 | 1.181932 | 1.094809 | 1.152668 | 2.368159 | 1.284230 | 1.500646 | 1.494570 | 2.458306 | 3.344494 | 3.916389 | 1.815898 | 1.640429 | 1.379948 |
std | 0.713585 | 0.866385 | 1.123288 | 0.834921 | 1.040933 | 0.455078 | 1.081787 | 0.671113 | 0.976220 | 0.580281 | 1.304499 | 0.604241 | 0.862143 | 0.874111 | 1.814101 | 1.576738 | 1.560494 | 0.966497 | 1.180153 | 0.821949 |
min | 0.208000 | 0.093000 | 0.211000 | 0.145000 | 0.000000 | 0.000000 | 0.167000 | 0.111000 | 0.000000 | 0.000000 | 0.160000 | 0.000000 | 0.000000 | 0.000000 | 0.325000 | 0.800000 | 0.821000 | 0.000000 | 0.100000 | 0.148000 |
25% | 0.891000 | 0.789500 | 1.808000 | 1.066000 | 0.517000 | 0.512500 | 1.255500 | 0.696500 | 0.522000 | 0.776500 | 1.216000 | 0.856000 | 0.826750 | 0.811000 | 1.320000 | 2.161000 | 2.892250 | 1.074000 | 0.780750 | 0.769000 |
50% | 1.352500 | 1.183000 | 2.472000 | 1.591000 | 0.827000 | 0.756500 | 2.073000 | 1.052500 | 0.777000 | 1.049000 | 2.285000 | 1.283000 | 1.291000 | 1.297000 | 2.019000 | 3.064000 | 3.847500 | 1.735000 | 1.315500 | 1.362000 |
75% | 1.848250 | 1.916000 | 3.295000 | 2.300000 | 1.393500 | 1.127000 | 3.047000 | 1.473500 | 1.300000 | 1.412000 | 3.134000 | 1.684500 | 2.055750 | 2.001000 | 3.077000 | 4.061000 | 4.857250 | 2.396500 | 2.277750 | 1.761500 |
max | 3.666000 | 4.165000 | 4.984000 | 4.166000 | 6.458000 | 2.236000 | 4.946000 | 3.836000 | 5.408000 | 3.612000 | 5.356000 | 2.992000 | 4.139000 | 4.549000 | 8.399000 | 7.962000 | 8.461000 | 4.835000 | 5.018000 | 4.550000 |
Get the series stats:
In [26]:
Copied!
dplpy.stats(df)
dplpy.stats(df)
Out[26]:
series | first | last | year | mean | median | stdev | skew | gini | ar1 | |
---|---|---|---|---|---|---|---|---|---|---|
1 | WWRC501 | 1000 | 1183 | 184 | 1.417 | 1.35 | 0.714 | 0.612 | 0.282 | 0.782 |
2 | WWRgq01 | 976 | 1174 | 199 | 1.406 | 1.18 | 0.866 | 0.906 | 0.337 | 0.858 |
3 | WWRa101 | 1066 | 1178 | 113 | 2.524 | 2.47 | 1.123 | 0.051 | 0.253 | 0.753 |
4 | WWRa301 | 1059 | 1181 | 123 | 1.705 | 1.59 | 0.835 | 0.454 | 0.275 | 0.788 |
5 | WWRgw01 | 961 | 1186 | 226 | 1.146 | 0.83 | 1.041 | 2.478 | 0.420 | 0.871 |
6 | WWRgw02 | 1011 | 1182 | 172 | 0.847 | 0.76 | 0.455 | 0.720 | 0.298 | 0.782 |
7 | WWRl501 | 1079 | 1185 | 107 | 2.167 | 2.07 | 1.082 | 0.264 | 0.283 | 0.818 |
8 | WWRgx01 | 960 | 1179 | 220 | 1.182 | 1.05 | 0.671 | 1.257 | 0.301 | 0.830 |
9 | WWRgy01 | 946 | 1180 | 235 | 1.095 | 0.78 | 0.976 | 2.173 | 0.415 | 0.933 |
10 | WWRbh01 | 962 | 1184 | 223 | 1.153 | 1.05 | 0.580 | 1.284 | 0.266 | 0.738 |
11 | WWRa601 | 1116 | 1184 | 69 | 2.368 | 2.28 | 1.304 | 0.270 | 0.311 | 0.879 |
12 | WWRgs01 | 957 | 1182 | 226 | 1.284 | 1.28 | 0.604 | 0.218 | 0.266 | 0.751 |
13 | WWRc401 | 1020 | 1183 | 164 | 1.501 | 1.29 | 0.862 | 0.772 | 0.317 | 0.801 |
14 | WWRc402 | 1020 | 1184 | 165 | 1.495 | 1.30 | 0.874 | 0.971 | 0.319 | 0.810 |
15 | WWRst01a | 956 | 1076 | 121 | 2.458 | 2.02 | 1.814 | 1.581 | 0.375 | 0.769 |
16 | WWRst01b | 956 | 1040 | 85 | 3.344 | 3.06 | 1.577 | 0.931 | 0.256 | 0.615 |
17 | WWRst02a | 954 | 1043 | 90 | 3.916 | 3.85 | 1.560 | 0.486 | 0.221 | 0.635 |
18 | WWRL601 | 1015 | 1161 | 147 | 1.816 | 1.74 | 0.966 | 0.360 | 0.300 | 0.743 |
19 | WWRb201 | 1044 | 1183 | 140 | 1.640 | 1.32 | 1.180 | 0.903 | 0.393 | 0.926 |
20 | WWRL801 | 1050 | 1184 | 135 | 1.380 | 1.36 | 0.822 | 0.990 | 0.322 | 0.799 |
Make a segment plot:
In [27]:
Copied!
dplpy.plot(df,type="seg")
dplpy.plot(df,type="seg")
Make a spaghetti plot:
In [28]:
Copied!
dplpy.plot(df, type="spag")
dplpy.plot(df, type="spag")
Let's look at the crossdating:
In [29]:
Copied!
dplpy.xdate(df, prewhiten=True, corr="Spearman", slide_period=50,bin_floor=100, p_val=0.05, show_flags=True)
dplpy.xdate(df, prewhiten=True, corr="Spearman", slide_period=50,bin_floor=100, p_val=0.05, show_flags=True)
Flags for WWRgy01 [B] Segment High -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 1125-1174 -1 -0.15 -0.16 -0.32 -0.05 0.12 0.04 -0.12 0.07 0.32 0.40 0.27 0.19 0.24 0.26 0.12 -0.02 -0.01 0.06 -0.07 -0.24 -0.26 Flags for WWRl501 [B] Segment High -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 1125-1174 1 0.14 -0.17 -0.05 -0.03 -0.10 -0.16 -0.01 0.02 -0.08 0.11 0.39 0.48 0.24 -0.02 0.18 0.15 0.08 0.03 -0.14 -0.23 -0.26
Out[29]:
WWRC501 | WWRL601 | WWRL801 | WWRa101 | WWRa301 | WWRa601 | WWRb201 | WWRbh01 | WWRc401 | WWRc402 | WWRgq01 | WWRgs01 | WWRgw01 | WWRgw02 | WWRgx01 | WWRgy01 | WWRl501 | WWRst01a | WWRst01b | WWRst02a | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1000-1049 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 0.335510 | NaN | NaN | 0.399184 | 0.375750 | 0.499640 | NaN | 0.528836 | 0.466315 | NaN | 0.536230 | NaN | NaN |
1025-1074 | 0.487539 | NaN | NaN | NaN | NaN | NaN | NaN | 0.621417 | NaN | NaN | 0.602017 | 0.356447 | 0.605762 | 0.698920 | 0.443745 | 0.577623 | NaN | 0.455462 | NaN | NaN |
1050-1099 | 0.621128 | 0.286050 | NaN | NaN | NaN | NaN | 0.527683 | 0.594430 | 0.428956 | 0.478992 | 0.510972 | 0.506170 | 0.557167 | 0.614118 | 0.516927 | 0.629196 | NaN | NaN | NaN | NaN |
1075-1124 | 0.575894 | 0.421849 | 0.466987 | 0.609892 | 0.603649 | NaN | 0.487635 | 0.521441 | 0.502425 | 0.557551 | 0.484370 | 0.437791 | 0.560816 | 0.620360 | 0.660504 | 0.657719 | NaN | NaN | NaN | NaN |
1100-1149 | 0.469676 | 0.485426 | 0.480720 | 0.583385 | 0.655318 | NaN | 0.549772 | 0.585786 | 0.538343 | 0.654742 | 0.612101 | 0.358463 | 0.740024 | 0.762977 | 0.649748 | 0.620264 | 0.463721 | NaN | NaN | NaN |
1125-1174 | 0.530852 | NaN | 0.466218 | 0.369316 | 0.637647 | 0.618727 | 0.566291 | 0.537383 | 0.558319 | 0.545450 | 0.446915 | 0.509916 | 0.523457 | 0.515486 | 0.510012 | 0.267611 | 0.386218 | NaN | NaN | NaN |
Apply a 50 year spline and calculate the residuals (division) from that spline to detrend series:
In [30]:
Copied!
df_rwi = dplpy.detrend(df, fit="spline", period=50, method="residual", plot=True)
df_rwi = dplpy.detrend(df, fit="spline", period=50, method="residual", plot=True)
Create a residual (AR-modeled) chronology:
In [32]:
Copied!
crn_res = dplpy.chron(df_rwi, biweight=True, prewhiten=True, plot=True)
crn_res = dplpy.chron(df_rwi, biweight=True, prewhiten=True, plot=True)
Last update:
2024-01-09