standardize_fill_value#
- geobricks.standardize_fill_value(data, *, var_list=None, attrs=None, encod=None, to_file=False)[source]#
Standardize the way the nodata value (fill value) is encoded in a netCDF dataset. In netCDF, several ways of embedding nodata information can be used (‘_Fillvalue’ or ‘missing_value’, in attributes or in encodings). Sometimes multiple embeddings are stored in the same dataset. When several nodata information are present in the same dataset, this function infers the most relevant one and removes the others. In the end, the relevant nodata information will be stored as a ‘_FillValue’ encoding only.
Parameters#
- datapath (str or pathlib.Path), or variable (xarray.Dataset, xarray.DataArray)
Dataset (netCDF or xarray variable) whose nodata information will be standardized.
Note that
data
will be loaded into a xarray.Dataset or xarray.DataArray.- var_list(list of) str, optional
Used to specify if only one data variable has to be standardized. Otherwise, the nodata information will be standardized for all data variables.
- attrsdict, optional
If the nodata information is present in an attrs dict dissociated from the dataset, it can be passed here.
- encoddict, optional
If the nodata information is present in an encoding dict dissociated from the dataset, it can be passed here.
- to_filebool or path (str or pathlib.Path), default False
If True and if
data
is a path (str or pathlib.Path), the resulting dataset will be exported to a file with the same pathname and the suffix ‘_std_fill_val’. Ifto_file
is a path, the resulting dataset will be exported to this specified filepath.
Returns#
- data_dsxarray.Dataset
Standard GEOP4TH variable (xarray.Dataset) with corrected nodata information.
- nodatanumeric
No-data value.
If
to_file
argument is used, the resulting dataset can also be exported to a file.