Trapping and release of gases by water ice and implications for icy bodies