Skip to content

Convert string properties to char strings in python mask creator#638

Merged
xylar merged 2 commits into
MPAS-Dev:masterfrom
xylar:fix-string-vars-in-mask-creator
Jun 6, 2025
Merged

Convert string properties to char strings in python mask creator#638
xylar merged 2 commits into
MPAS-Dev:masterfrom
xylar:fix-string-vars-in-mask-creator

Conversation

@xylar

@xylar xylar commented Jun 5, 2025

Copy link
Copy Markdown
Collaborator

Previously, properties (e.g. height and history) for mask variables were being written out as string fields. These work for NETCDF4 format but cannot be converted with ncks to CDF format. Instead, we want to write them out as character strings in the same way that transect and region names are handled. This merge handles all fields that are strings in the same way, using the length of the longest string as the dimension of character fields. This retains compatibility with NETCDF3* formats.

The mask creator has also been updated to use the desired ruff formatting and to use f-strings instead of format strings.

@xylar xylar self-assigned this Jun 5, 2025
@xylar xylar changed the title Fix string vars in mask creator Convert string properties to char strings in python mask creator Jun 5, 2025
@xylar

xylar commented Jun 5, 2025

Copy link
Copy Markdown
Collaborator Author

Testing

This was tested as part of a workflow to create culled meshes in Polaris on Chrysalis. Without this fix, string variables caused the transect mask creator to fail during writing NetCDF fields using the CDF5 conversion technique in #633. With this fix, string variables are successfully written as character arrays, which then allows conversion to CDF5 to proceed as expected.

@xylar xylar merged commit 353136b into MPAS-Dev:master Jun 6, 2025
6 checks passed
@xylar xylar deleted the fix-string-vars-in-mask-creator branch June 6, 2025 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant