Update Olympus Notebooks
This commit is contained in:
parent
47b290a23d
commit
9137c03392
@ -154,25 +154,30 @@
|
|||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"area = np.array([10, 100, 1e3, 1e4, 1e5])\n",
|
"area = np.array([10, 100, 1e3, 1e4, 1e5])\n",
|
||||||
"sd = np.array([0.5,0.9,0.99,0.999,0.9999])#,1e4,1e5,5e5])\n",
|
"sd = np.array([0.5,0.9,0.99,0.999])#,1e4,1e5,5e5])\n",
|
||||||
"moi = np.array([0.01,0.02,0.03,0.04,0.05,0.06,0.07,0.08,0.09,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,0.99])\n",
|
"moi = np.array([0.01,0.02,0.03,0.04,0.05,0.06,0.07,0.08,0.09,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,0.99])\n",
|
||||||
"\n",
|
"\n",
|
||||||
"t = triskele.Triskele(layers_stack[:,:,0], verbose=False)\n",
|
"t = triskele.Triskele(layers_stack[:,:,0], verbose=False)\n",
|
||||||
"attributes_min = t.filter(tree='min-tree',\n",
|
"attributes_min = t.filter(tree='min-tree',\n",
|
||||||
" area=area,\n",
|
" area=area,\n",
|
||||||
" #standard_deviation=sd,\n",
|
" standard_deviation=sd,\n",
|
||||||
" #moment_of_inertia=moi\n",
|
" moment_of_inertia=moi\n",
|
||||||
" )\n",
|
" )\n",
|
||||||
"attributes_max = t.filter(tree='max-tree',\n",
|
"attributes_max = t.filter(tree='max-tree',\n",
|
||||||
" area=area,\n",
|
" area=area,\n",
|
||||||
" #standard_deviation=sd,\n",
|
" standard_deviation=sd,\n",
|
||||||
" #moment_of_inertia=moi\n",
|
" moment_of_inertia=moi\n",
|
||||||
" )\n",
|
" )\n",
|
||||||
"\n",
|
"\n",
|
||||||
"attributes_min_lbl = ['origin']\n",
|
"attributes_min_lbl = ['origin']\n",
|
||||||
"attributes_min_lbl.extend(['Thickening area {}'.format(x) for x in area])\n",
|
"attributes_min_lbl.extend(['Thickening area {}'.format(x) for x in area])\n",
|
||||||
|
"attributes_min_lbl.extend(['Thickening σ {}'.format(x) for x in sd])\n",
|
||||||
|
"attributes_min_lbl.extend(['Thickening moment of inertia {}'.format(x) for x in sd])\n",
|
||||||
|
"\n",
|
||||||
"attributes_max_lbl = ['origin']\n",
|
"attributes_max_lbl = ['origin']\n",
|
||||||
"attributes_max_lbl.extend(['Thinning area {}'.format(x) for x in area])\n",
|
"attributes_max_lbl.extend(['Thinning area {}'.format(x) for x in area])\n",
|
||||||
|
"attributes_max_lbl.extend(['Thinning σ {}'.format(x) for x in sd])\n",
|
||||||
|
"attributes_max_lbl.extend(['Thinning moment of inertia {}'.format(x) for x in sd])\n",
|
||||||
"\n",
|
"\n",
|
||||||
"attributes_min.shape, attributes_max.shape"
|
"attributes_min.shape, attributes_max.shape"
|
||||||
]
|
]
|
||||||
@ -205,6 +210,35 @@
|
|||||||
"\n",
|
"\n",
|
||||||
"mshow(figs, attributes_lbl, 2)"
|
"mshow(figs, attributes_lbl, 2)"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"f = plt.Figure(figsize=(16,9))\n",
|
||||||
|
"f.imshow(attributes[:,:,0])\n",
|
||||||
|
"f.plt.show()"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"show(attributes[:,:,17])"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"{'I_{{{}}}'.format(42)}"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
|||||||
@ -139,8 +139,8 @@
|
|||||||
"t = triskele.Triskele(layers_stack[:,:,:], verbose=False)\n",
|
"t = triskele.Triskele(layers_stack[:,:,:], verbose=False)\n",
|
||||||
"attributes = t.filter(tree='tos-tree',\n",
|
"attributes = t.filter(tree='tos-tree',\n",
|
||||||
" area=area,\n",
|
" area=area,\n",
|
||||||
" standard_deviation=sd,\n",
|
" #standard_deviation=sd,\n",
|
||||||
" moment_of_inertia=moi\n",
|
" #moment_of_inertia=moi\n",
|
||||||
" )\n",
|
" )\n",
|
||||||
"attributes.shape"
|
"attributes.shape"
|
||||||
]
|
]
|
||||||
@ -165,6 +165,44 @@
|
|||||||
"plt.show()\n"
|
"plt.show()\n"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"plt.imshow((attributes[:,:,4].astype(np.float) - attributes[:,:,3])>0)\n",
|
||||||
|
"plt.show()"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"plt.imshow((attributes[:,:,4].astype(np.float) - attributes[:,:,3])<0)\n",
|
||||||
|
"plt.show()"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"show((attributes[:,:,6].astype(np.float) - attributes[:,:,5]))"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"attributes[0,0,:] = 0"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
|
|||||||
@ -104,15 +104,29 @@
|
|||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"area = np.array([25, 100, 500, 1e3, 5e3, 10e3, 50e3, 100e3, 150e3])\n",
|
"#area = np.array([25, 100, 500, 1e3, 5e3, 10e3, 50e3, 100e3, 150e3])\n",
|
||||||
|
"area = [100, 1e3, 1e4, 1e5]\n",
|
||||||
|
"moi = [.5, .7, .9]\n",
|
||||||
|
"sd = [.1, .5, .9]\n",
|
||||||
"\n",
|
"\n",
|
||||||
"t = triskele.Triskele(raster, verbose=False)\n",
|
"t = triskele.Triskele(raster, verbose=False)\n",
|
||||||
"attributes = t.filter(tree='tos-tree',\n",
|
"attributes = t.filter(tree='tos-tree',\n",
|
||||||
" area=area\n",
|
" area=area,\n",
|
||||||
|
" moment_of_inertia=moi,\n",
|
||||||
|
" standard_deviation=sd\n",
|
||||||
" )\n",
|
" )\n",
|
||||||
"attributes.shape"
|
"attributes.shape"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"show(attributes[:,:,-1])"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
@ -150,6 +164,9 @@
|
|||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
|
"%%time\n",
|
||||||
|
"\n",
|
||||||
|
"offset_stack = None\n",
|
||||||
"def create_patches(array, patch_size=3):\n",
|
"def create_patches(array, patch_size=3):\n",
|
||||||
" amp = int((patch_size - 1 ) / 2)\n",
|
" amp = int((patch_size - 1 ) / 2)\n",
|
||||||
"\n",
|
"\n",
|
||||||
@ -161,7 +178,8 @@
|
|||||||
" di = -ai if ai is not None else None\n",
|
" di = -ai if ai is not None else None\n",
|
||||||
"\n",
|
"\n",
|
||||||
" for j in range(-amp, amp+1):\n",
|
" for j in range(-amp, amp+1):\n",
|
||||||
" offset = np.zeros(array.shape)\n",
|
" offset = np.zeros_like(array)\n",
|
||||||
|
" #offset = np.empty(array.shape)\n",
|
||||||
" aj = j if j > 0 else None\n",
|
" aj = j if j > 0 else None\n",
|
||||||
" bj = j if j < 0 else None\n",
|
" bj = j if j < 0 else None\n",
|
||||||
" cj = -bj if bj is not None else None\n",
|
" cj = -bj if bj is not None else None\n",
|
||||||
@ -175,6 +193,26 @@
|
|||||||
"offset_stack.shape"
|
"offset_stack.shape"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
" init | user | sys | total\n",
|
||||||
|
" --- | ---: | ---: | ---:\n",
|
||||||
|
" empty | 27.9 s | 15.2 s | 43.1 s\n",
|
||||||
|
" zeros | 27.2 s | 14.1 s | 41.3 s\n",
|
||||||
|
" zeros_like | 6.47 s | 4.01 s | 10.5 s"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"%whos"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
|
|||||||
71
Notebooks/Node Streaming Benchmark.ipynb
Normal file
71
Notebooks/Node Streaming Benchmark.ipynb
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"from pathlib import Path"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"url = '../Data/test.tiff'"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"p1 = Path(url)\n",
|
||||||
|
"p1.exists(), p1.as_posix()"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"p2 = Path(p1)\n",
|
||||||
|
"p2.exists(), p2.as_posix()"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"%whos"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 2
|
||||||
|
}
|
||||||
95
Notebooks/Update Triskele.ipynb
Normal file
95
Notebooks/Update Triskele.ipynb
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"import sys\n",
|
||||||
|
"from pathlib import Path\n",
|
||||||
|
"import numpy as np\n",
|
||||||
|
"import matplotlib.pyplot as plt\n",
|
||||||
|
"\n",
|
||||||
|
"triskele_path = Path('../triskele/python/')\n",
|
||||||
|
"sys.path.append(str(triskele_path.resolve()))\n",
|
||||||
|
"import triskele\n",
|
||||||
|
"\n",
|
||||||
|
"def DFC_filter(raster):\n",
|
||||||
|
" raster[raster > 1e4] = raster[raster < 1e4].max()\n",
|
||||||
|
"\n",
|
||||||
|
"def show(im, im_size=1, save=None):\n",
|
||||||
|
" plt.figure(figsize=(16*im_size,3*im_size))\n",
|
||||||
|
" plt.imshow(im)\n",
|
||||||
|
" plt.colorbar()\n",
|
||||||
|
" \n",
|
||||||
|
" if save is not None:\n",
|
||||||
|
" plt.savefig(save, bbox_inches='tight', pad_inches=1)\n",
|
||||||
|
" \n",
|
||||||
|
" plt.show()"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"raster = triskele.read('../Data/phase1_rasters/DEM+B_C123/UH17_GEM051_TR.tif')\n",
|
||||||
|
"DFC_filter(raster)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"show(raster)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"t = triskele.Triskele(raster, verbose=False)\n",
|
||||||
|
"\n",
|
||||||
|
"area = np.array([1e3, 1e4, 1e5])\n",
|
||||||
|
"\n",
|
||||||
|
"res = t.filter(area=area)\n",
|
||||||
|
"res.shape"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"#old_res = res"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 2
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user