Skip to content

Commit

Permalink
Restored .set_sections so that the multifaultsource converter works a…
Browse files Browse the repository at this point in the history
…gain
  • Loading branch information
micheles authored and nastasi-oq committed Jun 3, 2024
1 parent 242a88e commit c9fce25
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions openquake/hazardlib/source/multi_fault.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@ def rupture_idxs(self):
except KeyError:
raise KeyError(f'{key} not found in {self.hdf5path}')

def set_sections(self, sections):
"""
Used in the UCERF converter, not in the engine
"""
self.sections = sections
dic = {i: sec for i, sec in enumerate(sections)}
save([self], dic, f'{self.source_id}.hdf5', del_rupture_idxs=False)

def set_msparams(self, secparams, close_sec=None, ry0=False,
mon1=performance.Monitor(),
mon2=performance.Monitor()):
Expand Down Expand Up @@ -251,7 +259,7 @@ def get_bounding_box(self, maxdist):


# NB: as side effect delete _rupture_idxs and add .hdf5path
def save(mfsources, sectiondict, hdf5path):
def save(mfsources, sectiondict, hdf5path, del_rupture_idxs=True):
"""
Utility to serialize MultiFaultSources and optionally computing msparams
"""
Expand All @@ -266,7 +274,8 @@ def save(mfsources, sectiondict, hdf5path):
raise IndexError('The section index %s in source %r is invalid'
% (exc.args[0], src.source_id))
all_rids.append(rids)
delattr(src, '_rupture_idxs') # save memory
if del_rupture_idxs:
delattr(src, '_rupture_idxs') # save memory
src.hdf5path = hdf5path

# store data
Expand Down

0 comments on commit c9fce25

Please sign in to comment.