aboutsummaryrefslogtreecommitdiff
path: root/metchart
diff options
context:
space:
mode:
authorGravatar Jonas Gunz <himself@jonasgunz.de> 2024-10-18 02:04:08 +0200
committerGravatar Jonas Gunz <himself@jonasgunz.de> 2024-10-18 02:04:08 +0200
commit274df86d989203823967bf34109801d30335a61d (patch)
tree9bfeaf5dc9447d6b96bb46b66f8b20997ed48bb5 /metchart
parent178138d4412aba7379393872c070b3718c94d58f (diff)
downloadmeteo_toolbox-274df86d989203823967bf34109801d30335a61d.tar.gz
add customization
Diffstat (limited to 'metchart')
-rw-r--r--metchart/customization.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/metchart/customization.py b/metchart/customization.py
new file mode 100644
index 0000000..84fc546
--- /dev/null
+++ b/metchart/customization.py
@@ -0,0 +1,32 @@
+from metpy.units import units
+
+import matplotlib as mpl
+from matplotlib.colors import LinearSegmentedColormap
+
+def register_colormaps():
+ # Define custom colormap
+ clcov_cmap = {
+ 'red': (
+ (0.0, 0.0, 0.0),
+ (0.1, 0.9, 0.9),
+ (1.0, 0.3, 0.3),
+ ),
+ 'green': (
+ (0.0, 0.5, 0.5),
+ (0.1, 0.9, 0.9),
+ (1.0, 0.3, 0.3),
+ ),
+ 'blue': (
+ (0.0, 0.9, 0.9),
+ (0.1, 0.9, 0.9),
+ (1.0, 0.3, 0.3),
+ ),
+ }
+
+ mpl.colormaps.register(LinearSegmentedColormap('clcov', clcov_cmap))
+
+def register_units():
+ # Define custom gpm and gpdm units. The default gpm in metpy is aliased to meter.
+ # We need the correct definition
+ units.define('_gpm = 9.80665 * J/kg')
+ units.define('_gpdm = 10 * _gpm')