from __future__ import annotations
import math
from low_comm_tools.constants import CORRELATION_POLS
[docs]
def grid_dims(n: int) -> tuple[int, int]:
"""Return (nrows, ncols) for a roughly-square grid fitting n items."""
ncols = round(math.sqrt(n))
while ncols > 1 and n % ncols != 0:
ncols -= 1
if ncols == 1:
# n is prime or close to it — round up to next factorable number
m = n + 1
ncols = round(math.sqrt(m))
while ncols > 1 and m % ncols != 0:
ncols -= 1
nrows = math.ceil(n / ncols)
return nrows, ncols
[docs]
SKA_COLOURS_RGBA_DICT = {
CORRELATION_POLS[0]: (
0.8941176470588236,
0.0274509803921568,
0.4117647058823529,
1.00,
),
CORRELATION_POLS[1]: (
1.0000000000000000,
0.7529411764705882,
0.0000000000000000,
0.15,
),
CORRELATION_POLS[2]: (
0.3568627450980392,
0.6078431372549019,
0.8352941176470589,
0.15,
),
CORRELATION_POLS[3]: (
0.0274509803921568,
0.0392156862745098,
0.4078431372549019,
1.00,
),
}
[docs]
SKA_HEX_COLOURS = [
"#e40769",
"#070a68",
"#ffc000",
"#5b9bd5",
]