code: def extrap_sec(data, dist, depth, w1=1.0, w2=0):
      
      from scipy.interpolate import interp1d
  
      new_data1 = []
      for row in data:
          mask = ~np.isnan(row)
          if mask.any():
              y = row[mask]
              if y.size == 1:
                  row = np.repeat(y, len(mask))
              else:
                  x = dist[mask]
                  f_i = interp1d(x, y)
                  f_x = _extrap1d(f_i)
                  row = f_x(dist)
          new_data1.append(row)
  
      new_data2 = []
      for col in data.T:
          mask = ~np.isnan(col)
          if mask.any():
              y = col[mask]
              if y.size == 1:
                  col = np.repeat(y, len(mask))
              else:
                  z = depth[mask]
                  f_i = interp1d(z, y)
                  f_z = _extrap1d(f_i)
                  col = f_z(depth)
          new_data2.append(col)
  
      new_data = np.array(new_data1) * w1 + np.array(new_data2).T * w2
      return new_data
docs: Extrapolates `data` to zones where the shallow stations are shadowed by
      the deep stations.  The shadow region usually cannot be extrapolates via
      linear interpolation.
  
      The extrapolation is applied using the gradients of the `data` at a certain
      level.
  
      Parameters
      ----------
      data : array_like
            Data to be extrapolated
      dist : array_like
             Stations distance
      fd : float
           Decay factor [0-1]
  
  
      Returns
      -------
      Sec_extrap : array_like
                   Extrapolated variable