def save_hmaps(self): """ Save hazard maps generated from the hazard curves """ oq = self.oqparam if oq.poes: mon = self.monitor('computing hazard maps') logging.info('Computing hazard maps for PoEs=%s', oq.poes) with mon: N = len(self.sitecol.complete) ct = oq.concurrent_tasks or 1 if 'hcurves' in self.datastore: kinds = self.datastore['hcurves'] hmaps_dt = numpy.dtype( [('%s-%s' % (imt, poe), F32) for imt in oq.imtls for poe in oq.poes]) for kind in kinds: self.datastore.create_dset( 'hmaps/' + kind, hmaps_dt, (N,), fillvalue=None) allargs = [] for slc in general.split_in_slices(N, ct): hcurves_by_kind = { kind: self.datastore['hcurves/' + kind][slc] for kind in kinds} allargs.append((hcurves_by_kind, slc, oq.imtls, oq.poes, mon)) for dic, slc in Starmap(build_hmaps, allargs): for kind, hmaps in dic.items(): self.datastore['hmaps/' + kind][slc] = hmaps else: # single realization pg = PmapGetter(self.datastore, self.rlzs_assoc) self.datastore['hmaps/mean'] = calc.make_hmap_array( pg.get_mean(), oq.imtls, oq.poes, N)
def save_hmaps(self): """ Save hazard maps generated from the hazard curves """ oq = self.oqparam if oq.poes: logging.info('Computing hazard maps for PoEs=%s', oq.poes) with self.monitor('computing hazard maps', autoflush=True, measuremem=True): N = len(self.sitecol.complete) if 'hcurves' in self.datastore: # TODO: we could parallelize this branch for kind in self.datastore['hcurves']: self.datastore['hmaps/' + kind] = calc.make_hmap_array( self.datastore['hcurves/' + kind], oq.imtls, oq.poes, N) else: # single realization pg = PmapGetter(self.datastore, self.rlzs_assoc) self.datastore['hmaps/mean'] = calc.make_hmap_array( pg.get_mean(), oq.imtls, oq.poes, N)