docs: def read_XPARM(path_to_XPARM='.'):
      """Loads the instrumental geometry information from the XPARM.XDS or GXPARM.XDS files at the proposed location"""
  
      if not os.path.exists(path_to_XPARM):
          raise Exception("path " + path_to_XPARM + "does not exist")
  
      if os.path.isdir(path_to_XPARM):
          candidate = os.path.join(path_to_XPARM, 'GXPARM.XDS')
          if os.path.isfile(candidate):
              path_to_XPARM = candidate
          else:
              candidate = os.path.join(path_to_XPARM, 'XPARM.XDS')
              if os.path.isfile(candidate):
                  path_to_XPARM = candidate
              else:
                  raise Exception("files GXPARM.XDS and XPARM.XDS are not found in the folder " + path_to_XPARM)
  
      with open(path_to_XPARM) as f:
          f.readline()  # skip header
          text = f.read()
  
      # parse the rest to numbers
      f = re.compile('-?\d+\.?\d*').finditer(text)
  
      try:
          result = dict(starting_frame=r_get_numbers(f, 1),
                        starting_angle=r_get_numbers(f, 1),
                        oscillation_angle=r_get_numbers(f, 1),
                        rotation_axis=r_get_numbers(f, 3),
  
                        wavelength=r_get_numbers(f, 1),
                        wavevector=r_get_numbers(f, 3),
  
                        space_group_nr=r_get_numbers(f, 1),
                        cell=r_get_numbers(f, 6),
                        unit_cell_vectors=np.reshape(r_get_numbers(f, 9), (3, 3)),
  
                        number_of_detector_segments=r_get_numbers(f, 1),
                        NX=r_get_numbers(f, 1),
                        NY=r_get_numbers(f, 1),
                        pixelsize_x=r_get_numbers(f, 1),
                        pixelsize_y=r_get_numbers(f, 1),
  
                        x_center=r_get_numbers(f, 1),
                        y_center=r_get_numbers(f, 1),
                        distance_to_detector=r_get_numbers(f, 1),
  
                        detector_x=r_get_numbers(f, 3),
                        detector_y=r_get_numbers(f, 3),
                        detector_normal=r_get_numbers(f, 3),
                        detector_segment_crossection=r_get_numbers(f, 5),
                        detector_segment_geometry=r_get_numbers(f, 9))
  
      except StopIteration:
          raise Exception('Wrong format of the XPARM.XDS file')
  
      # check there is nothing left
      try:
          f.next()
      except StopIteration:
          pass
      else:
          raise Exception('Wrong format of the XPARM.XDS file')
  
      return result