Debian Codegraph @

notebooks/dev/h-a-alpha-geocoded-tuto-draft.ipynb

raw
1 {
2 "cells": [
3 {
4 "cell_type": "markdown",
5 "id": "c165ac4d",
6 "metadata": {},
7 "source": [
8 "# Processing geocoded data\n",
9 "\n",
10 "In this notebook, we demonstrate the H/A/Alpha decomposition on a geocoded dataset."
11 ]
12 },
13 {
14 "cell_type": "code",
15 "execution_count": null,
16 "id": "99920dfb",
17 "metadata": {},
18 "outputs": [],
19 "source": [
20 "%load_ext autoreload\n",
21 "%autoreload 2\n",
22 "\n",
23 "import os\n",
24 "\n",
25 "from pathlib import Path\n",
26 "from polsarpro.io import open_netcdf_beam\n",
27 "from polsarpro.decompositions import h_a_alpha\n",
28 "# optional import for progress bar\n",
29 "from dask.diagnostics import ProgressBar\n",
30 "\n",
31 "# change to your data paths\n",
32 "# original dataset\n",
33 "input_alos_geo = Path(\"/data/psp/test_files/SAN_FRANCISCO_ALOS1_geocoded_T3_7_look_az.nc\")"
34 ]
35 },
36 {
37 "cell_type": "markdown",
38 "id": "e6f10073",
39 "metadata": {},
40 "source": [
41 "## Open the dataset"
42 ]
43 },
44 {
45 "cell_type": "code",
46 "execution_count": null,
47 "id": "14bc0335",
48 "metadata": {},
49 "outputs": [],
50 "source": [
51 "T3 = open_netcdf_beam(input_alos_geo)"
52 ]
53 },
54 {
55 "cell_type": "markdown",
56 "id": "fea64661",
57 "metadata": {},
58 "source": [
59 "## Apply the decomposition"
60 ]
61 },
62 {
63 "cell_type": "code",
64 "execution_count": null,
65 "id": "cb995ca2",
66 "metadata": {},
67 "outputs": [],
68 "source": [
69 "with ProgressBar():\n",
70 " res = h_a_alpha(T3, boxcar_size=[3 ,3])"
71 ]
72 },
73 {
74 "cell_type": "markdown",
75 "id": "d1136116",
76 "metadata": {},
77 "source": [
78 "## Display an output"
79 ]
80 },
81 {
82 "cell_type": "code",
83 "execution_count": null,
84 "id": "4f91a5d8",
85 "metadata": {},
86 "outputs": [],
87 "source": [
88 "res.entropy.plot.imshow()"
89 ]
90 },
91 {
92 "cell_type": "markdown",
93 "id": "5f9ee44e",
94 "metadata": {},
95 "source": [
96 "## Export an output as a GeoTIFF"
97 ]
98 },
99 {
100 "cell_type": "code",
101 "execution_count": null,
102 "id": "744ba4d0",
103 "metadata": {},
104 "outputs": [],
105 "source": [
106 "import rioxarray as riox\n",
107 "res.entropy.rio.to_raster(\"/data/psp/entropy_geo.tif\")"
108 ]
109 },
110 {
111 "cell_type": "markdown",
112 "id": "d6c8891d",
113 "metadata": {},
114 "source": [
115 "The resulting file may be opened in a GIS software."
116 ]
117 }
118 ],
119 "metadata": {
120 "kernelspec": {
121 "display_name": "psp",
122 "language": "python",
123 "name": "python3"
124 },
125 "language_info": {
126 "codemirror_mode": {
127 "name": "ipython",
128 "version": 3
129 },
130 "file_extension": ".py",
131 "mimetype": "text/x-python",
132 "name": "python",
133 "nbconvert_exporter": "python",
134 "pygments_lexer": "ipython3",
135 "version": "3.12.11"
136 }
137 },
138 "nbformat": 4,
139 "nbformat_minor": 5
140 }