Mapping CF conventions onto Zarr #461
Replies: 10 comments 51 replies
|
In my view, making the CF Metadata Conventions available in Zarr stores is not a major departure from the current CF. The Zarr data model is very similar to the netCDF enhanced data model, and with very few exceptions, a dataset stored in a netCDF file can be converted to a Zarr dataset using the same encoding of attributes, variables, and groups. There are arguablymore differences between netCDF-3 and netCDF-4 than there are between netCDF4 and Zarr. Remember that netCDF is an API, not a file format, and the canonical implementation (netCDF-C) can read and write netCDF-3, netCDF-4, and Zarr2 datasets. There are many such Zarr versions of CF-netCDF datasets already in existence. I'm not sure what we are being invited discuss - is it "What should a Zarr convention that re-encodes parts of CF look like?", or maybe I've misunderstood? Thanks, |
Maybe I am missing something here, but isn't this a structurally new capability in relation to netCDF, and thus CF? If this is true, are there any desirable OGC/ISO (etc.) functionality that depend or would be substantially facilitated by this -- and is maybe outside what CF currently handles? |
|
IIUC, Zarr implements the HDF5 data model [*]. (at least it started that way) And netCDF4 is a restricted subset of HDF 5. Which means that mapping CF to Zarr could be as "simple" as mapping it to a strict subset of Zarr, like is done for HDF5. Which seems to be what ncZarr is -- so isn't that the easiest first step? Someone may want to use Zarr features that aren't netCDF compatible -- if so, then that requires some extension to CF, but in that case, I think it should be done in a broader way -- e.g. a way that supports other more expansive data models, such as well HDF5, and ???) NOTE: folks are using xarray as a file-format-independent array management system, and xarray implements the netcdf4 data model (I'm not sure how strictly), and to some extent the CF data model. And folks are using it with Zarr and CF compliant datasets just fine right now. NOTE: I see this for nczarr (as implimented by the netCDF C lib:
That really surprises me -- why in the world would the string type not be included? that seems like it would be native to zarr. But oh well. [*] this sure makes it look like Zarr is HDF (and be extension, netcdf) compatible. |
Or library :- ) I agree with both of these. However, as much as we all want standards to be independent from implementation, there is the fact that a standard without an implementation is useless, and that, in practice, implementations tend to drive standards, rather than the other way around. Which I think was the point about xarray -- not that we focus on a particular language or library (though we sure have a history of that with netcdf-c :-) ) -- but that xarray is widely used, and is driving the state of practice forward, whether we like it or not. That is, xarray already provides a way (however imperfect) to use CF with Zarr, and i can tell you that a lot of users don't think twice about the fact that technically there is no standard for CF in Zarr .... The good news is that xarray does (Mostly?) implement the netcdf (with some CF extensions) data model, so it works pretty well.
Is that still true, AI tells me it's no longer the case, but it can hallucinate ... But in any case, that's irrelevant to CF -- that's a "which library works well for my workflow" problem, not a CF problem. Anyway -- back to the point about relying on particular libraries -- ncZarr is a particular library, and it deserves special attention, as it comes from Unidate, and is integrated with netcdf-C -- but it shouldn't drive our discussion of CF. We've (that is, David :-) ) have made a lot of progress with decoupling CF from netCDF with the development of the CF Data Model. If the CF Data Model can be represented in Zarr, then we're done, yes? I think the real question at hand is what to do about features that Zarr (or any other file format) has that netCDF doesn't have. (Is that what the nested attributes issue is about??). Do we extend the CF data model is a way that can not be supported by netCDF? THAT would be a real change. I think of a Data Model as a specification of what exactly can be stored -- actual data, metadata, relationships between data, etc. if multiple file formats (encodings) can be store that data -- that is, if you can losslessly convert between them, then there's nothing new that has to be done. And I think that's the case with Zarr and netCDF -- they both can fully store the CF data model.
Am I missing something? My analogy is image storage -- a core data model for images is an array of pixels -- maybe 24 bit RGB or 32 bit RGBA. Any file format/ encoding that can store an array of 24 or 32 bit values is compatible -- no one has to define a new Data Model when someone comes up with a fancier compression scheme to store an image. IN that analogy, isn't Zarr simply a new encoding? |
|
This might be somewhat tangential, but it might be of interest in this discussion to look at these two talks by Mark Kittisopikul (in chronological order or presentation)
Efficient Chunk Access across HDF5, Zarr, and TIFF”
https://www.youtube.com/watch?v=IEAcCmcOdJs
Using a HDF5 File as a Zarr v3 Shard
https://www.youtube.com/watch?v=c4b_yfIeHJc
…-Roy
On Feb 28, 2026, at 1:20 PM, Patrick ***@***.***> wrote:
It means that any encoding that preserves the logical structure can be used.
This is exactly my point. Where you say "logical structure", I say "semantics", but otherwise we are saying the same thing. Whether or not that uses nested attributes is immaterial.
Breaking down the process of ingesting a CF-compliant data set looks somewhat like this:
basic storage format/API -> CF encoding -> model -> tool -> user/application
basic storage format/API = netCDF to date, perhaps native Zarr can be added, maybe Parquet and others at a later stage.
CF encoding = CF semantics (everywhere the same!) structured to be optimal for the basic storage format/API.
model = CF data model as in Appendix I and as used in cf-python; I know of no other implementation; xarray and (my very own) ncdfCF use an implicit, specific data model.
tool = cf-python, xarray, ncdfCF, ... make CF data sets easily accesible with a published interface that end-users or application builders can use.
From the Zarr perspective the question is then, can we develop a native Zarr CF encoding (as opposed to the CF-netCDF encoding possibly stored in Zarr) and make that available to the model -> tool -> user/application level? In other words, could there be a Zarr-specific CF encoding which can then be ingested by the CF data model and cf-python and its user base, as well as to other tool chains?
The hard part would be translating the CF encoding to the model and/or the tool, but - as Chris already noted - that is not the concern of the CF community: if it is useful then it will be used.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
|
A typical use of Zarr data stores is to publish data over the internet, e.g. from a web server of through a cloud service. Zarr is increasingly favoured over netCDF (such as through a THREDDS server or OPeNDAP) because it scales better with increasing data request loads. Efficiency is key. Consider a bog-standard CMIP6 data set with a single data variable having T-Y-X dimensions and shape Reading from such a data variable encoded in the standard CF-netCDF style requires the user (or rather the tool that the user is using, such as Reading from the same data variable but encoded using a Zarr convention like 373KB may not sound like a major hurdle and the user may not even notice the additional download but for the data publisher, perhaps serving up thousands of data requests per day, that may be a different story. There is more to it than download size alone. The standard CF-netCDF encoding requires (at least) 21 HTTPS GET requests: one for the Something to consider, it would seem. |
|
Dear CF-folks, OK, I'll make a suggestion here. I think that some minor zarr encoding notes in the CF specification would be consistent with what the geozarr SWG is asking for. I don't think it would be absurd to try and progress key things as incremental changes to the spec that help focus the community of zarr implementers. If this proposal is worth pursuing, we would start the process of deliberating individual issues related to zarr encoding of cf. The conversation around CF-in-Zarr has gone in fits and starts and keeps stalling because individual issues haven't been isolated and dealt with separately. A strong separation of concerns would let the community make visible, durable progress on each in relative isolation instead of relitigating things over and over. I want to argue for rallying around the things that have been solved in this space and working toward conclusion on clearly defined and cohesive topics requiring some design consensus. The proposal: adopt a clean separation of concerns — this framework I lay out below, or an iteration on it. Treat the closed concerns as foundations to build on that are recognized stable aspects of CF in Zarr. Work the open concerns as parallel tracks where the technical solutions are largely in hand. NOTE: I don't mean to open debate on these items here -- the descriptions are to characterize each concern only. This comment is intended to propose that we break these out as independent issues to be worked incrementally and in relative isolation. Six concerns are actually in play. Two have reached working consensus already — recognizing the solved bits is itself valuable: Array Dimension Identity. The longstanding Missing Data Semantics. The conceptual distinction between Zarr's storage-level Four concerns are genuinely open, but each is self-contained enough to be tackled independently: Coordinate Role Identification. CF has clear and well-understood conventions for identifying dimension coordinates, auxiliary coordinates, and scalar coordinates. The gap is that Zarr has no structural location to express these roles. Tools that are not CF-aware cannot identify coordinate types without implementing CF's inference logic, which is a meaningful barrier to interoperability. The fix is small and self-contained: a Zarr convention adding an optional coordinate role attribute would close this without touching anything else in this list. Attribute Type Fidelity. NetCDF's typed attribute model — Axis Order Declaration. This is the most dangerous open problem because it fails silently. CF's CRS Representation Authority. This is where the most work remains, but it helps to be clear about what is and isn't in dispute. There is broad cross-community consensus — across PROJ 6+, pyproj, STAC, and the emerging GeoZarr Is this the right seperation of concerns? How else might we break up the issues to allow a more natural and cohesive incrementalism? Regards, Dave p.s. Pondering what it would look like to call out zarr encoding rules in the CF spec -- I was reminded that things like the "NUG" are formative documents for CF. I think a valid stance the CF community could take is that they expect something akin to the NUG (the ZUG?) to outline the encoding rules. If there's no appetite for solving the problems above, we could just say that, like the NUG, the ZUG is out of scope for CF. |
|
Hi Dave,
Of course it is an option. You apparently do not find it an attractive option, but that is a different issue. Ruling this out before the effort starts is a missed opportunity.
That we need to "start[...] from what we have" is a choice and it is a loaded choice. What we have is all tailored to netCDF and @davidhassell nicely summed up the scope of considering Zarr when he wrote:
That is a very narrow scope and not the topic of this discussion, really. David refers to the CF-netCDF encoding that we already have and incremental changes to that are nothing new, that is what we have been doing every day for many years. Is it really too big a leap of faith to take a step back and consider what CF would look like without netCDF? |
|
@pvanlaake: I think we need a new discussion for this topic. I've started one here: #463 If you (or anyone else) has a very different idea, then feel free to start your own discussion -- I'll probably close mine if it goes in another direction. |
|
@dblodgett-usgs: Thanks for nailing down the issues so clearly. A few thoughts on a couple points:
Honestly, this is a bit of a mess on CF with netCDF as well -- at least in the wild -- The overlap between I think this is also an example of a key problem -- a new "container" may not fully support all the CF concepts -- and a decision has to be made about what to do about that.
Hmm, it seems that for the most part, CF does not concern itself with data types -- e.g. a time coordinate can be stored with floats integers, etc ....
I would argue that that's a bug / missing feature in CRS parameterization. See the time example, we quite explicitly say that the choice of data type (or even units) for time says anything about the precision.
Any numeric metadata that give meaning to data type should probably be revisited.
Agreed -- though ideally CF would be inherently less tied to serialization details. |
Uh oh!
There was an error while loading. Please reload this page.
Topic for discussion
Over the last 2 ~ 3 years, the GeoZarr community has looked into data models in the larger n-dimensional data ecosystem with the aim to find commonalities which might serve as the basis for GeoZarr. Late last year it was determined that this is too onerous a process and not providing a clear path forward. Instead, GeoZarr is now inviting user groups to submit “conventions” built on top of Zarr to demonstrate working arrangements. This would lead, conceivably, to a variety of approaches, each one tailored to its own user base. It is expected that there will be a convergence over time to a common approach on attaching a geospatial reference frame to the Zarr data model.
For the CF community this is a very positive development because it means that we can define our own Zarr conventions to map CF semantics onto Zarr. Given that this is a new direction for GeoZarr, there is also very little established practice in the form other Zarr conventions that CF should align with (or, inversely, can build upon) so our hands are effectively free. By acting now, the CF community can propose an arrangement that is CF-compliant, clean, clear and efficient, rather than having to make CF fit with established Zarr conventions.
This new discussion builds on a number of previous discussions and announcements on GeoZarr here:
The purpose of this new discussion is to bring these different efforts together and respond to the new approach in the GeoZarr community to demonstrate working arrangements, and, not least, to make the CF Metadata Conventions available to native Zarr stores.
Zarr conventions
A Zarr convention is represented by a JSON sub-schema embedded in the
"attributes"section of azarr.jsonfile that is attached to every group and array in the Zarr store. Being JSON, the convention can have nested attributes. The task at hand is therefore to define one or more Zarr conventions that (jointly) comprise the CF conventions. Two draft examples, demonstrating two separate approaches to mapping CF onto Zarr, are available here:CF: A direct mapping of the current CF structure to Zarr: https://github.com/zarr-conventions/CF. This Zarr convention was suggested by the GeoZarr SWG as a starting point for enabling CF-compliant data sets in Zarr. It is not intended to be used as-is.cs: Restructuring CF semantics on coordinates in Zarr: https://github.com/R-CF/zarr_conventions_cs. This is a Zarr convention that I put together to demonstrate a modular approach, in this case for defining a coordinate system (a "domain" in the CF data model) aligned with ISO/OGC terminology. Additional Zarr conventions would cover other parts of CF.Another interesting example would be the Zarr convention for DGGS, which is used by HEALPix (CF-1.13): https://github.com/zarr-conventions/dggs. Other currently defined Zarr conventions are listed here: https://github.com/zarr-conventions.
Points for discussion
Making the CF Metadata Conventions available in Zarr stores is a major departure from the current CF. While the Zarr data model and netCDF have many things in common (groups, variables/arrays, attributes), there are also significant differences that need to be accounted for. Before delving into the technical details of defining one or more Zarr conventions for CF, a number of issues should be discussed and a consensus reached. The most fundamental of these, in my opinion, is the following:
The distinction between semantics and encoding is crucial here. As an example, in the current CF a coordinate variable is stored in a netCDF file as a variable; in the
csZarr convention above, regularly spaced coordinates are represented by an initial value and an increment in thecssub-schema. The encoding is different in both cases but the software reader will present both encodings as identical sequences of coordinates: the semantics are preserved.The first option, close alignment, is the approach in the
CFZarr convention linked to above. It has the benefit of being known to CF users and software developers. On the other hand, it perpetuates design decisions that may not be as relevant today as they were in the past. Some changes to the encoding will necessarily have to be made anyway because of the Zarr data model (no dimensions, for instance; no "NC_CHAR"!; compression is handled by Zarr).The second option, conserving CF semantics in an encoding that differs from the current encoding where necessary, as in the
csZarr convention above, means more up-front work for design and implementation and a new structure to be learned by CF users and software developers, but having the benefit of streamlining the encoding, better alignment with Zarr structures, possible alignment with standards like ISO/OGC, and more efficient storage.Many more arguments can be made for either position and I would like to invite the reader to contribute to the discussion here.
All reactions