Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add cmap for tornadoes #447

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion raster_api/runtime/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
24 changes: 23 additions & 1 deletion raster_api/runtime/src/cmap_data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,26 @@ 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 json

# 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 = {int(i):parse_color(tornado_ef_scale[i]) for i in tornado_ef_scale}

with open('tornado_ef_scale.json', 'w') as f:
json.dump(cmap, f)
1 change: 1 addition & 0 deletions raster_api/runtime/src/cmap_data/tornado_ef_scale.json
Original file line number Diff line number Diff line change
@@ -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]}
3 changes: 2 additions & 1 deletion raster_api/runtime/src/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Loading