API
- One C core with bindings for Python, R, Julia and JavaScript, all reading the same files.
A Rumi file is written once from frames that GeoZL has already compressed, and read many times by window, band and time step. Python, R and Julia write and read. C is the library every binding calls. JavaScript reads. The examples run these calls end to end.
Write, then read
import numpy as np
import rumi
image = np.random.default_rng(0).integers(0, 4096, (4, 1024, 1024), dtype=np.uint16)
frames = rumi.frames(image, "b (row h) (col w) -> row col (b h w)", tile_size=512)
for frame in frames:
graph = rumi.geozl.graph(frame.data, "planar>zigzag>lanes")
frame.compressed = rumi.geozl.compress(frame.data, graph)
header = rumi.write("scene.rumi", frames, bands=["B2", "B3", "B4", "B8"],
time=["2024-08-25"])
chip = rumi.read("scene.rumi", header, bands=[2, 3], window=(0, 0, 256, 256))
library(rumi)
image <- array(sample(0:4095, 1024 * 1024 * 4, replace = TRUE), c(1024, 1024, 4))
frames <- rumi_frames(image, "b (row h) (col w) -> row col (b h w)", tile_size = 512,
dtype = "uint16")
for (i in seq_along(frames$data)) {
graph <- rumi_geozl_graph(frames$data[[i]], "planar>zigzag>lanes", dtype = "uint16")
frames$compressed[[i]] <- rumi_geozl_compress(frames$data[[i]], graph)
}
header <- rumi_write("scene.rumi", frames, bands = c("B2", "B3", "B4", "B8"),
time = "2024-08-25")
chip <- rumi_read("scene.rumi", header, bands = c(3, 4), window = c(1, 1, 256, 256))
using Random, Rumi
using Rumi: GeoZL
image = rand(Xoshiro(0), UInt16(0):UInt16(4095), 1024, 1024, 4)
frames = Rumi.frames(image, "b (row h) (col w) -> row col (b h w)"; tile_size = 512)
for (i, tile) in enumerate(frames.data)
graph = GeoZL.graph(tile, "planar>zigzag>lanes")
frames.compressed[i] = GeoZL.compress(tile, graph)
end
header = Rumi.write("scene.rumi", frames; bands = ["B2", "B3", "B4", "B8"],
time = ["2024-08-25"])
chip = Rumi.read("scene.rumi", header; bands = [3, 4], window = (1, 1, 256, 256))
frames cuts the image into tiles, the loop compresses each one with GeoZL, and write stores the payloads as they are. write also returns the external header, a few dozen bytes that a reader needs before it opens the file. Keep it beside the path, in a catalog or a dataset index.
The same read can land on a GPU. With framework="torch" and device="cuda:0", or device="mps" on a Mac, GeoZL decodes the frames that end in PFOR or PivCo on the device and writes the samples straight into the tensor. Other frames decode on the CPU and are copied over.
Languages
| Python | Write and read, with windows, batches and GPU reads into PyTorch, JAX or TensorFlow. pip install rumi-eo |
|---|---|
| C | The library every binding calls, in rumi.h, with CPU, GPU and DLPack reads and the writer. |
| R | Write and read, with one-based indices and native (X, Y, Band, Time) arrays. install.packages("rumi", repos = "https://asterisk-labs.r-universe.dev") |
| Julia | Write and read, with one-based indices and native (X, Y, Band, Time) arrays. Pkg.add("Rumi") from the Asterisk registry |
| JavaScript | A reader that opens a whole .rumi file and fetches only the byte ranges it needs. npm install @asterisk-labs/rumi |
Python and JavaScript count from zero and return (Time, Band, Y, X). R and Julia count from one and return (X, Y, Band, Time), the order their arrays use.