code: def location(self, wave_field, depth=None, index=None):
          if not isinstance(wave_field, WaveField):
              wave_field = WaveField[wave_field]
          if index is None and depth is not None:
              for i, layer in enumerate(self[:-1]):
                  if layer.depth <= depth < layer.depth_base:
                      depth_within = depth - layer.depth
                      break
              else:
                  i = len(self) - 1
                  layer = self[-1]
                  depth_within = 0
          elif index is not None and depth is None:
              layer = self[index]
              i = self.index(layer)
              depth_within = 0
          else:
              raise NotImplementedError
          return Location(i, layer, wave_field, depth_within)