code: def gaussian1d_moments(data, mask=None):
      
  
      if np.any(~np.isfinite(data)):
          data = np.ma.masked_invalid(data)
          warnings.warn('Input data contains input values (e.g. NaNs or infs), '
                        'which were automatically masked.', AstropyUserWarning)
      else:
          data = np.ma.array(data)
  
      if mask is not None and mask is not np.ma.nomask:
          mask = np.asanyarray(mask)
          if data.shape != mask.shape:
              raise ValueError('data and mask must have the same shape.')
          data.mask |= mask
  
      data.fill_value = 0.
      data = data.filled()
  
      x = np.arange(data.size)
      x_mean = np.sum(x * data) / np.sum(data)
      x_stddev = np.sqrt(abs(np.sum(data * (x - x_mean)**2) / np.sum(data)))
      amplitude = np.ptp(data)
  
      return amplitude, x_mean, x_stddev
docs: Estimate 1D Gaussian parameters from the moments of 1D data.
  
      This function can be useful for providing initial parameter values
      when fitting a 1D Gaussian to the ``data``.
  
      Parameters
      ----------
      data : array_like (1D)
          The 1D array.
  
      mask : array_like (1D bool), optional
          A boolean mask, with the same shape as ``data``, where a `True`
          value indicates the corresponding element of ``data`` is masked.
  
      Returns
      -------
      amplitude, mean, stddev : float
          The estimated parameters of a 1D Gaussian.