Hi @kmuehlbauer ,
I have resampled the radolan hourly data to daily, monthly, quarterly and yearly values. Basically here my goal is to subset and plot the data of Brandenburg state. I have been trying different ways in the last couple of days, however I was not successful though. This time I am sharing the radolan hourly data file. Please have a look and let me know what I have to do inorder to plot the data for the specified region.
import geopandas
import rioxarray
import xarray
from shapely.geometry import mapping
import cartopy.crs as ccrs
rad = xarray.open_dataset("D:/Sandeep/Thesis/Data/ds2006h.nc")
rad
Out[65]:
<xarray.Dataset>
Dimensions: (time: 8757, y: 900, x: 900)
Coordinates:
* time (time) datetime64[ns] 2006-01-01T00:45:00 ... 2006-12-31T22:...
* y (y) float64 -4.658e+06 -4.657e+06 ... -3.76e+06 -3.759e+06
* x (x) float64 -5.23e+05 -5.22e+05 -5.21e+05 ... 3.75e+05 3.76e+05
lon (y, x) float64 ...
lat (y, x) float64 ...
spatial_ref int32 0
Data variables:
RW (time, y, x) float32 ...
Attributes:
radarid: 10000
formatversion: 2
radolanversion: 01.01.00
radarlocations: ['bln', 'drs', 'eis', 'emd', 'ess', 'fbg', 'fld', 'fra',...
rad.rio.set_spatial_dims(x_dim="x", y_dim="y", inplace=True)
rad.rio.write_crs("epsg:4839", inplace=True)
brandenburg = geopandas.read_file(r'D:\Sandeep\Thesis\Gemeindegrenzen_-_Brandenburg\Gemeindegrenzen_Brandenburg.shp')
This is how error looks like when I run the below line.
clipped = rad.rio.clip(brandenburg.geometry.apply(mapping), rad.rio.crs, drop=False)
Traceback (most recent call last):
File "C:\Users\Admin\AppData\Local\Temp\ipykernel_9012\191679719.py", line 1, in <cell line: 1>
clipped = rad.rio.clip(brandenburg.geometry.apply(mapping), rad.rio.crs, drop=False)
File "C:\Users\Admin\anaconda3\envs\wradlib\lib\site-packages\rioxarray\raster_dataset.py", line 380, in clip
self._obj[var]
File "C:\Users\Admin\anaconda3\envs\wradlib\lib\site-packages\rioxarray\raster_array.py", line 930, in clip
cropped_ds = _clip_xarray(
File "C:\Users\Admin\anaconda3\envs\wradlib\lib\site-packages\rioxarray\raster_array.py", line 229, in _clip_xarray
cropped_ds = xds.where(clip_mask_xray)
File "C:\Users\Admin\anaconda3\envs\wradlib\lib\site-packages\xarray\core\common.py", line 1099, in where
return ops.where_method(self, cond, other)
File "C:\Users\Admin\anaconda3\envs\wradlib\lib\site-packages\xarray\core\ops.py", line 177, in where_method
return apply_ufunc(
File "C:\Users\Admin\anaconda3\envs\wradlib\lib\site-packages\xarray\core\computation.py", line 1204, in apply_ufunc
return apply_dataarray_vfunc(
File "C:\Users\Admin\anaconda3\envs\wradlib\lib\site-packages\xarray\core\computation.py", line 315, in apply_dataarray_vfunc
result_var = func(*data_vars)
File "C:\Users\Admin\anaconda3\envs\wradlib\lib\site-packages\xarray\core\computation.py", line 683, in apply_variable_ufunc
input_data = [
File "C:\Users\Admin\anaconda3\envs\wradlib\lib\site-packages\xarray\core\computation.py", line 684, in <listcomp>
broadcast_compat_data(arg, broadcast_dims, core_dims)
File "C:\Users\Admin\anaconda3\envs\wradlib\lib\site-packages\xarray\core\computation.py", line 599, in broadcast_compat_data
data = variable.data
File "C:\Users\Admin\anaconda3\envs\wradlib\lib\site-packages\xarray\core\variable.py", line 386, in data
return self.values
File "C:\Users\Admin\anaconda3\envs\wradlib\lib\site-packages\xarray\core\variable.py", line 559, in values
return _as_array_or_item(self._data)
File "C:\Users\Admin\anaconda3\envs\wradlib\lib\site-packages\xarray\core\variable.py", line 265, in _as_array_or_item
data = np.asarray(data)
File "C:\Users\Admin\anaconda3\envs\wradlib\lib\site-packages\xarray\core\indexing.py", line 653, in __array__
self._ensure_cached()
File "C:\Users\Admin\anaconda3\envs\wradlib\lib\site-packages\xarray\core\indexing.py", line 650, in _ensure_cached
self.array = NumpyIndexingAdapter(np.asarray(self.array))
File "C:\Users\Admin\anaconda3\envs\wradlib\lib\site-packages\xarray\core\indexing.py", line 623, in __array__
return np.asarray(self.array, dtype=dtype)
File "C:\Users\Admin\anaconda3\envs\wradlib\lib\site-packages\xarray\core\indexing.py", line 524, in __array__
return np.asarray(array[self.key], dtype=None)
File "C:\Users\Admin\anaconda3\envs\wradlib\lib\site-packages\xarray\coding\variables.py", line 72, in __array__
return self.func(self.array)
File "C:\Users\Admin\anaconda3\envs\wradlib\lib\site-packages\xarray\coding\variables.py", line 219, in _scale_offset_decoding
data = np.array(data, dtype=dtype, copy=True)
File "C:\Users\Admin\anaconda3\envs\wradlib\lib\site-packages\xarray\coding\variables.py", line 72, in __array__
return self.func(self.array)
File "C:\Users\Admin\anaconda3\envs\wradlib\lib\site-packages\xarray\coding\variables.py", line 139, in _apply_mask
data = np.asarray(data, dtype=dtype)
MemoryError: Unable to allocate 26.4 GiB for an array with shape (8757, 900, 900) and data type float32