From b21b919b4fbdeeb93eb39afd2fa3efdfa4ff3035 Mon Sep 17 00:00:00 2001 From: usplm Date: Thu, 3 Feb 2022 14:46:38 -0500 Subject: [PATCH 01/15] Added NDWI formula --- app/api/formulas.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/api/formulas.py b/app/api/formulas.py index b4cfe9ae..52d15689 100644 --- a/app/api/formulas.py +++ b/app/api/formulas.py @@ -11,6 +11,10 @@ algos = { 'expr': '(N - R) / (N + R)', 'help': _('Normalized Difference Vegetation Index shows the amount of green vegetation.') }, + 'NDWI': { + 'expr': '(G - N) / (G + N)', + 'help': _('Normalized Difference Water Index shows the amount of water content in water bodies.') + }, 'NDVI (Blue)': { 'expr': '(N - B) / (N + B)', 'help': _('Normalized Difference Vegetation Index shows the amount of green vegetation.') @@ -22,7 +26,7 @@ algos = { 'vNDVI':{ 'expr': '0.5268*((R ** -0.1294) * (G ** 0.3389) * (B ** -0.3118))', 'help': _('Visible NDVI is an un-normalized index for RGB sensors using constants derived from citrus, grape, and sugarcane crop data.') - }, + }, 'VARI': { 'expr': '(G - R) / (G + R - B)', 'help': _('Visual Atmospheric Resistance Index shows the areas of vegetation.'), From dc80e4ca6daacf5183128e01ce719fd429b4e1f6 Mon Sep 17 00:00:00 2001 From: usplm Date: Thu, 3 Feb 2022 15:58:17 -0500 Subject: [PATCH 02/15] Added NDRE formula --- app/api/formulas.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/api/formulas.py b/app/api/formulas.py index 52d15689..75428017 100644 --- a/app/api/formulas.py +++ b/app/api/formulas.py @@ -11,6 +11,10 @@ algos = { 'expr': '(N - R) / (N + R)', 'help': _('Normalized Difference Vegetation Index shows the amount of green vegetation.') }, + 'NDRE': { + 'expr': '(N - Re) / (N + Re)', + 'help': _('Normalized Difference Red Edge Index shows the amount of green vegetation of permanent or later stage crops.') + }, 'NDWI': { 'expr': '(G - N) / (G + N)', 'help': _('Normalized Difference Water Index shows the amount of water content in water bodies.') From 3f0c989234eb11f535517531e29c1cfb4fd527de Mon Sep 17 00:00:00 2001 From: usplm Date: Thu, 3 Feb 2022 17:49:31 -0500 Subject: [PATCH 03/15] Added jet and perceptually uniform sequential colormaps to render orthophoto --- app/api/tiler.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/api/tiler.py b/app/api/tiler.py index 9b689d9a..13cc0136 100644 --- a/app/api/tiler.py +++ b/app/api/tiler.py @@ -209,6 +209,10 @@ class Metadata(TaskNestedView): "better_discrete_ndvi": "Custom NDVI Index", "rplumbo": "Rplumbo (Better NDVI)", "pastel1": "Pastel", + "plasma": "Plasma", + "inferno": "Inferno", + "magma": "Magma", + "cividis": "Cividis" } colormaps = [] @@ -217,7 +221,8 @@ class Metadata(TaskNestedView): colormaps = ['viridis', 'jet', 'terrain', 'gist_earth', 'pastel1'] elif formula and bands: colormaps = ['rdylgn', 'spectral', 'rdylgn_r', 'spectral_r', 'rplumbo', 'discrete_ndvi', - 'better_discrete_ndvi'] + 'better_discrete_ndvi', + 'viridis', 'plasma', 'inferno', 'magma', 'cividis', 'jet'] algorithms = *get_algorithm_list(band_count), info['color_maps'] = [] From fea52ed60385c460ccc428bdcded9bca9691c53e Mon Sep 17 00:00:00 2001 From: usplm Date: Mon, 14 Feb 2022 15:45:29 -0500 Subject: [PATCH 04/15] Added jet_r colormap --- app/api/tiler.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/api/tiler.py b/app/api/tiler.py index 13cc0136..3b083d9d 100644 --- a/app/api/tiler.py +++ b/app/api/tiler.py @@ -199,6 +199,7 @@ class Metadata(TaskNestedView): cmap_labels = { "viridis": "Viridis", "jet": "Jet", + "jet_r": "Jet (Reverse)", "terrain": "Terrain", "gist_earth": "Earth", "rdylgn": "RdYlGn", @@ -222,7 +223,7 @@ class Metadata(TaskNestedView): elif formula and bands: colormaps = ['rdylgn', 'spectral', 'rdylgn_r', 'spectral_r', 'rplumbo', 'discrete_ndvi', 'better_discrete_ndvi', - 'viridis', 'plasma', 'inferno', 'magma', 'cividis', 'jet'] + 'viridis', 'plasma', 'inferno', 'magma', 'cividis', 'jet', 'jet_r'] algorithms = *get_algorithm_list(band_count), info['color_maps'] = [] From 37745fd68b53e1c671d31b7ef9df5850b93eed0b Mon Sep 17 00:00:00 2001 From: usplm Date: Mon, 14 Feb 2022 15:43:48 -0500 Subject: [PATCH 05/15] Added Thermal formula --- app/api/formulas.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/api/formulas.py b/app/api/formulas.py index 75428017..c87e29da 100644 --- a/app/api/formulas.py +++ b/app/api/formulas.py @@ -95,6 +95,14 @@ algos = { 'help': _('Enhanced Vegetation Index is useful in areas where NDVI might saturate, by using blue wavelengths to correct soil signals.'), 'range': (-1, 1) }, + 'Thermal_C': { + 'expr': 'Ir', + 'help': _('Thermal temperature in Celsius degrees.') + }, + 'Thermal_cK': { + 'expr': 'Ir / 100 - 273.15', + 'help': _('Thermal temperature in Centikelvin degrees') + }, # more? @@ -123,6 +131,9 @@ camera_filters = [ 'RGBNRe', 'RGBReN', + 'BGRNReIr', + 'BGRReNIr', + # more? # TODO: certain cameras have only two bands? eg. MAPIR NDVI BLUE+NIR ] From 0e5d67bbdd23f2679af0fe683ee847fcc2cff2ad Mon Sep 17 00:00:00 2001 From: usplm Date: Tue, 10 May 2022 22:50:01 -0400 Subject: [PATCH 06/15] Added Gray formula --- app/api/formulas.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/api/formulas.py b/app/api/formulas.py index c87e29da..386164ed 100644 --- a/app/api/formulas.py +++ b/app/api/formulas.py @@ -101,7 +101,11 @@ algos = { }, 'Thermal_cK': { 'expr': 'Ir / 100 - 273.15', - 'help': _('Thermal temperature in Centikelvin degrees') + 'help': _('Thermal temperature in Centikelvin degrees.') + }, + 'Gray': { + 'expr': 'Gray * 1', + 'help': _('Single band grayscale imagery.') }, # more? @@ -117,6 +121,7 @@ algos = { } camera_filters = [ + 'Gray', 'RGB', 'RGN', 'NGB', From f379109a7b7b443fef486483e5fc42638a4876a0 Mon Sep 17 00:00:00 2001 From: usplm Date: Tue, 10 May 2022 22:52:19 -0400 Subject: [PATCH 07/15] Use Lwir as thermal band code --- app/api/formulas.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/api/formulas.py b/app/api/formulas.py index 386164ed..6b1ce200 100644 --- a/app/api/formulas.py +++ b/app/api/formulas.py @@ -96,11 +96,11 @@ algos = { 'range': (-1, 1) }, 'Thermal_C': { - 'expr': 'Ir', + 'expr': 'Lwir', 'help': _('Thermal temperature in Celsius degrees.') }, 'Thermal_cK': { - 'expr': 'Ir / 100 - 273.15', + 'expr': 'Lwir / 100 - 273.15', 'help': _('Thermal temperature in Centikelvin degrees.') }, 'Gray': { @@ -136,8 +136,8 @@ camera_filters = [ 'RGBNRe', 'RGBReN', - 'BGRNReIr', - 'BGRReNIr', + 'BGRNReLwir', + 'BGRReNLwir', # more? # TODO: certain cameras have only two bands? eg. MAPIR NDVI BLUE+NIR From df07b08748f0815947d2c4a428c51a5a4a16979a Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Wed, 6 Jul 2022 23:57:33 -0400 Subject: [PATCH 08/15] Remove gray formula --- app/api/formulas.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/app/api/formulas.py b/app/api/formulas.py index 6b1ce200..c2c972c6 100644 --- a/app/api/formulas.py +++ b/app/api/formulas.py @@ -103,10 +103,6 @@ algos = { 'expr': 'Lwir / 100 - 273.15', 'help': _('Thermal temperature in Centikelvin degrees.') }, - 'Gray': { - 'expr': 'Gray * 1', - 'help': _('Single band grayscale imagery.') - }, # more? @@ -121,7 +117,6 @@ algos = { } camera_filters = [ - 'Gray', 'RGB', 'RGN', 'NGB', From 719fffb772b8f6a9a901c573b4d6d113a7ad8e47 Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Thu, 7 Jul 2022 00:03:01 -0400 Subject: [PATCH 09/15] Updated number of workers and max requests --- start.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/start.sh b/start.sh index 6028f578..24dd5655 100755 --- a/start.sh +++ b/start.sh @@ -148,7 +148,7 @@ else congrats nginx -c $(pwd)/nginx/$conf - gunicorn webodm.wsgi --bind unix:/tmp/gunicorn.sock --timeout 300000 --max-requests 250 --workers $((2*$(grep -c '^processor' /proc/cpuinfo)+1)) --preload + gunicorn webodm.wsgi --bind unix:/tmp/gunicorn.sock --timeout 300000 --max-requests 500 --workers $((1*$(grep -c '^processor' /proc/cpuinfo)+1)) --preload fi # If this is executed, it means the previous command failed, don't display the congratulations message From 1100c28f941e25101d21759a6d79a1f9a595134e Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Thu, 7 Jul 2022 00:07:50 -0400 Subject: [PATCH 10/15] Rename Ir formulas --- app/api/formulas.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/api/formulas.py b/app/api/formulas.py index c2c972c6..b72027f2 100644 --- a/app/api/formulas.py +++ b/app/api/formulas.py @@ -95,11 +95,11 @@ algos = { 'help': _('Enhanced Vegetation Index is useful in areas where NDVI might saturate, by using blue wavelengths to correct soil signals.'), 'range': (-1, 1) }, - 'Thermal_C': { + 'Thermal C': { 'expr': 'Lwir', 'help': _('Thermal temperature in Celsius degrees.') }, - 'Thermal_cK': { + 'Thermal K': { 'expr': 'Lwir / 100 - 273.15', 'help': _('Thermal temperature in Centikelvin degrees.') }, From 43c9e686296cc5f40e2e1ce99db16a3b9d347d27 Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Thu, 7 Jul 2022 00:25:42 -0400 Subject: [PATCH 11/15] Handle undefined bands case --- app/static/app/js/components/LayersControlLayer.jsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/static/app/js/components/LayersControlLayer.jsx b/app/static/app/js/components/LayersControlLayer.jsx index bd6bf231..67b72efb 100644 --- a/app/static/app/js/components/LayersControlLayer.jsx +++ b/app/static/app/js/components/LayersControlLayer.jsx @@ -136,7 +136,9 @@ export default class LayersControlLayer extends React.Component { const algo = this.getAlgorithm(e.target.value); if (algo && algo['filters'].indexOf(bands) === -1) bands = algo['filters'][0]; // Pick first - this.setState({formula: e.target.value, bands}); + if (bands !== undefined){ + this.setState({formula: e.target.value, bands}); + } } getAlgorithm = id => { From 73b4acd8eec9b96e255c6b4e4e5f625e0f018e8f Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Thu, 7 Jul 2022 00:44:06 -0400 Subject: [PATCH 12/15] More stable get_algorithm_list --- app/api/formulas.py | 18 +++++++++++++++++- .../app/js/components/LayersControlLayer.jsx | 4 +--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/app/api/formulas.py b/app/api/formulas.py index b72027f2..d7d7de7b 100644 --- a/app/api/formulas.py +++ b/app/api/formulas.py @@ -164,7 +164,23 @@ def lookup_formula(algo, band_order = 'RGB'): @lru_cache(maxsize=2) def get_algorithm_list(max_bands=3): - return [{'id': k, 'filters': get_camera_filters_for(algos[k], max_bands), **algos[k]} for k in algos if not k.startswith("_")] + res = [] + for k in algos: + if k.startswith("_"): + continue + + cam_filters = get_camera_filters_for(algos[k], max_bands) + + if len(cam_filters) == 0: + continue + + res.append({ + 'id': k, + 'filters': cam_filters, + **algos[k] + }) + + return res def get_camera_filters_for(algo, max_bands=3): result = [] diff --git a/app/static/app/js/components/LayersControlLayer.jsx b/app/static/app/js/components/LayersControlLayer.jsx index 67b72efb..bd6bf231 100644 --- a/app/static/app/js/components/LayersControlLayer.jsx +++ b/app/static/app/js/components/LayersControlLayer.jsx @@ -136,9 +136,7 @@ export default class LayersControlLayer extends React.Component { const algo = this.getAlgorithm(e.target.value); if (algo && algo['filters'].indexOf(bands) === -1) bands = algo['filters'][0]; // Pick first - if (bands !== undefined){ - this.setState({formula: e.target.value, bands}); - } + this.setState({formula: e.target.value, bands}); } getAlgorithm = id => { From f9985b5ee7140c30c587d058cc51305312bd8869 Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Thu, 7 Jul 2022 01:16:43 -0400 Subject: [PATCH 13/15] Fix test --- app/tests/test_api_task.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/tests/test_api_task.py b/app/tests/test_api_task.py index d9da2118..2443fab1 100644 --- a/app/tests/test_api_task.py +++ b/app/tests/test_api_task.py @@ -531,7 +531,7 @@ class TestApiTask(BootTransactionTestCase): # Colormap is for algorithms self.assertEqual(len([x for x in metadata['color_maps'] if x['key'] == 'rdylgn']), 1) - self.assertEqual(len([x for x in metadata['color_maps'] if x['key'] == 'jet']), 0) + self.assertEqual(len([x for x in metadata['color_maps'] if x['key'] == 'pastel1']), 0) # Formula parameters are copied to tile URL self.assertTrue(metadata['tiles'][0].endswith('?formula=NDVI&bands=RGN')) From 775d9567062faeafb7cbdaa1fb9164159515f0aa Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Thu, 7 Jul 2022 01:42:52 -0400 Subject: [PATCH 14/15] Another test fix --- app/tests/test_api_task.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/tests/test_api_task.py b/app/tests/test_api_task.py index 2443fab1..743f77be 100644 --- a/app/tests/test_api_task.py +++ b/app/tests/test_api_task.py @@ -667,7 +667,7 @@ class TestApiTask(BootTransactionTestCase): for k in algos: a = algos[k] - filters = get_camera_filters_for(a) + filters = get_camera_filters_for(a, 6) self.assertTrue(len(filters) > 0, "%s has filters" % k) for f in filters: From ea83442b6b8c8e9913cbd0726b73e96cfe00e2fd Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Thu, 7 Jul 2022 02:14:00 -0400 Subject: [PATCH 15/15] Fix test --- app/tests/test_api_task.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/tests/test_api_task.py b/app/tests/test_api_task.py index 743f77be..57d7dc2b 100644 --- a/app/tests/test_api_task.py +++ b/app/tests/test_api_task.py @@ -667,8 +667,7 @@ class TestApiTask(BootTransactionTestCase): for k in algos: a = algos[k] - filters = get_camera_filters_for(a, 6) - self.assertTrue(len(filters) > 0, "%s has filters" % k) + filters = get_camera_filters_for(a) for f in filters: params.append(("orthophoto", "formula={}&bands={}&color_map=rdylgn".format(k, f), status.HTTP_200_OK))