docs: def save_boundaries_from_params_ds9(params, parmodel,
                                      list_islitlet,
                                      list_csu_bar_slit_center,
                                      uuid, grism, spfilter,
                                      ds9_filename, numpix=100,
                                      global_offset_x_pix=0,
                                      global_offset_y_pix=0):
      """Export to ds9 region file the boundaries parametrised with params.
  
      Parameters
      ----------
      params : :class:`~lmfit.parameter.Parameters`
          Parameters to be employed in the prediction of the distorted
          boundaries.
      parmodel : str
          Model to be assumed. Allowed values are 'longslit' and
          'multislit'.
      list_islitlet : list (integers)
          Slitlet numbers to be considered.
      list_csu_bar_slit_center : list of floats
          CSU bar slit centers of the considered slitlets.
      uuid: str
          UUID associated to the parameters 'params'.
      grism : str
          Employed grism.
      spfilter : str
          Employed filter.
      ds9_filename : str
          Output file name for the ds9 region file.
      numpix : int
          Number of points in which the X-range interval is subdivided
          in order to save each boundary as a connected set of line
          segments.
      global_offset_x_pix : int or float
          Global offset in the X direction to be applied after computing
          the expected location.
      global_offset_y_pix : int or float
          Global offset in the Y direction to be applied after computing
          the expected location.
  
      """
  
      ds9_file = open(ds9_filename, 'w')
  
      ds9_file.write('# Region file format: DS9 version 4.1\n')
      ds9_file.write('global color=green dashlist=2 4 width=2 '
                     'font="helvetica 10 normal roman" select=1 '
                     'highlite=1 dash=1 fixed=0 edit=1 '
                     'move=1 delete=1 include=1 source=1\n')
      ds9_file.write('physical\n#\n')
  
      ds9_file.write('#\n# uuid..: {0}\n'.format(uuid))
      ds9_file.write('# filter: {0}\n'.format(spfilter))
      ds9_file.write('# grism.: {0}\n'.format(grism))
  
      ds9_file.write('#\n# global_offset_x_pix: {0}\n'.format(
          global_offset_x_pix))
      ds9_file.write('# global_offset_y_pix: {0}\n#\n'.format(
          global_offset_y_pix))
  
      # duplicate to shorten the variable names
      xoff = float(global_offset_x_pix)
      yoff = float(global_offset_y_pix)
  
      if parmodel == "longslit":
          for dumpar in EXPECTED_PARAMETER_LIST:
              parvalue = params[dumpar].value
              ds9_file.write('# {0}: {1}\n'.format(dumpar, parvalue))
      else:
          for dumpar in EXPECTED_PARAMETER_LIST_EXTENDED:
              parvalue = params[dumpar].value
              ds9_file.write('# {0}: {1}\n'.format(dumpar, parvalue))
  
      for islitlet, csu_bar_slit_center in \
              zip(list_islitlet, list_csu_bar_slit_center):
          if islitlet % 2 == 0:
              colorbox = '#ff00ff'  # '#ff77ff'
          else:
              colorbox = '#00ffff'  # '#4444ff'
  
          ds9_file.write(
              '#\n# islitlet...........: {0}\n'.format(islitlet)
          )
          ds9_file.write(
              '# csu_bar_slit_center: {0}\n'.format(csu_bar_slit_center)
          )
          pol_lower_expected = expected_distorted_boundaries(
              islitlet, csu_bar_slit_center, [0], params, parmodel,
              numpts=101, deg=5, debugplot=0
          )[0].poly_funct
          pol_upper_expected = expected_distorted_boundaries(
              islitlet, csu_bar_slit_center, [1], params, parmodel,
              numpts=101, deg=5, debugplot=0
          )[0].poly_funct
          xdum = np.linspace(1, EMIR_NAXIS1, num=numpix)
          ydum = pol_lower_expected(xdum)
          for i in range(len(xdum)-1):
              ds9_file.write(
                  'line {0} {1} {2} {3}'.format(xdum[i]+xoff, ydum[i]+yoff,
                                                xdum[i+1]+xoff, ydum[i+1]+yoff)
              )
              ds9_file.write(' # color={0}\n'.format(colorbox))
          ydum = pol_upper_expected(xdum)
          for i in range(len(xdum)-1):
              ds9_file.write(
                  'line {0} {1} {2} {3}'.format(xdum[i]+xoff, ydum[i]+yoff,
                                                xdum[i+1]+xoff, ydum[i+1]+yoff)
              )
              ds9_file.write(' # color={0}\n'.format(colorbox))
          # slitlet label
          yc_lower = pol_lower_expected(EMIR_NAXIS1 / 2 + 0.5)
          yc_upper = pol_upper_expected(EMIR_NAXIS1 / 2 + 0.5)
          ds9_file.write('text {0} {1} {{{2}}} # color={3} '
                         'font="helvetica 10 bold '
                         'roman"\n'.format(EMIR_NAXIS1 / 2 + 0.5 + xoff,
                                           (yc_lower + yc_upper) / 2 + yoff,
                                           islitlet,
                                           colorbox))
  
      ds9_file.close()