When I run this command:
parameter = ['tp', 't2m']
ds = cml.load_source("file-pattern", data_path+"{var}.nc",var = parameter).to_xarray()
get Error: ValueError: cannot include dtype 'M' in a buffer
The complete error message is:
ValueError Traceback (most recent call last)
/tmp/ipykernel_222242/146458586.py in
7 #parameter = ['t2m']
8 parameter = ['tp', 't2m']
----> 9 ds = cml.load_source("file-pattern", data_path+"{var}.nc",var = parameter).to_xarray()
10 print(ds)
~/anaconda3/envs/S2SAI/lib/python3.7/site-packages/climetlab/sources/multi.py in to_xarray(self, **kwargs)
97
98 def to_xarray(self, **kwargs):
---> 99 return make_merger(self.merger, self.sources).to_xarray(**kwargs)
100
101 def to_tfdataset(self, **kwargs):
~/anaconda3/envs/S2SAI/lib/python3.7/site-packages/climetlab/mergers/init.py in to_xarray(self, **kwargs)
101 paths=self.paths,
102 reader_class=self.reader_class,
--> 103 **kwargs,
104 )
105
~/anaconda3/envs/S2SAI/lib/python3.7/site-packages/climetlab/mergers/xarray.py in merge(sources, paths, reader_class, **kwargs)
75 return reader_class.to_xarray_multi_from_paths(
76 paths,
---> 77 **options,
78 )
79
~/anaconda3/envs/S2SAI/lib/python3.7/site-packages/climetlab/readers/netcdf.py in to_xarray_multi_from_paths(cls, paths, **kwargs)
331 return xr.open_mfdataset(
332 paths,
--> 333 **options,
334 )
335
~/anaconda3/envs/S2SAI/lib/python3.7/site-packages/xarray/backends/api.py in open_mfdataset(paths, chunks, concat_dim, compat, preprocess, engine, data_vars, coords, combine, parallel, join, attrs_file, combine_attrs, **kwargs)
940 coords=coords,
941 join=join,
--> 942 combine_attrs=combine_attrs,
943 )
944 else:
~/anaconda3/envs/S2SAI/lib/python3.7/site-packages/xarray/core/combine.py in combine_by_coords(data_objects, compat, data_vars, coords, fill_value, join, combine_attrs, datasets)
989 fill_value=fill_value,
990 join=join,
--> 991 combine_attrs=combine_attrs,
992 )
~/anaconda3/envs/S2SAI/lib/python3.7/site-packages/xarray/core/merge.py in merge(objects, compat, join, fill_value, combine_attrs)
908 join,
909 combine_attrs=combine_attrs,
--> 910 fill_value=fill_value,
911 )
912 return Dataset._construct_direct(**merge_result._asdict())
~/anaconda3/envs/S2SAI/lib/python3.7/site-packages/xarray/core/merge.py in merge_core(objects, compat, join, combine_attrs, priority_arg, explicit_coords, indexes, fill_value)
639 prioritized = _get_priority_vars_and_indexes(aligned, priority_arg, compat=compat)
640 variables, out_indexes = merge_collected(
--> 641 collected, prioritized, compat=compat, combine_attrs=combine_attrs
642 )
643 assert_unique_multiindex_level_names(variables)
~/anaconda3/envs/S2SAI/lib/python3.7/site-packages/xarray/core/merge.py in merge_collected(grouped, prioritized, compat, combine_attrs)
240 variables = [variable for variable, _ in elements_list]
241 try:
--> 242 merged_vars[name] = unique_variable(name, variables, compat)
243 except MergeError:
244 if compat != "minimal":
~/anaconda3/envs/S2SAI/lib/python3.7/site-packages/xarray/core/merge.py in unique_variable(name, variables, compat, equals)
144 out = out.compute()
145 for var in variables[1:]:
--> 146 equals = getattr(out, compat)(var)
147 if not equals:
148 break
~/anaconda3/envs/S2SAI/lib/python3.7/site-packages/xarray/core/variable.py in no_conflicts(self, other, equiv)
1976 or both, contain NaN values.
1977 """
-> 1978 return self.broadcast_equals(other, equiv=equiv)
1979
1980 def quantile(
~/anaconda3/envs/S2SAI/lib/python3.7/site-packages/xarray/core/variable.py in broadcast_equals(self, other, equiv)
1958 except (ValueError, AttributeError):
1959 return False
-> 1960 return self.equals(other, equiv=equiv)
1961
1962 def identical(self, other, equiv=duck_array_ops.array_equiv):
~/anaconda3/envs/S2SAI/lib/python3.7/site-packages/xarray/core/variable.py in equals(self, other, equiv)
1942 try:
1943 return self.dims == other.dims and (
-> 1944 self._data is other._data or equiv(self.data, other.data)
1945 )
1946 except (TypeError, AttributeError):
~/anaconda3/envs/S2SAI/lib/python3.7/site-packages/xarray/core/duck_array_ops.py in array_notnull_equiv(arr1, arr2)
270 with warnings.catch_warnings():
271 warnings.filterwarnings("ignore", "In the future, 'NAT == x'")
--> 272 flag_array = (arr1 == arr2) | isnull(arr1) | isnull(arr2)
273 return bool(flag_array.all())
274 else:
~/anaconda3/envs/S2SAI/lib/python3.7/site-packages/dask/array/core.py in eq(self, other)
1745
1746 def eq(self, other):
-> 1747 return elemwise(operator.eq, self, other)
1748
1749 def gt(self, other):
~/anaconda3/envs/S2SAI/lib/python3.7/site-packages/dask/array/core.py in elemwise(op, *args, **kwargs)
3774 for a in args
3775 ),
-> 3776 **blockwise_kwargs
3777 )
3778
~/anaconda3/envs/S2SAI/lib/python3.7/site-packages/dask/array/blockwise.py in blockwise(func, out_ind, name, token, dtype, adjust_chunks, new_axes, align_arrays, concatenate, meta, *args, **kwargs)
143
144 if align_arrays:
--> 145 chunkss, arrays = unify_chunks(*args)
146 else:
147 arginds = [(a, i) for (a, i) in toolz.partition(2, args) if i is not None]
~/anaconda3/envs/S2SAI/lib/python3.7/site-packages/dask/array/core.py in unify_chunks(*args, **kwargs)
3043
3044 arginds = [
-> 3045 (asanyarray(a) if ind is not None else a, ind) for a, ind in partition(2, args)
3046 ] # [x, ij, y, jk]
3047 args = list(concat(arginds)) # [(x, ij), (y, jk)]
~/anaconda3/envs/S2SAI/lib/python3.7/site-packages/dask/array/core.py in (.0)
3043
3044 arginds = [
-> 3045 (asanyarray(a) if ind is not None else a, ind) for a, ind in partition(2, args)
3046 ] # [x, ij, y, jk]
3047 args = list(concat(arginds)) # [(x, ij), (y, jk)]
~/anaconda3/envs/S2SAI/lib/python3.7/site-packages/dask/array/core.py in asanyarray(a)
3618 elif hasattr(a, "to_dask_array"):
3619 return a.to_dask_array()
-> 3620 elif hasattr(a, "data") and type(a).module.startswith("xarray."):
3621 return asanyarray(a.data)
3622 elif isinstance(a, (list, tuple)) and any(isinstance(i, Array) for i in a):
ValueError: cannot include dtype 'M' in a buffer
can someone help find the reason for the error? Thank you very much.
When I run this command open one file, it's ok.
parameter = ['tp'']
ds = cml.load_source("file-pattern", data_path+"{var}.nc",var = parameter).to_xarray()
tp.nc Data information is :
<xarray.Dataset>
Dimensions: (category: 3, forecast_time: 53, lead_time: 2, latitude: 121, longitude: 240)
Coordinates:
- category (category) object 'below normal' 'near normal' 'above normal'
- forecast_time (forecast_time) datetime64[ns] 2020-01-02 ... 2020-12-31
- lead_time (lead_time) timedelta64[ns] 14 days 28 days
- latitude (latitude) float64 90.0 88.5 87.0 85.5 ... -87.0 -88.5 -90.0
- longitude (longitude) float64 0.0 1.5 3.0 4.5 ... 355.5 357.0 358.5
valid_time (forecast_time, lead_time) datetime64[ns] dask.array<chunksize=(53, 2), meta=np.ndarray>
Data variables:
tp (category, forecast_time, lead_time, latitude, longitude) float32 dask.array<chunksize=(3, 53, 2, 121, 240), meta=np.ndarray>
Attributes:
GRIB_edition: 1
GRIB_centre: ecmf
GRIB_centreDescription: European Centre for Medium-Range Weather Forecasts
GRIB_subCentre: 0
Conventions: CF-1.7
institution: European Centre for Medium-Range Weather Forecasts
history: 2021-06-04T12:48 GRIB to CDM+CF via cfgrib-0.9.9...
comment_lead_time: The value of valid_time does not refer to the da...
t2m.nc Data information is :
<xarray.Dataset>
Dimensions: (category: 3, forecast_time: 53, lead_time: 2, latitude: 121, longitude: 240)
Coordinates:
- category (category) object 'below normal' 'near normal' 'above normal'
- forecast_time (forecast_time) datetime64[ns] 2020-01-02 ... 2020-12-31
- lead_time (lead_time) timedelta64[ns] 14 days 28 days
- latitude (latitude) float64 90.0 88.5 87.0 85.5 ... -87.0 -88.5 -90.0
- longitude (longitude) float64 0.0 1.5 3.0 4.5 ... 355.5 357.0 358.5
valid_time (forecast_time, lead_time) datetime64[ns] dask.array<chunksize=(53, 2), meta=np.ndarray>
Data variables:
t2m (category, forecast_time, lead_time, latitude, longitude) float32 dask.array<chunksize=(3, 53, 2, 121, 240), meta=np.ndarray>
Attributes:
GRIB_edition: 1
GRIB_centre: ecmf
GRIB_centreDescription: European Centre for Medium-Range Weather Forecasts
GRIB_subCentre: 0
Conventions: CF-1.7
institution: European Centre for Medium-Range Weather Forecasts
history: 2021-06-04T12:48 GRIB to CDM+CF via cfgrib-0.9.9...
comment_lead_time: The value of valid_time does not refer to the da...
Finally, can someone help find the reason for the error? Thank you very much.