docs: def integrity_check(bounddict, max_dtu_offset):
      """Integrity check of 'bounddict' content.
  
      Parameters
      ----------
      bounddict : JSON structure
          Structure employed to store bounddict information.
      max_dtu_offset : float
          Maximum allowed difference in DTU location (mm) for each
          parameter
  
      """
  
      if 'meta_info' not in bounddict.keys():
          raise ValueError('"meta_info" not found in JSON file')
      if 'description' not in bounddict['meta_info'].keys():
          raise ValueError('"description" not found in JSON file')
      if bounddict['meta_info']['description'] != \
              'slitlet boundaries from fits to continuum-lamp exposures':
          raise ValueError('Unexpected "description" in JSON file')
  
      grism = bounddict['tags']['grism']
      print('>>> grism...:', grism)
      spfilter = bounddict['tags']['filter']
      print('>>> filter..:', spfilter)
  
      valid_slitlets = ["slitlet" + str(i).zfill(2) for i in
                        range(1, EMIR_NBARS + 1)]
      read_slitlets = list(bounddict['contents'].keys())
      read_slitlets.sort()
  
      first_dtu = True
      first_dtu_configuration = None  # avoid PyCharm warning
      list_dtu_configurations = []
  
      for tmp_slitlet in read_slitlets:
          if tmp_slitlet not in valid_slitlets:
              raise ValueError("Unexpected slitlet key: " + tmp_slitlet)
          # for each slitlet, check valid DATE-OBS (ISO 8601)
          read_dateobs = list(bounddict['contents'][tmp_slitlet].keys())
          read_dateobs.sort()
          for tmp_dateobs in read_dateobs:
              try:
                  datetime.strptime(tmp_dateobs, "%Y-%m-%dT%H:%M:%S.%f")
              except ValueError:
                  print("Unexpected date_obs key: " + tmp_dateobs)
                  raise
              # for each DATE-OBS, check expected fields
              tmp_dict = bounddict['contents'][tmp_slitlet][tmp_dateobs]
              valid_keys = ["boundary_coef_lower",
                            "boundary_coef_upper",
                            "boundary_xmax_lower",
                            "boundary_xmax_upper",
                            "boundary_xmin_lower",
                            "boundary_xmin_upper",
                            "csu_bar_left",
                            "csu_bar_right",
                            "csu_bar_slit_center",
                            "csu_bar_slit_width",
                            "rotang",
                            "xdtu",
                            "xdtu_0",
                            "ydtu",
                            "ydtu_0",
                            "zdtu",
                            "zdtu_0",
                            "zzz_info1",
                            "zzz_info2"]
              read_keys = tmp_dict.keys()
              for tmp_key in read_keys:
                  if tmp_key not in valid_keys:
                      print("ERROR:")
                      print("grism...:", grism)
                      print("slitlet.:", tmp_slitlet)
                      print("date_obs:", tmp_dateobs)
                      raise ValueError("Unexpected key " + tmp_key)
              for tmp_key in valid_keys:
                  if tmp_key not in read_keys:
                      print("ERROR:")
                      print("grism...:", grism)
                      print("slitlet.:", tmp_slitlet)
                      print("date_obs:", tmp_dateobs)
                      raise ValueError("Expected key " + tmp_key + " not found")
              if tmp_dict['boundary_xmax_lower'] <= \
                      tmp_dict['boundary_xmin_lower']:
                  print("ERROR:")
                  print("grism...:", grism)
                  print("slitlet.:", tmp_slitlet)
                  print("date_obs:", tmp_dateobs)
                  print("boundary_xmin_lower", tmp_dict['boundary_xmin_lower'])
                  print("boundary_xmax_lower", tmp_dict['boundary_xmax_lower'])
                  raise ValueError("Unexpected boundary_xmax_lower <= "
                                   "boundary_xmin_lower")
              if tmp_dict['boundary_xmax_upper'] <= \
                      tmp_dict['boundary_xmin_upper']:
                  print("ERROR:")
                  print("grism...:", grism)
                  print("slitlet.:", tmp_slitlet)
                  print("date_obs:", tmp_dateobs)
                  print("boundary_xmin_upper", tmp_dict['boundary_xmin_upper'])
                  print("boundary_xmax_upper", tmp_dict['boundary_xmax_upper'])
                  raise ValueError("Unexpected boundary_xmax_upper <= "
                                   "boundary_xmin_upper")
              if first_dtu:
                  first_dtu_configuration = \
                      DtuConfiguration.define_from_dictionary(tmp_dict)
                  first_dtu = False
                  list_dtu_configurations.append(first_dtu_configuration)
              else:
                  last_dtu_configuration = \
                      DtuConfiguration.define_from_dictionary(tmp_dict)
                  if not first_dtu_configuration.closeto(
                          last_dtu_configuration,
                          abserror=max_dtu_offset
                  ):
                      print("ERROR:")
                      print("grism...:", grism)
                      print("slitlet.:", tmp_slitlet)
                      print("date_obs:", tmp_dateobs)
                      print("First DTU configuration..:\n\t",
                            first_dtu_configuration)
                      print("Last DTU configuration...:\n\t",
                            last_dtu_configuration)
                      raise ValueError("Unexpected DTU configuration")
                  list_dtu_configurations.append(last_dtu_configuration)
  
      print("* Integrity check OK!")
  
      averaged_dtu_configuration = average_dtu_configurations(
          list_dtu_configurations)
      maxdiff_dtu_configuration = maxdiff_dtu_configurations(
          list_dtu_configurations
      )
  
      return averaged_dtu_configuration, maxdiff_dtu_configuration