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/1626#issuecomment-1112231763,https://api.github.com/repos/pydata/xarray/issues/1626,1112231763,IC_kwDOAMm_X85CS09T,601177,2022-04-28T13:51:17Z,2022-04-28T13:51:17Z,NONE,"> If this issue remains relevant, please comment here or remove the `stale` label; otherwise it will be marked as closed automatically
Still relevant.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,264582338
https://github.com/pydata/xarray/issues/1626#issuecomment-363129063,https://api.github.com/repos/pydata/xarray/issues/1626,363129063,MDEyOklzc3VlQ29tbWVudDM2MzEyOTA2Mw==,601177,2018-02-05T15:59:50Z,2018-02-05T22:01:35Z,NONE,"I'd also like to see better support for compound types, writing them for starters. I'll collect some information here:
* In the code @tfurf linked to ([_nc4_values_and_dtype](https://github.com/pydata/xarray/blob/27132fba1e465955e76ed155ba6cbb769c0904df/xarray/backends/netCDF4_.py#L81)), an `elif` needs to be added to catch structured dtypes. I think they have `kind == 'V'`.
* [`dtype.builtin`](https://docs.scipy.org/doc/numpy/reference/generated/numpy.dtype.isbuiltin.html) can be used to detect whether we are indeed dealing with a structured type. Namely `dtype.builtin` must be `0`.
* The structured type must fist be added to the `netCDF4.Dataset` using its method [`createCompoundType`](https://unidata.github.io/netcdf4-python/#netCDF4.Dataset.createCompoundType). This must be done recursively, with the deepest levels first.
* The netCDF variable is created in [`prepare_variable`](https://github.com/pydata/xarray/blob/27132fba1e465955e76ed155ba6cbb769c0904df/xarray/backends/netCDF4_.py#L311), which calls `_nc4_values_and_dtype`. There, via `self.ds` we also have access to the netCDF4 `Dataset` to be used for the creation of the as mentioned above. [However, is `self.ds` really the Dataset, or some `NetCDF4.Group`?](https://github.com/pydata/xarray/blob/27132fba1e465955e76ed155ba6cbb769c0904df/xarray/backends/netCDF4_.py#L112) In any case `_nc4_values_and_dtype` and its use in `prepare_variable` needs to be refactored, because we need access to the underlying netCDF4 `Dataset`.
Is there anything I've missed? Can someone shed light on whether `self.ds` in `prepare_variable` can be assumed to the underlying netCDF4 `Dataset`?","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,264582338