Skip to content

Commit 459dd04

Browse files
author
Jeff Whitaker
committed
add method to return variable _FillValue (get_fill_value)
1 parent 1352561 commit 459dd04

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

‎src/netCDF4/_netCDF4.pyx‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4638,6 +4638,27 @@ behavior is similar to Fortran or Matlab, but different than numpy.
46384638
return the group that this `Variable` is a member of."""
46394639
return self._grp
46404640

4641+
def get_fill_value(self):
4642+
"""
4643+
**`get_fill_value(self)`**
4644+
4645+
return the `_FillValue` associated with this `Variable` (None if data is not
4646+
pre-filled)."""
4647+
cdef int ierr, no_fill
4648+
with nogil:
4649+
ierr = nc_inq_var_fill(self._grpid,self._varid,&no_fill,NULL)
4650+
_ensure_nc_success(ierr)
4651+
if no_fill == 1:
4652+
return None
4653+
else:
4654+
try:
4655+
fillval = self._FillValue
4656+
except AttributeError:
4657+
if self._isprimitive:
4658+
return default_fillvals[self.dtype.str[1:]]
4659+
else:
4660+
return None
4661+
46414662
def ncattrs(self):
46424663
"""
46434664
**`ncattrs(self)`**

0 commit comments

Comments
 (0)