Skip to content

Commit

Permalink
Norman's review adressed
Browse files Browse the repository at this point in the history
  • Loading branch information
konstntokas committed Aug 7, 2024
1 parent af66aef commit f6a816b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
4 changes: 3 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
(#935, #940)

* xcube serve now allows to configure custom color maps via the configuration file.
It supports continuous, stepwise and categorical colormaps. (#1055)
It supports continuous, stepwise and categorical colormaps, which may be
configured as shown in the [section CustomColorMaps of the xcube serve documentation](docs/source/cli/xcube_serve.rst/`customcolormaps`)
(#1055)

### Fixes

Expand Down
13 changes: 10 additions & 3 deletions docs/source/cli/xcube_serve.rst
Original file line number Diff line number Diff line change
Expand Up @@ -672,9 +672,16 @@ CustomColorMaps [optional]
In this section, the user can customize colormaps. Xcube server supports three types
of colormaps, namely

* Continuous
* Stepwise
* Categorical
* Continuous: Continuous color assignment, where each <value> represents a support
point of a color gradient.
* Stepwise: Stepwise color mapping where values within the range of two subsequent
<value>s are mapped to the same color. A <color> gets associated with the first
<value> of each boundary range, while the last color gets ignored.
* Categorical: Values represent unique categories or indexes that are mapped to a color.
The data and the <value> must be of type integer. If a category does not have a
<value> in the color mapping, it will be displayed as transparent. Suitable for
categorical datasets.


which can be configured as shown below:

Expand Down
4 changes: 2 additions & 2 deletions xcube/util/cmaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def __init__(
cmap_alpha: Optional[matplotlib.colors.Colormap] = None,
norm: Optional[matplotlib.colors.Normalize] = None,
values: Optional[Sequence[Union[int, float]]] = None,
cm_code: Optional[str] = None,
cm_code: Optional[dict[str, Any]] = None,
):
assert_instance(cm_name, str)
if cm_type is None:
Expand Down Expand Up @@ -536,7 +536,7 @@ def parse_cm_code(cm_code: str) -> tuple[str, Optional[Colormap]]:
cat_name=CUSTOM_CATEGORY.name,
cmap=cmap,
values=values,
cm_code=cm_code,
cm_code=user_color_map,
)
except (SyntaxError, KeyError, ValueError, TypeError):
# If we arrive here, the submitted user-specific cm_code is wrong
Expand Down

0 comments on commit f6a816b

Please sign in to comment.