The cleopatra preset library, through Digital-Earth¶
cleopatra 0.31 ships a library of ~200 named parameter presets (cleopatra.styling.colors.DATA_STYLES). Each preset bundles a colormap, a normalization, and a human label tuned for a specific geophysical variable — elevation, sea-surface temperature, radar reflectivity, aerosol optical depth, and so on.
Digital-Earth exposes the whole library through one keyword: pass style="<preset>" to any raster method (field, contours, pcolormesh, grid_cells, …) and the map picks up that preset's colormap and label. This notebook tours the library; the siblings drill into domains, palettes, and colour scaling.
%matplotlib inline
from pathlib import Path
import numpy as np
from pyramids.dataset import Dataset
from digitalearth.static import Map, grid
from cleopatra.styling.colors import DATA_STYLES
DATA = Path('../../../examples/data') # notebook-relative path (docs/examples/presets -> repo root)
dem = Dataset.read_file(str(DATA / 'LisbonElevation.tif')) # a small bundled DEM (EPSG:4326)
dem
Driver: GTiff/GeoTIFF
Files: ../../../examples/data/LisbonElevation.tif
Size is 547, 421
Coordinate System is:
GEOGCRS["WGS 84",
ENSEMBLE["World Geodetic System 1984 ensemble",
MEMBER["World Geodetic System 1984 (Transit)"],
MEMBER["World Geodetic System 1984 (G730)"],
MEMBER["World Geodetic System 1984 (G873)"],
MEMBER["World Geodetic System 1984 (G1150)"],
MEMBER["World Geodetic System 1984 (G1674)"],
MEMBER["World Geodetic System 1984 (G1762)"],
MEMBER["World Geodetic System 1984 (G2139)"],
MEMBER["World Geodetic System 1984 (G2296)"],
ELLIPSOID["WGS 84",6378137,298.257223563,
LENGTHUNIT["metre",1]],
ENSEMBLEACCURACY[2.0]],
PRIMEM["Greenwich",0,
ANGLEUNIT["degree",0.0174532925199433]],
CS[ellipsoidal,2],
AXIS["geodetic latitude (Lat)",north,
ORDER[1],
ANGLEUNIT["degree",0.0174532925199433]],
AXIS["geodetic longitude (Lon)",east,
ORDER[2],
ANGLEUNIT["degree",0.0174532925199433]],
USAGE[
SCOPE["Horizontal component of 3D system."],
AREA["World."],
BBOX[-90,-180,90,180]],
ID["EPSG",4326]]
Data axis to CRS axis mapping: 2,1
Origin = (-9.238194440498766,38.796805547328496)
Pixel Size = (0.000277777777839,-0.000277777778395)
Metadata:
AREA_OR_POINT=Area
Image Structure Metadata:
INTERLEAVE=BAND
Corner Coordinates:
Upper Left ( -9.2381944, 38.7968055) ( 9d14'17.50"W, 38d47'48.50"N)
Lower Left ( -9.2381944, 38.6798611) ( 9d14'17.50"W, 38d40'47.50"N)
Upper Right ( -9.0862500, 38.7968055) ( 9d 5'10.50"W, 38d47'48.50"N)
Lower Right ( -9.0862500, 38.6798611) ( 9d 5'10.50"W, 38d40'47.50"N)
Center ( -9.1622222, 38.7383333) ( 9d 9'44.00"W, 38d44'18.00"N)
Band 1 Block=547x3 Type=Float32, ColorInterp=Gray
What is in the library¶
Every preset is a named entry cleopatra resolves from DATA_STYLES. They span terrain, weather, ocean, atmospheric-composition and radar families, plus the full set of perceptually-uniform scientific colour maps (batlow, broc, hawaii, davos, …).
presets = sorted({sub for v in DATA_STYLES.values() if isinstance(v, dict) for sub in v})
print(len(presets), 'presets available')
print('examples:', presets[:16])
201 presets available examples: ['acton', 'aerosol_optical_depth_550nm', 'air_temperature', 'anomaly', 'aod', 'bam', 'bamO', 'bamako', 'bathymetry', 'batlow', 'batlowK', 'batlowW', 'berlin', 'bilbao', 'broc', 'brocO']
One field, many presets¶
The quickest way to feel the library is to render the same elevation field under a spread of presets. digitalearth.static.grid lays out a grid of shared-CRS maps; each panel just calls field(dem, style=...).
show = ['elevation', 'bathymetry', 'batlow', 'hawaii', 'broc',
'davos', 'grayC', 'temperature', 'anomaly']
fig, maps = grid(3, 3, crs=dem.epsg, figsize=(13, 11))
for m, preset in zip(maps, show):
m.field(dem, style=preset)
m.set_title(preset)
fig;
A preset carries its label¶
A preset is more than a colormap — it also knows what it is plotting. Rendering one on its own and adding a colorbar shows the preset's colormap and its label together.
m = Map(crs=dem.epsg, figsize=(9, 7))
m.field(dem, style='elevation')
m.colorbar(label='elevation (m)')
m.set_title("style='elevation'")
m.fig;
Presets are just a keyword — the next notebooks pair them with matching data (02_domain_presets), show the palette builders behind them (03_palettes_and_colormaps), and drive the colour scaling and terrain shading (04_color_scaling_and_terrain).