Skip to content

open_edataset

open_edataset(remote_conn, file_path, flag='r', dataset_type='grid', compression='zstd', compression_level=1, num_groups=None, lock_timeout=300, force_lock=False, **kwargs)

Open a cfdb that is linked with a remote S3 database.

Parameters:

Name Type Description Default
remote_conn S3Connection, str, or dict

The object to connect to a remote. It can be an S3Connection object, an http url string, or a dict with the parameters for initializing an S3Connection object.

required
file_path str or Path

It must be a path to a local file location. If you want to use a tempfile, then use the name from the NamedTemporaryFile initialized class.

required
flag str

Flag associated with how the file is opened according to the dbm style.

  • 'r' -- Open existing database for reading only (default).
  • 'w' -- Open existing database for reading and writing.
  • 'c' -- Open database for reading and writing, creating it if it doesn't exist.
  • 'n' -- Always create a new, empty database, open for reading and writing.

A dataset "exists" if it exists locally OR remotely: with 'w'/'c', a fresh local file path attaches to an existing remote dataset (its structure is pulled on demand) rather than creating a new one. A new dataset is only created when neither exists (or with 'n', which always creates new).

'r'
dataset_type str

The dataset type when CREATING a new dataset. Default is 'grid'. Existing datasets (local or remote) always open with their stored type (and the matching class); this parameter is then ignored.

  • 'grid' -- The standard CF conventions dimensions/coordinates. Each coordinate must be unique and increasing in ascending order. Each coordinate represents a single axis (i.e. x, y, z, t). The z axis is currently optional.
  • 'ts_ortho' -- A special time series coordinate structure representing the orthogonal multidimensional array representation of time series. Designed for time series data with sparse geometries (e.g. station time series data). The Geometry dtype must represent the xy axis. The z axis is currently optional.
'grid'
compression str

The compression algorithm used for compressing all data. Must be either 'zstd' or 'lz4'. zstd has a good balance of compression ratio to speed, while lz4 emphasises speed. Default is 'zstd'.

'zstd'
compression_level int or None

The compression level used by the compression algorithm. Setting this to None will use the defaults, which is 1 for both compression options.

1
num_groups int or None

The number of groups for grouped S3 object storage. Required when creating a new database (flag='n'). For existing databases, this value is read from S3 metadata and the user-provided value is ignored. Guidance: aim for groups of 10-100MB each. A reasonable starting point is max(10, total_expected_keys // 50). Too few groups means large S3 objects and slow partial updates; too many means more API calls per push. Each group's data is limited to 4GB due to offset encoding.

None
lock_timeout int

Maximum time in seconds to wait for the write lock when opening for write. Default is 300 (5 minutes). Only applies when flag is not 'r'. Raises TimeoutError if the lock cannot be acquired within the timeout.

300
force_lock bool

If True, break any existing write locks before acquiring. Use this to recover from stale locks left by crashed processes. Default is False.

False
**kwargs

Any kwargs that can be passed to ebooklet.open_ebooklet.

{}

Returns:

Type Description
EDataset