Skip to content

Add new net_cdf4 codec - #288

Merged
jeandet merged 14 commits into
SciQLop:mainfrom
co-libri-org:netcdf_codec
Jun 24, 2026
Merged

jeandet merged 14 commits into
SciQLop:mainfrom
co-libri-org:netcdf_codec

Conversation

@RichardHitier

Copy link
Copy Markdown
Contributor

See #209

Comment thread speasy/core/codecs/bundled_codecs/istp/__init__.py Fixed
Comment thread speasy/core/codecs/bundled_codecs/istp/__init__.py Fixed
Comment thread speasy/core/codecs/bundled_codecs/istp/netcdf.py Fixed

@brenard-irap brenard-irap left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks, Richard.
I really appreciate the code factorization.
My remarks are mostly aligned with those in SciQLop/PyISTP#1
I'll try to find some additional files for testing.

if dim_name not in ds.variables:
var = ds.createVariable(dim_name, 'f8', (dim_name,))
var.units = "seconds since 1970-01-01T00:00:00"
var.VAR_TYPE = "support_data"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It may be worth considering whether multiple options for the time format should be supported here.
The ISTP specification tends to recommend TT2000, but I’m not convinced it is necessarily more appropriate than a Unix timestamp.

if (var is not None) and (var.values.shape[0] == var.axes[0].values.shape[0]):
time_axis_name = var.axes[0].name
return _valid_variable_or_none(SpeasyVariable(
axes=[VariableTimeAxis(values=var.axes[0].values.copy(),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Regarding what I mentioned in SciQLop/PyISTP#1 (review), this would be the right place to delegate to the codec the interpretation and conversion of the time variable data into datetime64.

from speasy.core.codecs import get_codec

AC_MFI = os.path.join(os.path.dirname(__file__), "resources", "ac_h2s_mfi_cdaweb.nc")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I’ll try to provide you with additional test cases.
However, there are far fewer publicly available datasets in netCDF compared to CDF...

RichardHitier and others added 12 commits June 2, 2026 16:30
- eliminate duplication moving helpers into istp/__init__.py
- create istp/cdf.py and istp/netcdf.py
        accept timedelta

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- _write_variable: return type was bool but never returned a value, changed to None
- _already_in_cdf: already returns _ax.name (str), so a.name was a bug, use a directly
- save_variables: replace hasattr(file, 'write') with isinstance(file, io.IOBase) for Pylance narrowing

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
 copy/paste issue inherited from istp/ refactoring

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@sonarqubecloud

sonarqubecloud Bot commented Jun 2, 2026

Copy link
Copy Markdown

    - Log exception at debug level
    - rewrite except clause
pycdfpp expects bytes when loading from a buffer, not memoryview.
@jeandet
jeandet merged commit e08e512 into SciQLop:main Jun 24, 2026
6 of 22 checks passed
@sonarqubecloud

Copy link
Copy Markdown

@jeandet jeandet added enhancement New feature or request CDPP labels Sep 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CDPP enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants