act.transform.make_coord#

act.transform.make_coord(start, stop, freq, name='time')[source]#

Create a coordinate DataArray for datetimes or numeric steps.

Parameters:
  • start (int, float, str, numpy.datetime64, or pandas.Timestamp) – Start value (datetime-like or numeric).

  • stop (int, float, str, numpy.datetime64, or pandas.Timestamp) – Stop value (datetime-like or numeric).

  • freq (int, float, or str) – Frequency step. For datetimes, a pandas frequency string (e.g. '30min', '1h'). For numeric coordinates, a float or int step size.

  • name (str) – Name of the coordinate and dimension (default 'time').

Returns:

xarray.DataArray – Coordinate array with name as its dimension and coordinate.

Examples

A datetime coordinate, from datetime-like endpoints and a pandas frequency string. The endpoints may be strings, numpy.datetime64, or pandas.Timestamp.

target_time = act.transform.make_coord('2023-01-01', '2023-01-02', '30min')

A numeric coordinate, from numeric endpoints and a numeric step. Note that the numeric form excludes stop, following numpy.arange, while the datetime form includes it, following pandas.date_range.

target_height = act.transform.make_coord(0.0, 5000.0, 250.0, name='height')