Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async-lock = "3.4.0"
numpy = "0.26"
num-traits = "0.2"
delegate = "0.13"
omfiles-rs = { git = "https://github.com/open-meteo/rust-omfiles", rev = "91c7a1bfc01c5394332eb1b9b9a035f61554bf07", package = "omfiles", features = ["metadata-tree"] }
omfiles-rs = { git = "https://github.com/open-meteo/rust-omfiles", rev = "c7e6d4daed18e05bc8bb5d4373185096a493a662", package = "omfiles", features = ["metadata-tree"] }
om-file-format-sys = { git = "https://github.com/open-meteo/om-file-format", rev = "a484a5a90914ff934fc451dff30b671b9ba8e38e" }
thiserror = "2.0.12"

Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ ignore = [
[project.entry-points."xarray.backends"]
om = "omfiles.xarray:OmXarrayEntrypoint"

[project.entry-points."numcodecs.codecs"]
turbo_pfor = "omfiles._numcodecs:TurboPfor"

[project.entry-points."zarr.codecs"]
"omfiles.pfor" = "omfiles._zarr3:PforCodec"
"omfiles.pfor_serializer" = "omfiles._zarr3:PforSerializer"
3 changes: 0 additions & 3 deletions python/omfiles/_numcodecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,3 @@ def decode(self, buf, out=None): # type: ignore
buf = buf

return self._impl.decode_array(buf, np.dtype(self.dtype), self.chunk_elements)


numcodecs.register_codec(TurboPfor)
10 changes: 10 additions & 0 deletions python/omfiles/omfiles.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,16 @@ class OmFileReader:

It is safe to call this method multiple times.
"""
def get_complete_lut(self) -> builtins.list[builtins.int]:
r"""
Retrieve the complete lookup table for the variable.

The lookup table is a monotonically increasing array of u64 values containing
n+1 elements, where n is the number of chunks. Each value represents the absolute
offset in the file of the end of the chunk, and the first value is the start offset
of the first chunk. The size of chunk j can be calculated as lut[j+1] - lut[j]
using zero-based indexing.
"""
def get_child_by_index(self, index: builtins.int) -> OmFileReader:
r"""
Get a child reader at the specified index.
Expand Down
1 change: 1 addition & 0 deletions src/codecs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use numpy::{
ndarray, IntoPyArray, PyArray1, PyArrayDescr, PyArrayDescrMethods, PyArrayDyn, PyArrayMethods,
PyUntypedArray, PyUntypedArrayMethods,
};
use omfiles_rs::_om_file_format_sys as om_file_format_sys;
use pyo3::exceptions::{PyTypeError, PyValueError};
use pyo3::prelude::*;
use pyo3::types::PyBytes;
Expand Down
18 changes: 18 additions & 0 deletions src/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,24 @@ impl OmFileReader {
self.with_reader(|reader| Ok(reader.data_type().is_scalar()))
}

/// Retrieve the complete lookup table for the variable.
///
/// The lookup table is a monotonically increasing array of u64 values containing
/// n+1 elements, where n is the number of chunks. Each value represents the absolute
/// offset in the file of the end of the chunk, and the first value is the start offset
/// of the first chunk. The size of chunk j can be calculated as lut[j+1] - lut[j]
/// using zero-based indexing.
fn get_complete_lut(&self) -> PyResult<Vec<u64>> {
let lut = self.with_reader(|reader| {
reader
.expect_array()
.map_err(convert_omfilesrs_error)?
.get_complete_lut()
.map_err(convert_omfilesrs_error)
})?;
Ok(lut)
}

/// Check if the variable is a group (a variable with data type None).
///
/// Returns:
Expand Down
Loading