问题
How can I get the default fill values using netcdf4-python? According to this issue one can get it via netCDF4._default_fillvals
, but this gives AttributeError: module 'netCDF4' has no attribute '_default_fillvals'
1.5.0.1. The information is available somewhere, because print(v)
tells me filling on, default _FillValue of 9.969209968386869e+36 used
. Unfortunately the file has not set the fill value attribute. Short of parsing the output of v.__repr__()
, how can I find the default fill value?
回答1:
This is documented in a parenthetical remark in the documentation for Dataset.create_variable.
From the Changelog for version 0.9.7:
* changed netCDF4._default_fillvals to netCDF4.default_fillvals (to make part of public API). Added to docs (issue 94).
From the documentation for the Dataset.create_variable
static method:
The optional keyword
fill_value
can be used to override the default netCDF_FillValue
(the value that the variable gets filled with before any data is written to it, defaults given innetCDF4.default_fillvals
). Iffill_value
is set to False, then the variable is not pre-filled.
This was fixed in commit 36f6544b10f791f31c3a0911ea97351e03490c75.
来源:https://stackoverflow.com/questions/56038566/how-do-i-get-the-default-fill-values