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 476602539,MDU6SXNzdWU0NzY2MDI1Mzk=,3184,scipy skewnorm function doesnt work with xarray rolling window?,44284270,open,0,,,3,2019-08-04T22:48:08Z,2022-04-18T16:01:40Z,,NONE,,,,"#### MCVE Code Sample ```python loc,scale,shape = da.rolling(time=59).reduce(scipy.stats.skewnorm) ``` #### Expected Output ```python-traceback Traceback (most recent call last): File """", line 1, in File ""/Users/mada0007/anaconda3/envs/modes/lib/python3.7/site-packages/xarray/core/rolling.py"", line 217, in reduce result = windows.reduce(func, dim=rolling_dim, **kwargs) File ""/Users/mada0007/anaconda3/envs/modes/lib/python3.7/site-packages/xarray/core/dataarray.py"", line 1636, in reduce var = self.variable.reduce(func, dim, axis, keep_attrs, **kwargs) File ""/Users/mada0007/anaconda3/envs/modes/lib/python3.7/site-packages/xarray/core/variable.py"", line 1371, in reduce data = func(input_data, axis=axis, **kwargs) File ""/Users/mada0007/anaconda3/envs/modes/lib/python3.7/site-packages/scipy/stats/_distn_infrastructure.py"", line 770, in __call__ return self.freeze(*args, **kwds) File ""/Users/mada0007/anaconda3/envs/modes/lib/python3.7/site-packages/scipy/stats/_distn_infrastructure.py"", line 767, in freeze return rv_frozen(self, *args, **kwds) File ""/Users/mada0007/anaconda3/envs/modes/lib/python3.7/site-packages/scipy/stats/_distn_infrastructure.py"", line 435, in __init__ shapes, _, _ = self.dist._parse_args(*args, **kwds) TypeError: _parse_args() got an unexpected keyword argument 'axis' ``` #### Output of ``ommit: None python: 3.7.2 (default, Dec 29 2018, 00:00:04) [Clang 4.0.1 (tags/RELEASE_401/final)] python-bits: 64 OS: Darwin OS-release: 18.2.0 machine: x86_64 processor: i386 byteorder: little LC_ALL: None LANG: None LOCALE: en_AU.UTF-8 libhdf5: 1.10.4 libnetcdf: 4.6.2 xarray: 0.12.1 pandas: 0.24.2 numpy: 1.15.4 scipy: 1.2.1 netCDF4: 1.5.1.2 pydap: installed h5netcdf: None h5py: None Nio: None zarr: None cftime: 1.0.3.4 nc_time_axis: None PseudonetCDF: None rasterio: None cfgrib: None iris: None bottleneck: None dask: 1.2.2 distributed: 1.28.1 matplotlib: 3.0.3 cartopy: 0.17.0 seaborn: 0.9.0 setuptools: 40.8.0 pip: 19.0.3 conda: None pytest: None IPython: None sphinx: None`` How can I please make this code work? ","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/3184/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue 467814673,MDU6SXNzdWU0Njc4MTQ2NzM=,3124,selecting only october to march from monthly data using xarray,44284270,closed,0,,,9,2019-07-14T09:23:46Z,2021-07-14T15:10:40Z,2019-07-15T02:25:32Z,NONE,,,," I have array of monthy data. I want to select monthly values starting from october to march like this my data = starts from [1950-01,1950-02,1950-03, ...] this is what I want selection = [1950-10, 1950-11, 1950-12, 1960-1,1960-2, 1960-3, ...] # notice it continues to 1960 thanks ","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/3124/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue 543825272,MDU6SXNzdWU1NDM4MjUyNzI=,3656,apply rolling window on function,44284270,closed,0,,,5,2019-12-30T10:16:27Z,2021-02-12T00:05:52Z,2021-02-12T00:05:51Z,NONE,,,,"I am looking for how to apply xarray rolling window to this function. I have really searched a lot but my effort is still futile.. My data is xarray data of shape (time, lon, lat) (323x180x360) respectively ```python def get_grps(s,axis=0, thresh=-1, Nmin=2): """""" Nmin : int > 0 Min number of consecutive values below threshold. """""" s = pd.Series(s) m = np.logical_and.reduce([s.shift(-i).le(thresh) for i in range(Nmin)]) if Nmin > 1: m = pd.Series(m, index=s.index).replace({False: np.NaN}).ffill(limit=Nmin-1).fillna(False) else: m = pd.Series(m, index=s.index) # Form consecutive groups gps = m.ne(m.shift(1)).cumsum().where(m) # Return None if no groups, else the aggregations if gps.isnull().all(): return [0] else: d = s.groupby(gps).agg([list, sum, 'size']).reset_index(drop=True) data = len((d['sum'])) ### returning frequency data = np.array(data) return (data) ``` ### I tried this ```python spi = xr.DataArray(dims=(""time"", ""lon"", ""lat""), data=np.random.randn(324, 180, 360)) spi.rolling(time=59).reduce(get_grps) ``` ## I get this error ```python Traceback (most recent call last): File """", line 1, in File ""/Users/mada0007/anaconda3/envs/RESEARCH_QUESTION_TWO/lib/python3.7/site-packages/xarray/core/rolling.py"", line 287, in reduce result = windows.reduce(func, dim=rolling_dim, **kwargs) File ""/Users/mada0007/anaconda3/envs/RESEARCH_QUESTION_TWO/lib/python3.7/site-packages/xarray/core/dataarray.py"", line 2216, in reduce var = self.variable.reduce(func, dim, axis, keep_attrs, keepdims, **kwargs) File ""/Users/mada0007/anaconda3/envs/RESEARCH_QUESTION_TWO/lib/python3.7/site-packages/xarray/core/variable.py"", line 1529, in reduce data = func(input_data, axis=axis, **kwargs) File """", line 7, in get_grps File ""/Users/mada0007/anaconda3/envs/RESEARCH_QUESTION_TWO/lib/python3.7/site-packages/pandas/core/series.py"", line 314, in __init__ data = sanitize_array(data, index, dtype, copy, raise_cast_failure=True) File ""/Users/mada0007/anaconda3/envs/RESEARCH_QUESTION_TWO/lib/python3.7/site-packages/pandas/core/internals/construction.py"", line 730, in sanitize_array raise Exception(""Data must be 1-dimensional"") Exception: Data must be 1-dimensional ``` How can I rectify this? Thanks ","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/3656/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue 538809911,MDU6SXNzdWU1Mzg4MDk5MTE=,3632,applying ufunc over lon and lat ,44284270,closed,0,,,5,2019-12-17T03:25:44Z,2020-08-23T17:37:29Z,2020-08-23T17:37:29Z,NONE,,,,"I am trying to apply ufunc to my code to speed it up. Currently I am looping over lon and lat and it takes ages. After long reads I came up with this though am still not sure where I a going wrong. Suggestions and Ideas would be very helpful to get me going. thanks ``` python def get_grps(s, thresh=-1, Nmin=3): """""" Nmin : int > 0 Min number of consecutive values below threshold. """""" s = pd.Series(s) m = np.logical_and.reduce([s.shift(-i).le(thresh) for i in range(Nmin)]) if Nmin > 1: m = pd.Series(m, index=s.index).replace({False: np.NaN}).ffill(limit=Nmin-1).fillna(False) else: m = pd.Series(m, index=s.index) # Form consecutive groups gps = m.ne(m.shift(1)).cumsum().where(m) # Return None if no groups, else the aggregations if gps.isnull().all(): return [0] else: d = s.groupby(gps).agg([list, sum, 'size']).reset_index(drop=True) data = np.sum((d['size'])) return data ``` obj is 3d data of shape (324x180x360) (time,lat,lon) ``` python def consec_events(obj): time_nums = xr.DataArray(obj['time'].values.astype(np.float), dims='time', coords={'time': obj['time']}, name='time_nums') trend = xr.apply_ufunc(get_grps,time_nums, obj, vectorize=True, input_core_dims=[['time'], ['time']], output_core_dims=[[]], output_dtypes=[np.float], dask='parallelized',output_sizes={'ntime':time_nums.shape[0]}) return trend results = consec_events(spi) ``` ### ERROR IS HERE ``` ... File ""/Users/mada0007/anaconda3/envs/RESEARCH_QUESTION_TWO/lib/python3.7/site-packages/numpy/lib/function_base.py"", line 2157, in _vectorize_call res = self._vectorize_call_with_signature(func, args) File ""/Users/mada0007/anaconda3/envs/RESEARCH_QUESTION_TWO/lib/python3.7/site-packages/numpy/lib/function_base.py"", line 2221, in _vectorize_call_with_signature output[index] = result ValueError: setting an array element with a sequence. ``` I am relatively new to apply this and I have been reading quite a lot. I would appreciatiate if I can be corrected on how to properly apply this over time dimension of my data and get resulting 2d array for each lon and lat? ","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/3632/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue 540682976,MDU6SXNzdWU1NDA2ODI5NzY=,3650,Ipcc srex regions updated ,44284270,closed,0,,,1,2019-12-20T01:25:59Z,2019-12-20T22:06:02Z,2019-12-20T22:06:02Z,NONE,,,,"There has been updated to IPCC srex regions which has not yet been implemented in xarray I think. In particular I am looking for how I can subset this new cordinate for CENTRAL africa AFRICA;Central-Africa;CAF; 8,-10.0; 8,0; 15.0,14.7; 27.0,14.7; 27.0,-10.0;;;;;;;;; Values on the right are longitudes and values on the left are lattitudes respectively. ","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/3650/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue 417666040,MDU6SXNzdWU0MTc2NjYwNDA=,2804,Error when oppening netcdf file with open_mfdataset,44284270,closed,0,,,3,2019-03-06T07:46:57Z,2019-03-06T23:14:26Z,2019-03-06T23:14:26Z,NONE,,,,"#### Code Sample, a copy-pastable example if possible ```python dset = xr.open_mfdataset('/Users/mada0007/Desktop/Spi1_data/*.nc',autoclose=True) spi_all = dset['pr'][:,:,:] spi_lat = dset['lat'][:] spi_lon = dset['lon'][:] ``` this is my error message ```python-traceback Traceback (most recent call last): File """", line 1, in File ""/Users/mada0007/anaconda3/envs/Research_ass/lib/python2.7/site-packages/xarray/backends/api.py"", line 637, in open_mfdataset datasets = [open_(p, **open_kwargs) for p in paths] File ""/Users/mada0007/anaconda3/envs/Research_ass/lib/python2.7/site-packages/xarray/backends/api.py"", line 344, in open_dataset ds = maybe_decode_store(store) File ""/Users/mada0007/anaconda3/envs/Research_ass/lib/python2.7/site-packages/xarray/backends/api.py"", line 274, in maybe_decode_store drop_variables=drop_variables) File ""/Users/mada0007/anaconda3/envs/Research_ass/lib/python2.7/site-packages/xarray/conventions.py"", line 461, in decode_cf decode_coords, drop_variables=drop_variables) File ""/Users/mada0007/anaconda3/envs/Research_ass/lib/python2.7/site-packages/xarray/conventions.py"", line 394, in decode_cf_variables stack_char_dim=stack_char_dim) File ""/Users/mada0007/anaconda3/envs/Research_ass/lib/python2.7/site-packages/xarray/conventions.py"", line 300, in decode_cf_variable var = coder.decode(var, name=name) File ""/Users/mada0007/anaconda3/envs/Research_ass/lib/python2.7/site-packages/xarray/coding/times.py"", line 412, in decode dtype = _decode_cf_datetime_dtype(data, units, calendar) File ""/Users/mada0007/anaconda3/envs/Research_ass/lib/python2.7/site-packages/xarray/coding/times.py"", line 131, in _decode_cf_datetime_dtype raise ValueError(msg) ValueError: unable to decode time units u'days since 0001-01-01' with calendar u'days since 0001-01-01'. Try opening your dataset with decode_times=False. Full traceback: Traceback (most recent call last): File ""/Users/mada0007/anaconda3/envs/Research_ass/lib/python2.7/site-packages/xarray/coding/times.py"", line 122, in _decode_cf_datetime_dtype result = decode_cf_datetime(example_value, units, calendar) File ""/Users/mada0007/anaconda3/envs/Research_ass/lib/python2.7/site-packages/xarray/coding/times.py"", line 192, in decode_cf_datetime flat_num_dates.astype(np.float), units, calendar) File ""/Users/mada0007/anaconda3/envs/Research_ass/lib/python2.7/site-packages/xarray/coding/times.py"", line 92, in _decode_datetime_with_cftime only_use_cftime_datetimes=True)) File ""cftime/_cftime.pyx"", line 265, in cftime._cftime.num2date File ""cftime/_cftime.pyx"", line 730, in cftime._cftime.utime.__init__ ######ValueError: calendar must be one of ['standard', 'gregorian', 'proleptic_gregorian', 'noleap', 'julian', 'all_leap', '365_day', '366_day', '360_day'], got 'days since 0001-01-01' ``` #### Problem description trying to open this netcdf files which was writtend by me, code not working at all expecting ext #### Output of ``xr.show_versions()``
INSTALLED VERSIONS ------------------ commit: None python: 2.7.15 | packaged by conda-forge | (default, Feb 27 2019, 20:44:16) [GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] python-bits: 64 OS: Darwin OS-release: 18.2.0 machine: x86_64 processor: i386 byteorder: little LC_ALL: None LANG: None LOCALE: None.None libhdf5: 1.10.2 libnetcdf: 4.6.1 xarray: 0.11.3 pandas: 0.24.1 numpy: 1.16.2 scipy: 1.2.1 netCDF4: 1.4.2 pydap: None h5netcdf: None h5py: None Nio: None zarr: None cftime: 1.0.3.4 PseudonetCDF: None rasterio: None cfgrib: None iris: None bottleneck: None cyordereddict: None dask: 1.1.3 distributed: None matplotlib: 2.2.3 cartopy: 0.17.0 seaborn: None setuptools: 40.8.0 pip: 19.0.3 conda: None pytest: None IPython: None sphinx: None
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/2804/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue 408010761,MDU6SXNzdWU0MDgwMTA3NjE=,2755,rolling count not working,44284270,closed,0,,,5,2019-02-08T05:24:11Z,2019-02-08T14:43:59Z,2019-02-08T07:50:56Z,NONE,,,,"This is my code ```python R = OM.rolling(time=59) for label, arr_window in R: aa_try = dset.precip \ .where(dset.precip < 50) \ .count(dim='time') ``` so my data is of shape 324,72,144 i.e. time,lon and lat. I want to do a rolling count over the time dimention with threshold as specified above. the problem is I expect to get data of the same dimension but instead I get only 2d data. Is there anyway to get around this? Any advice will be very helpfull. [this should explain **why** the current behavior is a problem and why the expected output is a better solution.]
Output of INSTALLED VERSIONS ------------------ commit: None python: 3.6.6.final.0 python-bits: 64 OS: Darwin OS-release: 18.2.0 machine: x86_64 processor: i386 byteorder: little LC_ALL: None LANG: None LOCALE: en_AU.UTF-8 xarray: 0.11.0 pandas: 0.23.4 numpy: 1.15.4 scipy: 1.1.0 netCDF4: 1.4.1 h5netcdf: None h5py: 2.8.0 Nio: None zarr: None cftime: 1.0.3.4 PseudonetCDF: None rasterio: None iris: 2.2.0 bottleneck: None cyordereddict: None dask: 1.0.0 distributed: 1.25.0 matplotlib: 3.0.2 cartopy: 0.17.0 seaborn: 0.9.0 setuptools: 40.6.2 pip: 18.1 conda: None pytest: None IPython: 7.2.0 sphinx: 1.8.3
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/2755/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue