id,node_id,number,title,user,state,locked,assignee,milestone,comments,created_at,updated_at,closed_at,author_association,active_lock_reason,draft,pull_request,body,reactions,performed_via_github_app,state_reason,repo,type 376389539,MDU6SXNzdWUzNzYzODk1Mzk=,2535,HDF error when trying to write Dataset read with rasterio to NetCDF,5638829,closed,0,,,17,2018-11-01T13:21:15Z,2023-03-29T16:01:26Z,2023-03-29T16:01:26Z,NONE,,,,"I'm getting an HDF error when trying to write a Dataset read from GeoTiff (rasterio backend) to NetCDF. See reproducible example below: ```python import urllib.request import tempfile import os import xarray as xr path = tempfile.gettempdir() url = 'https://earthexplorer.usgs.gov/browse/gisready/landsat_8/LC08_L1TP_026047_20180110_20180119_01_T1.zip' filename = os.path.join(path, url.split('/')[-1]) nc_name = os.path.join(path, 'landsat_rgb.nc') # Download file if not exist (11 Mb) if not os.path.isfile(filename): urllib.request.urlretrieve(url, filename) # Read rgb file using rasterio backend rgb_name = '/'.join(['/vsizip', filename, os.path.basename(filename).split('.')[-2] + '.tif']) ds = xr.open_rasterio(rgb_name) ds = ds.to_dataset('band').rename({1:'blue', 2:'green', 3:'red'}) print(ds) # # Dimensions: (x: 7611, y: 7761) # Coordinates: # * y (y) float64 2.193e+06 2.193e+06 2.193e+06 ... 1.961e+06 1.960e+06 # * x (x) float64 3.732e+05 3.732e+05 3.733e+05 ... 6.015e+05 6.015e+05 # Data variables: # blue (y, x) uint8 ... # red (y, x) uint8 ... # green (y, x) uint8 ... # Attributes: # transform: (30.0, 0.0, 373185.0, 0.0, -30.0, 2193315.0) # crs: +init=epsg:32614 # res: (30.0, 30.0) # is_tiled: 1 # nodatavals: (nan, nan, nan) # Write to netcdf ds.to_netcdf(nc_name) ``` #### Output of ``xr.show_versions()``
python -c ""import xarray as xr; xr.show_versions()"" INSTALLED VERSIONS ------------------ commit: None python: 3.6.5.final.0 python-bits: 64 OS: Linux OS-release: 4.15.0-36-generic machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: en_US.UTF-8 xarray: 0.10.9 pandas: 0.23.4 numpy: 1.15.3 scipy: None netCDF4: 1.4.2 h5netcdf: None h5py: None Nio: None zarr: 2.2.0 cftime: 1.0.2.1 PseudonetCDF: None rasterio: 1.0.9 iris: None bottleneck: None cyordereddict: None dask: 0.20.0 distributed: None matplotlib: None cartopy: None seaborn: None setuptools: 40.5.0 pip: 18.1 conda: None pytest: None IPython: 7.1.1 sphinx: None
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/2535/reactions"", ""total_count"": 2, ""+1"": 2, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue 293725143,MDU6SXNzdWUyOTM3MjUxNDM=,1878,dtype kwargs of aggregation methods not passed to numpy function,5638829,closed,0,,,3,2018-02-01T23:47:58Z,2018-02-02T00:06:02Z,2018-02-01T23:58:08Z,NONE,,,,"Hi, I'm trying to pass `dtype=` as kwargs to some aggregation methods, but it seems that the argument is ignored. See the example below. ```python import xarray as xr import numpy as np from datetime import datetime import datetime as dt arr = np.random.randint(0, 10000, size=(20, 1000, 1000), dtype=np.int16) date_list = [datetime(2018, 1, 1) + dt.timedelta(delta) for delta in range(20)] xarr = xr.DataArray(arr, dims=['time', 'x', 'y'], coords={'time': date_list}) xset = xr.Dataset({'blue': xarr, 'green': xarr, 'red': xarr}) print(xset) # # Dimensions: (time: 20, x: 1000, y: 1000) # Coordinates: # * time (time) datetime64[ns] 2018-01-01 2018-01-02 2018-01-03 ... # Dimensions without coordinates: x, y # Data variables: # blue (time, x, y) int16 1946 9194 1563 8318 938 8498 7999 6609 6275 ... # red (time, x, y) int16 1946 9194 1563 8318 938 8498 7999 6609 6275 ... # green (time, x, y) int16 1946 9194 1563 8318 938 8498 7999 6609 6275 ... xset_mean = xset.mean('time', keep_attrs=True, dtype=np.int16) print(xset_mean) # # Dimensions: (x: 1000, y: 1000) # Dimensions without coordinates: x, y # Data variables: # blue (x, y) float64 5.46e+03 4.717e+03 5.959e+03 4.31e+03 4.865e+03 ... # red (x, y) float64 5.46e+03 4.717e+03 5.959e+03 4.31e+03 4.865e+03 ... # green (x, y) float64 5.46e+03 4.717e+03 5.959e+03 4.31e+03 4.865e+03 ... # Pure numpy arr_mean = arr.mean(axis=0, dtype=np.int16) print(arr_mean.dtype) # int16 ```
INSTALLED VERSIONS ------------------ commit: None python: 3.5.2.final.0 python-bits: 64 OS: Linux OS-release: 4.4.0-104-generic machine: x86_64 processor: x86_64 byteorder: little LC_ALL: en_US.UTF-8 LANG: en_US.UTF-8 LOCALE: en_US.UTF-8 xarray: 0.10.0 pandas: 0.22.0 numpy: 1.14.0 scipy: None netCDF4: 1.3.1 h5netcdf: None Nio: None bottleneck: None cyordereddict: None dask: 0.16.0 matplotlib: None cartopy: None seaborn: None setuptools: 38.4.0 pip: 9.0.1 conda: None pytest: None IPython: None sphinx: None
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/1878/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue