Lost all my work on HAPs and LFAPs (nginx fixed!)
This commit is contained in:
parent
22ac9807f7
commit
6b179c4bfb
@ -30,17 +30,42 @@
|
|||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"# Specific Utils\n",
|
"# Specific Utils\n",
|
||||||
|
"im_size = 2\n",
|
||||||
"\n",
|
"\n",
|
||||||
"def DFC_filter(raster):\n",
|
"def DFC_filter(raster):\n",
|
||||||
" raster[raster > 1e4] = raster[raster < 1e4].max()\n",
|
" raster[raster > 1e4] = raster[raster < 1e4].max()\n",
|
||||||
"\n",
|
"\n",
|
||||||
"def show(im):\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.imshow(im)\n",
|
||||||
" plt.colorbar()\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()"
|
" plt.show()"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## Load a single raster"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
@ -61,6 +86,13 @@
|
|||||||
"show(raster)"
|
"show(raster)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## Compute attributes"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
@ -76,6 +108,19 @@
|
|||||||
"attributes.shape"
|
"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",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
@ -83,10 +128,17 @@
|
|||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"a = attributes\n",
|
"a = attributes\n",
|
||||||
"i = 3\n",
|
"i = 7\n",
|
||||||
"show(a[:,:,i].astype(np.float) - a[:,:,i+1])"
|
"show(a[:,:,i].astype(np.float) - a[:,:,i+1])"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## Compute patches"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
@ -125,7 +177,7 @@
|
|||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"offset_stack[-3,-3,:].reshape(-1,1)"
|
"offset_stack[-2,-3,:].reshape(-1,1)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -134,7 +186,8 @@
|
|||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"show(offset_stack[:,:,0])"
|
"stack_std = np.std(offset_stack, axis=-1)\n",
|
||||||
|
"stack_std.shape"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -143,7 +196,11 @@
|
|||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"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": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"hist = np.stack(raster, raster[:]"
|
"size = '{}x{}'.format(patch_size, patch_size)\n",
|
||||||
]
|
"figs = [raster,\n",
|
||||||
},
|
" stack_avr,\n",
|
||||||
{
|
" stack_mean,\n",
|
||||||
"cell_type": "code",
|
" stack_min,\n",
|
||||||
"execution_count": null,
|
" stack_max,\n",
|
||||||
"metadata": {},
|
" stack_var,\n",
|
||||||
"outputs": [],
|
" stack_std\n",
|
||||||
"source": [
|
" ]\n",
|
||||||
"np.repeat(100,10)"
|
"ttls = ['Origin',\n",
|
||||||
]
|
" 'Average ' + size,\n",
|
||||||
},
|
" 'Mean ' + size,\n",
|
||||||
{
|
" 'Minimum ' + size,\n",
|
||||||
"cell_type": "code",
|
" 'Maximum ' + size,\n",
|
||||||
"execution_count": null,
|
" 'Variance ' + size,\n",
|
||||||
"metadata": {},
|
" 'STD ' + size\n",
|
||||||
"outputs": [],
|
" ]\n",
|
||||||
"source": [
|
"mshow(figs, ttls)"
|
||||||
"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)"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user