def get_coord_by_index(da, indx):
    """
    Take an Xarray DataArray, return a coordinate by its index in the
    order of the data structure. E.g. if var is defined on: ('time', 'lat'),
    indx=0 will return the coordinate labelled as 'time'.
    """
    coord_name = da.dims[indx]
    return da.coords[coord_name]