Пример #1
0
 def rtree_filter(self):
     """
     :returns: an RtreeFilter
     """
     return RtreeFilter(self.src_filter.sitecol,
                        self.oqparam.maximum_distance,
                        self.src_filter.filename)
Пример #2
0
def plot_sites(calc_id):
    """
    Plot the sites and the bounding boxes of the sources, enlarged by
    the maximum distance
    """
    import matplotlib.pyplot as p
    from matplotlib.patches import Rectangle
    dstore = datastore.read(calc_id)
    sitecol = dstore['sitecol']
    csm = dstore['composite_source_model']
    oq = dstore['oqparam']
    rfilter = RtreeFilter(sitecol, oq.maximum_distance)
    fig = p.figure()
    ax = fig.add_subplot(111)
    ax.grid(True)
    for src in csm.get_sources():
        llcorner, width, height = rfilter.get_rectangle(src)
        ax.add_patch(Rectangle(llcorner, width, height, fill=False))
    p.scatter(sitecol.lons, sitecol.lats, marker='+')
    p.show()
Пример #3
0
 def filter_csm(self):
     """
     :returns: (filtered CompositeSourceModel, SourceFilter)
     """
     oq = self.oqparam
     src_filter = SourceFilter(self.sitecol.complete, oq.maximum_distance)
     monitor = self.monitor('prefiltering')
     if (oq.prefilter_sources == 'numpy' or rtree is None):
         csm = self.csm.filter(src_filter, monitor)
     elif oq.prefilter_sources == 'rtree':
         prefilter = RtreeFilter(self.sitecol.complete, oq.maximum_distance)
         csm = self.csm.filter(prefilter, monitor)
     else:
         csm = self.csm.filter(BaseFilter(), monitor)
     return csm, src_filter
Пример #4
0
 def filter_csm(self):
     """
     :returns: (filtered CompositeSourceModel, SourceFilter)
     """
     oq = self.oqparam
     mon = self.monitor('prefilter')
     self.hdf5cache = self.datastore.hdf5cache()
     src_filter = SourceFilter(self.sitecol.complete, oq.maximum_distance,
                               self.hdf5cache)
     if (oq.prefilter_sources == 'numpy' or rtree is None):
         csm = self.csm.filter(src_filter, mon)
     elif oq.prefilter_sources == 'rtree':
         prefilter = RtreeFilter(self.sitecol.complete, oq.maximum_distance,
                                 self.hdf5cache)
         csm = self.csm.filter(prefilter, mon)
     else:  # prefilter_sources='no'
         csm = self.csm.filter(SourceFilter(None, {}), mon)
     return csm, src_filter
Пример #5
0
 def get_filter(self):
     """
     :returns: a SourceFilter/RtreeFilter or None
     """
     oq = self.oqparam
     self.hdf5cache = self.datastore.hdf5cache()
     self.src_filter = SourceFilter(self.sitecol.complete,
                                    oq.maximum_distance, self.hdf5cache)
     if 'ucerf' in oq.calculation_mode:
         # do not preprocess
         return
     elif oq.prefilter_sources == 'rtree':
         # rtree can be used only with processpool, otherwise one gets an
         # RTreeError: Error in "Index_Create": Spatial Index Error:
         # IllegalArgumentException: SpatialIndex::DiskStorageManager:
         # Index/Data file cannot be read/writen.
         src_filter = RtreeFilter(self.sitecol.complete,
                                  oq.maximum_distance, self.hdf5cache)
     else:
         src_filter = self.src_filter
     return src_filter
Пример #6
0
 def filter_csm(self):
     """
     :returns: (filtered CompositeSourceModel, SourceFilter)
     """
     oq = self.oqparam
     mon = self.monitor('prefilter')
     self.hdf5cache = self.datastore.hdf5cache()
     src_filter = SourceFilter(self.sitecol.complete, oq.maximum_distance,
                               self.hdf5cache)
     if (oq.prefilter_sources == 'numpy' or rtree is None):
         logging.info('Prefiltering the sources with numpy')
         csm = self.csm.pfilter(src_filter, oq.concurrent_tasks, mon)
     elif oq.prefilter_sources == 'rtree':
         logging.info('Prefiltering the sources with rtree')
         prefilter = RtreeFilter(self.sitecol.complete, oq.maximum_distance,
                                 self.hdf5cache)
         csm = self.csm.pfilter(prefilter, oq.concurrent_tasks, mon)
     else:  # prefilter_sources='no'
         logging.info('Not prefiltering the sources')
         csm = self.csm
     logging.info('There are %d realizations', csm.info.get_num_rlzs())
     return src_filter, csm