def gainbias(lmax, lmin, qcalmax, qcalmin):
    """Calculates gain and bias from max and min radiance"""
    gain = (lmax - lmin)/(qcalmax - qcalmin)
    bias = (qcalmax*lmin - qcalmin*lmax)/(qcalmax - qcalmin)
    return gain, bias