INTERP2D1d : Interpolate values from a 2D matrix along a 1D trajectory
    
    @param x: 1st dimension vector of size NX
    @param y: 2nd dimension vector of size NY
    @param Z: Array to interpolate (NXxNY)
    @param xout: 1st dimension vector of size Nout
    @param yout: 2nd dimension vector of size Nout
    
    @return: Interpolated array (Nout)
    
    @author: Renaud DUSSURGET, LER/PAC, Ifremer La Seyne

def interp2d1d(x,y,Z,xout,yout,**kwargs):
    """    
    INTERP2D1d : Interpolate values from a 2D matrix along a 1D trajectory
    
    @param x: 1st dimension vector of size NX
    @param y: 2nd dimension vector of size NY
    @param Z: Array to interpolate (NXxNY)
    @param xout: 1st dimension vector of size Nout
    @param yout: 2nd dimension vector of size Nout
    
    @return: Interpolated array (Nout)
    
    @author: Renaud DUSSURGET, LER/PAC, Ifremer La Seyne
    """

    gx = np.reshape(np.repeat(x,y.size),(x.size,y.size)).transpose((1,0))
    gy = np.reshape(np.repeat(y,x.size),(y.size,x.size))

    gxout = xout
    gyout = yout
    gz = Z.flatten()
    
    Zout=np.empty(Z.shape,dtype=Z.dtype)
    
#    if isinstance(Z,np.ma.masked_array):
#        mask=Z.mask
#        Zout=np.ma.array(Zout,mask=True)
#    else : mask=np.ones(gz.shape,dtype=bool)
     
#    points_masked = zip(*(gx[mask].flatten(),gy[mask].flatten()))
    points = zip(*(gx.flatten(),gy.flatten()))
#    gz=gz[mask.flatten()]
    xi = zip(*(gxout,gyout))
    
    try : Zout = scipy.interpolate.griddata(points, gz, xi, **kwargs)
    except RuntimeError : Zout = np.NaN
#    Zout = sc.interpolate.griddata(points, gz, xi, **kwargs)
    return Zout