Lost all my work on HAPs and LFAPs (nginx fixed!)

This commit is contained in:
Florent Guiotte 2018-03-30 23:01:57 +02:00
parent 22ac9807f7
commit 6b179c4bfb

View File

@ -30,17 +30,42 @@
"outputs": [],
"source": [
"# Specific Utils\n",
"im_size = 2\n",
"\n",
"def DFC_filter(raster):\n",
" raster[raster > 1e4] = raster[raster < 1e4].max()\n",
"\n",
"def show(im):\n",
" plt.figure(figsize=(16*2,3*2))\n",
" plt.figure(figsize=(16*im_size,3*im_size))\n",
" plt.imshow(im)\n",
" plt.colorbar()\n",
" plt.show()\n",
"\n",
"def mshow(Xs, titles=None):\n",
" s = len(Xs)\n",
"\n",
" plt.figure(figsize=(16*im_size,3*im_size*s))\n",
"\n",
" for i in range(s):\n",
" plt.subplot(s,1,i+1)\n",
" plt.imshow(Xs[i])\n",
" \n",
" if titles is not None:\n",
" plt.title(titles[i])\n",
" \n",
" plt.colorbar()\n",
" \n",
" plt.savefig('test.png', bbox_inches='tight', pad_inches=1)\n",
" plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Load a single raster"
]
},
{
"cell_type": "code",
"execution_count": null,
@ -61,6 +86,13 @@
"show(raster)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Compute attributes"
]
},
{
"cell_type": "code",
"execution_count": null,
@ -76,6 +108,19 @@
"attributes.shape"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"figs = list()\n",
"for i in range(attributes.shape[2]):\n",
" figs.append(attributes[:,:,i])\n",
" \n",
"mshow(figs)"
]
},
{
"cell_type": "code",
"execution_count": null,
@ -83,10 +128,17 @@
"outputs": [],
"source": [
"a = attributes\n",
"i = 3\n",
"i = 7\n",
"show(a[:,:,i].astype(np.float) - a[:,:,i+1])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Compute patches"
]
},
{
"cell_type": "code",
"execution_count": null,
@ -125,7 +177,7 @@
"metadata": {},
"outputs": [],
"source": [
"offset_stack[-3,-3,:].reshape(-1,1)"
"offset_stack[-2,-3,:].reshape(-1,1)"
]
},
{
@ -134,7 +186,8 @@
"metadata": {},
"outputs": [],
"source": [
"show(offset_stack[:,:,0])"
"stack_std = np.std(offset_stack, axis=-1)\n",
"stack_std.shape"
]
},
{
@ -143,7 +196,11 @@
"metadata": {},
"outputs": [],
"source": [
"del offset_stack"
"stack_mean = np.mean(offset_stack, axis=-1)\n",
"stack_avr = np.average(offset_stack, axis=-1)\n",
"stack_var = np.var(offset_stack, axis=-1)\n",
"stack_min = np.min(offset_stack, axis=-1)\n",
"stack_max = np.max(offset_stack, axis=-1)"
]
},
{
@ -152,61 +209,24 @@
"metadata": {},
"outputs": [],
"source": [
"hist = np.stack(raster, raster[:]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"np.repeat(100,10)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"pstl = list()\n",
"\n",
"for c, p in [(100, .06), (60, .1), (12, .5), (20, .3)]:\n",
" st = np.random.binomial(np.repeat(c,1e7), p)\n",
" pst = pd.DataFrame(st, columns=['{} - {}'.format(c, p)])\n",
" pstl.append(pst)\n",
" \n",
"psta = pd.concat(pstl)\n",
"pd.options.display.float_format = '{:.2f}'.format\n",
"display(psta.describe())\n",
"psta.hist(figsize=(16, 9))\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"pd.concat([pst, pst], axis=1)"
"size = '{}x{}'.format(patch_size, patch_size)\n",
"figs = [raster,\n",
" stack_avr,\n",
" stack_mean,\n",
" stack_min,\n",
" stack_max,\n",
" stack_var,\n",
" stack_std\n",
" ]\n",
"ttls = ['Origin',\n",
" 'Average ' + size,\n",
" 'Mean ' + size,\n",
" 'Minimum ' + size,\n",
" 'Maximum ' + size,\n",
" 'Variance ' + size,\n",
" 'STD ' + size\n",
" ]\n",
"mshow(figs, ttls)"
]
}
],