Proposal: Reframe NetCDF as a reference structural encoding of CF so other structural layers can be defined. #486
Replies: 14 comments 31 replies
|
Dear Dave Thanks for making this proposal. I take this as a pre-proposal, or an outline proposal, since it's not a conventions issue. Is that the idea? As I say in commenting in Patrick's discussion, I prefer an incremental approach, such as this one. I argue also that any change should be designed as sufficient for the current need and that, for the moment, our need is to modify the CF conventions document to make it neutral between netCDF and Zarr, since those are the only formats for which it's actually being used. I understand your stated aim to separate CF cleanly from netCDF, but I think it will help us to keep in mind that Zarr is the present need. That will clarify what "separating cleanly from netCDF means" for this purpose. It sounds like some other formats, which we have not yet begun to consider in detail, might differ more fundamentally, and thus require a more radical "separation". For example, tabular formats might not have a way to support hierarchical groups. But let's not think about such difficulties now (unless someone advocates that we should). I would further argue that we should specifically include in ouour aim to say how CF maps to Zarr. Unless that's part of it, I'm not convinced we should make any change at all. The document is already fine for netCDF alone! The aim I'm suggesting is thus a bit broader than yours, but not huge! I think it would be helpful to develop it in a branch, rather than a series of independent PRs, because I suspect that there will be interactions between different aspects of it. Also, doing it as a branch in the CF repo would enable collaboration. I agree with your warning about forking CF. I definitely don't want that to happen, so I think it's important to be clear about the timescale. You suggest CF 1.14. That means we have to agree it by a week today, which I feel is too soon. I would suggest CF 1.15, giving us a year, but there's no reason to delay. The branch should be merged back into In Geozarr issue 138 I suggested various things we could do towards netCDF/Zarr-neutrality (arising from a discussion with David). Here's that list, with a few additions and changes in the light of your proposal. Some of them are included in your detailed proposal.
Best wishes Jonathan |
|
Just a note on gitHub usage: A branch in the main repo is absolutely the way to manage significant changes like this -- I suggest getting this work into a local branch sooner than later -- there is no reason to wait. [Git is great for this sort of thing, whatever happens in a branch has no effect on anything else....] A key limit, however, is how many people have push permissions on the main repo ... anyone that is making significant contributions should, or is become a mess ... |
But a serious pain in the @#$ -- PRs from forks work great for small self-contained changes from one person, they are a nightmare for collaboration on large refactor. Note that git flow (or other workflows) requires branching and controlled merging, it does not require the branches be forks...
But you can protect a branch, so folks can't push to main. I personally believe in-a-trust-folks philosophy -- is there anyone we that we want to make significant contributions to this effort that we don't trust to no mess with other things? If so, then:
Is a good solution -- we can give that special temp repo a broader set of team members. |
|
Dear Jonathan, Dave and Chris, Thanks, Jonathan, for setting out your list. A good part of it is also what the #484 proposal aims for:
Where we still differ is on the architecture: incremental adjustment of the current document, or a document built from the outset on a separation between semantics (Part I) and encodings (Part II, with netCDF as the reference encoding). So far that difference has mostly been argued as a matter of preference. I don't think more argument will settle it. Concrete examples will. I therefore propose that we work in two branches/repos, both taken from
To be clear about the second branch/repo: it is a study for comparison, not a fork of CF and not a competing submission for CF-1.15. Its purpose is to let the community judge both approaches on actual text and format. Whatever is found useful can be moved into For the comparison, I suggest two criteria:
Jonathan, I agree that enabling CF on Zarr is the present need. But the second criterion is exactly what will tell us whether a change made for Zarr is a real separation or a restatement of netCDF in other terms. Ethan's example of Parquet for DSG data in #484 shows that the question is not hypothetical. On the mechanics, I'm happy to follow whatever is agreed here for Dave's branch/repo, whether that is a protected branch in the conventions repository or a separate repository in the organisation. Both branches/repos should be governed the same way. My aim is to have a substantial part of the second branch/repo ready for discussion well before the 2027 Workshop, so that the comparison can be part of the programme there. Best regards, |
|
Thanks @pvanlaake -- this is a helpful boiling down of the process a couple tiny notes:
hmm -- it will be interesting to see how that plays out in reality -- it could just make things more confusing. I actually think that CDL is a pretty good "psuedo-code" that captures the key points in a clear an understandable way, even for folks that are not NetCDF-fluent. And I can't think of any other encoding that would be as clear in human readable text form (maybe JSON?) -- however, as I write this, I'm reminded of a parallel example: In the Python packaging docs, they describe how to do the same thing with multiple tools, and have swtichable-tab system to easily let the user choose which they want to look at, e.g. : https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#declaring-the-build-backend So that could work nicely. I think worth exploring, in any case. As for the two-pronged approach -- it seem like a lot of duplicative work to me -- but if you want to so it, I agree that a fleshed out example is probably the best way to make a decision. Though:
Frankly, The Zarr data model is so close to netCDF that I don't think this would really demonstrate much -- is there another more different encoding that we could use as a test-case? |
As I said, it works fine for PRs for a small self contained change from one person. But if you are doing a major re-working with a group, each separate person has their own fork, and that only they can write too (without another permission-heck process) -- and then you have many different version that constantly have to be rebased. It is substantially more overhead than letting multiple folks push directly to the working copy. Or you can have "feature branches" for a particular change, and more than one person can work on that branch as well. |
|
Hi All -- I've created a branch https://github.com/cf-convention/cf-conventions/tree/no-netcdf -- I will moderate PRs to that branch in the interest of this goal. My plan is to draft initial content based on my detailed proposal and the follow up discussion. I will open a PR against main as a work in progress where we can review and comment on specific details of the plan. |
|
Dear Dave, Patrick et al. Thanks for the branch, Dave. I've reopened this discussion because I think some useful conversations have been taking place in it, which might continue fruitfully, and anyway it's useful for reference. I hope that's OK with everyone. In addition, I expect we will need a place to discuss what we are doing in this project, as it proceeds. Discussion in PRs is helpful and convenient when it's about the wording in individual places in the text, but if conversations begin about more general issues it can get very confusing, with several threads going on in different places in the PR. I think we ran into that difficulty with the very complicated PRs for leap seconds, for example. For those reasons we advise against substantial discussions about content in PRs, in I will think about several PRs for the detailed points I listed above. Ethan asked
It feels more collaborative, I would say, if any participant can merge their own work - once everyone has agreed, of course. But I agree we don't want to complicate the permissions in the organisation, which you've worked hard to sort out. Let's see how we get on. Patrick wrote about "try[ing] different presentation: a hyperlinked site with a Getting Started entry point for newcomers, from which the Parts can still be rendered as PDF. This is to acknowledge the substantial discussion on finding more appropriate ways to present the CF conventions to users during the breakout session at the recent CF Workshop." Thanks. That was a useful discussion, and it will be interesting to see your ideas to that end. Patrick also commented,
I understand the point, and I agree with you and Ethan that there are other possibilities. My suspicion is that there isn't a unique, absolute, well-defined way to state CF independent of encoding. The degree of generality needed depends on what we're trying to encompass. My point is that we shouldn't go further from our present netCDF-API-like ways than we need to, because everyone is used to things as they are. If there's no gain (in terms of being able to do something we need to do), why should we cause pain to users of the CF document? Chris wrote,
Yes, that sort of thing is what I had in mind for CDL and Zarr-JSON. But there's no need for it if Zarr users of CF are perfectly happy with CDL alone. Best wishes Jonathan |
Good point -- this may be a good argument for making a fork of the repo in which to do this major update / re-write -- treating it as its own project, and then we'll have issues, etc that can be used. But we can wait and see how "major" it is. @pvanlaake's version is major -- I think that one should go in a separate repo. |
|
Dear Jonathan, Thanks for reopening the discussion, and for your comments. On whether there is a well-defined way to state CF independent of encoding: I agree there is no unique, absolute one. But CF has already established its level of generality. Appendix I describes the CF data model as an interpretation of CF that is "as far as possible independent of the netCDF encoding", and the data model paper presents it as describing all CF-compliant data. Stating the conventions at the level of the data model's constructs is therefore not an arbitrary abstraction. It is the target the community has already adopted. The separation I propose is relative to that model, not absolute. On the pain to users, we should recognise that CF is currently offered in just a single encoding flavour: netCDF. If another encoding is added then that will have no impact whatsoever on the current users of CF. New users of CF preferring Zarr for their data are subject to double pain, however: first to extract the CF semantics from its current entanglement with the netCDF encoding; and secondly, and way more pernicious if you ask me, having to navigate the choices that data producers of Zarr data repositories have made in the absence of normative guidance from the CF community. Restructuring the conventions does have a cost for readers who know the current document well. That cost has to be weighed against the difficulty newcomers have with the current text, which was a recurring theme at the breakout session. On the gain: you write that dual examples are not needed if Zarr users are happy with CDL. Many Zarr users do not write through the netCDF API at all. As an example, GeoZarr, which ESA is adopting for its Sentinel archive, organises its metadata differently from the netCDF data model, so CDL does not describe what these users write. For them, a CF statement that is not expressed in netCDF-API terms is a real gain, not a theoretical one. It would be good to hear directly from those communities in this discussion - we of course already had a presentation from the GeoZarr chair at the workshop, as a starting point. Finally, on the practical side: could the maintainers confirm whether a second branch, taken from Best wishes, |
|
Hi Dave @dblodgett-usgs Just a quick comment on the missing data section of your proposal.
As a netCDF library defined attribute [1], I think [1] From the NUG: 1) "Attribute names commencing with underscore ('_') are reserved for use by the netCDF library" and 2) "The netCDF library itself does not handle [missing data] in any special way, except that the value of a |
|
Dave @dblodgett-usgs, thanks for opening conventions issue 677. I will contribute to it later. In the way Dave has written it, his issue (677) will become the proposal to merge his branch I think this is a good procedure, for this new kind of situation. I suggest that we shouldn't "legislate" excessively about this in advance, because we don't know how it will work out, but that it's good to be clear at any time what our agreed procedure actually is, and revise it by consensus if necessary as we go along. If it's successful, we can write it later in Dave and @ethanrd have discussed the process for updating the branch. They both think that it should be similar to the process we use for usual issues to update |
|
Patrick @pvanlaake, I agree that diffs are quite difficult to understand for large-scale rearrangements, since they're shown as deletions and additions (of equal text). For humans to understand, it occurs to me that it would be most digestible if you could produce some diagram or table, which lists on the left the current sections and order of contents, and on the right the proposed rearrangement. That will enable us easily to see and think about the mapping. To implement it clearly within a branch, you could perhaps:
Would that work? |
|
All: Workflow is always a balance between a well managed process and an low-enough friction system that work can get done. I would argue that for a major re-structuring, the "usual" git PR from a fork, review, merge, etc process really does not work well. In particular, @pvanlaake's proposal is a major restructuring, I think the best process would be to create a new fork of the CF repo, and use that to do this restructuring -- it would not lose any history or anything else, and it could be kept up to date (rebased) with the main one as much as we want. Then there would be a small team for that repo, with different permissions than for the main CF repo. git is an amazing tool -- the entire point of the "distributed" model is that all repos are essentially equal and you can branch and merge between repos (almost) as easily as you can within one repo. In particular, whatever we do -- if at least @pvanlaake can't push to the branch that hold the large refactor, this is not going to go well. Again -- go ahead and try -- to my point above, a fork can be made at any time in the future. |
Uh oh!
There was an error while loading. Please reload this page.
Topic for discussion
Proposal: Reframe NetCDF as a reference structural encoding of CF so other structural layers can be defined.
This proposal follows from #463 and #484. It aims for minimal and incremental modification to enable CF to be supported by structural encodings beyond NetCDF. It prioritizes compatibility with existing NetCDF and Zarr data but also refines CF in a way that cleanly separates it from NetCDF, unblocking the potential for future structural layers.
1. Premise
CF defines constructs (what a coordinate variable, a cell method, a grid mapping means) and relies on a structural data model to hold them (dimensions, variables, attributes, groups). Today the structural model required to conform with CF is netCDF, required by a single sentence in Section 1.3: "The terms in this document that refer to components of a netCDF file are defined in the NUG."
Appendix I describes the netCDF encoding "CF-netCDF" and establishes CF independence from the NetCDF encoding as a design goal (Hassell et al. 2017).
This proposal makes the NetCDF encoding of CF explicit and substitutable. It evolves CF to state the components it requires of any structural layer, keeping the (NetCDF User's Guide) as a reference encoding, and scopes the handful of sections that describe netCDF as such.
This proposal does not change any CF semantics, restructure the document, deprecate the netCDF encoding, or define a Zarr (or other) encoding within CF.
2. Structural layers
_FillValue, dimension coordinate arrays). It documents what xarray already writes and is registered under the zarr-conventions framework.Conventionsdeclaration (e.g."NZ-1.0 CF-1.14").3. The edits to be applied in one PR
Section 1.3 Terminology (+ one sentence in Section 1.1).
Replace the NUG-binding sentence with the list of components CF requires of a structural layer:
1. named, sized dimensions shared within a group
2. typed N-d variables incl. scalars with an ordered dimension list
3. attributes at variable and group/global level
4. a root group (groups optional)
5. coordinate variables (1-D, name = dimension)
6. reserved
_FillValue.Define the NUG as the reference encoding.
Define "most rapidly varying dimension" by declared (CDL) order rather than storage.
Why: This core dependency is CF's only required binding to netCDF. Spelling out the contract with the NUG makes it substitutable. Declared-order definition allows the "(CDL order)" rule in ch. 7, ch. 9 and the conformance doc to go unchanged.
Chapter 2 scoping
Chapter 2, "NetCDF Files and Components" will need to be reframed to emphasize that NetCDF is a reference implementation of the CF constructs.
Regarding strings, CF already defines the base requirement and implementation options as a "may be" statement: Section 2.2 says an n-dimensional array of strings "may be implemented as" a
stringvariable with n dimensions or acharvariable with n+1. Both netCDF forms (NC_STRING, and NC_CHAR with a trailing string-length dimension) and both registered Zarr v3 string types (string,fixed_length_utf32) are arrays of Unicode strings, and they map losslessly in both directions. The edit therefore would state the base requirement and that in netCDF, it is stored in the two existing forms.Why: These sections describe the netCDF structural encoding of CF as an exemplar. We have verified that xarray's Zarr v3 output for CF-netCDF
stringvariables already lands on registered Zarr types, so no new string concept or deliberation is needed. All other adjustments are reframing to provide clarity that NetCDF is the reference encoding.Section 2.5.1 Missing data
Restate the missing-data rules in CF rather than deferring to NUG Appendix A:
_FillValue(a scalar of the same type as the stored data) are missing.valid_range, or belowvalid_minor abovevalid_max, are missing.missing_valueare missing._FillValueis the recommended attribute._FillValueis absent.The CF rules already in this section (missing data permitted in data and auxiliary coordinate variables but not in coordinate variables; missing values interpreted before unpacking;
actual_range) are unchanged. The paragraph on the NUG 2.3 to 2.4 change and the description of the NetCDF library's pre-fill behaviour remain as NetCDF-scoped notes.Why: This section is the heaviest deference to the NUG in the document — CF's definition of "missing" currently lives in a document CF does not version or control, a point @larsbarring raised in #463. @JonathanGregory proposed stating these rules in CF in his #463 summary. Item 5 preserves current CF-netCDF reader behavior while making explicit a property another structural encoding may lack: Zarr's storage
fill_valueinitializes unwritten chunks and carries no masking semantics, so an array without_FillValuehas no missing-data indicator there.Section 2.6 Attributes (incl. Section 2.6.1)
Conventionsis the root-group attribute by which a dataset declares the conventions it follows. CF already states the list syntax (blank-separated, or comma-separated when a name contains blanks), so the sentence attributing that syntax to NUG Appendix A becomes an informational note._FillValue,missing_value,valid_*,flag_valuesandflag_maskstake the type of their variable;actual_rangetakes the unpacked type;scale_factorandadd_offsetmust befloatordoubleand determine the unpacked type. Proposal: Where attribute types are not declared, the same-type rules resolve from the variable's data type, andscale_factorandadd_offsetare taken asdouble.Why: Without this paragraph, CF's typed-attribute rules cannot be applied where attributes are JSON values, which is the case for Zarr. The
doubledefault is the guidance Section 8.1 already gives for packed data whose attribute types do not conform ("unpacked todoubletype, in order to minimize the risk of loss of precision"), so existing CF-netCDF datasets don't read differently.Section 2.7 Groups
The search strategies (absolute path, relative path, proximity, lateral) and the rules for
Conventions,external_variables,titleandhistoryin non-root groups are defined within CF and do not need to change.Why: Section 2.7 came in with CF-1.8 and is CF's own name-resolution convention; the dimension-ID clause is its only NetCDF-bound sentence. Stating identity by name and length is what a layer that scopes dimension names per group needs in order to apply the section at all.
Reference wording
unitsstrings" and states that CF does not require the UDUNITS software for conversion. Align Section 1.4 and the bibliography entry with that scoping — the reference is to the UDUNITS unit grammar and database, not to the software package.Why: These are alignments with scoping CF already states, not changes in meaning.
Not changed
Appendix A's cross-references to NUG Appendix A stay as attribution — CF defines every attribute it requires in its own text (Sections 2.5.1, 2.6.2, 3.1, 3.2 and 8.1), so the citations record provenance rather than deference. Appendix I is unchanged; it already describes the encoding-independent data model this proposal relies on. CDL remains the notation for examples. The unlimited-dimension mentions in Chapter 9 and Appendix H are already conditional on wanting to append and do not need to be edited; the same holds for Section 8.4, which presents the NetCDF library's quantization attributes as one implementation among others. Incidental "netCDF file" wording in Chapters 4, 5, 7 and 9 and Appendix D can become "dataset" as an optional follow-up.
4. Why this path
Parsimonious. Six sections and one PR that do not introduce ideas beyond what Appendix I already introduces, "CF-netCDF", and every CF-netCDF dataset remains valid verbatim — the condition Section 1.2 item 10 sets for any change.
Incremental. Each edit can be checked as a thought experiment against data and software that exist today — netcdf-c, xarray, cf-python, the cf-checker — rather than as a restructure every reader and every training document has to absorb before its value can be judged.
Compatibility-first. The structural layers are written from what implementations already do: the NUG from NetCDF, NZ which documents xarray's Zarr V3. Conformance of existing data against a structural layer defined independent of CF is therefore testable now rather than after a new encoding is designed and adopted.
Progressive. The edits unblock the use cases raised in #484 — ESA's Sentinel archive on Zarr, Copernicus ARCO ERA5, ERDDAP's Parquet output — without limiting the potential to pursue a more significant Part I / Part II restructure, a formal grammar, or other formalization later. Each of those will be easier once the binding between CF and its structural layer is explicit.
Governance-light. CF defines the components it requires. Who publishes an encoding for a given container, and whether that encoding is in CF as an appendix, remains a decision the community can make case by case, as discussed in #463.
5. Proposed next step
I will draft the PR against cf-conventions and open it for discussion, with the Section 1.3 component list and the Section 2.5.1 and 2.6 restatements as the parts most in need of review. I would ask the maintainers of the groups material (Section 2.7), the Discrete Sampling Geometries chapter, and the conformance document to review the respective edits. The target is CF-1.14.
Three questions for this thread:
doubleguidance?LLM Agent Disclosure: Claude Fable 5.1 was used to assist research and outlining this discussion entry. The outline was filled in and edited by @dblodgett-usgs. All LLM generated text has been reviewed and validated.
"Any use of trade, firm, or product names is for descriptive purposes only and does not imply endorsement by the U.S. Government."
All reactions