docs: def build_damage_array(data, damage_dt):
      """
      :param data: an array of shape (A, L, 1, D) or (A, L, 2, D)
      :param damage_dt: a damage composite data type loss_type -> states
      :returns: a composite array of length N and dtype damage_dt
      """
      A, L, MS, D = data.shape
      dmg = numpy.zeros(A, damage_dt)
      for a in range(A):
          for l, lt in enumerate(damage_dt.names):
              std = any(f for f in damage_dt[lt].names if f.endswith('_stdv'))
              if MS == 1 or not std:  # there is only the mean value
                  dmg[lt][a] = tuple(data[a, l, 0])
              else:  # there are both mean and stddev
                  # data[a, l].T has shape (D, 2)
                  dmg[lt][a] = tuple(numpy.concatenate(data[a, l].T))
      return dmg