def chisqmin(sim,obs,sigmasim,sigmaobs):
    """takes arrays of observed and model data
    finds the slope to best match them"""

    num=sum(sim*obs/(sigmasim**2.+sigmaobs**2.))
    denom=sum(sim**2./(sigmasim**2.+sigmaobs**2.))
    a=num/denom

    return a