code: def export_curves_stats(self, aids, key):
          
          oq = self.dstore['oqparam']
          stats = oq.hazard_stats().items()  # pair (name, func)
          stat2idx = {stat[0]: s for s, stat in enumerate(stats)}
          if 'loss_curves-stats' in self.dstore:  # classical_risk
              dset = self.dstore['loss_curves-stats']
              data = dset[aids]  # shape (A, S)
              if key == 'stats':
                  return {stat[0]: data[:, s] for s, stat in enumerate(stats)}
              else:  # a specific statistics
                  return {key: data[:, stat2idx[key]]}
          elif 'curves-stats' in self.dstore:  # event_based_risk
              dset = self.dstore['curves-stats']
              data = dset[aids]
              if key == 'stats':
                  return {stat[0]: data[:, s] for s, stat in enumerate(stats)}
              else:  # a specific statistics
                  return {key: data[:, stat2idx[key]]}
          else:
              raise KeyError('no loss curves in %s' % self.dstore)
docs: :returns: a dictionary rlzi -> record of dtype loss_curve_dt