Skip to content

Commit

Permalink
updated to convert variables with byte-like strings to base64
Browse files Browse the repository at this point in the history
  • Loading branch information
lawi119 committed Nov 1, 2023
1 parent 2b2dfb5 commit 506e00e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/stactools/ecmwf_forecast/_kerchunk_helper_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,16 @@ def get_kerchunk_indices(part):
elif ((part.stream == "scwv") or (part.stream == "wave")) and (part.type == "fc"):
mzz = MultiZarrToZarr(out, concat_dims=["time"])

return compress_lat_lon(mzz.translate())
return convert_base64(compress_lat_lon(mzz.translate()))


def convert_base64(d):
for key in d['refs']:
if (('/0' in key) & ('.' not in key) & ('latitude' not in key) & ('longitude' not in key)):
if d['refs'][key][0:6]!='base64':
d['refs'][key] = (b"base64:" + base64.b64encode(d['refs'][key].encode())).decode()

return d


def compress_lat_lon(d):
Expand Down

0 comments on commit 506e00e

Please sign in to comment.