Update Notebooks with JurseSF research
This commit is contained in:
parent
506eb11946
commit
9d1360fbe6
@ -199,7 +199,6 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"sys.path.append('..')\n",
|
||||
"import ld2dap"
|
||||
]
|
||||
},
|
||||
@ -231,7 +230,7 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"tif = ld2dap.LoadTIFF('../Data/phase1_rasters/DSM_C12/UH17c_GEF051_TR.tif')\n",
|
||||
"trh = ld2dap.Treshold(1e4)\n",
|
||||
"#trh = ld2dap.Treshold(1e4)\n",
|
||||
"aps = ld2dap.SelfDualAttributeProfiles(area=[100, 1e3, 1e4])\n",
|
||||
"dsp = ld2dap.ShowFig(symb=True)\n",
|
||||
"dif = ld2dap.Differential()\n",
|
||||
@ -240,8 +239,8 @@
|
||||
"ddsp.input = dif\n",
|
||||
"dif.input = aps\n",
|
||||
"dsp.input = aps\n",
|
||||
"aps.input = trh\n",
|
||||
"trh.input = tif\n",
|
||||
"aps.input = tif\n",
|
||||
"#trh.input = tif\n",
|
||||
"\n",
|
||||
"tif.run()"
|
||||
]
|
||||
|
@ -6,16 +6,11 @@
|
||||
"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"
|
||||
"import ld2dap"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
293
Notebooks/Split First.ipynb
Normal file
293
Notebooks/Split First.ipynb
Normal file
@ -0,0 +1,293 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import numpy as np\n",
|
||||
"import matplotlib.pyplot as plt\n",
|
||||
"import triskele\n",
|
||||
"import ld2dap\n",
|
||||
"\n",
|
||||
"figsize = np.array((16, 9)) * 2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Split First for JURSE\n",
|
||||
"\n",
|
||||
"Load raster, $n$ split along dimension $d$, describe and merge in description stack."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"n = 3; d = 0"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Load data"
|
||||
]
|
||||
},
|
||||
{
|
||||
"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": [
|
||||
"load = ld2dap.LoadTIFF(layers_files)\n",
|
||||
"#trsh = ld2dap.Treshold(1e4)\n",
|
||||
"rout = ld2dap.RawOutput()\n",
|
||||
"\n",
|
||||
"rout.input = load\n",
|
||||
"trsh.input = load\n",
|
||||
"\n",
|
||||
"rout.run()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Split"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"step = int(rout.data.shape[d] / n)\n",
|
||||
"\n",
|
||||
"fig, axs = plt.subplots(n, figsize=figsize * n)\n",
|
||||
"\n",
|
||||
"view = np.moveaxis(rout.data, d, 0)\n",
|
||||
"\n",
|
||||
"cuts = list()\n",
|
||||
"for i in range(n):\n",
|
||||
" cut = np.moveaxis(view[i*step:(i+1)*step+1], 0, d)\n",
|
||||
" cuts.append(cut)\n",
|
||||
" \n",
|
||||
" # Disp\n",
|
||||
" axs[i].imshow(cut[:,:,0], cmap=plt.get_cmap('GnBu'))\n",
|
||||
" axs[i].set_title('Cut {}'.format(i))\n",
|
||||
" \n",
|
||||
"plt.show()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Describe"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"dcuts = list()\n",
|
||||
"\n",
|
||||
"for cut in cuts:\n",
|
||||
" rinp = ld2dap.RawInput(cut, rout.metadata)\n",
|
||||
" aps = ld2dap.AttributeProfiles(area=[100,1e3,1e4])\n",
|
||||
" vout = ld2dap.RawOutput()\n",
|
||||
" \n",
|
||||
" vout.input = aps\n",
|
||||
" aps.input = rinp\n",
|
||||
" \n",
|
||||
" vout.run()\n",
|
||||
" \n",
|
||||
" dcuts.append(vout.data)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Merge"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"descriptors = np.zeros(rout.data.shape[:2] + (dcuts[0].shape[-1],))\n",
|
||||
"\n",
|
||||
"for i, cut in enumerate(dcuts):\n",
|
||||
" descriptors[i*step:(i+1)*step+1] = cut"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Visual test"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"t_inp = ld2dap.RawInput(descriptors, vout.metadata)\n",
|
||||
"t_dsp = ld2dap.ShowFig(stack_id=3, symb=True, fname='../Res/bands.png')\n",
|
||||
"\n",
|
||||
"t_dsp.input = t_inp\n",
|
||||
"\n",
|
||||
"t_dsp.run()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"descriptors.shape"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"dim = 5\n",
|
||||
"A = np.arange(64).reshape((4, 8, 2))\n",
|
||||
"A = A[:,:,np.newaxis] if A.ndim == 2 else A\n",
|
||||
"B = np.zeros(A.shape[:2] + (A.shape[2] * dim,))\n",
|
||||
"A.shape, B.shape"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"step = int(A.shape[0] / n)\n",
|
||||
"cuts = list()\n",
|
||||
"\n",
|
||||
"for i in range(n):\n",
|
||||
" cut = A[i*step:(i+1)*step+1]\n",
|
||||
" cut = np.repeat(cut, dim, axis=2)\n",
|
||||
" cuts.append(cut)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"for i, cut in enumerate(cuts):\n",
|
||||
" B[i*step:(i+1)*step+1] = cut\n",
|
||||
"B"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"cuts[0].shape"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"np.tile(A[:,:,np.newaxis], (1,1,10))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"A.shape"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"np.repeat(A.reshape(, 2, axis=1)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"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
|
||||
}
|
73
Notebooks/dtypes are evil.ipynb
Normal file
73
Notebooks/dtypes are evil.ipynb
Normal file
@ -0,0 +1,73 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import numpy as np\n",
|
||||
"import ld2dap\n",
|
||||
"import triskele"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"load = ld2dap.LoadTIFF('../Data/phase1_rasters/Intensity_C1/UH17_GI1F051_TR.tif')\n",
|
||||
"trsh = ld2dap.Treshold(1e4)\n",
|
||||
"disp = ld2dap.ShowFig()\n",
|
||||
"rout = ld2dap.RawOutput()\n",
|
||||
"\n",
|
||||
"rout.input = trsh\n",
|
||||
"disp.input = trsh\n",
|
||||
"trsh.input = load\n",
|
||||
"\n",
|
||||
"disp.run()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"rinp = ld2dap.RawInput(rout.data.astype(np.uint16), rout.metadata)\n",
|
||||
"\n",
|
||||
"disp.input = rinp\n",
|
||||
"\n",
|
||||
"disp.run()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"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