Model calibration for ice sheets and glaciers dynamics: a general theory of inverse problems in glaciology