gplately.default_netcdf_fill_value

gplately.default_netcdf_fill_value(grid, significant_digits=None)[source]

Return the default fill value that would be used when calling write_netcdf_grid with fill_value=None.

Notes

This is useful when you need to set some values in grid to a fill value (eg, masking out continents from a seafloor age grid) before writing out the grid with write_netcdf_grid.

If significant_digits is NOT specified (ie, None) and the grid data type is floating-point then the default is np.nan. This essentially means that np.nan is only used (as the default) when losslessly compressing floating-point data. This is because lossy compression with a NaN fill value appears to not always mask out NaN regions.

In all other cases the default is determined by netCDF based on the grid type. For example, the default for floating-point types is 9.969209968386869e+36 (see netCDF4.default_fillvals). In this case, please ensure the default is outside the range of your valid grid data, otherwise you should specify a custom fill value when calling write_netcdf_grid.

Parameters:
  • grid (ndarray) – The grid that the default fill value will be used for (when writing the grid data to a netCDF file).

  • significant_digits (int, optional) – Whether lossy data compression will be applied when writing the grid data to a netCDF file. This should be the same value that you will pass to write_netcdf_grid.

Return type:

The default fill value, or None if the grid type does not have a default value (according to netCDF4).