def get_cube_datatype(cube):
    """
    Detect cube datatype.

    Supported datatypes are:
    timeseries   - (time), scalar depth
    surfacetrack - (time), aux latitude, longitude, scalar depth
    profile      - (depth), scalar latitude, longitude
    timeprofile  - (time, depth)
    transect - (depth, index), aux latitude, longitude, depth
    timetransect - (time, depth, index)
    """
    # gather coordinate names
    dim_coords = [c.name() for c in cube.dim_coords]
    aux_coords = [c.name() for c in cube.aux_coords if len(c.points) > 1]
    dim_or_aux_coords = dim_coords + aux_coords
    scalar_coords = [c.name() for c in cube.aux_coords if len(c.points) == 1]
    ndims = len(cube.shape)

    if (ndims == 1 and 'time' in dim_coords and 'depth' in scalar_coords and
            len(aux_coords) == 0):
        datatype = 'timeseries'
    elif (ndims == 1 and 'time' in dim_coords and 'depth' in scalar_coords and
            'latitude' in aux_coords and
            'longitude' in aux_coords):
        datatype = 'surfacetrack'
    elif (ndims == 1 and 'depth' in dim_coords and 'time' in scalar_coords and
            len(aux_coords) == 0):
        datatype = 'profile'
    elif (ndims == 2 and 'time' in dim_coords and 'depth' in dim_coords and
          'latitude' not in aux_coords):
        datatype = 'timeprofile'
    elif (ndims == 3 and 'time' in dim_coords and
          'depth' in dim_or_aux_coords):
        datatype = 'timetransect'
    elif (ndims == 2 and 'depth' in dim_or_aux_coords
          and 'latitude' in aux_coords):
        datatype = 'transect'
    else:
        print(cube)
        print(f'dim coords {dim_coords}')
        print(f'aux coords {aux_coords}')
        print(f'scalar coords {scalar_coords}')
        raise NotImplementedError('Unknown cube data type')
    return datatype