esa-snappy 1.0.8__cp39-none-any.whl → 1.0.9__cp39-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,418 +1,418 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "markdown",
5
- "id": "eff9f1b9-ebce-4968-aa1d-eb33efd37813",
6
- "metadata": {},
7
- "source": [
8
- "## Snapista Demo notebook - Using band maths, setting up operators, creating and running a graph..."
9
- ]
10
- },
11
- {
12
- "cell_type": "code",
13
- "execution_count": 1,
14
- "id": "77db105d",
15
- "metadata": {},
16
- "outputs": [
17
- {
18
- "name": "stdout",
19
- "output_type": "stream",
20
- "text": [
21
- "Python version: 3.11.9 | packaged by Anaconda, Inc. | (main, Apr 19 2024, 16:40:41) [MSC v.1916 64 bit (AMD64)]\n",
22
- "Location of esa_snappy package: D:\\olaf\\miniconda3_py311\\Lib\\site-packages\\esa_snappy\n"
23
- ]
24
- }
25
- ],
26
- "source": [
27
- "# Some information...\n",
28
- "\n",
29
- "import os\n",
30
- "import sys\n",
31
- "print(\"Python version: \" + sys.version)\n",
32
- "\n",
33
- "import sysconfig\n",
34
- "print(\"Location of esa_snappy package: \" + sysconfig.get_paths()['purelib'] + os.sep + \"esa_snappy\")"
35
- ]
36
- },
37
- {
38
- "cell_type": "code",
39
- "execution_count": 2,
40
- "id": "f3b2ca32-63fc-4a92-8be4-5f459be87a9f",
41
- "metadata": {},
42
- "outputs": [],
43
- "source": [
44
- "# Import esa_snappy and snapista...\n",
45
- "\n",
46
- "import esa_snappy\n",
47
- "import snapista\n",
48
- "\n",
49
- "from snapista import Graph\n",
50
- "from snapista import Operator\n",
51
- "from snapista import read_file\n",
52
- "from snapista import TargetBand\n",
53
- "from snapista import TargetBandDescriptors"
54
- ]
55
- },
56
- {
57
- "cell_type": "code",
58
- "execution_count": 3,
59
- "id": "d0ac6a29-c799-41b2-b028-e55a3315de63",
60
- "metadata": {},
61
- "outputs": [],
62
- "source": [
63
- "# Set up a graph...\n",
64
- "\n",
65
- "try:\n",
66
- " g = Graph()\n",
67
- "except Exception as ex:\n",
68
- " print(\"Cannot set up Snapista Graph():\", ex)"
69
- ]
70
- },
71
- {
72
- "cell_type": "code",
73
- "execution_count": 4,
74
- "id": "1a94bc96-3104-4726-b01c-48fad9cfb5d6",
75
- "metadata": {},
76
- "outputs": [],
77
- "source": [
78
- "# Add 'Read' operator to the graph for reading example input...\n",
79
- "\n",
80
- "g.add_node(operator=Operator(\"Read\", file='./data/subset_0_of_S3A_OL_1_ERR____20160701T092853_20160701T093053_20170919T102725_0119_006_036______MR1_R_NT_002.nc'), node_id=\"Read\")\n"
81
- ]
82
- },
83
- {
84
- "cell_type": "code",
85
- "execution_count": 5,
86
- "id": "96b93cd5-2f58-442b-88c3-ce4cbc793661",
87
- "metadata": {},
88
- "outputs": [],
89
- "source": [
90
- "# Set up a 'BandMaths' operator to compute a simple NDVI. Set up a target band for NDVI result...\n",
91
- "\n",
92
- "band_maths = Operator('BandMaths')\n",
93
- "\n",
94
- "ndvi = TargetBand(name='ndvi', expression='(Oa08_radiance - Oa17_radiance)/(Oa08_radiance + Oa17_radiance)')\n",
95
- " \n",
96
- "band_maths.targetBandDescriptors = TargetBandDescriptors([ndvi])"
97
- ]
98
- },
99
- {
100
- "cell_type": "code",
101
- "execution_count": 6,
102
- "id": "1564302c-f7a2-47a2-a5f6-85147b88536b",
103
- "metadata": {},
104
- "outputs": [
105
- {
106
- "name": "stdout",
107
- "output_type": "stream",
108
- "text": [
109
- "targetBandDescriptors <snapista.target_band_descriptors.TargetBandDescriptors object at 0x000001B75A9730D0>\n",
110
- "Instance TargetBandDescriptors: True\n",
111
- "Instance Aggregators: False\n",
112
- "Instance BinningOutputBands: False\n",
113
- "Instance BinningVariables: False\n",
114
- "Instance str: False\n"
115
- ]
116
- }
117
- ],
118
- "source": [
119
- "# Add 'BandMaths' operator to the graph...\n",
120
- "\n",
121
- "g.add_node(operator=band_maths, node_id=\"BandMaths\" ,source='Read')"
122
- ]
123
- },
124
- {
125
- "cell_type": "code",
126
- "execution_count": 7,
127
- "id": "6558126a-e281-497d-a365-3a6b0497762c",
128
- "metadata": {},
129
- "outputs": [
130
- {
131
- "data": {
132
- "text/plain": [
133
- "Operator('BandMerge', sourceBandNames='None', geographicError='1.0E-5f', source='['Read', 'BandMaths']')"
134
- ]
135
- },
136
- "execution_count": 7,
137
- "metadata": {},
138
- "output_type": "execute_result"
139
- }
140
- ],
141
- "source": [
142
- "# Set up a 'Merge' operator to merge input with NDVI result...\n",
143
- "\n",
144
- "merge = Operator(\"BandMerge\", source=[\"Read\", \"BandMaths\"])\n",
145
- "\n",
146
- "merge"
147
- ]
148
- },
149
- {
150
- "cell_type": "code",
151
- "execution_count": 8,
152
- "id": "216903df-8ef4-403b-9437-5653733120fb",
153
- "metadata": {},
154
- "outputs": [],
155
- "source": [
156
- "# Add 'Merge' operator to the graph...\n",
157
- "\n",
158
- "g.add_node(operator=merge, node_id=\"Merge\", source=[\"Read\", \"BandMaths\"])"
159
- ]
160
- },
161
- {
162
- "cell_type": "code",
163
- "execution_count": 9,
164
- "id": "cc5346c1-d9f6-49b2-8f7a-a59b9104e589",
165
- "metadata": {},
166
- "outputs": [
167
- {
168
- "data": {
169
- "text/plain": [
170
- "Operator('Subset', bandNames='Oa08_radiance,Oa17_radiance,ndvi', tiePointGridNames='None', region='None', referenceBand='None', geoRegion='None', subSamplingX='1', subSamplingY='1', fullSwath='false', copyMetadata='false')"
171
- ]
172
- },
173
- "execution_count": 9,
174
- "metadata": {},
175
- "output_type": "execute_result"
176
- }
177
- ],
178
- "source": [
179
- "# Set up a 'Subset' operator to extract just three bands...\n",
180
- "\n",
181
- "subset = Operator('Subset', bandNames=\"Oa08_radiance,Oa17_radiance,ndvi\")\n",
182
- "\n",
183
- "subset"
184
- ]
185
- },
186
- {
187
- "cell_type": "code",
188
- "execution_count": 10,
189
- "id": "5120cf7c-9fd4-4c50-a90c-38800b6ba01d",
190
- "metadata": {},
191
- "outputs": [],
192
- "source": [
193
- "# Add 'Subset' operator to the graph...\n",
194
- "\n",
195
- "g.add_node(operator=subset, node_id=\"Subset\", source='Merge')"
196
- ]
197
- },
198
- {
199
- "cell_type": "code",
200
- "execution_count": 11,
201
- "id": "8f90a68b-d124-428e-bdf6-1f3ea070c667",
202
- "metadata": {},
203
- "outputs": [
204
- {
205
- "data": {
206
- "text/plain": [
207
- "Operator('Write', file='None', formatName='BEAM-DIMAP', deleteOutputOnFailure='true', writeEntireTileRows='false', clearCacheAfterRowWrite='false')"
208
- ]
209
- },
210
- "execution_count": 11,
211
- "metadata": {},
212
- "output_type": "execute_result"
213
- }
214
- ],
215
- "source": [
216
- "# Set up a 'Write' operator to write final target product with the three bands...\n",
217
- "\n",
218
- "write = Operator(\"Write\")\n",
219
- "\n",
220
- "write"
221
- ]
222
- },
223
- {
224
- "cell_type": "code",
225
- "execution_count": 12,
226
- "id": "0548a3a6-cf3c-4f26-a48d-0e92556ee09c",
227
- "metadata": {},
228
- "outputs": [],
229
- "source": [
230
- "# Add 'Write' operator to the graph. Define a NetCDF output file...\n",
231
- "\n",
232
- "g.add_node(operator=Operator(\"Write\", file='./data/snapista_demo_bandmaths_result.nc', formatName='NetCDF4-BEAM'), node_id=\"Write\", source='Subset')"
233
- ]
234
- },
235
- {
236
- "cell_type": "code",
237
- "execution_count": 13,
238
- "id": "825327d3-cc7f-4a1d-840d-52d40a39c4fd",
239
- "metadata": {},
240
- "outputs": [
241
- {
242
- "name": "stdout",
243
- "output_type": "stream",
244
- "text": [
245
- "<graph>\n",
246
- " <version>1.0</version>\n",
247
- " <node id=\"Read\">\n",
248
- " <operator>Read</operator>\n",
249
- " <sources/>\n",
250
- " <parameters class=\"com.bc.ceres.binding.dom.XppDomElement\">\n",
251
- " <bandNames/>\n",
252
- " <copyMetadata>true</copyMetadata>\n",
253
- " <file>./data/subset_0_of_S3A_OL_1_ERR____20160701T092853_20160701T093053_20170919T102725_0119_006_036______MR1_R_NT_002.nc</file>\n",
254
- " <formatName/>\n",
255
- " <geometryRegion/>\n",
256
- " <maskNames/>\n",
257
- " <pixelRegion/>\n",
258
- " <useAdvancedOptions>false</useAdvancedOptions>\n",
259
- " </parameters>\n",
260
- " </node>\n",
261
- " <node id=\"BandMaths\">\n",
262
- " <operator>BandMaths</operator>\n",
263
- " <sources>\n",
264
- " <sourceProduct refid=\"Read\"/>\n",
265
- " </sources>\n",
266
- " <parameters class=\"com.bc.ceres.binding.dom.XppDomElement\">\n",
267
- " <targetBands>\n",
268
- " <targetBand>\n",
269
- " <name>ndvi</name>\n",
270
- " <expression>(Oa08_radiance - Oa17_radiance)/(Oa08_radiance + Oa17_radiance)</expression>\n",
271
- " <type>float32</type>\n",
272
- " <description/>\n",
273
- " <unit/>\n",
274
- " <no_data_value>NaN</no_data_value>\n",
275
- " </targetBand>\n",
276
- " </targetBands>\n",
277
- " <variables/>\n",
278
- " </parameters>\n",
279
- " </node>\n",
280
- " <node id=\"Merge\">\n",
281
- " <operator>BandMerge</operator>\n",
282
- " <sources>\n",
283
- " <sourceProduct refid=\"Read\"/>\n",
284
- " <sourceProduct.1 refid=\"BandMaths\"/>\n",
285
- " </sources>\n",
286
- " <parameters class=\"com.bc.ceres.binding.dom.XppDomElement\">\n",
287
- " <geographicError>1.0E-5f</geographicError>\n",
288
- " <sourceBandNames/>\n",
289
- " </parameters>\n",
290
- " </node>\n",
291
- " <node id=\"Subset\">\n",
292
- " <operator>Subset</operator>\n",
293
- " <sources>\n",
294
- " <sourceProduct refid=\"Merge\"/>\n",
295
- " </sources>\n",
296
- " <parameters class=\"com.bc.ceres.binding.dom.XppDomElement\">\n",
297
- " <bandNames>Oa08_radiance,Oa17_radiance,ndvi</bandNames>\n",
298
- " <copyMetadata>false</copyMetadata>\n",
299
- " <fullSwath>false</fullSwath>\n",
300
- " <geoRegion/>\n",
301
- " <referenceBand/>\n",
302
- " <region/>\n",
303
- " <subSamplingX>1</subSamplingX>\n",
304
- " <subSamplingY>1</subSamplingY>\n",
305
- " <tiePointGridNames/>\n",
306
- " </parameters>\n",
307
- " </node>\n",
308
- " <node id=\"Write\">\n",
309
- " <operator>Write</operator>\n",
310
- " <sources>\n",
311
- " <sourceProduct refid=\"Subset\"/>\n",
312
- " </sources>\n",
313
- " <parameters class=\"com.bc.ceres.binding.dom.XppDomElement\">\n",
314
- " <clearCacheAfterRowWrite>false</clearCacheAfterRowWrite>\n",
315
- " <deleteOutputOnFailure>true</deleteOutputOnFailure>\n",
316
- " <file>./data/snapista_demo_bandmaths_result.nc</file>\n",
317
- " <formatName>NetCDF4-BEAM</formatName>\n",
318
- " <writeEntireTileRows>false</writeEntireTileRows>\n",
319
- " </parameters>\n",
320
- " </node>\n",
321
- "</graph>\n",
322
- "\n"
323
- ]
324
- }
325
- ],
326
- "source": [
327
- "# View graph in XML representation...\n",
328
- "\n",
329
- "g.view()"
330
- ]
331
- },
332
- {
333
- "cell_type": "code",
334
- "execution_count": 14,
335
- "id": "3328eb96-de62-4fbe-9f05-f0266b22b69d",
336
- "metadata": {},
337
- "outputs": [
338
- {
339
- "name": "stdout",
340
- "output_type": "stream",
341
- "text": [
342
- "Processing the graph, this may take a while. Please wait...\n",
343
- "Executing processing graph\n",
344
- "15%30%45%60%...70%..90% done.\n",
345
- "SEVERE: org.esa.snap.runtime.Engine: Failed to modify class loader field 'usr_paths'\n",
346
- "java.lang.NoSuchMethodException: java.lang.ClassLoader.initializePath(java.lang.String)\n",
347
- "\tat java.base/java.lang.Class.getDeclaredMethod(Class.java:2848)\n",
348
- "\tat org.esa.snap.runtime.Engine.setJavaLibraryPath(Engine.java:286)\n",
349
- "\tat org.esa.snap.runtime.Engine.setJavaLibraryPath(Engine.java:265)\n",
350
- "\tat org.esa.snap.runtime.Engine.<init>(Engine.java:46)\n",
351
- "\tat org.esa.snap.runtime.Engine.start(Engine.java:117)\n",
352
- "\tat org.esa.snap.runtime.Engine.start(Engine.java:90)\n",
353
- "\tat org.esa.snap.runtime.Launcher.run(Launcher.java:51)\n",
354
- "\tat org.esa.snap.runtime.Launcher.main(Launcher.java:31)\n",
355
- "\tat java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)\n",
356
- "\tat java.base/java.lang.reflect.Method.invoke(Method.java:580)\n",
357
- "\tat com.exe4j.runtime.LauncherEngine.launch(LauncherEngine.java:84)\n",
358
- "\tat com.exe4j.runtime.WinLauncher.main(WinLauncher.java:94)\n",
359
- "\tat com.install4j.runtime.launcher.WinLauncher.main(WinLauncher.java:25)\n",
360
- "\n",
361
- "INFO: org.esa.snap.core.gpf.operators.tooladapter.ToolAdapterIO: Initializing external tool adapters\n",
362
- "INFO: org.esa.snap.core.util.EngineVersionCheckActivator: Please check regularly for new updates for the best SNAP experience.\n",
363
- "WARNING: org.esa.snap.dataio.netcdf.util.MetadataUtils: Missing configuration property 'snap.dataio.netcdf.metadataElementLimit'. Using default (100).\n",
364
- "4280 [main] INFO serverStartup - Nc4Iosp: NetCDF-4 C library loaded (jna_path='C:\\Users\\olafd\\.snap\\auxdata\\netcdf_natives\\12.0.0.0\\amd64', libname='netcdf').\n",
365
- "4287 [main] INFO serverStartup - NetcdfLoader: set log level: old=0 new=0\n",
366
- "4287 [main] INFO serverStartup - Nc4Iosp: set log level: old=0 new=0\n",
367
- "Processing finished successfully.\n"
368
- ]
369
- },
370
- {
371
- "data": {
372
- "text/plain": [
373
- "0"
374
- ]
375
- },
376
- "execution_count": 14,
377
- "metadata": {},
378
- "output_type": "execute_result"
379
- }
380
- ],
381
- "source": [
382
- "# Save graph as XML file, then run it...\n",
383
- "\n",
384
- "g.save_graph('./data/snapista_demo_bandmaths.xml')\n",
385
- "g.run()"
386
- ]
387
- },
388
- {
389
- "cell_type": "code",
390
- "execution_count": null,
391
- "id": "eaef2574-6a7d-484b-86f9-69f8f4b531e3",
392
- "metadata": {},
393
- "outputs": [],
394
- "source": []
395
- }
396
- ],
397
- "metadata": {
398
- "kernelspec": {
399
- "display_name": "Python 3 (ipykernel)",
400
- "language": "python",
401
- "name": "python3"
402
- },
403
- "language_info": {
404
- "codemirror_mode": {
405
- "name": "ipython",
406
- "version": 3
407
- },
408
- "file_extension": ".py",
409
- "mimetype": "text/x-python",
410
- "name": "python",
411
- "nbconvert_exporter": "python",
412
- "pygments_lexer": "ipython3",
413
- "version": "3.11.9"
414
- }
415
- },
416
- "nbformat": 4,
417
- "nbformat_minor": 5
418
- }
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "id": "eff9f1b9-ebce-4968-aa1d-eb33efd37813",
6
+ "metadata": {},
7
+ "source": [
8
+ "## Snapista Demo notebook - Using band maths, setting up operators, creating and running a graph..."
9
+ ]
10
+ },
11
+ {
12
+ "cell_type": "code",
13
+ "execution_count": 1,
14
+ "id": "77db105d",
15
+ "metadata": {},
16
+ "outputs": [
17
+ {
18
+ "name": "stdout",
19
+ "output_type": "stream",
20
+ "text": [
21
+ "Python version: 3.11.9 | packaged by Anaconda, Inc. | (main, Apr 19 2024, 16:40:41) [MSC v.1916 64 bit (AMD64)]\n",
22
+ "Location of esa_snappy package: D:\\olaf\\miniconda3_py311\\Lib\\site-packages\\esa_snappy\n"
23
+ ]
24
+ }
25
+ ],
26
+ "source": [
27
+ "# Some information...\n",
28
+ "\n",
29
+ "import os\n",
30
+ "import sys\n",
31
+ "print(\"Python version: \" + sys.version)\n",
32
+ "\n",
33
+ "import sysconfig\n",
34
+ "print(\"Location of esa_snappy package: \" + sysconfig.get_paths()['purelib'] + os.sep + \"esa_snappy\")"
35
+ ]
36
+ },
37
+ {
38
+ "cell_type": "code",
39
+ "execution_count": 2,
40
+ "id": "f3b2ca32-63fc-4a92-8be4-5f459be87a9f",
41
+ "metadata": {},
42
+ "outputs": [],
43
+ "source": [
44
+ "# Import esa_snappy and snapista...\n",
45
+ "\n",
46
+ "import esa_snappy\n",
47
+ "import snapista\n",
48
+ "\n",
49
+ "from snapista import Graph\n",
50
+ "from snapista import Operator\n",
51
+ "from snapista import read_file\n",
52
+ "from snapista import TargetBand\n",
53
+ "from snapista import TargetBandDescriptors"
54
+ ]
55
+ },
56
+ {
57
+ "cell_type": "code",
58
+ "execution_count": 3,
59
+ "id": "d0ac6a29-c799-41b2-b028-e55a3315de63",
60
+ "metadata": {},
61
+ "outputs": [],
62
+ "source": [
63
+ "# Set up a graph...\n",
64
+ "\n",
65
+ "try:\n",
66
+ " g = Graph()\n",
67
+ "except Exception as ex:\n",
68
+ " print(\"Cannot set up Snapista Graph():\", ex)"
69
+ ]
70
+ },
71
+ {
72
+ "cell_type": "code",
73
+ "execution_count": 4,
74
+ "id": "1a94bc96-3104-4726-b01c-48fad9cfb5d6",
75
+ "metadata": {},
76
+ "outputs": [],
77
+ "source": [
78
+ "# Add 'Read' operator to the graph for reading example input...\n",
79
+ "\n",
80
+ "g.add_node(operator=Operator(\"Read\", file='./data/subset_0_of_S3A_OL_1_ERR____20160701T092853_20160701T093053_20170919T102725_0119_006_036______MR1_R_NT_002.nc'), node_id=\"Read\")\n"
81
+ ]
82
+ },
83
+ {
84
+ "cell_type": "code",
85
+ "execution_count": 5,
86
+ "id": "96b93cd5-2f58-442b-88c3-ce4cbc793661",
87
+ "metadata": {},
88
+ "outputs": [],
89
+ "source": [
90
+ "# Set up a 'BandMaths' operator to compute a simple NDVI. Set up a target band for NDVI result...\n",
91
+ "\n",
92
+ "band_maths = Operator('BandMaths')\n",
93
+ "\n",
94
+ "ndvi = TargetBand(name='ndvi', expression='(Oa08_radiance - Oa17_radiance)/(Oa08_radiance + Oa17_radiance)')\n",
95
+ " \n",
96
+ "band_maths.targetBandDescriptors = TargetBandDescriptors([ndvi])"
97
+ ]
98
+ },
99
+ {
100
+ "cell_type": "code",
101
+ "execution_count": 6,
102
+ "id": "1564302c-f7a2-47a2-a5f6-85147b88536b",
103
+ "metadata": {},
104
+ "outputs": [
105
+ {
106
+ "name": "stdout",
107
+ "output_type": "stream",
108
+ "text": [
109
+ "targetBandDescriptors <snapista.target_band_descriptors.TargetBandDescriptors object at 0x000001B75A9730D0>\n",
110
+ "Instance TargetBandDescriptors: True\n",
111
+ "Instance Aggregators: False\n",
112
+ "Instance BinningOutputBands: False\n",
113
+ "Instance BinningVariables: False\n",
114
+ "Instance str: False\n"
115
+ ]
116
+ }
117
+ ],
118
+ "source": [
119
+ "# Add 'BandMaths' operator to the graph...\n",
120
+ "\n",
121
+ "g.add_node(operator=band_maths, node_id=\"BandMaths\" ,source='Read')"
122
+ ]
123
+ },
124
+ {
125
+ "cell_type": "code",
126
+ "execution_count": 7,
127
+ "id": "6558126a-e281-497d-a365-3a6b0497762c",
128
+ "metadata": {},
129
+ "outputs": [
130
+ {
131
+ "data": {
132
+ "text/plain": [
133
+ "Operator('BandMerge', sourceBandNames='None', geographicError='1.0E-5f', source='['Read', 'BandMaths']')"
134
+ ]
135
+ },
136
+ "execution_count": 7,
137
+ "metadata": {},
138
+ "output_type": "execute_result"
139
+ }
140
+ ],
141
+ "source": [
142
+ "# Set up a 'Merge' operator to merge input with NDVI result...\n",
143
+ "\n",
144
+ "merge = Operator(\"BandMerge\", source=[\"Read\", \"BandMaths\"])\n",
145
+ "\n",
146
+ "merge"
147
+ ]
148
+ },
149
+ {
150
+ "cell_type": "code",
151
+ "execution_count": 8,
152
+ "id": "216903df-8ef4-403b-9437-5653733120fb",
153
+ "metadata": {},
154
+ "outputs": [],
155
+ "source": [
156
+ "# Add 'Merge' operator to the graph...\n",
157
+ "\n",
158
+ "g.add_node(operator=merge, node_id=\"Merge\", source=[\"Read\", \"BandMaths\"])"
159
+ ]
160
+ },
161
+ {
162
+ "cell_type": "code",
163
+ "execution_count": 9,
164
+ "id": "cc5346c1-d9f6-49b2-8f7a-a59b9104e589",
165
+ "metadata": {},
166
+ "outputs": [
167
+ {
168
+ "data": {
169
+ "text/plain": [
170
+ "Operator('Subset', bandNames='Oa08_radiance,Oa17_radiance,ndvi', tiePointGridNames='None', region='None', referenceBand='None', geoRegion='None', subSamplingX='1', subSamplingY='1', fullSwath='false', copyMetadata='false')"
171
+ ]
172
+ },
173
+ "execution_count": 9,
174
+ "metadata": {},
175
+ "output_type": "execute_result"
176
+ }
177
+ ],
178
+ "source": [
179
+ "# Set up a 'Subset' operator to extract just three bands...\n",
180
+ "\n",
181
+ "subset = Operator('Subset', bandNames=\"Oa08_radiance,Oa17_radiance,ndvi\")\n",
182
+ "\n",
183
+ "subset"
184
+ ]
185
+ },
186
+ {
187
+ "cell_type": "code",
188
+ "execution_count": 10,
189
+ "id": "5120cf7c-9fd4-4c50-a90c-38800b6ba01d",
190
+ "metadata": {},
191
+ "outputs": [],
192
+ "source": [
193
+ "# Add 'Subset' operator to the graph...\n",
194
+ "\n",
195
+ "g.add_node(operator=subset, node_id=\"Subset\", source='Merge')"
196
+ ]
197
+ },
198
+ {
199
+ "cell_type": "code",
200
+ "execution_count": 11,
201
+ "id": "8f90a68b-d124-428e-bdf6-1f3ea070c667",
202
+ "metadata": {},
203
+ "outputs": [
204
+ {
205
+ "data": {
206
+ "text/plain": [
207
+ "Operator('Write', file='None', formatName='BEAM-DIMAP', deleteOutputOnFailure='true', writeEntireTileRows='false', clearCacheAfterRowWrite='false')"
208
+ ]
209
+ },
210
+ "execution_count": 11,
211
+ "metadata": {},
212
+ "output_type": "execute_result"
213
+ }
214
+ ],
215
+ "source": [
216
+ "# Set up a 'Write' operator to write final target product with the three bands...\n",
217
+ "\n",
218
+ "write = Operator(\"Write\")\n",
219
+ "\n",
220
+ "write"
221
+ ]
222
+ },
223
+ {
224
+ "cell_type": "code",
225
+ "execution_count": 12,
226
+ "id": "0548a3a6-cf3c-4f26-a48d-0e92556ee09c",
227
+ "metadata": {},
228
+ "outputs": [],
229
+ "source": [
230
+ "# Add 'Write' operator to the graph. Define a NetCDF output file...\n",
231
+ "\n",
232
+ "g.add_node(operator=Operator(\"Write\", file='./data/snapista_demo_bandmaths_result.nc', formatName='NetCDF4-BEAM'), node_id=\"Write\", source='Subset')"
233
+ ]
234
+ },
235
+ {
236
+ "cell_type": "code",
237
+ "execution_count": 13,
238
+ "id": "825327d3-cc7f-4a1d-840d-52d40a39c4fd",
239
+ "metadata": {},
240
+ "outputs": [
241
+ {
242
+ "name": "stdout",
243
+ "output_type": "stream",
244
+ "text": [
245
+ "<graph>\n",
246
+ " <version>1.0</version>\n",
247
+ " <node id=\"Read\">\n",
248
+ " <operator>Read</operator>\n",
249
+ " <sources/>\n",
250
+ " <parameters class=\"com.bc.ceres.binding.dom.XppDomElement\">\n",
251
+ " <bandNames/>\n",
252
+ " <copyMetadata>true</copyMetadata>\n",
253
+ " <file>./data/subset_0_of_S3A_OL_1_ERR____20160701T092853_20160701T093053_20170919T102725_0119_006_036______MR1_R_NT_002.nc</file>\n",
254
+ " <formatName/>\n",
255
+ " <geometryRegion/>\n",
256
+ " <maskNames/>\n",
257
+ " <pixelRegion/>\n",
258
+ " <useAdvancedOptions>false</useAdvancedOptions>\n",
259
+ " </parameters>\n",
260
+ " </node>\n",
261
+ " <node id=\"BandMaths\">\n",
262
+ " <operator>BandMaths</operator>\n",
263
+ " <sources>\n",
264
+ " <sourceProduct refid=\"Read\"/>\n",
265
+ " </sources>\n",
266
+ " <parameters class=\"com.bc.ceres.binding.dom.XppDomElement\">\n",
267
+ " <targetBands>\n",
268
+ " <targetBand>\n",
269
+ " <name>ndvi</name>\n",
270
+ " <expression>(Oa08_radiance - Oa17_radiance)/(Oa08_radiance + Oa17_radiance)</expression>\n",
271
+ " <type>float32</type>\n",
272
+ " <description/>\n",
273
+ " <unit/>\n",
274
+ " <no_data_value>NaN</no_data_value>\n",
275
+ " </targetBand>\n",
276
+ " </targetBands>\n",
277
+ " <variables/>\n",
278
+ " </parameters>\n",
279
+ " </node>\n",
280
+ " <node id=\"Merge\">\n",
281
+ " <operator>BandMerge</operator>\n",
282
+ " <sources>\n",
283
+ " <sourceProduct refid=\"Read\"/>\n",
284
+ " <sourceProduct.1 refid=\"BandMaths\"/>\n",
285
+ " </sources>\n",
286
+ " <parameters class=\"com.bc.ceres.binding.dom.XppDomElement\">\n",
287
+ " <geographicError>1.0E-5f</geographicError>\n",
288
+ " <sourceBandNames/>\n",
289
+ " </parameters>\n",
290
+ " </node>\n",
291
+ " <node id=\"Subset\">\n",
292
+ " <operator>Subset</operator>\n",
293
+ " <sources>\n",
294
+ " <sourceProduct refid=\"Merge\"/>\n",
295
+ " </sources>\n",
296
+ " <parameters class=\"com.bc.ceres.binding.dom.XppDomElement\">\n",
297
+ " <bandNames>Oa08_radiance,Oa17_radiance,ndvi</bandNames>\n",
298
+ " <copyMetadata>false</copyMetadata>\n",
299
+ " <fullSwath>false</fullSwath>\n",
300
+ " <geoRegion/>\n",
301
+ " <referenceBand/>\n",
302
+ " <region/>\n",
303
+ " <subSamplingX>1</subSamplingX>\n",
304
+ " <subSamplingY>1</subSamplingY>\n",
305
+ " <tiePointGridNames/>\n",
306
+ " </parameters>\n",
307
+ " </node>\n",
308
+ " <node id=\"Write\">\n",
309
+ " <operator>Write</operator>\n",
310
+ " <sources>\n",
311
+ " <sourceProduct refid=\"Subset\"/>\n",
312
+ " </sources>\n",
313
+ " <parameters class=\"com.bc.ceres.binding.dom.XppDomElement\">\n",
314
+ " <clearCacheAfterRowWrite>false</clearCacheAfterRowWrite>\n",
315
+ " <deleteOutputOnFailure>true</deleteOutputOnFailure>\n",
316
+ " <file>./data/snapista_demo_bandmaths_result.nc</file>\n",
317
+ " <formatName>NetCDF4-BEAM</formatName>\n",
318
+ " <writeEntireTileRows>false</writeEntireTileRows>\n",
319
+ " </parameters>\n",
320
+ " </node>\n",
321
+ "</graph>\n",
322
+ "\n"
323
+ ]
324
+ }
325
+ ],
326
+ "source": [
327
+ "# View graph in XML representation...\n",
328
+ "\n",
329
+ "g.view()"
330
+ ]
331
+ },
332
+ {
333
+ "cell_type": "code",
334
+ "execution_count": 14,
335
+ "id": "3328eb96-de62-4fbe-9f05-f0266b22b69d",
336
+ "metadata": {},
337
+ "outputs": [
338
+ {
339
+ "name": "stdout",
340
+ "output_type": "stream",
341
+ "text": [
342
+ "Processing the graph, this may take a while. Please wait...\n",
343
+ "Executing processing graph\n",
344
+ "15%30%45%60%...70%..90% done.\n",
345
+ "SEVERE: org.esa.snap.runtime.Engine: Failed to modify class loader field 'usr_paths'\n",
346
+ "java.lang.NoSuchMethodException: java.lang.ClassLoader.initializePath(java.lang.String)\n",
347
+ "\tat java.base/java.lang.Class.getDeclaredMethod(Class.java:2848)\n",
348
+ "\tat org.esa.snap.runtime.Engine.setJavaLibraryPath(Engine.java:286)\n",
349
+ "\tat org.esa.snap.runtime.Engine.setJavaLibraryPath(Engine.java:265)\n",
350
+ "\tat org.esa.snap.runtime.Engine.<init>(Engine.java:46)\n",
351
+ "\tat org.esa.snap.runtime.Engine.start(Engine.java:117)\n",
352
+ "\tat org.esa.snap.runtime.Engine.start(Engine.java:90)\n",
353
+ "\tat org.esa.snap.runtime.Launcher.run(Launcher.java:51)\n",
354
+ "\tat org.esa.snap.runtime.Launcher.main(Launcher.java:31)\n",
355
+ "\tat java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)\n",
356
+ "\tat java.base/java.lang.reflect.Method.invoke(Method.java:580)\n",
357
+ "\tat com.exe4j.runtime.LauncherEngine.launch(LauncherEngine.java:84)\n",
358
+ "\tat com.exe4j.runtime.WinLauncher.main(WinLauncher.java:94)\n",
359
+ "\tat com.install4j.runtime.launcher.WinLauncher.main(WinLauncher.java:25)\n",
360
+ "\n",
361
+ "INFO: org.esa.snap.core.gpf.operators.tooladapter.ToolAdapterIO: Initializing external tool adapters\n",
362
+ "INFO: org.esa.snap.core.util.EngineVersionCheckActivator: Please check regularly for new updates for the best SNAP experience.\n",
363
+ "WARNING: org.esa.snap.dataio.netcdf.util.MetadataUtils: Missing configuration property 'snap.dataio.netcdf.metadataElementLimit'. Using default (100).\n",
364
+ "4280 [main] INFO serverStartup - Nc4Iosp: NetCDF-4 C library loaded (jna_path='C:\\Users\\olafd\\.snap\\auxdata\\netcdf_natives\\12.0.0.0\\amd64', libname='netcdf').\n",
365
+ "4287 [main] INFO serverStartup - NetcdfLoader: set log level: old=0 new=0\n",
366
+ "4287 [main] INFO serverStartup - Nc4Iosp: set log level: old=0 new=0\n",
367
+ "Processing finished successfully.\n"
368
+ ]
369
+ },
370
+ {
371
+ "data": {
372
+ "text/plain": [
373
+ "0"
374
+ ]
375
+ },
376
+ "execution_count": 14,
377
+ "metadata": {},
378
+ "output_type": "execute_result"
379
+ }
380
+ ],
381
+ "source": [
382
+ "# Save graph as XML file, then run it...\n",
383
+ "\n",
384
+ "g.save_graph('./data/snapista_demo_bandmaths.xml')\n",
385
+ "g.run()"
386
+ ]
387
+ },
388
+ {
389
+ "cell_type": "code",
390
+ "execution_count": null,
391
+ "id": "eaef2574-6a7d-484b-86f9-69f8f4b531e3",
392
+ "metadata": {},
393
+ "outputs": [],
394
+ "source": []
395
+ }
396
+ ],
397
+ "metadata": {
398
+ "kernelspec": {
399
+ "display_name": "Python 3 (ipykernel)",
400
+ "language": "python",
401
+ "name": "python3"
402
+ },
403
+ "language_info": {
404
+ "codemirror_mode": {
405
+ "name": "ipython",
406
+ "version": 3
407
+ },
408
+ "file_extension": ".py",
409
+ "mimetype": "text/x-python",
410
+ "name": "python",
411
+ "nbconvert_exporter": "python",
412
+ "pygments_lexer": "ipython3",
413
+ "version": "3.11.9"
414
+ }
415
+ },
416
+ "nbformat": 4,
417
+ "nbformat_minor": 5
418
+ }