read dataset fill value question

155 views
Skip to first unread message

Matthew Gidden

unread,
May 10, 2017, 11:21:46 AM5/10/17
to xar...@googlegroups.com
Hi folks,

Had a bit of a counterintuitive result today. Before making an issue, I thought I'd ask the list.

I have a nc file with _FillValue=0. When I read that in with xarray, the fillvalue used appears to by np.nan. Is that expected behavior?

Gist available here: https://gist.github.com/gidden/fc8eb41c1117f144d1e656f4800c2b82

Cheers,
Matt

Stephan Hoyer

unread,
May 10, 2017, 12:30:49 PM5/10/17
to xarray
Yes, by default xarray converts data points equal to _FillValue to NaN, which we treat as a missing value for all operations. You can disable this with mask_and_scale=False in open_dataset.

--
You received this message because you are subscribed to the Google Groups "xarray" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xarray+unsubscribe@googlegroups.com.
To post to this group, send email to xar...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/xarray/CAHRdPFwPnwDe4dWYNHM1PXqgCNGTzgiuzQimsZ3nQLXDacduvQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Matthew Gidden

unread,
May 10, 2017, 1:23:38 PM5/10/17
to xar...@googlegroups.com
Ok, great. I saw this option but was a little confused with why I would also want to scale. Would a PR that added simply a `mask` or `fillna` argument to open_dataset be of interest? This is what I would have wanted for my use case, but perhaps I'm misunderstanding the design purpose.

Stephan Hoyer

unread,
May 10, 2017, 5:53:35 PM5/10/17
to xarray
Yes, it probably makes sense to split mask_and_scale into separate options. Though we do want to figure out a way to reduce the proliferation of these options (https://github.com/pydata/xarray/issues/939).

Reply all
Reply to author
Forward
0 new messages