Skip to content

Refactor normalization/denormalization methods in data_reader_base.py to reduce code duplication #956

@simone99n

Description

@simone99n

Is your feature request related to a problem? Please describe.

The current implementation of normalize_* and denormalize_* methods (normalize_geoinfos, normalize_source_channels, normalize_target_channels, denormalize_source_channels, denormalize_target_channels) in data_reader_base.py contains code duplication. Each method repeats similar logic, which increases maintenance costs and the risk of inconsistencies or bugs.

Describe the solution you'd like

Introduce helper functions (e.g., _normalize and _denormalize) that encapsulate the shared logic. Each method would then call the helper with the appropriate indices, mean, and standard deviation arrays.
Extra: replace the assert statement with an "if + ValueError"

Describe alternatives you've considered

Creating one generic function for both normalization and denormalization with a flag (but in my opinion this is less clear and potentially confusing)

Additional context

No response

Organisation

CMCC

Metadata

Metadata

Assignees

Labels

dataAnything related to the datasets used in the projectdata:readingEverything related to data reading

Type

Projects

Status

In Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions