You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
744 lines
135 KiB
Plaintext
744 lines
135 KiB
Plaintext
6 years ago
|
{
|
||
|
"cells": [
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 1,
|
||
|
"metadata": {
|
||
|
"ExecuteTime": {
|
||
|
"end_time": "2018-12-05T00:54:50.235522Z",
|
||
|
"start_time": "2018-12-05T00:54:42.731587Z"
|
||
|
}
|
||
|
},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"import pandas as pd\n",
|
||
|
"import os\n",
|
||
|
"import numpy.ma as ma\n",
|
||
|
"\n",
|
||
|
"import numpy\n",
|
||
|
"from pyearth import Earth\n",
|
||
|
"from matplotlib import pyplot\n",
|
||
|
"\n",
|
||
|
"np.random.seed(2017)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 2,
|
||
|
"metadata": {
|
||
|
"ExecuteTime": {
|
||
|
"end_time": "2018-12-05T00:54:54.936556Z",
|
||
|
"start_time": "2018-12-05T00:54:50.271465Z"
|
||
|
}
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"Importing profiles.csv\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stderr",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"C:\\Users\\z5189959\\Desktop\\nsw-2016-storm-impact\\.venv\\lib\\site-packages\\numpy\\lib\\arraysetops.py:522: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison\n",
|
||
|
" mask |= (ar1 == a)\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"def df_from_csv(csv, index_col, data_folder='../data/interim'):\n",
|
||
|
" print('Importing {}'.format(csv))\n",
|
||
|
" return pd.read_csv(os.path.join(data_folder,csv), index_col=index_col)\n",
|
||
|
"\n",
|
||
|
"df_profiles = df_from_csv('profiles.csv', index_col=[0, 1, 2])"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"ExecuteTime": {
|
||
|
"end_time": "2018-12-04T23:49:04.770025Z",
|
||
|
"start_time": "2018-12-04T23:49:04.265699Z"
|
||
|
}
|
||
|
},
|
||
|
"source": [
|
||
|
"## Try using pyearth"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 73,
|
||
|
"metadata": {
|
||
|
"ExecuteTime": {
|
||
|
"end_time": "2018-12-05T01:54:00.320555Z",
|
||
|
"start_time": "2018-12-05T01:53:58.905803Z"
|
||
|
},
|
||
|
"code_folding": [
|
||
|
5,
|
||
|
20,
|
||
|
31,
|
||
|
40
|
||
|
],
|
||
|
"scrolled": false
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEWCAYAAABrDZDcAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAIABJREFUeJzs3Xl4ZGWZ8P/vXXtlreyd9J5uOr3TYDeNg4CAwoALig6LDuIy4juKzshwiSC+Oj+HURzGV0bHUUYRdQRkUVBEhh1UaKQbeqW7odNL9j2VVCW1n+f3Ry2k0kkn3Z2kstyf68qV1HlOznlOVXLu8+xijEEppdTcZct1BpRSSuWWBgKllJrjNBAopdQcp4FAKaXmOA0ESik1x2kgUEqpOU4DgZrzROQsEXlTRIIi8gER+YOIXJNK+7iI/CnXeVRqMmkgUMdFRL4uIv+T63xMsP8P+L4xpsAY87Ax5mJjzM8m84Qi8k4RaRpjn7tFxIjIGUO2LReRowb/pPaNi0jNsO1fF5FY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gOHDjAG2+8gWVZOc69Umqu0UAwCdJP/DabDbfbTSgU4k9/+hNdXV1s27aNRCKB3W4nFothWRbGGKLRKLt37+bgwYMaDJRSU0oDwSRItwEYYwgGg9x7770kEgkAQqEQu3btYmBgAK/Xm6k6CoVCBAIBXn31VQ0GSqkppYFgErjdbnw+HwMDAwwODhKLxbLS0wPNjhw5QiKRIJFI4PV6McbQ19fH9u3bNRgopaaMBoJJICKUl5dTXl7Ok08+SSQSGXG/trY2GhoacLvdWJZFJBJhcHCQnp4etm/fTmNjo44xUEpNOg0Ek8AYQ2dnJ7/85S85cOBAVtr
|
||
|
"text/plain": [
|
||
|
"<Figure size 432x288 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {
|
||
|
"needs_background": "light"
|
||
|
},
|
||
|
"output_type": "display_data"
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"[ { 'slope': -0.06617795750241562,\n",
|
||
|
" 'type': 'land',\n",
|
||
|
" 'x_end': 63.0,\n",
|
||
|
" 'x_start': 40.5,\n",
|
||
|
" 'z_end': 9.943990321404,\n",
|
||
|
" 'z_mean': 9.20564731619437,\n",
|
||
|
" 'z_start': 8.348161899068224},\n",
|
||
|
" { 'slope': -0.09424321140128608,\n",
|
||
|
" 'x_end': 69.0,\n",
|
||
|
" 'x_start': 63.0,\n",
|
||
|
" 'z_end': 10.532233612481347,\n",
|
||
|
" 'z_mean': 10.310033111599461,\n",
|
||
|
" 'z_start': 10.062895267627406},\n",
|
||
|
" { 'slope': 0.07278057230588836,\n",
|
||
|
" 'x_end': 96.0,\n",
|
||
|
" 'x_start': 69.0,\n",
|
||
|
" 'z_end': 9.071344271845113,\n",
|
||
|
" 'z_mean': 9.942154478828064,\n",
|
||
|
" 'z_start': 10.600758995514095},\n",
|
||
|
" { 'slope': 0.010222110457455531,\n",
|
||
|
" 'x_end': 105.0,\n",
|
||
|
" 'x_start': 96.0,\n",
|
||
|
" 'z_end': 8.940005362742282,\n",
|
||
|
" 'z_mean': 8.960960594412768,\n",
|
||
|
" 'z_start': 9.032076613769703},\n",
|
||
|
" { 'slope': -0.006783434031405405,\n",
|
||
|
" 'x_end': 171.0,\n",
|
||
|
" 'x_start': 105.0,\n",
|
||
|
" 'z_end': 9.377956662680647,\n",
|
||
|
" 'z_mean': 9.12742372282666,\n",
|
||
|
" 'z_start': 8.933411617025225},\n",
|
||
|
" { 'slope': 0.04487864391014401,\n",
|
||
|
" 'x_end': 177.0,\n",
|
||
|
" 'x_start': 171.0,\n",
|
||
|
" 'z_end': 9.159019876027982,\n",
|
||
|
" 'z_mean': 9.312931484934994,\n",
|
||
|
" 'z_start': 9.382296403384132},\n",
|
||
|
" { 'slope': 0.28077356578561746,\n",
|
||
|
" 'x_end': 198.0,\n",
|
||
|
" 'x_start': 177.0,\n",
|
||
|
" 'z_end': 3.9204468853264824,\n",
|
||
|
" 'z_mean': 6.663384763062234,\n",
|
||
|
" 'z_start': 9.046622396024778},\n",
|
||
|
" { 'slope': 0.08534897213040515,\n",
|
||
|
" 'x_end': 204.0,\n",
|
||
|
" 'x_start': 198.0,\n",
|
||
|
" 'z_end': 3.3242471595653202,\n",
|
||
|
" 'z_mean': 3.4936366209579663,\n",
|
||
|
" 'z_start': 3.754184455095742},\n",
|
||
|
" { 'slope': 0.02118839446027552,\n",
|
||
|
" 'type': 'berm',\n",
|
||
|
" 'x_end': 252.0,\n",
|
||
|
" 'x_start': 204.0,\n",
|
||
|
" 'z_end': 2.11417905440144,\n",
|
||
|
" 'z_mean': 2.7099232730105225,\n",
|
||
|
" 'z_start': 3.26349144192863},\n",
|
||
|
" { 'slope': 0.06273209072355844,\n",
|
||
|
" 'type': 'foreshore',\n",
|
||
|
" 'x_end': 285.5,\n",
|
||
|
" 'x_start': 252.0,\n",
|
||
|
" 'z_end': 0.0614306329519847,\n",
|
||
|
" 'z_mean': 1.0727411577535628,\n",
|
||
|
" 'z_start': 2.070753280242818}]\n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zGHgnif7vEVX9vIh8EqhW1U/Mem9yaYD9JGaJHAYud2ZaGGOMyYOctTBUtde5YCk5sHeUxHz2m0gsY4Dz+M4sb38r8JiqjjhB4jHgulzV1RhjzOJWZXEu50rZVwIHScw174VEUJlnBkYLmRdcdTHPxVMicidwJ0Bpaenlu3btWrmKG2NMgTt8+PCQqs5ZMyybnAcMESkjMU3xt1V1XGT2BajZ35YlLWvfmareA9wDsH//fj106NC5VtUYYzYcETmzeKmEnM6Sci6seRD4uqp+y0nuT1496jwOZHlrF5lX6LaSfZVKY4wxqySXs6QE+EcS69fclZb1MC9fyJNcCnm27wPXOleEVpO4COr7uaqrMcaYxeWyhfEaEldnvkkS91J4RkRuIHFl8DUicgK4xnmNiOwXkS8DOCuL/imJtWB+AXzGSTPGGJMnBXWlt41hGGPM8ojIYVXdv5SydqW3McaYJbGAsc689NJLxGKxxQsaY8wKs5ukryPd3d3cddddNDU1ceONN/LKV76SJU5TNsaY82YBY42La5zOsU6ODR3j0fsfRVXp7e3lwIEDbN26lZtvvplXvCLbbRaMMWZl2aD3GhGOhTkxfIJjQ8c4OnSUo0NHOTZ0jGNDx5iOTNMYbuSmoZuyvnfnzp3cfPPNbN++fZVrbYxZ75Yz6G0BY5WNBcdSgSA9MJwaOUVM5x+bKI2Vsn98PztmduCaZ+jprW99K7fcckuuqm6MKUDLCRjWJZUDqkrvZC9HB4/OCQw9E+d2wfqUe4rHqx/n2bJn2T+xnwuCF8wps2PHDuLxOOPj44yOjhIOhwEoKyujurqa4uJiG/MwxpwzCxjnIRqP0j7anjUwjIfGV2w7Vf4qXlH3isRf/SvYVbeLqmAVP//hzzl
|
||
|
"text/plain": [
|
||
|
"<Figure size 432x288 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {
|
||
|
"needs_background": "light"
|
||
|
},
|
||
|
"output_type": "display_data"
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"[ { 'slope': -0.006232531713848901,\n",
|
||
|
" 'type': 'land',\n",
|
||
|
" 'x_end': 87.0,\n",
|
||
|
" 'x_start': 54.0,\n",
|
||
|
" 'z_end': 18.907362973310256,\n",
|
||
|
" 'z_mean': 18.226859544431967,\n",
|
||
|
" 'z_start': 18.244707421270647},\n",
|
||
|
" { 'slope': 0.10048504940215892,\n",
|
||
|
" 'x_end': 90.0,\n",
|
||
|
" 'x_start': 87.0,\n",
|
||
|
" 'z_end': 18.81114066206634,\n",
|
||
|
" 'z_mean': 18.95124513461371,\n",
|
||
|
" 'z_start': 19.011103385573893},\n",
|
||
|
" { 'slope': 0.7867562476656698,\n",
|
||
|
" 'x_end': 105.0,\n",
|
||
|
" 'x_start': 90.0,\n",
|
||
|
" 'z_end': 8.264119331473214,\n",
|
||
|
" 'z_mean': 13.443236505259332,\n",
|
||
|
" 'z_start': 18.482680684877423},\n",
|
||
|
" { 'slope': 0.138231538826561,\n",
|
||
|
" 'x_end': 108.0,\n",
|
||
|
" 'x_start': 105.0,\n",
|
||
|
" 'z_end': 7.625424767531349,\n",
|
||
|
" 'z_mean': 7.719382219664138,\n",
|
||
|
" 'z_start': 7.899377829775406},\n",
|
||
|
" { 'slope': -0.24669278691155727,\n",
|
||
|
" 'x_end': 111.0,\n",
|
||
|
" 'x_start': 108.0,\n",
|
||
|
" 'z_end': 8.25183247996525,\n",
|
||
|
" 'z_mean': 8.037437899312298,\n",
|
||
|
" 'z_start': 7.767262334494268},\n",
|
||
|
" { 'slope': -0.022224358740496428,\n",
|
||
|
" 'x_end': 138.0,\n",
|
||
|
" 'x_start': 111.0,\n",
|
||
|
" 'z_end': 8.805851879663944,\n",
|
||
|
" 'z_mean': 8.69776858676918,\n",
|
||
|
" 'z_start': 8.321441165942321},\n",
|
||
|
" { 'slope': 0.011690412029154119,\n",
|
||
|
" 'x_end': 174.0,\n",
|
||
|
" 'x_start': 138.0,\n",
|
||
|
" 'z_end': 8.399119455457473,\n",
|
||
|
" 'z_mean': 8.591198407135863,\n",
|
||
|
" 'z_start': 8.769268316237742},\n",
|
||
|
" { 'slope': 0.06596545786924302,\n",
|
||
|
" 'x_end': 183.0,\n",
|
||
|
" 'x_start': 174.0,\n",
|
||
|
" 'z_end': 7.84469125226732,\n",
|
||
|
" 'z_mean': 8.148131103000907,\n",
|
||
|
" 'z_start': 8.376950179198564},\n",
|
||
|
" { 'slope': 0.19014969366205653,\n",
|
||
|
" 'x_end': 213.0,\n",
|
||
|
" 'x_start': 183.0,\n",
|
||
|
" 'z_end': 2.9990666738937883,\n",
|
||
|
" 'z_mean': 5.087790707786215,\n",
|
||
|
" 'z_start': 7.748699573256347},\n",
|
||
|
" { 'slope': 0.012096582737314357,\n",
|
||
|
" 'type': 'berm',\n",
|
||
|
" 'x_end': 219.0,\n",
|
||
|
" 'x_start': 213.0,\n",
|
||
|
" 'z_end': 2.9163517442302123,\n",
|
||
|
" 'z_mean': 2.9347601110839676,\n",
|
||
|
" 'z_start': 2.975348176164513},\n",
|
||
|
" { 'slope': 0.03056014910314705,\n",
|
||
|
" 'x_end': 255.0,\n",
|
||
|
" 'x_start': 219.0,\n",
|
||
|
" 'z_end': 2.050738949067936,\n",
|
||
|
" 'z_mean': 2.653057687157337,\n",
|
||
|
" 'z_start': 2.927273834441084},\n",
|
||
|
" { 'slope': 0.06806395674070564,\n",
|
||
|
" 'type': 'foreshore',\n",
|
||
|
" 'x_end': 285.5,\n",
|
||
|
" 'x_start': 255.0,\n",
|
||
|
" 'z_end': 0.04691924522162938,\n",
|
||
|
" 'z_mean': 1.100297110086715,\n",
|
||
|
" 'z_start': 2.0068617905167647}]\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXwAAAEWCAYAAABliCz2AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHR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fv9OJ1OnE4npmni9XqXvpAoIy18IcSGk8lkSCaTNDQ0AGBZFqOjo2itsSwLp1PaqqshAV8Ise4OHz7M5OSk/dg0TRwOB/X19bS2tqK1xjRNpqenSaVSTE1NIUu7r5x8TAohKq40vDKbzaK1RimF2+3G4/Fw6tQpvvGNb/Dtb3+b66+/nte//vU4nU7S6TRaa/x+P8FgEL/fT3NzM36/n8nJSSKRiKR1VkgCvhCiokrDK8fHx5mYmGBqaopQKERtbS1VVVXccccdQKFVf88999Db28uv/uqvkkwmGRsbI51OY5omO3bswOVykU6nyeVyZLNZCfgrJAFfCFFR6XSaoaEhpqenGR4exuPxMDQ0BEBnZ6c91LLkta99LZOTkzQ3N5PL5UgkEvT19WGapv28VCpFKBQiFArJ8MwVkIAvhKgYrTUDAwP09fUxOTmJaZqYpkkul6O3t3fO/he7du2ivb2doaEhDMPA7XbjcrmYmppiZGSESCQCQH19PclkkkwmI638FZCAL4SomHQ6zcDAAIlEgnw+TzabJR6P4/P5iMViZR21AD09PTgcDvL5PJlMhnw+j8PhwOv14vf7CQQCOJ1OXC4XqVRKhmeukAR8IUTFxONxkskkwWCQVCqFYRik02kcDgdnzpyZU940TSYnJ9Fac+bMGTv419bW4vF
|
||
|
"text/plain": [
|
||
|
"<Figure size 432x288 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {
|
||
|
"needs_background": "light"
|
||
|
},
|
||
|
"output_type": "display_data"
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"[ { 'slope': 0.0008328773436106309,\n",
|
||
|
" 'type': 'berm',\n",
|
||
|
" 'x_end': 58.0,\n",
|
||
|
" 'x_start': 37.0,\n",
|
||
|
" 'z_end': 1.8572595562110041,\n",
|
||
|
" 'z_mean': 1.8943805115420846,\n",
|
||
|
" 'z_start': 1.910394386927169},\n",
|
||
|
" { 'slope': -0.021220543877635122,\n",
|
||
|
" 'type': 'berm',\n",
|
||
|
" 'x_end': 138.0,\n",
|
||
|
" 'x_start': 58.0,\n",
|
||
|
" 'z_end': 3.5977328867797485,\n",
|
||
|
" 'z_mean': 2.7247048500781106,\n",
|
||
|
" 'z_start': 1.8468598845719795},\n",
|
||
|
" { 'slope': -0.06381773295732189,\n",
|
||
|
" 'x_end': 142.0,\n",
|
||
|
" 'x_start': 138.0,\n",
|
||
|
" 'z_end': 3.8359998018824712,\n",
|
||
|
" 'z_mean': 3.741723519647647,\n",
|
||
|
" 'z_start': 3.6479493664613014},\n",
|
||
|
" { 'slope': -0.016157748520191067,\n",
|
||
|
" 'x_end': 157.0,\n",
|
||
|
" 'x_start': 142.0,\n",
|
||
|
" 'z_end': 4.169920934351783,\n",
|
||
|
" 'z_mean': 4.013083138991948,\n",
|
||
|
" 'z_start': 3.8843177342116757},\n",
|
||
|
" { 'slope': -0.1322171985012303,\n",
|
||
|
" 'x_end': 177.0,\n",
|
||
|
" 'x_start': 157.0,\n",
|
||
|
" 'z_end': 6.427354838550462,\n",
|
||
|
" 'z_mean': 5.4360212510513115,\n",
|
||
|
" 'z_start': 4.223480595415142},\n",
|
||
|
" { 'slope': 0.34782985777944603,\n",
|
||
|
" 'x_end': 193.0,\n",
|
||
|
" 'x_start': 177.0,\n",
|
||
|
" 'z_end': 1.3683244048034364,\n",
|
||
|
" 'z_mean': 3.876447007928749,\n",
|
||
|
" 'z_start': 6.295019014555152},\n",
|
||
|
" { 'slope': 0.06019958288565148,\n",
|
||
|
" 'type': 'foreshore',\n",
|
||
|
" 'x_end': 213.5,\n",
|
||
|
" 'x_start': 193.0,\n",
|
||
|
" 'z_end': 0.06618164722605435,\n",
|
||
|
" 'z_mean': 0.6722026822899186,\n",
|
||
|
" 'z_start': 1.1980470061124415}]\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"from scipy.signal import savgol_filter\n",
|
||
|
"import re\n",
|
||
|
"from scipy.stats import linregress\n",
|
||
|
"import warnings\n",
|
||
|
"warnings.simplefilter(action='ignore', category=FutureWarning)\n",
|
||
|
"\n",
|
||
|
"def get_breakpoints(model, min_distance=20):\n",
|
||
|
" # Get breakpoints\n",
|
||
|
" breakpoints = []\n",
|
||
|
" for line in model.summary().split('\\n'):\n",
|
||
|
" # Get unpruned lines\n",
|
||
|
" if 'No' in line and 'None' not in line:\n",
|
||
|
" # Get break points\n",
|
||
|
" m = re.search(\"h\\(x0-(\\d*\\.?\\d+)\\)\", line)\n",
|
||
|
" if m:\n",
|
||
|
" breakpoints.append(float(m.groups()[0]))\n",
|
||
|
" m = re.search(\"h\\((\\d*\\.?\\d+)-x0\\)\", line)\n",
|
||
|
" if m:\n",
|
||
|
" breakpoints.append(float(m.groups()[0]))\n",
|
||
|
" return sorted(list(set(breakpoints)))\n",
|
||
|
" \n",
|
||
|
"def get_segments(breakpoints, x_min, x_max):\n",
|
||
|
" segments = []\n",
|
||
|
" breakpoints = [x_min] + breakpoints + [x_max]\n",
|
||
|
"\n",
|
||
|
" for x1, x2 in zip(breakpoints, breakpoints[1:]):\n",
|
||
|
" segments.append({\n",
|
||
|
" 'x_start': x1,\n",
|
||
|
" 'x_end': x2\n",
|
||
|
" })\n",
|
||
|
" return segments \n",
|
||
|
"\n",
|
||
|
"def get_segment_slopes(segments, x, z):\n",
|
||
|
" for segment in segments:\n",
|
||
|
" mask = ma.masked_where((segment['x_start'] < x) & (x < segment['x_end']),x ).mask\n",
|
||
|
" segment['z_mean'] = np.mean(z[mask])\n",
|
||
|
" segment['z_start'] = np.mean(z[mask][0])\n",
|
||
|
" segment['z_end'] = np.mean(z[mask][-1])\n",
|
||
|
" segment['slope'] = -linregress(x[mask], z[mask]).slope\n",
|
||
|
" return segments\n",
|
||
|
" \n",
|
||
|
"def classify_segments(segments, x,z):\n",
|
||
|
" \n",
|
||
|
" # Most seaward slope must be foreshore\n",
|
||
|
" segments[-1]['type'] = 'foreshore'\n",
|
||
|
" \n",
|
||
|
" # Most landward slope must be land\n",
|
||
|
" segments[0]['type'] = 'land'\n",
|
||
|
" \n",
|
||
|
" # Segments with really high slopes must be structures\n",
|
||
|
" for seg in segments:\n",
|
||
|
" if seg['slope'] > 2.0:\n",
|
||
|
" seg['type'] = 'structure'\n",
|
||
|
" \n",
|
||
|
" # Segments with large change of slope and \n",
|
||
|
" # Segment with max slope should be dune face\n",
|
||
|
"# dune_face_idx = [n for n, seg in enumerate(segments) if seg['slope']==max(x['slope'] for x in segments)][0]\n",
|
||
|
"# segments[dune_face_idx]['type'] = 'dune_face'\n",
|
||
|
" \n",
|
||
|
" # Pick out berms \n",
|
||
|
" for seg in segments:\n",
|
||
|
" if (-0.03 < seg['slope'] < 0.03 # berms should be relatively flat\n",
|
||
|
" and 0 < seg['z_mean'] < 4 # berms should be located between 0-4 m AHD\n",
|
||
|
" ): # berms should be seaward of dune face\n",
|
||
|
" seg['type'] = 'berm'\n",
|
||
|
" \n",
|
||
|
"# slope = None\n",
|
||
|
"# for seg in reversed(segments):\n",
|
||
|
"# if slope is None:\n",
|
||
|
"# continue\n",
|
||
|
"# elif slope - 0.03 < seg['slope'] < slope + 0.03:\n",
|
||
|
"# seg['type'] = 'foreshore'\n",
|
||
|
"# else:\n",
|
||
|
"# break\n",
|
||
|
" \n",
|
||
|
" return segments\n",
|
||
|
"\n",
|
||
|
"def get_piecewise_linear_model(x,z):\n",
|
||
|
" #Fit an Earth model\n",
|
||
|
" model = Earth(penalty=3,thresh=0.0005)\n",
|
||
|
" model.fit(x,z)\n",
|
||
|
" return model\n",
|
||
|
"\n",
|
||
|
"def plot_profile_classification(site_id, profile_type):\n",
|
||
|
" df_profile = df_profiles.query(\"site_id == '{}' and profile_type == '{}'\".format(site_id, profile_type))\n",
|
||
|
" x = np.array(df_profile.index.get_level_values('x').tolist())\n",
|
||
|
" z = np.array(df_profile.z.tolist()) \n",
|
||
|
" \n",
|
||
|
" nan_mask = ma.masked_invalid(z).mask\n",
|
||
|
" x = x[~nan_mask]\n",
|
||
|
" z_unfiltered = z[~nan_mask]\n",
|
||
|
" z = savgol_filter(z_unfiltered, 51, 3)\n",
|
||
|
" \n",
|
||
|
" model = get_piecewise_linear_model(x,z)\n",
|
||
|
" breakpoints = get_breakpoints(model)\n",
|
||
|
" segments = get_segments(breakpoints, x_min=x.min(), x_max=x.max())\n",
|
||
|
" segments = get_segment_slopes(segments, x=x, z=z)\n",
|
||
|
"# segments = merge_similar_segments(segments)\n",
|
||
|
" segments = classify_segments(segments, x=x, z=z)\n",
|
||
|
" \n",
|
||
|
" pyplot.figure()\n",
|
||
|
" pyplot.plot(x,z_unfiltered, color='0.5',marker='.', alpha=.2, ms=10,linestyle=\"None\")\n",
|
||
|
"\n",
|
||
|
" # Plot different segments\n",
|
||
|
" foreshore_segments = [x for x in segments if x.get('type') == 'foreshore']\n",
|
||
|
" for seg in foreshore_segments:\n",
|
||
|
" pyplot.plot([seg['x_start'], seg['x_end']],\n",
|
||
|
" [seg['z_start'], seg['z_end']],\n",
|
||
|
" linewidth=4, \n",
|
||
|
" color='b')\n",
|
||
|
"\n",
|
||
|
" land_segments = [x for x in segments if x.get('type') == 'land']\n",
|
||
|
" for seg in land_segments:\n",
|
||
|
" pyplot.plot([seg['x_start'], seg['x_end']],\n",
|
||
|
" [seg['z_start'], seg['z_end']],\n",
|
||
|
" linewidth=4, \n",
|
||
|
" color='g')\n",
|
||
|
"\n",
|
||
|
" berm_segments = [x for x in segments if x.get('type') == 'berm']\n",
|
||
|
" for seg in berm_segments:\n",
|
||
|
" pyplot.plot([seg['x_start'], seg['x_end']],\n",
|
||
|
" [seg['z_start'], seg['z_end']],\n",
|
||
|
" linewidth=4, \n",
|
||
|
" color='y')\n",
|
||
|
"\n",
|
||
|
" dune_face_segments = [x for x in segments if x.get('type') == 'dune_face']\n",
|
||
|
" for seg in dune_face_segments:\n",
|
||
|
" pyplot.plot([seg['x_start'], seg['x_end']],\n",
|
||
|
" [seg['z_start'], seg['z_end']],\n",
|
||
|
" linewidth=4, \n",
|
||
|
" color='r')\n",
|
||
|
" \n",
|
||
|
" structure_segments = [x for x in segments if x.get('type') == 'structure']\n",
|
||
|
" for seg in structure_segments:\n",
|
||
|
" pyplot.plot([seg['x_start'], seg['x_end']],\n",
|
||
|
" [seg['z_start'], seg['z_end']],\n",
|
||
|
" linewidth=4, \n",
|
||
|
" color='m')\n",
|
||
|
" \n",
|
||
|
" unclassified_segments = [x for x in segments if x.get('type') is None]\n",
|
||
|
" for seg in unclassified_segments:\n",
|
||
|
" pyplot.plot([seg['x_start'], seg['x_end']],\n",
|
||
|
" [seg['z_start'], seg['z_end']],\n",
|
||
|
" linewidth=4, \n",
|
||
|
" color='0.4')\n",
|
||
|
"\n",
|
||
|
" pyplot.xlabel('x (m)')\n",
|
||
|
" pyplot.ylabel('z (m AHD)')\n",
|
||
|
" pyplot.title('{} profile at {}'.format(profile_type, site_id))\n",
|
||
|
" pyplot.show()\n",
|
||
|
"\n",
|
||
|
" import pprint\n",
|
||
|
" pp = pprint.PrettyPrinter(indent=4)\n",
|
||
|
" pp.pprint(segments)\n",
|
||
|
"\n",
|
||
|
"plot_profile_classification('NARRA0018', 'prestorm')\n",
|
||
|
"plot_profile_classification('NARRA0019', 'prestorm')\n",
|
||
|
"plot_profile_classification('CRESn0017', 'poststorm')"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"heading_collapsed": true
|
||
|
},
|
||
|
"source": [
|
||
|
"## Try lmfit"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {
|
||
|
"hidden": true
|
||
|
},
|
||
|
"outputs": [],
|
||
|
"source": []
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 26,
|
||
|
"metadata": {
|
||
|
"ExecuteTime": {
|
||
|
"end_time": "2018-12-05T01:13:41.773484Z",
|
||
|
"start_time": "2018-12-05T01:13:27.230746Z"
|
||
|
},
|
||
|
"code_folding": [
|
||
|
0
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SSaTZDIZ+4xYj8fzkjPtVCplb31cbDkdGRnB4XCQyWTsNQrBYPAlVxELcauVVKBfWuss9n3HYjFGR0eJRqNordn0zDO84pvfpL+tje8+9BCZCxb+FMssgN2HrrW292RZKMXVpNlslhdeeIFkKESyvJyJtWtJp9N4PB4qKyvZtm0bbatXY4yOXl7O6euDn/8cHn8cLlycZBjQ1HTlwF+zpvBicAvKOZZlcf78eSYnJ8lmsySTSTweDzU1NVRWVlJWVraoWx2k02nGxsaYnp4mm80yOztLOBwmHo+TSCSoqamxX7QvDfTizL63t5eJiQlSqRQDAwPkcjmi0SimadovVhUVFaxevZrVq1dTW1sroS6WTMkEutaaaDTK8PCw/dbYsixOnjyJy+UiHo8Tj8fZ9uSTvPz73+fsxo189y1vwXK54IJecygEk8fjoby8nGw2i8PhoKqq6paE+vr165menqanp8cOEcMwSKVS9hYBMLfvS3MzvPzll3+hbBaGhl4M+gtD/8knYXi4UPYpcjqhpeXqHTp1dYUXhRugteb8+fOcOnWKcDjMxMQEmUyGTCZDMBikoqKCtrY2tm3bZr9g3kqWZTE5OUlvb69dLgmHw2QyGftc2GQySXNz82VrC4oTg7GxMYaHh4lEIvbOmcUXh3w+j2ma+P1+EokE4XAYr9dLeXm5lGHEkimJQC/+AxwaGmJgYIB0Oo3f7yefzzM6OorX62U2FmPnD37A7iee4PjWrfzwwQfJGwaKwqzc6XTaJRoo1NDj8Thut5v6+nq8Xu8NLSq6XsVj7FKpFENDQxddk9aaWCzG0aNHcblcNDc3X3n253S+OPt+5Ssv//N0GgYGrnzT9gc/gLGxix/v8RTq9Fea3be2FkpHl4wjlUoxMjJCJBJhYmLCnqE7HA5isRj
|
||
|
"text/plain": [
|
||
|
"<Figure size 432x288 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {
|
||
|
"needs_background": "light"
|
||
|
},
|
||
|
"output_type": "display_data"
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"[[Model]]\n",
|
||
|
" Model(piecewise_linear)\n",
|
||
|
"[[Fit Statistics]]\n",
|
||
|
" # fitting method = ampgo, with L-BFGS-B as local solver\n",
|
||
|
" # function evals = 79866\n",
|
||
|
" # data points = 491\n",
|
||
|
" # variables = 8\n",
|
||
|
" chi-square = 65.4379204\n",
|
||
|
" reduced chi-square = 0.13548224\n",
|
||
|
" Akaike info crit = -973.533027\n",
|
||
|
" Bayesian info crit = -939.961474\n",
|
||
|
"[[Variables]]\n",
|
||
|
" x0: 62.1499306 (init = 40.5)\n",
|
||
|
" x1: 181.207436 (init = 40.5)\n",
|
||
|
" x2: 196.301872 (init = 40.5)\n",
|
||
|
" b: 5.81709441 (init = 0)\n",
|
||
|
" k1: 0.06544372 (init = 0)\n",
|
||
|
" k2: -0.07421739 (init = 0)\n",
|
||
|
" k3: -0.32199700 (init = 0)\n",
|
||
|
" k4: 0.29325377 (init = 0)\n",
|
||
|
"\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"from lmfit import Model, Parameters\n",
|
||
|
"\n",
|
||
|
"def get_data():\n",
|
||
|
" site_id='NARRA0018'\n",
|
||
|
" profile_type='prestorm'\n",
|
||
|
" df_profile = df_profiles.query(\"site_id == '{}' and profile_type == '{}'\".format(site_id, profile_type))\n",
|
||
|
" x = np.array(df_profile.index.get_level_values('x').tolist())\n",
|
||
|
" z = np.array(df_profile.z.tolist()) \n",
|
||
|
"\n",
|
||
|
" nan_mask = ma.masked_invalid(z).mask\n",
|
||
|
" x = x[~nan_mask]\n",
|
||
|
" z = z[~nan_mask]\n",
|
||
|
" return x,z\n",
|
||
|
"\n",
|
||
|
"# def piecewise_linear(x, x0, x1, b, k1, k2, k3):\n",
|
||
|
"# condlist = [x < x0, (x >= x0) & (x < x1), x >= x1]\n",
|
||
|
"# funclist = [lambda x: k1*x + b, lambda x: k1*x + b + k2*(x-x0), lambda x: k1*x + b + k2*(x-x0) + k3*(x - x1)]\n",
|
||
|
"# return np.piecewise(x, condlist, funclist)\n",
|
||
|
"\n",
|
||
|
"# x,z = get_data()\n",
|
||
|
"\n",
|
||
|
"# fmodel = Model(piecewise_linear)\n",
|
||
|
"# params = Parameters()\n",
|
||
|
"# params.add('x0', value=0, vary=True, min=min(x), max=max(x))\n",
|
||
|
"# params.add('x1', value=0, vary=True, min=min(x), max=max(x))\n",
|
||
|
"# params.add('b', value=0, vary=True)\n",
|
||
|
"# params.add('k1', value=0, vary=True, min=-0.01, max=0.01)\n",
|
||
|
"# params.add('k2', value=0, vary=True, min=-0.1, max=-0.5)\n",
|
||
|
"# params.add('k3', value=0, vary=True, min=0.1, max=0.5)\n",
|
||
|
"\n",
|
||
|
"def piecewise_linear(x, x0, x1, x2, b, k1, k2, k3,k4):\n",
|
||
|
" condlist = [x < x0, (x >= x0) & (x < x1), (x >= x1) & (x < x2), x >= x2]\n",
|
||
|
" funclist = [lambda x: k1*x + b, lambda x: k1*x + b + k2*(x-x0), lambda x: k1*x + b + k2*(x-x0) + k3*(x - x1), lambda x: k1*x + b + k2*(x-x0) + k3*(x - x1) +k4*(x-x2)]\n",
|
||
|
" return np.piecewise(x, condlist, funclist)\n",
|
||
|
"\n",
|
||
|
"x,z = get_data()\n",
|
||
|
"\n",
|
||
|
"fmodel = Model(piecewise_linear)\n",
|
||
|
"params = Parameters()\n",
|
||
|
"params.add('x0', value=0, vary=True, min=min(x), max=max(x))\n",
|
||
|
"params.add('x1', value=0, vary=True, min=min(x), max=max(x))\n",
|
||
|
"params.add('x2', value=0, vary=True, min=min(x), max=max(x))\n",
|
||
|
"params.add('b', value=0, vary=True)\n",
|
||
|
"params.add('k1', value=0, vary=True, min=-0.5, max=0.5)\n",
|
||
|
"params.add('k2', value=0, vary=True, min=-0.5, max=0.5)\n",
|
||
|
"params.add('k3', value=0, vary=True, min=-0.5, max=0.5)\n",
|
||
|
"params.add('k4', value=0, vary=True, min=-0.5, max=0.5)\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"result = fmodel.fit(z, params, x=x,method='ampgo')\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"pyplot.figure()\n",
|
||
|
"pyplot.plot(x,z, color='0.5',marker='.', alpha=.2, ms=10,linestyle=\"None\")\n",
|
||
|
"pyplot.plot(x,result.best_fit, color='r')\n",
|
||
|
"pyplot.show()\n",
|
||
|
"print(result.fit_report())"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"## Try spline"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 65,
|
||
|
"metadata": {
|
||
|
"ExecuteTime": {
|
||
|
"end_time": "2018-12-05T01:49:30.968871Z",
|
||
|
"start_time": "2018-12-05T01:49:30.648994Z"
|
||
|
},
|
||
|
"code_folding": [
|
||
|
2
|
||
|
]
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD8CAYAAABn919SAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAIABJREFUeJzs3Xl01Nd9///nnX3RMtr3HRAgAcJIBgyxHcdL4t2O46xO7KZJ47iJ03N6epqTnvbb7zenJ9/fN2lip2lax67TxIntxguO45J4i+MFGyNAgFgESGjfNZrRaDT73N8faKYYGwxIaBm9H+foIA0f6XM/GumlO/fzvvcqrTVCCCEWP8N8N0AIIcTskEAXQogUIYEuhBApQgJdCCFShAS6EEKkCAl0IYRIERLoQgiRIiTQhRAiRUigCyFEijDN5clyc3N1ZWXlXJ5SCCEWvd27d49qrfM+7Lg5DfTKykqam5vn8pRCCLHoKaW6zuU4GXIRQogUIYEuhBApQgJdCCFShAS6EEKkCAl0IY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b+e977+W2//f/uOnhh/nN/fczrhR79uwBFn6oa63p6+vj6NGjeDweRkZGCIfDhMNh0tPTycrKorq6moaGBkymi/9jF4/HGR0dpaOjIzlc4vF4CIfDxONxrFYrgUCAsrKy980tSHQMhoaG6O/vx+v14uzt5cZ/+Rdypl+tRcxm3vrkJ+m89lqmpqbweDzY7XYyMzNlGEbMm5QI9MQvYG9vL93d3YRCIZxOJwaPh8Z//EeKjx/n0ObN9JWUENCa4+vWEbV
|
||
|
"text/plain": [
|
||
|
"<Figure size 432x288 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {
|
||
|
"needs_background": "light"
|
||
|
},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"from scipy.signal import savgol_filter\n",
|
||
|
"\n",
|
||
|
"def get_data():\n",
|
||
|
" site_id='NARRA0018'\n",
|
||
|
" profile_type='prestorm'\n",
|
||
|
" df_profile = df_profiles.query(\"site_id == '{}' and profile_type == '{}'\".format(site_id, profile_type))\n",
|
||
|
" x = np.array(df_profile.index.get_level_values('x').tolist())\n",
|
||
|
" z = np.array(df_profile.z.tolist()) \n",
|
||
|
"\n",
|
||
|
" nan_mask = ma.masked_invalid(z).mask\n",
|
||
|
" x = x[~nan_mask]\n",
|
||
|
" z = z[~nan_mask]\n",
|
||
|
" return x,z\n",
|
||
|
"\n",
|
||
|
"x,z = get_data()\n",
|
||
|
"\n",
|
||
|
"z_filtered = savgol_filter(z, 31, 3)\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"pyplot.figure()\n",
|
||
|
"pyplot.plot(x,z, color='0.5',marker='.', alpha=.2, ms=10,linestyle=\"None\")\n",
|
||
|
"pyplot.plot(x,z_filtered, color='r')\n",
|
||
|
"pyplot.show()\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"metadata": {
|
||
|
"kernelspec": {
|
||
|
"display_name": "Python 3",
|
||
|
"language": "python",
|
||
|
"name": "python3"
|
||
|
},
|
||
|
"language_info": {
|
||
|
"codemirror_mode": {
|
||
|
"name": "ipython",
|
||
|
"version": 3
|
||
|
},
|
||
|
"file_extension": ".py",
|
||
|
"mimetype": "text/x-python",
|
||
|
"name": "python",
|
||
|
"nbconvert_exporter": "python",
|
||
|
"pygments_lexer": "ipython3",
|
||
|
"version": "3.6.7"
|
||
|
},
|
||
|
"toc": {
|
||
|
"base_numbering": 1,
|
||
|
"nav_menu": {},
|
||
|
"number_sections": true,
|
||
|
"sideBar": true,
|
||
|
"skip_h1_title": false,
|
||
|
"title_cell": "Table of Contents",
|
||
|
"title_sidebar": "Contents",
|
||
|
"toc_cell": false,
|
||
|
"toc_position": {},
|
||
|
"toc_section_display": true,
|
||
|
"toc_window_display": false
|
||
|
},
|
||
|
"varInspector": {
|
||
|
"cols": {
|
||
|
"lenName": 16,
|
||
|
"lenType": 16,
|
||
|
"lenVar": 40
|
||
|
},
|
||
|
"kernels_config": {
|
||
|
"python": {
|
||
|
"delete_cmd_postfix": "",
|
||
|
"delete_cmd_prefix": "del ",
|
||
|
"library": "var_list.py",
|
||
|
"varRefreshCmd": "print(var_dic_list())"
|
||
|
},
|
||
|
"r": {
|
||
|
"delete_cmd_postfix": ") ",
|
||
|
"delete_cmd_prefix": "rm(",
|
||
|
"library": "var_list.r",
|
||
|
"varRefreshCmd": "cat(var_dic_list()) "
|
||
|
}
|
||
|
},
|
||
|
"types_to_exclude": [
|
||
|
"module",
|
||
|
"function",
|
||
|
"builtin_function_or_method",
|
||
|
"instance",
|
||
|
"_Feature"
|
||
|
],
|
||
|
"window_display": false
|
||
|
}
|
||
|
},
|
||
|
"nbformat": 4,
|
||
|
"nbformat_minor": 2
|
||
|
}
|