@@ -266,10 +266,12 @@ def __array__(self, *args, **kwargs):
266266 if args :
267267 dtype = args [0 ]
268268
269- if dtype and dtype != self .dtype :
270- raise ValueError (
271- 'Requested datatype does not match this chunk'
272- )
269+ # Allow casting to alternate dtypes. Native dtype
270+ # is no longer enforced.
271+ #if dtype and dtype != self.dtype:
272+ # raise ValueError(
273+ # 'Requested datatype does not match this chunk'
274+ # )
273275
274276 array = self ._get_array (* args )
275277
@@ -280,7 +282,9 @@ def __array__(self, *args, **kwargs):
280282 self ._correct_slice (array .dimensions )
281283
282284 try :
283- var = np .array (array [tuple (self ._extent )], dtype = self .dtype )
285+ # Still allowed to request a specific dtype
286+ # Otherwise dtype casting prevented
287+ var = np .array (array [tuple (self ._extent )], dtype = dtype )
284288 except IndexError :
285289 raise ValueError (
286290 f"Unable to select required 'extent' of { self .extent } "
@@ -315,6 +319,10 @@ def _get_array(self, *args):
315319
316320 try :
317321 array = ds .variables [varname ]
322+ # Disable auto mask/scaling - implemented by Xarray
323+ if self .format == 'nc' :
324+ array .set_auto_maskandscale (False )
325+ # only added in netCDF4-python v1.2.8
318326 except KeyError :
319327 raise ValueError (
320328 f"Dask Chunk at '{ self .position } ' does not contain "
0 commit comments