I couldn\'t find a working solution to fit a 2D gaussian to data in R elsewhere. I am trying to fit a 2D gaussian to some data, where the shape of the gaussian is determined