wrf.to_np

wrf.to_np(array)

Return the numpy.ndarray contained in an xarray.DataArray instance.

If the xarray.DataArray instance does not contain a _FillValue or missing_value attribute, then this routine simply returns the xarray.DataArray.values attribute. If the xarray.DataArray object contains a _FillValue or missing_value attribute, then this routine returns a numpy.ma.MaskedArray instance, where the NaN values (used by xarray to represent missing data) are replaced with the fill value.

If the object passed in to this routine is not an xarray.DataArray instance, then this routine simply returns the passed in object. This is useful in situations where you do not know if you have an xarray.DataArray or a numpy.ndarray and simply want a numpy.ndarray returned.

Parameters:array (xarray.DataArray, numpy.ndarray, or any object) – Can be any object type, but is generally used with xarray.DataArray or numpy.ndarray.
Returns:The extracted array or the array object if array is not a xarray.DataArray object..
Return type:numpy.ndarray or numpy.ma.MaskedArray