From e2a685007651d8346d0bc58e6ec0488185d8865f Mon Sep 17 00:00:00 2001 From: Martin Schubert Date: Sun, 19 Oct 2025 16:28:58 -0700 Subject: [PATCH 1/3] avoid loading data --- src/ccmaps/ccmaps.py | 17 ++++++---- src/ccmaps/data/wbgyr.txt | 65 --------------------------------------- 2 files changed, 11 insertions(+), 71 deletions(-) delete mode 100644 src/ccmaps/data/wbgyr.txt diff --git a/src/ccmaps/ccmaps.py b/src/ccmaps/ccmaps.py index e30ef9b..5bdcbfd 100644 --- a/src/ccmaps/ccmaps.py +++ b/src/ccmaps/ccmaps.py @@ -4,15 +4,12 @@ """ import base64 -import pathlib import zlib from typing import Any, Sequence import numpy as onp from matplotlib import colors -_DATA_PATH = f"{pathlib.Path(__file__).resolve().parent}/data" - # Code is from https://github.com/rsmith-nl/wavelength_to_rgb. _CTBL = ( @@ -78,10 +75,18 @@ def cmap_for_wavelength( ) -WBGYR = colors.LinearSegmentedColormap.from_list( - name="wbgyr", - colors=onp.loadtxt(f"{_DATA_PATH}/wbgyr.txt", delimiter=","), +values = onp.asarray([0.000, 0.190, 0.397, 0.603, 0.810, 1.000]) +rgb = onp.asarray( + [ + [1.000, 1.000, 1.000], + [0.730, 0.830, 0.955], + [0.400, 1.000, 0.400], + [1.000, 1.000, 0.000], + [1.000, 0.000, 0.000], + [0.600, 0.200, 0.000], + ] ) +WBGYR = colors.LinearSegmentedColormap.from_list("wbgyr", list(zip(values, rgb))) """The white-blue-green-yellow-red colormap.""" diff --git a/src/ccmaps/data/wbgyr.txt b/src/ccmaps/data/wbgyr.txt deleted file mode 100644 index 543c6a8..0000000 --- a/src/ccmaps/data/wbgyr.txt +++ /dev/null @@ -1,65 +0,0 @@ -# https://github.com/flexcompute/metalens/blob/main/BGYR_cmp.txt -1,1,1 -0.97745,0.98595,0.99641 -0.9549,0.9719,0.99281 -0.93235,0.95784,0.98922 -0.9098,0.94379,0.98562 -0.88725,0.92974,0.98203 -0.86471,0.91569,0.97843 -0.84216,0.90163,0.97484 -0.81961,0.88758,0.97124 -0.79706,0.87353,0.96765 -0.77451,0.85948,0.96405 -0.75196,0.84542,0.96046 -0.72941,0.83137,0.95686 -0.70407,0.84434,0.91403 -0.67873,0.85732,0.87119 -0.65339,0.87029,0.82836 -0.62805,0.88326,0.78552 -0.60271,0.89623,0.74268 -0.57738,0.9092,0.69985 -0.55204,0.92217,0.65701 -0.5267,0.93514,0.61418 -0.50136,0.94811,0.57134 -0.47602,0.96109,0.52851 -0.45068,0.97406,0.48567 -0.42534,0.98703,0.44284 -0.4,1,0.4 -0.44615,1,0.36923 -0.49231,1,0.33846 -0.53846,1,0.30769 -0.58462,1,0.27692 -0.63077,1,0.24615 -0.67692,1,0.21538 -0.72308,1,0.18462 -0.76923,1,0.15385 -0.81538,1,0.12308 -0.86154,1,0.092308 -0.90769,1,0.061538 -0.95385,1,0.030769 -1,1,0 -1,0.92308,0 -1,0.84615,0 -1,0.76923,0 -1,0.69231,0 -1,0.61538,0 -1,0.53846,0 -1,0.46154,0 -1,0.38462,0 -1,0.30769,0 -1,0.23077,0 -1,0.15385,0 -1,0.076923,0 -1,0,0 -0.96667,0.016667,0 -0.93333,0.033333,0 -0.9,0.05,0 -0.86667,0.066667,0 -0.83333,0.083333,0 -0.8,0.1,0 -0.76667,0.11667,0 -0.73333,0.13333,0 -0.7,0.15,0 -0.66667,0.16667,0 -0.63333,0.18333,0 -0.6,0.2,0 From b5263e79ed41b8b54761cbca6eb80c5e8630810b Mon Sep 17 00:00:00 2001 From: Martin Schubert Date: Sun, 19 Oct 2025 16:30:40 -0700 Subject: [PATCH 2/3] isort formatting --- src/ccmaps/ccmaps.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ccmaps/ccmaps.py b/src/ccmaps/ccmaps.py index 5bdcbfd..c02f3eb 100644 --- a/src/ccmaps/ccmaps.py +++ b/src/ccmaps/ccmaps.py @@ -10,7 +10,6 @@ import numpy as onp from matplotlib import colors - # Code is from https://github.com/rsmith-nl/wavelength_to_rgb. _CTBL = ( b"eNrV0ltr0AUAxuHn1rqoiAqSiA6EEJ3ogBUJeeFFRUdJOjOyWau1bLZpGztnM1oyy" From e4eec233965d43ea85f373d0c7fab515100c3c5e Mon Sep 17 00:00:00 2001 From: Martin Schubert Date: Sun, 19 Oct 2025 16:31:39 -0700 Subject: [PATCH 3/3] Version updated from v0.1.0 to v0.2.0 --- .bumpversion.toml | 2 +- pyproject.toml | 2 +- src/ccmaps/__init__.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.bumpversion.toml b/.bumpversion.toml index d7d1979..3095f12 100644 --- a/.bumpversion.toml +++ b/.bumpversion.toml @@ -1,5 +1,5 @@ [tool.bumpversion] -current_version = "v0.1.0" +current_version = "v0.2.0" commit = true commit_args = "--no-verify" tag = true diff --git a/pyproject.toml b/pyproject.toml index b8db35a..6e9fc40 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "ccmaps" -version = "v0.1.0" +version = "v0.2.0" description = "A few custom matplotlib colormaps." keywords = ["matplotlib", "color"] readme = "README.md" diff --git a/src/ccmaps/__init__.py b/src/ccmaps/__init__.py index b458457..670406c 100644 --- a/src/ccmaps/__init__.py +++ b/src/ccmaps/__init__.py @@ -1,6 +1,6 @@ """ccmaps: A few custom colormaps for matplotlib.""" -__version__ = "v0.1.0" +__version__ = "v0.2.0" __author__ = "Martin F. Schubert " from .ccmaps import BKR as BKR