Skip to content

BUG - write_cdf incorrectly coded for xarray_to_cdf istp default #3006

@tmplummer

Description

@tmplummer

Description of the issue

The default keyword value in xarray_to_cdf for istp validation is True, but in write_cdf, if the istp keyword is not set, the default is False but that never gets set. Relevant code section below.

Steps to reproduce the issue

No response

Expected vs Actual behavior

No response

Code Snippet (If applicable)

if "l1" in data_level:
        if "terminate_on_warning" not in extra_cdf_kwargs:
            extra_cdf_kwargs["terminate_on_warning"] = False  # type: ignore
    else:
        if "terminate_on_warning" not in extra_cdf_kwargs:
            extra_cdf_kwargs["terminate_on_warning"] = True  # type: ignore
        if "istp" not in extra_cdf_kwargs:
            extra_cdf_kwargs["istp"] = True  # type: ignore
    if "compression" not in extra_cdf_kwargs:
        extra_cdf_kwargs["compression"] = 6  # type: ignore

    prev_cdflib_level = cdflib_logger.level
    try:
        if not extra_cdf_kwargs.get("istp", False):
            # Suppress cdflib logging messages for data levels that don't need
            # strict ISTP compliance
            logger.info("Disabling cdflib ISTP logging for level 1 data products")
            cdflib_logger.setLevel(logging.ERROR)
        xarray_to_cdf(dataset, str(file_path), **extra_cdf_kwargs)

Additional notes, affected areas, and suggested fixes

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

Status

In Progress

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions