def get_ncattrs(obj):
    """
    Returns ncattrs of a netcdf object as a dictionary
    :param obj: Object to collect ncattrs from
    :return: dictionary representation of those ncattrs
    """
    out = {}
    for key in obj.ncattrs():
        value = obj.getncattr(key)
        if hasattr(value, 'tolist'):
            value = value.tolist()
        out[key] = value
    return out
