docs: def build_damage_dt(dstore, mean_std=True):
      """
      :param dstore: a datastore instance
      :param mean_std: a flag (default True)
      :returns:
         a composite dtype loss_type -> (mean_ds1, stdv_ds1, ...) or
         loss_type -> (ds1, ds2, ...) depending on the flag mean_std
      """
      oq = dstore['oqparam']
      damage_states = ['no_damage'] + list(
          dstore.get_attr('risk_model', 'limit_states'))
      dt_list = []
      for ds in damage_states:
          ds = str(ds)
          if mean_std:
              dt_list.append(('%s_mean' % ds, F32))
              dt_list.append(('%s_stdv' % ds, F32))
          else:
              dt_list.append((ds, F32))
      damage_dt = numpy.dtype(dt_list)
      loss_types = oq.loss_dt().names
      return numpy.dtype([(lt, damage_dt) for lt in loss_types])