def compute_gmfs_curves(self, monitor):
        """
        :returns: a dict with keys gmfdata, indices, hcurves
        """
        oq = self.oqparam
        with monitor('GmfGetter.init', measuremem=True):
            self.init()
        hcurves = {}  # key -> poes
        if oq.hazard_curves_from_gmfs:
            hc_mon = monitor('building hazard curves', measuremem=False)
            duration = oq.investigation_time * oq.ses_per_logic_tree_path
            with monitor('building hazard', measuremem=True):
                gmfdata = self.get_gmfdata()  # returned later
                hazard = self.get_hazard(data=gmfdata)
            for sid, hazardr in hazard.items():
                dic = general.group_array(hazardr, 'rlzi')
                for rlzi, array in dic.items():
                    with hc_mon:
                        gmvs = array['gmv']
                        for imti, imt in enumerate(oq.imtls):
                            poes = _gmvs_to_haz_curve(
                                gmvs[:, imti], oq.imtls[imt],
                                oq.investigation_time, duration)
                            hcurves[rsi2str(rlzi, sid, imt)] = poes
        elif oq.ground_motion_fields:  # fast lane
            with monitor('building hazard', measuremem=True):
                gmfdata = self.get_gmfdata()
        else:
            return {}
        if len(gmfdata) == 0:
            return dict(gmfdata=[])
        indices = []
        gmfdata.sort(order=('sid', 'rlzi', 'eid'))
        start = stop = 0
        for sid, rows in itertools.groupby(gmfdata['sid']):
            for row in rows:
                stop += 1
            indices.append((sid, start, stop))
            start = stop
        res = dict(gmfdata=gmfdata, hcurves=hcurves,
                   sig_eps=numpy.array(self.sig_eps, self.sig_eps_dt),
                   indices=numpy.array(indices, (U32, 3)))
        return res
def compute_gmfs_curves ( self , monitor ) : oq = self . oqparam with monitor ( 'GmfGetter.init' , measuremem = True ) : self . init ( ) hcurves = { } if oq . hazard_curves_from_gmfs : hc_mon = monitor ( 'building hazard curves' , measuremem = False ) duration = oq . investigation_time * oq . ses_per_logic_tree_path with monitor ( 'building hazard' , measuremem = True ) : gmfdata = self . get_gmfdata ( ) hazard = self . get_hazard ( data = gmfdata ) for sid , hazardr in hazard . items ( ) : dic = general . group_array ( hazardr , 'rlzi' ) for rlzi , array in dic . items ( ) : with hc_mon : gmvs = array [ 'gmv' ] for imti , imt in enumerate ( oq . imtls ) : poes = _gmvs_to_haz_curve ( gmvs [ : , imti ] , oq . imtls [ imt ] , oq . investigation_time , duration ) hcurves [ rsi2str ( rlzi , sid , imt ) ] = poes elif oq . ground_motion_fields : with monitor ( 'building hazard' , measuremem = True ) : gmfdata = self . get_gmfdata ( ) else : return { } if len ( gmfdata ) == 0 : return dict ( gmfdata = [ ] ) indices = [ ] gmfdata . sort ( order = ( 'sid' , 'rlzi' , 'eid' ) ) start = stop = 0 for sid , rows in itertools . groupby ( gmfdata [ 'sid' ] ) : for row in rows : stop += 1 indices . append ( ( sid , start , stop ) ) start = stop res = dict ( gmfdata = gmfdata , hcurves = hcurves , sig_eps = numpy . array ( self . sig_eps , self . sig_eps_dt ) , indices = numpy . array ( indices , ( U32 , 3 ) ) ) return res
:returns: a dict with keys gmfdata, indices, hcurves