ld2daps/Notebooks/Node Streaming Benchmark.ipynb

287 lines
6.3 KiB
Plaintext

{
"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",
"import collections\n",
"\n",
"ld2dap_path = Path('../')\n",
"sys.path.append(str(ld2dap_path.resolve()))\n",
"import ld2dap\n",
"from ld2dap.core import Filter"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"layers_files = [\n",
" '../Data/phase1_rasters/DEM+B_C123/UH17_GEM051_TR.tif',\n",
" '../Data/phase1_rasters/DEM_C123_3msr/UH17_GEG051_TR.tif',\n",
" '../Data/phase1_rasters/DEM_C123_TLI/UH17_GEG05_TR.tif',\n",
" '../Data/phase1_rasters/DSM_C12/UH17c_GEF051_TR.tif',\n",
" '../Data/phase1_rasters/Intensity_C1/UH17_GI1F051_TR.tif',\n",
" '../Data/phase1_rasters/Intensity_C2/UH17_GI2F051_TR.tif',\n",
" '../Data/phase1_rasters/Intensity_C3/UH17_GI3F051_TR.tif'\n",
"]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"l = ld2dap.LoadTIFF(layers_files)\n",
"t = ld2dap.Treshold(1e4)\n",
"a = ld2dap.SelfDualAttributeProfiles(area = [1e3, 1e6])\n",
"f = ld2dap.Differential()\n",
"d_ap_3 = ld2dap.ShowFig(stack_id=3, fname='../Res/daps_3.png', pad_inches=0, symb=True, vmax=255, transparent=True)\n",
"d_dap_3 = ld2dap.ShowFig(stack_id=3, fname='../Res/aps_3.png', pad_inches=0, symb=True, vmax=255, transparent=True)\n",
"d_ap_6 = ld2dap.ShowFig(stack_id=6, fname='../Res/daps_6.png', pad_inches=0, symb=True, vmax=255, transparent=True)\n",
"d_dap_6 = ld2dap.ShowFig(stack_id=6, fname='../Res/aps_6.png', pad_inches=0, symb=True, vmax=255, transparent=True)\n",
"\n",
"\n",
"\n",
"t.input = l\n",
"a.input = t\n",
"f.input = a\n",
"d_dap_3.input = f\n",
"d_dap_6.input = f\n",
"d_ap_3.input = a\n",
"d_ap_6.input = a\n",
"l.run()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$\\rho^{area}_{1000}$"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"load = ld2dap.LoadTIFF(('../Data/phase1_rasters/DEM_C123_TLI/UH17_GEG05_TR.tif', '../Data/phase1_rasters/Intensity_C1/UH17_GI1F051_TR.tif')[:])\n",
"trsh = ld2dap.Treshold(1e4)\n",
"aps = ld2dap.AttributeProfiles(area=[1e4,1e5], moi=[.1,.5,.9])\n",
"diff = ld2dap.Differential()\n",
"disp = ld2dap.ShowFig('all', True)\n",
"out = ld2dap.RawOutput()\n",
"out2 = ld2dap.RawOutput()\n",
"\n",
"out.input = aps\n",
"#diff.input = aps\n",
"\n",
"#out2.input = diff\n",
"disp.input = aps\n",
"\n",
"aps.input = trsh\n",
"\n",
"trsh.input = load\n",
"\n",
"disp.run()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"'\\rho'.format()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"out.data.shape"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"plt.imshow(out.data[:,:,10])\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"load = ld2dap.LoadTIFF(('../Data/phase1_rasters/DEM_C123_TLI/UH17_GEG05_TR.tif', '../Data/phase1_rasters/Intensity_C1/UH17_GI1F051_TR.tif')[1])\n",
"disp = ld2dap.ShowFig('all')\n",
"trsh = ld2dap.Treshold(1e4)\n",
"\n",
"trsh.input = load\n",
"disp.input = trsh\n",
"\n",
"disp.run()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print(out)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"' > '.join(x if x is not None else '' for x in out.metadata[0].desc[3])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print(out.metadata[1])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"disp._showfig(data=out.data, stack=out.metadata[1])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"out.data[:,:,5] == out.data[:,:,-1]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print(out.metadata[1])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"' > '.join(filter(None, out.metadata[0].desc[3]))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"for x in out.metadata[0].desc:\n",
" print (x)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"for i, m in enumerate(out.metadata):\n",
" print('{}: {}'.format(i, m))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"A = 'est'\n",
"isinstance(A, collections.Iterable)"
]
},
{
"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
}