Ejemplo n.º 1
0
    def __iadd__(self, other):
        """
        Rich method '+='

        .. rubric:: Example

        >>> from eqcorrscan import Template
        >>> family_a = Family(template=Template(name='a'))
        >>> family_b = Family(template=Template(name='a'))
        >>> family_a += family_b
        >>> print(family_a)
        Family of 0 detections from template a
        """
        if isinstance(other, Family):
            if other.template == self.template:
                self.detections.extend(other.detections)
                self.__catalog.events.extend(get_catalog(other.detections))
            else:
                raise NotImplementedError('Templates do not match')
        elif isinstance(other, Detection) and other.template_name \
                == self.template.name:
            self.detections.append(other)
            self.__catalog.events.extend(get_catalog([other]))
        elif isinstance(other, Detection):
            raise NotImplementedError('Templates do not match')
        else:
            raise NotImplementedError('Can only extend with a Detection or '
                                      'Family object.')
        return self
Ejemplo n.º 2
0
 def __init__(self, template, detections=None, catalog=None):
     """Instantiation of Family object."""
     self.template = template
     if isinstance(detections, Detection):
         detections = [detections]
     self.detections = detections or []
     self.__catalog = get_catalog(self.detections)
     if catalog:
         Logger.warning("Setting catalog directly is no-longer supported, "
                        "now generated from detections.")
Ejemplo n.º 3
0
 def catalog(self):
     if len(self.__catalog) != len(self.detections):
         self.__catalog = get_catalog(self.detections)
     return self.__catalog