code: def _get_origin(event):
      
      if event.preferred_origin() is not None:
          origin = event.preferred_origin()
      elif len(event.origins) > 0:
          origin = event.origins[0]
      else:
          raise IndexError('No origin set, cannot constrain')
      return origin
docs: Get the origin of an event.
  
      :type event: :class:`obspy.core.event.Event`
      :param event: Event to get the origin of.
      :return: :class:`obspy.core.event.Origin`