From 9ce45f363b7f8a094861496424a803532b48ae02 Mon Sep 17 00:00:00 2001 From: Olaf Veerman Date: Mon, 30 Nov 2020 11:09:02 +0000 Subject: [PATCH 1/5] Use correct opacity property Fix nasa-impact/covid-dashboard#482 --- covid_api/db/static/datasets/no2-diff.json | 3 +++ covid_api/db/static/datasets/no2.json | 3 +++ covid_api/db/static/datasets/recovery.json | 2 +- covid_api/db/static/datasets/slowdown.json | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/covid_api/db/static/datasets/no2-diff.json b/covid_api/db/static/datasets/no2-diff.json index b1691b7..4f71e91 100644 --- a/covid_api/db/static/datasets/no2-diff.json +++ b/covid_api/db/static/datasets/no2-diff.json @@ -11,6 +11,9 @@ "{api_url}/{z}/{x}/{y}@1x?url=s3://covid-eo-data/OMNO2d_HRMDifference/OMI_trno2_0.10x0.10_{date}_Col3_V4.nc.tif&resampling_method=bilinear&bidx=1&rescale=-8000000000000000%2C8000000000000000&color_map=rdbu_r" ] }, + "paint": { + "raster-opacity": 0.9 + }, "exclusive_with": [ "co2", "co2-diff", diff --git a/covid_api/db/static/datasets/no2.json b/covid_api/db/static/datasets/no2.json index 387e8ea..962abd6 100644 --- a/covid_api/db/static/datasets/no2.json +++ b/covid_api/db/static/datasets/no2.json @@ -11,6 +11,9 @@ "{api_url}/{z}/{x}/{y}@1x?url=s3://covid-eo-data/OMNO2d_HRM/OMI_trno2_0.10x0.10_{date}_Col3_V4.nc.tif&resampling_method=bilinear&bidx=1&rescale=0%2C1.5e16&color_map=custom_no2&color_formula=gamma r {gamma}" ] }, + "paint": { + "raster-opacity": 0.9 + }, "exclusive_with": [ "agriculture", "co2", diff --git a/covid_api/db/static/datasets/recovery.json b/covid_api/db/static/datasets/recovery.json index a6a6719..fd4980b 100644 --- a/covid_api/db/static/datasets/recovery.json +++ b/covid_api/db/static/datasets/recovery.json @@ -11,7 +11,7 @@ ] }, "paint": { - "raster_opacity": 0.9 + "raster-opacity": 0.9 }, "exclusiveWith": [ "agriculture", diff --git a/covid_api/db/static/datasets/slowdown.json b/covid_api/db/static/datasets/slowdown.json index 1e4df50..286dbbd 100644 --- a/covid_api/db/static/datasets/slowdown.json +++ b/covid_api/db/static/datasets/slowdown.json @@ -10,7 +10,7 @@ ] }, "paint": { - "raster_opacity": 0.9 + "raster-opacity": 0.9 }, "exclusiveWith": [ "agriculture", From ca3502c2cf6d0d840fd609672cd1073cdfea80a2 Mon Sep 17 00:00:00 2001 From: Leo Thomas Date: Mon, 30 Nov 2020 08:56:09 -0500 Subject: [PATCH 2/5] added underscore alias for `raster-opacity` --- covid_api/models/static.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/covid_api/models/static.py b/covid_api/models/static.py index d1d858d..646fbc1 100644 --- a/covid_api/models/static.py +++ b/covid_api/models/static.py @@ -69,11 +69,22 @@ class DatasetComparison(BaseModel): time_unit: Optional[str] +def snake_case_to_kebab_case(s): + """Util method to convert kebab-case fieldnames to snake_case.""" + return s.replace("_", "-") + + class Paint(BaseModel): """Paint Model.""" raster_opacity: int + class Config: + """Paint Model Config""" + + alias_generator = snake_case_to_kebab_case + allow_population_by_field_name = True + class Dataset(BaseModel): """Dataset Model.""" From c7fd0431503f6b32ea8acfb45d695bcc0953f833 Mon Sep 17 00:00:00 2001 From: Olaf Veerman Date: Mon, 30 Nov 2020 13:56:22 +0000 Subject: [PATCH 3/5] Load XCO2 base data from the correct path --- covid_api/db/static/datasets/co2.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/covid_api/db/static/datasets/co2.json b/covid_api/db/static/datasets/co2.json index 41aeb85..002e373 100644 --- a/covid_api/db/static/datasets/co2.json +++ b/covid_api/db/static/datasets/co2.json @@ -34,7 +34,7 @@ "source": { "type": "raster", "tiles": [ - "{api_url}/{z}/{x}/{y}@1x?url=s3://covid-eo-data/xco2/xco2_16day_base.{date}.tif&resampling_method=bilinear&bidx=1&rescale=0.000408%2C0.000419&color_map=rdylbu_r&color_formula=gamma r {gamma}" + "{api_url}/{z}/{x}/{y}@1x?url=s3://covid-eo-data/xco2-base/xco2_16day_base.{date}.tif&resampling_method=bilinear&bidx=1&rescale=0.000408%2C0.000419&color_map=rdylbu_r&color_formula=gamma r {gamma}" ] } }, From 7c8c739f908bf8391420c7199a015f301b8d80d6 Mon Sep 17 00:00:00 2001 From: Olaf Veerman Date: Mon, 30 Nov 2020 15:49:51 +0000 Subject: [PATCH 4/5] Bump to v0.3.2 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 0ed47df..8c64aed 100644 --- a/setup.py +++ b/setup.py @@ -41,7 +41,7 @@ setup( name="covid_api", - version="0.3.1", + version="0.3.2", description=u"", long_description=long_description, long_description_content_type="text/markdown", From c391befacd168692278ff797f49223a19171fd7b Mon Sep 17 00:00:00 2001 From: Olaf Veerman Date: Mon, 30 Nov 2020 16:48:24 +0000 Subject: [PATCH 5/5] Update the Nightlight VIIRS legend to match the color map Fix #NASA-IMPACT/covid-dashboard#473 --- covid_api/db/static/datasets/nightlights-viirs.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/covid_api/db/static/datasets/nightlights-viirs.json b/covid_api/db/static/datasets/nightlights-viirs.json index 51e0d67..38c152c 100644 --- a/covid_api/db/static/datasets/nightlights-viirs.json +++ b/covid_api/db/static/datasets/nightlights-viirs.json @@ -34,11 +34,11 @@ "min": "less", "max": "more", "stops": [ - "#08041d", - "#1f0a46", - "#52076c", - "#f57c16", - "#f7cf39" + "#440357", + "#3b508a", + "#208f8c", + "#5fc961", + "#fde725" ] }, "info": "Darker colors indicate fewer night lights and less activity. Lighter colors indicate more night lights and more activity. Check out the HD dataset below to see a light-corrected version of this dataset."