code: def add_layer(self, depth, soil):
          
  
          self._layers[depth] = soil
          self._sort_layers()
          if self.hydrostatic:
              if depth >= self.gwl:
                  soil.saturation = 1.0
              else:
                  li = self.get_layer_index_by_depth(depth)
                  layer_height = self.layer_height(li)
                  if layer_height is None:
                      soil.saturation = 0.0
                  elif depth + layer_height <= self.gwl:
                      soil.saturation = 0.0
                  else:
                      sat_height = depth + self.layer_height(li) - self.gwl
                      soil.saturation = sat_height / self.layer_height(li)
docs: Adds a soil to the SoilProfile at a set depth.
  
          Note, the soils are automatically reordered based on depth from surface.
  
          :param depth: depth from surface to top of soil layer
          :param soil: Soil object