⚠️ Notice: This package is still under construction and not fully production ready yet. API changes may occur and some features might be incomplete.
This project provides JavaScript/TypeScript support for reading and processing OmFile format data efficiently. OmFile format is a scientific data format optimized for meteorological data from the Open-Meteo project.
The repository is structured into two separate packages:
- file-format-wasm: WebAssembly bindings for the OmFileFormat C library
- file-reader: JavaScript/TypeScript API for working with OmFile data
- Efficient reading of OmFile format data through WebAssembly
- Support for multiple data sources (local files, HTTP, in-memory, S3)
- Browser and Node.js compatibility
- TypeScript support
- High-performance data access to
.om
files
npm install @openmeteo/file-reader
Usage depends on the backend you want to use to access the data and the environment you are in (Node, Browser).
import { OmFileReader, FileBackendNode, OmDataType } from "@openmeteo/file-reader";
const backend = new FileBackendNode("/path/to/your/file.om");
const reader = await OmFileReader.create(backend);
// this selects all data of all dimensions
// If the array you are reading is too big, this might result in OOM
const readRanges = reader.getDimensions().map((dim) => {
return {
start: 0,
end: dim,
};
});
const data = await reader.read(OmDataType.FloatArray, readRanges);
console.log(data);
import { OmFileReader, FileBackend } from "@openmeteo/file-reader";
// Assume you have a <input type="file" id="fileInput" />
const fileInput = document.getElementById("fileInput");
fileInput.addEventListener("change", async (event) => {
const file = event.target.files[0];
const backend = new FileBackend(file);
const reader = await OmFileReader.create(backend);
// this selects all data of all dimensions
// If the array you are reading is too big, this might result in OOM
const readRanges = reader.getDimensions().map((dim) => {
return {
start: 0,
end: dim,
};
});
const data = await reader.read(OmDataType.FloatArray, readRanges);
console.log(data);
});
const buffer = new Uint8Array([...]); // Your OmFile data
const backend = new FileBackend(buffer);
const reader = await OmFileReader.create(backend);
import { MemoryHttpBackend, OmFileReader } from "@openmeteo/file-reader";
const backend = new MemoryHttpBackend({ url: "https://example.com/data.om" });
const reader = await OmFileReader.create(backend);
- Node.js 16+
- Docker (for building the WebAssembly component)
# Clone the repository with submodules
git clone --recursive https://github.com/open-meteo/typescript-omfiles.git
# Install dependencies
npm install
# This will use docker emscripten/emsdk container
# to compile the C code to WASM
npm run build
# Run the tests
npm run test
Contributions are welcome! Please feel free to open an Issue or to submit a Pull Request.