Remove spectral attributes from DataArray #892
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.
Summary
Remove spectral-specific attributes from DataArray to ensure consistent API across all geometry types. Spectral information is now accessed through
geometry, maintaining a clear separation of concerns.Migration path: Deprecated properties provide backward compatibility with warnings that guide users to the new API.
Why This Change?
DataArray should have a consistent interface regardless of geometry type. Previously, DataArrays with spectral geometries had extra attributes (
frequencies,directions) that weren't available for other geometry types, creating an inconsistent API.After this change:
Migration Guide
Accessing Spectral Metadata
Spectral information is now accessed through the geometry:
The old syntax still works but shows a
FutureWarningpointing you to the new API.Changes
What Changed
da.frequenciesda.geometry.frequenciesda.n_frequenciesda.geometry.n_frequenciesda.directionsda.geometry.directionsda.n_directionsda.geometry.n_directionsWhat Still Works
mikeio.read("spectrum.dfsu")da.plot()works unchangedda.geometryhas all spectral metadataImplementation
FutureWarningto guide users to new APIgeometryso code continues to work during migration_calc_Hm0()helper)da.geometry.frequenciespattern