Skip to content

Chardata docs#7194

Open
pp-mo wants to merge 8 commits into
SciTools:FEATURE_chardatafrom
pp-mo:chardata_docs
Open

Chardata docs#7194
pp-mo wants to merge 8 commits into
SciTools:FEATURE_chardatafrom
pp-mo:chardata_docs

Conversation

@pp-mo

@pp-mo pp-mo commented Jul 7, 2026

Copy link
Copy Markdown
Member

Closes #6924

In writing this, I have encountered a bit of a doubt about the implementation : #7195
But for the sake of getting this under review, I'm going to treat that as a separate issue :
I believe it can only simplify the account here.

scitools-ci[bot]
scitools-ci Bot previously requested changes Jul 7, 2026

@scitools-ci scitools-ci Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Templating

This PR includes changes that may be worth sharing via templating. For each file listed below, please either:

  • Action the suggestion via a pull request editing/adding the relevant file in the SciTools/.github templates/ directory. 1
  • Raise an issue against the SciTools/.github repo for the above action if you really don't have 10mins spare right now. Include an assignee, to avoid it being forgotten.
  • Dismiss the suggestion if the changes are not suitable for templating.

You will need to dismiss this review before this PR can be merged. Recommend the reviewer does this as their final action before merging, as this text will continually update as commits come in.

Templated files

The following changed files are templated:

Footnotes

  1. Include this text in the PR body to avoid any notifications about applying the template changes back to the source repo!
    @scitools-templating: please no update notification on: iris

@pp-mo pp-mo changed the base branch from main to FEATURE_chardata July 7, 2026 11:15
@pp-mo pp-mo changed the base branch from FEATURE_chardata to main July 7, 2026 11:20
@codecov

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.29%. Comparing base (ebc6531) to head (473db52).

Additional details and impacted files
@@                Coverage Diff                @@
##           FEATURE_chardata    #7194   +/-   ##
=================================================
  Coverage             90.29%   90.29%           
=================================================
  Files                    92       92           
  Lines                 25171    25171           
  Branches               4700     4700           
=================================================
  Hits                  22728    22728           
  Misses                 1673     1673           
  Partials                770      770           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@pp-mo pp-mo changed the base branch from main to FEATURE_chardata July 8, 2026 10:19
@pp-mo pp-mo requested a review from pt331 July 8, 2026 14:27
@pp-mo pp-mo linked an issue Jul 8, 2026 that may be closed by this pull request
2 tasks
@pp-mo pp-mo marked this pull request as ready for review July 8, 2026 15:34
@pp-mo pp-mo dismissed scitools-ci[bot]’s stale review July 8, 2026 17:09

Changes to pre-commit actually occurred in the target branch 'FEATURE_chardata'.
Only appeared here because I temporarily changed the target to 'main' to get docs building

@pt331 pt331 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My review is all over the place since I was adding them as I was reading and rereading, but I think I understand the overall idea. Most of the comments are nitpicks or thoughts on structuring.

Summary
^^^^^^^

* Iris currently *only* fully supports fixed-width 'char' type data in netCDF variables

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the single quotes intended to be backticks? It doesn't look like the rest of the document uses single quotes for this.


* Iris currently *only* fully supports fixed-width 'char' type data in netCDF variables

* the 'string' type (variable-width unicode strings) will be added in a future release

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A link to an issue to track this might be useful

have used a variable attribute ``_Encoding`` indicating the encoding name.

The NetCDF documentation also mentions that an ``_Encoding`` attribute may be used to
represent non-ascii strings. However this is described as "reserved for future use",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Citation would be useful

.. note::

In Iris, **the 'string' data type is not supported at present**, though this is
planned for future releases. See the following section `Variable-length datatypes`_

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as previous comment for link to issue

encoding support (described below).


In Iris

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the Iris part of this section should be the first under summary, since I imagine users are most interested in that. The other sections are more to provide context for decisions made in Iris

cubes and coordinates.

* the numpy dtype is of the type "U<xx>", where <xx> is a character width.
* the character width relates to a string *dimension* of the netCDF variable,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not following what this bullet point means.

* 'char' variable data is represented as numpy string arrays in Iris objects, such as
cubes and coordinates.

* the numpy dtype is of the type "U<xx>", where <xx> is a character width.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is referred to as "string width" later on. I think that term is more correct?


In the netCDF CF Conventions
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The `CF Conventions <https://https://cfconventions.org/>`_ define a subset of

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This link is broken

* it **is** required to *save* any non-ascii characters

The following describes the nature of character and string data handling in :
netCDF itself; the CF conventions; the netCDF4 Python module and the Iris implementation.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NetCDF is inconsistently capitalised



Character and String datatypes
------------------------------

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think an introduction might be warranted. Something like:

In NetCDF, text can be represented in 2 ways:

  • char: the number of characters in the text is fixed
  • string: the number of characters in the text can vary

Then text can have different encodings, which affects the number of bytes used to store a character. For example:

  • ASCII and UTF-32: the number of bytes are fixed
  • UTF-8 and UTF-16: the number of bytes can vary

This section discusses how Iris handles the different cases and how the standards and interpretations have changed.

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.

Complete documentation of chardata handling

2 participants