Skip to content

Varstrs - #254

Draft
pp-mo wants to merge 5 commits into
SciTools:mainfrom
pp-mo:varstrs
Draft

Varstrs#254
pp-mo wants to merge 5 commits into
SciTools:mainfrom
pp-mo:varstrs

Conversation

@pp-mo

@pp-mo pp-mo commented Aug 17, 2026

Copy link
Copy Markdown
Member

Closes #223 (treating that as an issue)

WIP currently based off #253

Starting point code.

  • use arrays of type object (dtype "O") to represent variable-length string data
    • ... as netCDF4 does
  • support read and write to netCDF4
    • elements are all type "str", but we can't easily/quickly verify that
    • when writing, use .astype("U"), so can write ~any objects-- but obviously, won't round-trip
    • when reading, special control ncdata.netcdf4.ASSUMED_TYPICAL_STRINGLENGTH controls chunking

The code changes are surprisingly small + simple.

Todo:

  • read/write to Iris : presumably needs similar support in Iris itself -- cf Support variable-length strings iris#7092
  • read/write to Xarray
    * N.B. Xarray already supports them?
  • tests
  • documentation (many changes needed to existing?)
  • ASSUMED_TYPICAL_STRINGLENGTH should probably be inside a threadsafe setting/context object.

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

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant