summaryrefslogtreecommitdiff
path: root/szilagyi/plots.py
blob: 31b8af2656fba12ef0d9b3e74b7a00f5667377ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import math

import matplotlib.pyplot as plot

from . import _dataset
from .nomogram import calculate_swi


MAX_X = 40
MAX_Y = 50000


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_X, width))
	Y = list(_grid(0, MAX_Y, height))
	for y in _scaled_range(height, MAX_Y):
		row = []
		for x in _scaled_range(width, MAX_X):
			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()