DS-SET(1)

NAME
ds-set - Set variable data, dimensions and attributes in an existing or new dataset.

SYNOPSIS
ds set ds_attrs input output [options]
ds set var [type [dims [data]]] [attrs]... input output [options]
ds set { var [type [dims [data]]] [attrs]... }... ds_attrs input output [options]

ARGUMENTS

var Variable name.

type
    Variable type (str), or none to keep the original type if data is not supplied or autodetect based on data if data is supplied. One of: float32 and float64 (32-bit and 64-bit floating-point number, resp.), int8, int16, int32 and int64 (8-bit, 16-bit, 32-bit and 64-bit integer, resp.), uint8, uint16, uint32 and uint64 (8-bit, 16-bit, 32-bit and 64-bit unsigned integer, resp.), bool (boolean), str (string) and unicode (Unicode).

dims
    Variable dimension name (if single), an array of variable dimensions (if multiple), none to keep original dimension or autogenerate if a new variable, or { } to autogenerate new dimension names.

data
    Variable data. This can be a PST https://github.com/peterkuma/pst-formatted scalar or an array. none values are interpreted as missing values.

attrs
    Variable attributes or dataset attributes if var is none as attr: value pairs.

ds_attrs
    Dataset attributes as attr: value pairs.

input
    Input file or none for a new file to be created.

output
    Output file.

options
    See help for ds for global options. Note that with this command options can only be supplied before the command name or at the end of the command line.

EXAMPLES
Write variables time and temperature to dataset.nc.

    $ ds set { time none time { 1 2 3 } long_name: time units: s } { temperature none time { 16. 18. 21. } long_name: temperature units: celsius } title: "Temperature data" none dataset.nc

Set data of a variable temperature to an array of 16.0, 18.0, 21.0 in dataset.nc and save the output in output.nc.

    $ ds set temperature none none { 16. 18. 21. } dataset.nc output.nc

Set a dimension of a variable temperature to time, data to an array of 16.0, 18.0, 21.0, its attribute long_name to "temperature" and units to "celsius" in dataset.nc and save the output in output.nc.

    $ ds set temperature none time { 16. 18. 21. } long_name: temperature units: celsius dataset.nc output.nc

Set multiple variables in dataset.nc and save the output in output.nc.

    $ ds set { time none time { 1 2 3 } long_name: time units: s } { temperature none time { 16. 18. 21. } long_name: temperature units: celsius } title: "Temperature data" dataset.nc output.nc

Set a dataset attribute newtitle to New title in dataset.nc and save the output in output.nc.

    $ ds set newtitle: "New title" dataset.nc output.nc

Set an attribute newunits of a variable temperature to K in dataset.nc and save the output in output.nc.

    $ ds set temperature newunits: K dataset.nc output.nc