Skip to content

Commit

Permalink
Fixed SourceFilter [skip hazardlib]
Browse files Browse the repository at this point in the history
  • Loading branch information
micheles committed Dec 10, 2018
1 parent 1213cc7 commit ea9b2ee
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
10 changes: 2 additions & 8 deletions openquake/calculators/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from openquake.baselib import (
config, general, hdf5, datastore, __version__ as engine_version)
from openquake.baselib.performance import perf_dt, Monitor
from openquake.hazardlib.calc.filters import SourceFilter, RtreeFilter
from openquake.hazardlib.calc.filters import SourceFilter
from openquake.hazardlib import InvalidFile
from openquake.hazardlib.source import rupture
from openquake.risklib import riskinput, riskmodels
Expand Down Expand Up @@ -355,19 +355,13 @@ def block_splitter(self, sources, weight=get_weight):
@general.cached_property
def src_filter(self):
"""
:returns: a SourceFilter/RtreeFilter or None
:returns: a SourceFilter/UcerfFilter
"""
oq = self.oqparam
self.hdf5cache = self.datastore.hdf5cache()
sitecol = self.sitecol.complete if self.sitecol else None
if 'ucerf' in oq.calculation_mode:
return UcerfFilter(sitecol, oq.maximum_distance, self.hdf5cache)
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.
return RtreeFilter(sitecol, oq.maximum_distance, self.hdf5cache)
return SourceFilter(sitecol, oq.maximum_distance, self.hdf5cache)

def can_read_parent(self):
Expand Down
14 changes: 11 additions & 3 deletions openquake/commonlib/readinput.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
from openquake.baselib.python3compat import decode, zip
from openquake.baselib.node import Node
from openquake.hazardlib.const import StdDev
from openquake.hazardlib.calc.filters import split_sources
from openquake.hazardlib.calc.filters import split_sources, RtreeFilter
from openquake.hazardlib.calc.gmf import CorrelationButNoInterIntraStdDevs
from openquake.hazardlib import (
geo, site, imt, valid, sourceconverter, nrml, InvalidFile)
Expand Down Expand Up @@ -887,8 +887,16 @@ def get_composite_source_model(oqparam, monitor=None, in_memory=True,
if (srcfilter and oqparam.split_sources and
oqparam.prefilter_sources != 'no' and
oqparam.calculation_mode not in 'ucerf_hazard ucerf_risk'):
mon = monitor('split_filter')
csm = parallel_split_filter(csm, srcfilter, split_all, mon)
if oqparam.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.
srcfilter = RtreeFilter(srcfilter.sitecol,
oqparam.maximum_distance,
srcfilter.hdf5path)
csm = parallel_split_filter(
csm, srcfilter, split_all, monitor('split_filter'))
return csm


Expand Down

0 comments on commit ea9b2ee

Please sign in to comment.