Set string length in write_netcdf()#641
Merged
Merged
Conversation
This merge also cleans up the way that fill values and int64-->int32 conversions are handled.
This is necessary because we can't encode strings of different lengths with the same dimension name.
0ae3649 to
f58fa91
Compare
Collaborator
Author
TestingThis has been tested with the MPAS-Analysis test suite. Without these fixes, the suite was failing during mask creation steps but with these fixes runs successfully. |
Collaborator
Author
|
Polaris' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces enhancements and refactoring to the
mpas_toolspackage, primarily focusing on improving the handling of string variables in NetCDF files, simplifying function signatures, and improving code readability. The most significant changes include adding support for configurable string length (nchar) in NetCDF files, removing redundantnchararguments from various functions, and reformatting code for better clarity.There is also a fix to a bug introduced in #638 related to adding non-string properties to mask datasets.
Enhancements to NetCDF handling:
default_ncharinmpas_tools/io.pyto define the default string length for NetCDF files. Updated thewrite_netcdffunction to include an optionalncharparameter for string length customization. [1] [2] [3]write_netcdfto handle string variables with the specifiedncharand to improve compatibility with MPAS by convertingint64variables toint32.Refactoring and simplification:
ncharargument from multiple functions inmpas_tools/mesh/mask.py, such as_add_properties,_compute_region_masks, and_compute_transect_masks. The string length is now handled internally usingdefault_nchar. [1] [2] [3]mpas_tools/mesh/mask.pyto align with the removal ofnchar. This change simplifies the function signatures and reduces redundancy. [1] [2] [3]Code readability improvements:
mpas_tools/ocean/moc.pyfor better readability, including breaking long lines, improving argument alignment, and using parentheses for multi-line expressions. [1] [2] [3]moc_southern_boundary_extractorfunction to use a more readable argument parser configuration.These changes improve the usability, maintainability, and clarity of the
mpas_toolspackage.