Skip to content

Tools

cfdb_to_netcdf4

cfdb_to_netcdf4(cfdb_path, nc_path, compression='gzip', sel=None, sel_loc=None, include_data_vars=None, exclude_data_vars=None, **kwargs)

Simple function to convert a cfdb to a netcdf4. Selection options are also available. The h5netcdf package must be installed to write netcdf4 files.

Parameters:

Name Type Description Default
cfdb_path Union[str, Path]

The source path of the cfdb to be converted.

required
nc_path Union[str, Path]

The target path for the netcdf4 file.

required
sel dict

Selection by coordinate indexes.

None
sel_loc dict

Selection by coordinate values.

None
max_mem

The max memory in bytes if required when coordinates are in decending order (and must be resorted in ascending order).

required
kwargs

Any kwargs that can be passed to the h5netcdf.File function.

{}

Returns:

Type Description
None

Dataset.copy

Copy a dataset to a new cfdb file. See Dataset for the full class reference.

with cfdb.open_dataset('source.cfdb') as ds:
    new_ds = ds.copy('destination.cfdb')
    print(new_ds)
    new_ds.close()

Parameters:

Parameter Type Description
file_path str or Path Target file path
include_data_vars list of str or None Only include these data variables
exclude_data_vars list of str or None Exclude these data variables

Dataset.to_netcdf4

Export a dataset to netCDF4 format. Requires h5netcdf.

with cfdb.open_dataset('source.cfdb') as ds:
    ds.to_netcdf4('output.nc', compression='gzip')

Parameters:

Parameter Type Description
file_path str or Path Output netCDF4 file path
compression str HDF5 compression (default: 'gzip')
include_data_vars list of str or None Only include these data variables
exclude_data_vars list of str or None Exclude these data variables
**file_kwargs Passed to h5netcdf.File()

Importing from Other Formats

For importing data from netCDF4 and other formats into cfdb, use the cfdb-ingest package.