From c2337f3d9573ffadb0bca01377ebc43746a67afd Mon Sep 17 00:00:00 2001 From: smohiudd Date: Fri, 22 Nov 2024 13:00:23 -0700 Subject: [PATCH 1/4] cmap for tornadoes --- raster_api/runtime/src/cmap_data/README.md | 25 ++++++++++++++++++ .../runtime/src/cmap_data/tornadoes.npy | Bin 0 -> 1152 bytes 2 files changed, 25 insertions(+) create mode 100644 raster_api/runtime/src/cmap_data/tornadoes.npy diff --git a/raster_api/runtime/src/cmap_data/README.md b/raster_api/runtime/src/cmap_data/README.md index 1a489350..b86363a6 100644 --- a/raster_api/runtime/src/cmap_data/README.md +++ b/raster_api/runtime/src/cmap_data/README.md @@ -109,4 +109,29 @@ for k in texture_categories.keys(): cmap[int(k)] = np.array(parse_color(texture_categories[k])) np.save("soil_texture.npy", cmap) +``` + +##### Tornadoes colormap + +```python +from rio_tiler.colormap import parse_color +import numpy as np + +# Colormap for Enhanced Fujita (EF) scale ratings +tornado_ef_scale = { + "-1": "#b3bcc9", + "0": "#add8e6", + "1": "#90ee90", + "2": "#ffe71f", + "3": "#ffa500", + "4": "#ff0000", + "5": "#ff00ff" +} + +cmap = np.zeros((256, 4), dtype=np.uint8) +cmap[:] = np.array([0, 0, 0, 255]) +for k in tornado_ef_scale.keys(): + cmap[int(k)] = np.array(parse_color(tornado_ef_scale[k])) + +np.save("tornadoes.npy", cmap) ``` \ No newline at end of file diff --git a/raster_api/runtime/src/cmap_data/tornadoes.npy b/raster_api/runtime/src/cmap_data/tornadoes.npy new file mode 100644 index 0000000000000000000000000000000000000000..85dee39a656c4905dd7559831246c1e648707970 GIT binary patch literal 1152 zcmbR27wQ`j$;eQ~P_3SlTAW;@Zl$1JQ);NLqoAIaUsO_*m=~X4l#&V(cT3DEP6dh= zXCxM+0{I$7re-<{CYm}5wF+bcuC+Iw{h#n|!vFuz<^TU*%JBa`0|N&o-= literal 0 HcmV?d00001 From a215fe0c9a50f4ec1e1dabf51d05b68f7d5929e7 Mon Sep 17 00:00:00 2001 From: smohiudd Date: Wed, 27 Nov 2024 11:44:44 -0700 Subject: [PATCH 2/4] include colormap json file --- raster_api/runtime/setup.py | 2 +- raster_api/runtime/src/cmap_data/README.md | 11 ++++------- .../runtime/src/cmap_data/tornado_ef_scale.json | 1 + raster_api/runtime/src/cmap_data/tornadoes.npy | Bin 1152 -> 0 bytes raster_api/runtime/src/dependencies.py | 3 ++- 5 files changed, 8 insertions(+), 9 deletions(-) create mode 100644 raster_api/runtime/src/cmap_data/tornado_ef_scale.json delete mode 100644 raster_api/runtime/src/cmap_data/tornadoes.npy diff --git a/raster_api/runtime/setup.py b/raster_api/runtime/setup.py index d2860fc8..28f92b43 100644 --- a/raster_api/runtime/setup.py +++ b/raster_api/runtime/setup.py @@ -7,7 +7,7 @@ inst_reqs = [ "boto3", - "rio-tiler==6.5.0", + "rio-tiler==7.2.2", "titiler.pgstac==1.3.0", "titiler.core>=0.18.5,<0.19", "titiler.mosaic>=0.18.5,<0.19", diff --git a/raster_api/runtime/src/cmap_data/README.md b/raster_api/runtime/src/cmap_data/README.md index b86363a6..2377adca 100644 --- a/raster_api/runtime/src/cmap_data/README.md +++ b/raster_api/runtime/src/cmap_data/README.md @@ -115,7 +115,7 @@ np.save("soil_texture.npy", cmap) ```python from rio_tiler.colormap import parse_color -import numpy as np +import json # Colormap for Enhanced Fujita (EF) scale ratings tornado_ef_scale = { @@ -128,10 +128,7 @@ tornado_ef_scale = { "5": "#ff00ff" } -cmap = np.zeros((256, 4), dtype=np.uint8) -cmap[:] = np.array([0, 0, 0, 255]) -for k in tornado_ef_scale.keys(): - cmap[int(k)] = np.array(parse_color(tornado_ef_scale[k])) +cmap = {int(i):parse_color(tornado_ef_scale[i]) for i in tornado_ef_scale} -np.save("tornadoes.npy", cmap) -``` \ No newline at end of file +with open('tornado_ef_scale.json', 'w') as f: + json.dump(cmap, f) \ No newline at end of file diff --git a/raster_api/runtime/src/cmap_data/tornado_ef_scale.json b/raster_api/runtime/src/cmap_data/tornado_ef_scale.json new file mode 100644 index 00000000..f6d9c9d6 --- /dev/null +++ b/raster_api/runtime/src/cmap_data/tornado_ef_scale.json @@ -0,0 +1 @@ +{"-1": [179, 188, 201, 255], "0": [173, 216, 230, 255], "1": [144, 238, 144, 255], "2": [255, 231, 31, 255], "3": [255, 165, 0, 255], "4": [255, 0, 0, 255], "5": [255, 0, 255, 255]} \ No newline at end of file diff --git a/raster_api/runtime/src/cmap_data/tornadoes.npy b/raster_api/runtime/src/cmap_data/tornadoes.npy deleted file mode 100644 index 85dee39a656c4905dd7559831246c1e648707970..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1152 zcmbR27wQ`j$;eQ~P_3SlTAW;@Zl$1JQ);NLqoAIaUsO_*m=~X4l#&V(cT3DEP6dh= zXCxM+0{I$7re-<{CYm}5wF+bcuC+Iw{h#n|!vFuz<^TU*%JBa`0|N&o-= diff --git a/raster_api/runtime/src/dependencies.py b/raster_api/runtime/src/dependencies.py index cee0a08b..1e97d3cf 100644 --- a/raster_api/runtime/src/dependencies.py +++ b/raster_api/runtime/src/dependencies.py @@ -10,8 +10,9 @@ # Try backported to PY<39 `importlib_resources`. from importlib_resources import files as resources_files # type: ignore + VEDA_CMAPS_FILES = { - f.stem: str(f) for f in (resources_files(__package__) / "cmap_data").glob("*.npy") # type: ignore + f.stem: str(f) for f in (resources_files(__package__) / "cmap_data").glob("*.[npy json]*") # type: ignore } cmap = default_cmap.register(VEDA_CMAPS_FILES) ColorMapParams = create_colormap_dependency(cmap) From 480dbe3acd1d12412fb6ceed75db0ae4851fbcf7 Mon Sep 17 00:00:00 2001 From: smohiudd Date: Fri, 29 Nov 2024 10:24:29 -0700 Subject: [PATCH 3/4] Revert "include colormap json file" This reverts commit a215fe0c9a50f4ec1e1dabf51d05b68f7d5929e7. --- raster_api/runtime/setup.py | 2 +- raster_api/runtime/src/cmap_data/README.md | 11 +++++++---- .../runtime/src/cmap_data/tornado_ef_scale.json | 1 - raster_api/runtime/src/cmap_data/tornadoes.npy | Bin 0 -> 1152 bytes raster_api/runtime/src/dependencies.py | 3 +-- 5 files changed, 9 insertions(+), 8 deletions(-) delete mode 100644 raster_api/runtime/src/cmap_data/tornado_ef_scale.json create mode 100644 raster_api/runtime/src/cmap_data/tornadoes.npy diff --git a/raster_api/runtime/setup.py b/raster_api/runtime/setup.py index 28f92b43..d2860fc8 100644 --- a/raster_api/runtime/setup.py +++ b/raster_api/runtime/setup.py @@ -7,7 +7,7 @@ inst_reqs = [ "boto3", - "rio-tiler==7.2.2", + "rio-tiler==6.5.0", "titiler.pgstac==1.3.0", "titiler.core>=0.18.5,<0.19", "titiler.mosaic>=0.18.5,<0.19", diff --git a/raster_api/runtime/src/cmap_data/README.md b/raster_api/runtime/src/cmap_data/README.md index 2377adca..b86363a6 100644 --- a/raster_api/runtime/src/cmap_data/README.md +++ b/raster_api/runtime/src/cmap_data/README.md @@ -115,7 +115,7 @@ np.save("soil_texture.npy", cmap) ```python from rio_tiler.colormap import parse_color -import json +import numpy as np # Colormap for Enhanced Fujita (EF) scale ratings tornado_ef_scale = { @@ -128,7 +128,10 @@ tornado_ef_scale = { "5": "#ff00ff" } -cmap = {int(i):parse_color(tornado_ef_scale[i]) for i in tornado_ef_scale} +cmap = np.zeros((256, 4), dtype=np.uint8) +cmap[:] = np.array([0, 0, 0, 255]) +for k in tornado_ef_scale.keys(): + cmap[int(k)] = np.array(parse_color(tornado_ef_scale[k])) -with open('tornado_ef_scale.json', 'w') as f: - json.dump(cmap, f) \ No newline at end of file +np.save("tornadoes.npy", cmap) +``` \ No newline at end of file diff --git a/raster_api/runtime/src/cmap_data/tornado_ef_scale.json b/raster_api/runtime/src/cmap_data/tornado_ef_scale.json deleted file mode 100644 index f6d9c9d6..00000000 --- a/raster_api/runtime/src/cmap_data/tornado_ef_scale.json +++ /dev/null @@ -1 +0,0 @@ -{"-1": [179, 188, 201, 255], "0": [173, 216, 230, 255], "1": [144, 238, 144, 255], "2": [255, 231, 31, 255], "3": [255, 165, 0, 255], "4": [255, 0, 0, 255], "5": [255, 0, 255, 255]} \ No newline at end of file diff --git a/raster_api/runtime/src/cmap_data/tornadoes.npy b/raster_api/runtime/src/cmap_data/tornadoes.npy new file mode 100644 index 0000000000000000000000000000000000000000..85dee39a656c4905dd7559831246c1e648707970 GIT binary patch literal 1152 zcmbR27wQ`j$;eQ~P_3SlTAW;@Zl$1JQ);NLqoAIaUsO_*m=~X4l#&V(cT3DEP6dh= zXCxM+0{I$7re-<{CYm}5wF+bcuC+Iw{h#n|!vFuz<^TU*%JBa`0|N&o-= literal 0 HcmV?d00001 diff --git a/raster_api/runtime/src/dependencies.py b/raster_api/runtime/src/dependencies.py index 1e97d3cf..cee0a08b 100644 --- a/raster_api/runtime/src/dependencies.py +++ b/raster_api/runtime/src/dependencies.py @@ -10,9 +10,8 @@ # Try backported to PY<39 `importlib_resources`. from importlib_resources import files as resources_files # type: ignore - VEDA_CMAPS_FILES = { - f.stem: str(f) for f in (resources_files(__package__) / "cmap_data").glob("*.[npy json]*") # type: ignore + f.stem: str(f) for f in (resources_files(__package__) / "cmap_data").glob("*.npy") # type: ignore } cmap = default_cmap.register(VEDA_CMAPS_FILES) ColorMapParams = create_colormap_dependency(cmap) From f10e2546e530f4306f765866882efff7ac78e367 Mon Sep 17 00:00:00 2001 From: smohiudd Date: Fri, 29 Nov 2024 10:29:48 -0700 Subject: [PATCH 4/4] fix tornado ef colorscale value --- raster_api/runtime/src/cmap_data/README.md | 16 ++++++++-------- .../{tornadoes.npy => tornado_ef_scale.npy} | Bin 1152 -> 1152 bytes 2 files changed, 8 insertions(+), 8 deletions(-) rename raster_api/runtime/src/cmap_data/{tornadoes.npy => tornado_ef_scale.npy} (88%) diff --git a/raster_api/runtime/src/cmap_data/README.md b/raster_api/runtime/src/cmap_data/README.md index b86363a6..1ad7b09e 100644 --- a/raster_api/runtime/src/cmap_data/README.md +++ b/raster_api/runtime/src/cmap_data/README.md @@ -119,13 +119,13 @@ import numpy as np # Colormap for Enhanced Fujita (EF) scale ratings tornado_ef_scale = { - "-1": "#b3bcc9", - "0": "#add8e6", - "1": "#90ee90", - "2": "#ffe71f", - "3": "#ffa500", - "4": "#ff0000", - "5": "#ff00ff" + "0": "#add8e6", #EF0 + "1": "#90ee90", #EF1 + "2": "#ffe71f", #EF2 + "3": "#ffa500", #EF3 + "4": "#ff0000", #EF4 + "5": "#ff00ff", #EF5 + "6": "#b3bcc9", #EFU } cmap = np.zeros((256, 4), dtype=np.uint8) @@ -133,5 +133,5 @@ cmap[:] = np.array([0, 0, 0, 255]) for k in tornado_ef_scale.keys(): cmap[int(k)] = np.array(parse_color(tornado_ef_scale[k])) -np.save("tornadoes.npy", cmap) +np.save("tornado_ef_scale.npy", cmap) ``` \ No newline at end of file diff --git a/raster_api/runtime/src/cmap_data/tornadoes.npy b/raster_api/runtime/src/cmap_data/tornado_ef_scale.npy similarity index 88% rename from raster_api/runtime/src/cmap_data/tornadoes.npy rename to raster_api/runtime/src/cmap_data/tornado_ef_scale.npy index 85dee39a656c4905dd7559831246c1e648707970..f91528143491a9fe4c92d2a08d4bbba1cd91a032 100644 GIT binary patch delta 17 ZcmZqRY~Y+QgL(6wlN;yXWuCZ!0{}yt2k!s? delta 18 acmZqRY~Y+QW8;Dc%o8`Tux#FQ@;?Ad<_PZq