diff --git a/app/api/formulas.py b/app/api/formulas.py index b4cfe9ae..d7d7de7b 100644 --- a/app/api/formulas.py +++ b/app/api/formulas.py @@ -11,6 +11,14 @@ 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.') + }, 'NDVI (Blue)': { 'expr': '(N - B) / (N + B)', 'help': _('Normalized Difference Vegetation Index shows the amount of green vegetation.') @@ -22,7 +30,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.'), @@ -87,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': 'Lwir', + 'help': _('Thermal temperature in Celsius degrees.') + }, + 'Thermal K': { + 'expr': 'Lwir / 100 - 273.15', + 'help': _('Thermal temperature in Centikelvin degrees.') + }, # more? @@ -115,6 +131,9 @@ camera_filters = [ 'RGBNRe', 'RGBReN', + 'BGRNReLwir', + 'BGRReNLwir', + # more? # TODO: certain cameras have only two bands? eg. MAPIR NDVI BLUE+NIR ] @@ -145,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/api/tiler.py b/app/api/tiler.py index 9b689d9a..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", @@ -209,6 +210,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 +222,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', 'jet_r'] algorithms = *get_algorithm_list(band_count), info['color_maps'] = [] diff --git a/app/tests/test_api_task.py b/app/tests/test_api_task.py index d9da2118..57d7dc2b 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')) @@ -668,7 +668,6 @@ class TestApiTask(BootTransactionTestCase): for k in algos: a = algos[k] filters = get_camera_filters_for(a) - self.assertTrue(len(filters) > 0, "%s has filters" % k) for f in filters: params.append(("orthophoto", "formula={}&bands={}&color_map=rdylgn".format(k, f), status.HTTP_200_OK)) 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