def getParamIndx(fit, name, parameter):
    """Get index for a specific parameter for a specific source
    from model in UnbinnedAnalysis object fit"""
    ID = -1
    # Try to get the first component (if summed analysis)
    try:    fit = fit.components[0]
    except: pass
    spec = fit[name].funcs['Spectrum']
    for indx, parName in zip(spec._parIds, spec.paramNames):
        if(parName == parameter):
            ID = indx
    if(ID == -1):
        print(('Parameter %s not found for source %s in file %s.' %
             (parameter, name, fit.srcModel)))

    return ID