36
36
37
37
38
38
class PydapArrayWrapper (BackendArray ):
39
- def __init__ (self , array , batch = False , cache = None ):
39
+ def __init__ (self , array , batch = False , cache = None , checksums = True ):
40
40
self .array = array
41
41
self ._batch = batch
42
42
self ._cache = cache
43
+ self ._checksums = checksums
43
44
44
45
@property
45
46
def shape (self ) -> tuple [int , ...]:
@@ -63,7 +64,7 @@ def _getitem(self, key):
63
64
from pydap .lib import resolve_batch_for_all_variables
64
65
65
66
dataset = self .array .dataset
66
- resolve_batch_for_all_variables (self .array , key )
67
+ resolve_batch_for_all_variables (self .array , key , checksums = self . _checksums )
67
68
result = np .asarray (
68
69
dataset ._current_batch_promise .wait_for_result (self .array .id )
69
70
)
@@ -98,7 +99,15 @@ class PydapDataStore(AbstractDataStore):
98
99
be useful if the netCDF4 library is not available.
99
100
"""
100
101
101
- def __init__ (self , dataset , group = None , session = None , batch = False , protocol = None ):
102
+ def __init__ (
103
+ self ,
104
+ dataset ,
105
+ group = None ,
106
+ session = None ,
107
+ batch = False ,
108
+ protocol = None ,
109
+ checksums = True ,
110
+ ):
102
111
"""
103
112
Parameters
104
113
----------
@@ -113,6 +122,7 @@ def __init__(self, dataset, group=None, session=None, batch=False, protocol=None
113
122
self ._batch_done = False
114
123
self ._array_cache = {} # holds 1D dimension data
115
124
self ._protocol = protocol
125
+ self ._checksums = checksums # true by default
116
126
117
127
@classmethod
118
128
def open (
@@ -126,6 +136,7 @@ def open(
126
136
verify = None ,
127
137
user_charset = None ,
128
138
batch = False ,
139
+ checksums = True ,
129
140
):
130
141
from pydap .client import open_url
131
142
from pydap .net import DEFAULT_TIMEOUT
@@ -157,6 +168,7 @@ def open(
157
168
# pydap dataset
158
169
dataset = url .ds
159
170
args = {"dataset" : dataset }
171
+ args ["checksums" ] = checksums
160
172
if group :
161
173
args ["group" ] = group
162
174
if url .startswith (("http" , "dap2" )):
@@ -202,7 +214,7 @@ def open_store_variable(self, var):
202
214
else :
203
215
# all non-dimension variables
204
216
data = indexing .LazilyIndexedArray (
205
- PydapArrayWrapper (var , self ._batch , self ._array_cache )
217
+ PydapArrayWrapper (var , self ._batch , self ._array_cache , self . _checksums )
206
218
)
207
219
208
220
return Variable (dimensions , data , var .attributes )
@@ -256,7 +268,9 @@ def _get_data_array(self, var):
256
268
257
269
if not self ._batch_done or var .id not in self ._array_cache :
258
270
# store all dim data into a dict for reuse
259
- self ._array_cache = get_batch_data (var .parent , self ._array_cache )
271
+ self ._array_cache = get_batch_data (
272
+ var .parent , self ._array_cache , self ._checksums
273
+ )
260
274
self ._batch_done = True
261
275
262
276
return self ._array_cache [var .id ]
@@ -305,6 +319,7 @@ def open_dataset(
305
319
verify = None ,
306
320
user_charset = None ,
307
321
batch = False ,
322
+ checksums = True ,
308
323
) -> Dataset :
309
324
store = PydapDataStore .open (
310
325
url = filename_or_obj ,
@@ -316,6 +331,7 @@ def open_dataset(
316
331
verify = verify ,
317
332
user_charset = user_charset ,
318
333
batch = batch ,
334
+ checksums = checksums ,
319
335
)
320
336
store_entrypoint = StoreBackendEntrypoint ()
321
337
with close_on_error (store ):
@@ -349,6 +365,7 @@ def open_datatree(
349
365
verify = None ,
350
366
user_charset = None ,
351
367
batch = False ,
368
+ checksums = True ,
352
369
) -> DataTree :
353
370
groups_dict = self .open_groups_as_dict (
354
371
filename_or_obj ,
@@ -366,6 +383,7 @@ def open_datatree(
366
383
verify = application ,
367
384
user_charset = user_charset ,
368
385
batch = batch ,
386
+ checksums = checksums ,
369
387
)
370
388
371
389
return datatree_from_dict_with_io_cleanup (groups_dict )
@@ -388,6 +406,7 @@ def open_groups_as_dict(
388
406
verify = None ,
389
407
user_charset = None ,
390
408
batch = False ,
409
+ checksums = True ,
391
410
) -> dict [str , Dataset ]:
392
411
from xarray .core .treenode import NodePath
393
412
@@ -400,6 +419,7 @@ def open_groups_as_dict(
400
419
verify = verify ,
401
420
user_charset = user_charset ,
402
421
batch = batch ,
422
+ checksums = checksums ,
403
423
)
404
424
405
425
# Check for a group and make it a parent if it exists
0 commit comments