'Create a period field for _id of grouped fields.
:param period: Period duration in seconds
:param first_ts: First timestamp for first period
:return:'

@staticmethod
def _make_period_dict(period, first_ts):

    if (period >= 0):
        period_unique_dict = {'period_start': {'$divide': [{'$subtract': [{'$subtract': ['$timestamp', first_ts]}, {'$mod': [{'$subtract': ['$timestamp', first_ts]}, (period * 1000)]}]}, (period * 1000)]}}
    else:
        period_unique_dict = {'$period_start': {'$add': [0, 0]}}
    return period_unique_dict
