How to obtain the posterior probability of 2D distribution?

Should have been “this model”, e.g. you PyMC model.

You are sampling both velocity and depth in the model. Do you want to do that jointly? Or do want to be able to have a dynamic number of variables? The 2nd isn’t possible, you need specialized MCMC samplers to handle random variables with random dimensions. What you could do is specify a reasonable maximum then try to disable contributions from depth above a certain level, see here for example.