File tree Expand file tree Collapse file tree 1 file changed +12
-16
lines changed Expand file tree Collapse file tree 1 file changed +12
-16
lines changed Original file line number Diff line number Diff line change 1+ import numpy as np
12import os .path
23import sys
34
@@ -24,23 +25,18 @@ class PruneDataTest(CliTest):
2425 def setUp (self ) -> None :
2526 rimraf (self .TEST_CUBE )
2627 cube = new_cube (time_periods = 3 ,
27- variables = dict (precipitation = 1.0 ,
28- temperature = 1.0 )) \
28+ variables = dict (precipitation = np . nan ,
29+ temperature = np . nan )) \
2930 .chunk (dict (time = 1 , lat = 90 , lon = 90 ))
30-
31- write_cube (cube , self .TEST_CUBE , "zarr" , cube_asserted = True )
32-
33- # we need to manually edit the fill values, otherwise, as of zarr 2.11,
34- # empty chunks are not written
35- import json
36- with open (f'{ self .TEST_CUBE } /.zmetadata' ) as metadata :
37- metadata_dict = json .load (metadata )
38- metadata_dict ['metadata' ]['precipitation/.zarray' ]['fill_value' ] \
39- = 1.0
40- metadata_dict ['metadata' ]['temperature/.zarray' ]['fill_value' ] \
41- = 1.0
42- with open (f'{ self .TEST_CUBE } /.zmetadata' , 'w' ) as metadata :
43- json .dump (metadata_dict , metadata )
31+ encoding = {
32+ 'precipitation' : {
33+ '_FillValue' : None
34+ },
35+ 'temperature' : {
36+ '_FillValue' : None
37+ }
38+ }
39+ cube .to_zarr (self .TEST_CUBE , encoding = encoding )
4440
4541 def tearDown (self ) -> None :
4642 rimraf (self .TEST_CUBE )
You can’t perform that action at this time.
0 commit comments