def format_climatology(param, clm, sensor_range, site, node, sensor, stream):
    """
    Creates a dictionary object that can later be saved to a CSV formatted
    file for use in the Climatology lookup tables.

    :param param: parameter name of the variable for the calculated climatology
    :param clm: results of the climatology test, used to create the table
    :param sensor_range: list of vendor defined ranges for valid data
    :param site: Site designator, extracted from the first part of the reference
        designator
    :param node: Node designator, extracted from the second part of the reference
        designator
    :param sensor: Sensor designator, extracted from the third and fourth part of
        the reference designator
    :param stream: Stream name that contains the data of interest
    :return qc_dict: dictionary with the sensor and user gross range values
        added in the formatting expected by the QC lookup
    """
    # create the lookup dictionary
    var_explained = clm.regression['variance_explained']
    qc_dict = {
        'subsite': site,
        'node': node,
        'sensor': sensor,
        'stream': stream,
        'parameters': {'inp': param, 'tinp': 'time', 'zinp': 'None'},
        'climatologyTable': 'climatology_tables/{}-{}-{}-{}.csv'.format(site, node, sensor, param),
        'source': 'The variance explained by the climatological model is {:.1%}.'.format(var_explained[0])
    }

    # create the climatology table
    header_str = ''
    value_str = '[0, 0]'
    for idx, mu in enumerate(clm.monthly_fit):
        # use the index number to create the header row
        header_str += ',[{}, {}]'.format(idx+1, idx+1)

        # calculate the climatological ranges
        cmin = mu - clm.monthly_std.values[idx] * 3
        if cmin < sensor_range[0]:
            cmin = sensor_range[0]

        cmax = mu + clm.monthly_std.values[idx] * 3
        if cmax > sensor_range[1]:
            cmax = sensor_range[1]

        # append the data to ranges
        value_str += ',[{:.2f}, {:.2f}]'.format(cmin, cmax)

    clm_table = header_str + '\n' + value_str

    return qc_dict, clm_table