def om_values(values, year):
    """
    Return a list of values for an observation model parameter.

    :param values: Values may be scalar, a list of scalars, or a dictionary
        that maps years to a scalar or list of scalars.
    :param year: The calendar year of the simulation.

    :raises ValueError: If the values are a dictionary and the year is not a
        valid key, or if there are duplicate values.
    :raises TypeError: If the values are not one of the types defined above.
    """
    if isinstance(values, dict):
        # The values are stored in a dictionary and are indexed by year.
        if year in values:
            values = values[year]
        else:
            raise ValueError('Invalid year {}'.format(year))
    try:
        # Try treating the values as a list of values.
        values = list(values)
    except TypeError:
        # If that fails, assume we have a scalar value.
        return [values]
    # Detect duplicate values.
    if len(set(values)) == len(values):
        return values
    else:
        raise ValueError("Duplicate values in {}".format(values))