def lnlike(pzero, imcolor, imluminmask, x, y):
    flux = pzero[0]
    rotation_angle = pzero[5]#np.arctan2(pzero[5], pzero[1]) * 180 / np.pi
    intermediate_axis = pzero[1]#) / np.cos(rotation_angle / 180 * np.pi)
    xcenter = pzero[2]
    ycenter = pzero[3]
    aspect_ratio = pzero[4]
    if xcenter < 0 or ycenter < 0 or xcenter > nx or ycenter > ny:
        #print("Bad location: {} {}".format(xcenter, ycenter))
        return -np.inf
    #height = width * aspect_ratio
    #height = pzero[3]
    #x1 = xcenter - width
    #x2 = xcenter + width
    #y1 = ycenter - height
    #y2 = ycenter + height
    #if x1 > 0 and x2 < im[0, :].size and y1 > 0 and y2 < im[:, 0].size:
    par = [flux, intermediate_axis, xcenter, ycenter, aspect_ratio, 
            rotation_angle]
    whale_model = whaleutil.whale_2d(x, y, par)

    #whale_model[imluminmask] = 0
    #modelloc = whale_model > 0
    #cost = -imcolor[modelloc].sum()
    #luminindex = whale_model > 0
    #penalty_lumin = imlumin[luminindex].sum()
    resid_color = np.abs(imcolor - whale_model)
    cost = resid_color[imluminmask].sum()# + 0.1 * penalty_lumin
    #if cost < 4.5e3:
    #    #print(par, cost)
    #    import matplotlib.pyplot as plt
    #    #plt.imshow(imlumin, origin='lower')
    #    #plt.colorbar()
    #    #plt.contour(whale_model)
    #    #plt.show()
    #    print(par)
    #    plt.imshow(imcolor - whale_model, origin='lower')
    #    plt.colorbar()
    #    try:
    #        plt.contour(whale_model)
    #    except:
    #        import pdb; pdb.set_trace()
    #    plt.title(str(cost))
    #    plt.show()
    #    import pdb; pdb.set_trace()
    #import pdb; pdb.set_trace()
    return -cost
        #plt.imshow(im[:, :, 0])
        #plt.colorbar()
        #plt.show()
        #import pdb; pdb.set_trace()

        ny, nx = im[:, :, 0].shape
        #print(nx, ny)
        xvec = np.arange(nx)
        yvec = np.arange(ny)
        x, y = np.meshgrid(xvec, yvec)
        #plt.imshow(x)
        #plt.show()

        print(parvalues)

        whale_model = whale_2d(x, y, parvalues)

        # identify the head
        #rotation_angle = np.arctan2(par['rotation_angle'].values[0], \
        #        par['size'].values[0]) * 180 / np.pi
        phi0 = par['rotation_angle'].values[0]
        a0 = np.abs(par['size'].values[0]) / np.sqrt(par['aspect_ratio'].values[0])
        b0 = a0 * par['aspect_ratio'].values[0]
        x0 = par['xcenter'].values[0]
        y0 = par['ycenter'].values[0]
        xhead, yhead = xy_rotate(a0, 0, 0, 0, phi0)
        xhead *= -1
        xhead += x0
        yhead += y0
        xhead1 = xhead
        yhead1 = yhead