docs: def write_modes_to_file(self, filename="mode.dat", plot=True, analyse=True):
          """
          Writes the mode fields to a file and optionally plots them.
  
          Args:
              filename (str): The nominal filename to use for the saved
                  data.  The suffix will be automatically be changed to
                  identifiy each mode number.  Default is 'mode.dat'
              plot (bool): `True` if plots should be generates,
                  otherwise `False`.  Default is `True`.
              analyse (bool): `True` if an analysis on the fundamental
                  mode should be performed.  The analysis adds to the
                  plot of the fundamental mode the power mode-field
                  diameter (MFD) and marks it on the output, and it
                  marks with a cross the maximum E-field value.
                  Default is `True`.
  
          Returns:
              dict: A dictionary containing the effective indices
              and mode field profiles (if solved for).
          """
          modes_directory = "./modes_semi_vec/"
          if not os.path.isdir(modes_directory):
              os.mkdir(modes_directory)
          filename = modes_directory + filename
  
          for i, mode in enumerate(self._ms.modes):
              filename_mode = self._get_mode_filename(
                  self._semi_vectorial_method, i, filename
              )
              self._write_mode_to_file(np.real(mode), filename_mode)
  
              if plot:
                  if i == 0 and analyse:
                      A, centre, sigma_2 = anal.fit_gaussian(
                          self._structure.xc, self._structure.yc, np.abs(mode)
                      )
                      subtitle = (
                          "E_{max} = %.3f, (x_{max}, y_{max}) = (%.3f, %.3f), MFD_{x} = %.3f, "
                          "MFD_{y} = %.3f"
                      ) % (A, centre[0], centre[1], sigma_2[0], sigma_2[1])
                      self._plot_mode(
                          self._semi_vectorial_method,
                          i,
                          filename_mode,
                          self.n_effs[i],
                          subtitle,
                          sigma_2[0],
                          sigma_2[1],
                          centre[0],
                          centre[1],
                          wavelength=self._structure._wl,
                      )
                  else:
                      self._plot_mode(
                          self._semi_vectorial_method,
                          i,
                          filename_mode,
                          self.n_effs[i],
                          wavelength=self._structure._wl,
                      )
  
          return self.modes