ds format

Documentation version: 2.0.1 3.0.0 3.1.0 3.2.0 3.3.3 3.4.0 3.5.2 3.6.1 3.7.0 4.0.1 4.1.0 (latest) master
You are viewing documentation for version 2.0.1. The latest release is 4.1.0.
GitHub

Python API

The ds-format Python package provides API for reading, writing and manipulating data fies. The library can be imported with:

import ds_format as ds

Contents

Function Description
get_dims Get all dimension names in a dataset.
get_vars Get all variable names in a dataset.
group_by Group values along a dimension.
merge Merge datasets along a dimension.
read Read dataset from a file.
readdir Read multiple files in a directory.
rename Rename a variable.
rename_dim Rename a dimension.
select Filter dataset by a selector.
write Write dataset to a file.

Constants

ds.drivers.netcdf.JD_UNITS

days since -4713-11-24 12:00 UTC

NetCDF units for storing Julian date time variables.

ds.drivers.netcdf.JD_CALENDAR

proleptic_greogorian

NetCDF calendar for storing Julian date time variables.

Functions

get_dims

ds.get_dims(d)

Get all dimension names in a dataset.

Arguments:

Returns dimension names (list of str).

get_vars

ds.get_vars(d)

Get all variable names in a dataset.

Arguments:

Returns variable names (list of str).

group_by

ds.group_by(d, dim, group, func)

Group values along a dimension. Each variable with a given dimension dim is split by group into subsets. Each subset is replaced with a value computed by func.

Arguments:

Returns None.

merge

ds.merge(dd, dim, new=None, variables=None)

Merge datasets along a dimension dim. If the dimension is not defined in the dataset, merge along a new dimension dim. If new is None and dim is not new, variables without the dimension are set with the first occurrence of the variable. If new is not None and dim is not new, variables without the dimension dim are merged along a new dimension new. If variables is not None, only those variables are merged along a new dimension and other variables are set to the first occurrence of the variable.

Arguments:

Returns a dataset (dict).

read

ds.read(filename, variables=None, sel=None, full=False, jd=False)

Read dataset from a file.

Arguments:

Supported formats:

Returns dataset (dict).

readdir

ds.readdir(dirname, variables=None, merge=None, warnings=[], ...)

Read multiple files in a directory.

Arguments:

Returns a list of datasets (list of dict) if merge is None or a merged dataset (dict) if merge is a dimension name.

rename

ds.rename(d, old, new)

Rename a variable. Any dimension with the same name is also renamed.

Arguments:

Returns None.

rename_dim

ds.rename_dim(d, old, new)

Rename a dimension.

Arguments:

Returns None.

select

ds.select(d, sel)

Filter dataset by a selector.

Arguments:

Selector is a dictionary where each key is a dimension name and value is a mask to apply along the dimension or a list of indexes.

Returns None.

write

ds.write(filename, d)

Write dataset to a file. The file type is determined from the file extension.

Arguments:

Supported formats:

Returns None.