caterva2.get_chunk#

caterva2.get_chunk(path, nchunk, urlbase=None, auth_cookie=None)#

Get the unidimensional compressed chunk of a dataset.

Parameters:
  • path (str) – The path of the dataset.

  • nchunk (int) – The unidimensional chunk id to get.

  • urlbase (str) – The base of URLs of the subscriber to query. Default is caterva2.sub_urlbase_default.

  • auth_cookie (str) – An optional HTTP cookie for authorizing access.

Returns:

The compressed chunk.

Return type:

bytes obj

Examples

>>> import caterva2 as cat2
>>> urlbase = 'https://demo.caterva2.net'
>>> cat2.subscribe('example', urlbase)
'Ok'
>>> info_schunk = cat2.get_info('example/ds-2d-fields.b2nd', urlbase)['schunk']
>>> info_schunk['nchunks']
1
>>> info_schunk['cratio']
6.453000645300064
>>> chunk = cat2.get_chunk('example/ds-2d-fields.b2nd', 0,  urlbase)
>>> info_schunk['chunksize'] / len(chunk)
6.453000645300064