html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,performed_via_github_app,issue
https://github.com/pydata/xarray/issues/2304#issuecomment-462592638,https://api.github.com/repos/pydata/xarray/issues/2304,462592638,MDEyOklzc3VlQ29tbWVudDQ2MjU5MjYzOA==,791145,2019-02-12T02:48:00Z,2019-02-12T02:48:00Z,NONE,"Hi everyone,
I've start using xarray recently, so I apologize if I'm saying something wrong...
I've also faced the here reported issue, so have tried to find some answers.
Unpacking netcdf files with respect to the NUG attributes (**scale_factor** and **add_offset**) seems to be mentioned by the CF-Conventions directives. And it's clear about which data type should be applied to the unpacked data. [cf-conventions-1.7/packed-data](http://cfconventions.org/Data/cf-conventions/cf-conventions-1.7/build/ch08.html#packed-data)
In this chapter you can read that: ""_If the scale_factor and add_offset attributes are of the same data type as the associated variable, the unpacked data is assumed to be of the same data type as the packed data. However, if the scale_factor and add_offset attributes are of a different data type from the variable (containing the packed data) then the unpacked data should match the type of these attributes_"".
In my opinion this should be the default behavior of the [xarray.decode_cf](http://xarray.pydata.org/en/stable/generated/xarray.decode_cf.html) function. Which doesn't invalidate the idea of forcing the unpacked data dtype.
However non of the **CFScaleOffsetCoder** and **CFMaskCoder** de/encoder classes seems to be according with these CF directives, since the first one doesn't look for the **scale_factor** or **add_offset** dtypes, and the second one also changes the unpacked data dtype (maybe because _nan_ values are being used to replace the fill values).
Sorry for such an extensive comment, without any solutions proposal...
Regards! :+1: ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,343659822