docs: def new(self, sources_by_grp):
          """
          Generate a new CompositeSourceModel from the given dictionary.
  
          :param sources_by_group: a dictionary grp_id -> sources
          :returns: a new CompositeSourceModel instance
          """
          source_models = []
          for sm in self.source_models:
              src_groups = []
              for src_group in sm.src_groups:
                  sg = copy.copy(src_group)
                  sg.sources = sorted(sources_by_grp.get(sg.id, []),
                                      key=operator.attrgetter('id'))
                  src_groups.append(sg)
              newsm = logictree.LtSourceModel(
                  sm.names, sm.weight, sm.path, src_groups,
                  sm.num_gsim_paths, sm.ordinal, sm.samples)
              source_models.append(newsm)
          new = self.__class__(self.gsim_lt, self.source_model_lt, source_models,
                               self.optimize_same_id)
          new.info.update_eff_ruptures(new.get_num_ruptures())
          new.info.tot_weight = new.get_weight()
          return new