credit.preblock.nan#
Classes#
Replace NaN values with a constant fill value for selected variables. |
Module Contents#
- class credit.preblock.nan.FillNan(variables: list[str] = None, data_types: list[str] = None, fill_value: float = 0.0)#
Bases:
credit.preblock.base.BasePreblockReplace NaN values with a constant fill value for selected variables.
Walks a nested batch dict of the form
batch[data_type][source][var_key]and replaces any NaN entries withfill_valuefor the selected variables. Only NaNs are touched;+/-infand finite values are left unchanged.variablesmay contain full or partial names (e.g."era5/prognostic/3d"expands to every variable beneath it) and is expanded against the first batch viacredit.preblock._utils._parse_variable_selection(). An empty or omittedvariableslist means “every variable”. Specifying a subset lets severalFillNanpreblocks coexist, each filling different variables with a different value.Config example:
type: "fill_nan" args: variables: # optional, defaults to all variables - "era5/prognostic/3d/Q" data_types: # optional, defaults to ['input', 'target'] - "input" - "target" fill_value: 0.0 # optional, default 0.0
- variables = []#
- variables_expanded = False#
- data_types = ['input', 'target']#
- fill_value = 0.0#
- forward(batch: dict) dict#