Skip to content

Instantly share code, notes, and snippets.

@mdsumner
Last active March 21, 2025 20:47

Open a virtual dataset, how can I get the dict() of references from .lat?

import virtualizarr
oisst = virtualizarr.open_virtual_dataset("https://www.ncei.noaa.gov/data/sea-surface-temperature-optimum-interpolation/v2.1/access/avhrr/198109/oisst-avhrr-v02r01.19810901.nc")

oisst.lat
<xarray.DataArray 'lat' (lat: 720)> Size: 3kB
ManifestArray<shape=(720,), dtype=float32, chunks=(720,)>
Coordinates:
    lat      (lat) float32 3kB ManifestArray<shape=(720,), dtype=float32, chu...
Attributes:
    long_name:  Latitude
    units:      degrees_north
    grids:      Uniform grid from -89.875 to 89.875 by 0.25

I would a dict something like

{
"0": {"path": "https://www.ncei...<snip>oisst-avhrr-v02r01.19810901.nc", "offset": 0, "length": 720}
}
@mdsumner
Copy link
Author

Answer (thanks to Tom Nicholas!)

oisst.lat.variable.data.manifest.dict()
{'0': {'path': 'https://www.ncei.noaa.gov/data/sea-surface-temperature-optimum-interpolation/v2.1/access/avhrr/198109/oisst-avhrr-v02r01.19810901.nc', 'offset': 1024105, 'length': 820}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment