import math import matplotlib.pyplot as plot from . import _dataset from ._nomogram import calculate_swi as _calculate_swi from ._nomogram import MAX_TEMPERATURE_DIFFERENCE, MAX_CONVECTIVE_CLOUD_DEPTH def _grid(start, end, steps): step = (end - start) / steps i = start while i < end or math.isclose(i, end): yield i i += step def _scaled_range(steps, maximum): step = maximum / steps for i in range(steps): yield i * step def colorful(width=1000, height=1000): C = [] X = list(_grid(0, MAX_TEMPERATURE_DIFFERENCE, width)) Y = list(_grid(0, MAX_CONVECTIVE_CLOUD_DEPTH, height)) for y in _scaled_range(height, MAX_CONVECTIVE_CLOUD_DEPTH): row = [] for x in _scaled_range(width, MAX_TEMPERATURE_DIFFERENCE): row.append(_calculate_swi(x, y)) C.append(row) plot.pcolormesh(X, Y, C, cmap='viridis', vmin=-10, vmax=10, rasterized=True) for _, data in _dataset.INDICES: plot.plot([x.x for x in data], [x.y for x in data]) plot.show() if __name__ == "__main__": colorful()