def collapseTs(ts=None):
    global _timeseries_data
    _d = {}
    if not ts:
        print("Error: Time series data not provided. Pass time series into the function.")
    else:
        try:
            _raw = _timeseries_data[ts[0]["time_id"]]
            print(mode_ts("collapse", mode="", ts=ts))
            _d = collapse(ts, _raw)
            _d = rm_empty_fields(_d)
        except Exception as e:
            print("Error: Unable to collapse the time series: {}".format(e))
            logger_start.error("collapseTs: unable to collapse the time series: {}".format(e))
    return _d