def params_to_lists(params):
    """Dictionaries are more convenient for storing and working with the parameters of the gaussians and lorentzians,
    but leastsq wants the initial parameters as a list (as far as I can tell...). This will take a list of dictionaries
    and convert it to a single list according to the following order:
    yoffset, ymax, halfwidth, x0 (repeating ymax, halfwidth, and x0 for any additional functions)"""
    if type(params) != list: raise TypeError('Incorrect data type: function params_to_list needs a list of dictionaries.')
    listofparams = [params[0]['yoffset']] # yoffset should be the same for all functions, so just pass it from the first one.
    for peak in params:
        listofparams.append(peak['ymax'])
        listofparams.append(peak['halfwidth'])
        listofparams.append(peak['x0'])
    return listofparams