Пример #1
0
def compute_gmfs(job_id, sites, rupture_id, gmfcoll_id, realizations):
    """
    Compute ground motion fields and store them in the db.

    :param job_id:
        ID of the currently running job.
    :param sites:
        The subset of the full SiteCollection scanned by this task
    :param rupture_id:
        The parsed rupture model from which we will generate
        ground motion fields.
    :param gmfcoll_id:
        the id of a :class:`openquake.engine.db.models.Gmf` record
    :param realizations:
        Number of realizations to create.
    """

    hc = models.HazardCalculation.objects.get(oqjob=job_id)
    rupture_mdl = source.nrml_to_hazardlib(
        models.ParsedRupture.objects.get(id=rupture_id).nrml,
        hc.rupture_mesh_spacing, None, None)
    imts = [haz_general.imt_to_hazardlib(x)
            for x in hc.intensity_measure_types]
    gsim = AVAILABLE_GSIMS[hc.gsim]()  # instantiate the GSIM class
    correlation_model = haz_general.get_correl_model(hc)

    with EnginePerformanceMonitor('computing gmfs', job_id, gmfs):
        gmf = ground_motion_fields(
            rupture_mdl, sites, imts, gsim,
            hc.truncation_level, realizations=realizations,
            correlation_model=correlation_model)
    with EnginePerformanceMonitor('saving gmfs', job_id, gmfs):
        save_gmf(gmfcoll_id, gmf, sites)
Пример #2
0
def compute_gmfs(job_id, rupture_ids, output_id, task_no, realizations):
    """
    Compute ground motion fields and store them in the db.

    :param job_id:
        ID of the currently running job.
    :param rupture_ids:
        List of ids of parsed rupture model from which we will generate
        ground motion fields.
    :param output_id:
        output_id idenfitifies the reference to the output record.
    :param task_no:
        The task_no in which the calculation results will be placed.
        This ID basically corresponds to the sequence number of the task,
        in the context of the entire calculation.
    :param realizations:
        Number of realizations which are going to be created.
    """

    hc = models.HazardCalculation.objects.get(oqjob=job_id)
    rupture_mdl = source.nrml_to_hazardlib(
        models.ParsedRupture.objects.get(id=rupture_ids[0]).nrml,
        hc.rupture_mesh_spacing, None, None)
    imts = [haz_general.imt_to_hazardlib(x)
            for x in hc.intensity_measure_types]
    gsim = AVAILABLE_GSIMS[hc.gsim]
    correlation_model = haz_general.get_correl_model(hc)
    gmf = ground_motion_fields(
        rupture_mdl, hc.site_collection, imts, gsim(),
        hc.truncation_level, realizations=realizations,
        correlation_model=correlation_model)

    save_gmf(output_id, gmf, hc.site_collection.mesh, task_no)
Пример #3
0
def compute_gmfs(job_id, sites, rupture, gmf_id, realizations):
    """
    Compute ground motion fields and store them in the db.

    :param job_id:
        ID of the currently running job.
    :param sites:
        The subset of the full SiteCollection scanned by this task
    :param rupture:
        The hazardlib rupture from which we will generate
        ground motion fields.
    :param gmf_id:
        the id of a :class:`openquake.engine.db.models.Gmf` record
    :param realizations:
        Number of realizations to create.
    """
    hc = models.HazardCalculation.objects.get(oqjob=job_id)
    imts = [from_string(x) for x in hc.intensity_measure_types]
    gsim = AVAILABLE_GSIMS[hc.gsim]()  # instantiate the GSIM class
    correlation_model = haz_general.get_correl_model(hc)

    with EnginePerformanceMonitor('computing gmfs', job_id, gmfs):
        return ground_motion_fields(
            rupture, sites, imts, gsim,
            hc.truncation_level, realizations=realizations,
            correlation_model=correlation_model)
Пример #4
0
def compute_gmfs(job_id, sites, rupture_id, output_id, realizations):
    """
    Compute ground motion fields and store them in the db.

    :param job_id:
        ID of the currently running job.
    :param sites:
        The subset of the full SiteCollection scanned by this task
    :param rupture_id:
        The parsed rupture model from which we will generate
        ground motion fields.
    :param output_id:
        output_id idenfitifies the reference to the output record.
    :param realizations:
        Number of realizations to create.
    """

    hc = models.HazardCalculation.objects.get(oqjob=job_id)
    rupture_mdl = source.nrml_to_hazardlib(
        models.ParsedRupture.objects.get(id=rupture_id).nrml,
        hc.rupture_mesh_spacing, None, None)
    imts = [haz_general.imt_to_hazardlib(x)
            for x in hc.intensity_measure_types]
    gsim = AVAILABLE_GSIMS[hc.gsim]()  # instantiate the GSIM class
    correlation_model = haz_general.get_correl_model(hc)
    gmf = ground_motion_fields(
        rupture_mdl, sites, imts, gsim,
        hc.truncation_level, realizations=realizations,
        correlation_model=correlation_model)
    save_gmf(output_id, gmf, sites.mesh)
Пример #5
0
    def test_mearn_nearfault_distance_taper(self):
        rupture = self.make_rupture()
        site1 = Site(location=Point(27.9, 41), vs30=1200.,
                     vs30measured=True, z1pt0=2.36, z2pt5=2.)
        site2 = Site(location=Point(28.1, 41), vs30=1200.,
                     vs30measured=True, z1pt0=2.36, z2pt5=2.)
        sites = SiteCollection([site1, site2])

        fields = ground_motion_fields(
            rupture, sites, [PGV()], ChiouYoungs2014NearFaultEffect(),
            truncation_level=0, realizations=1)
        gmf = fields[PGV()]
        self.assertAlmostEquals(2.27395, gmf[0], delta=1e-4)
        self.assertAlmostEquals(3.38409, gmf[1], delta=1e-4)
Пример #6
0
    def test_mearn_nearfault_distance_taper(self):
        rupture = self.make_rupture()
        site1 = Site(location=Point(27.9, 41), vs30=1200.,
                     vs30measured=True, z1pt0=2.36, z2pt5=2.)
        site2 = Site(location=Point(28.1, 41), vs30=1200.,
                     vs30measured=True, z1pt0=2.36, z2pt5=2.)
        sites = SiteCollection([site1, site2])

        fields = ground_motion_fields(
            rupture, sites, [PGV()], ChiouYoungs2014NearFaultEffect(),
            truncation_level=0, realizations=1)
        gmf = fields[PGV()]
        self.assertAlmostEquals(2.27395, gmf[0], delta=1e-4)
        self.assertAlmostEquals(3.38409, gmf[1], delta=1e-4)
def ground_motion_from_rupture(rupture,
                               sites=None,
                               imts=[PGA()],
                               gsim=ChiouYoungs2014(),
                               truncation_level=4,
                               realizations=1,
                               **kwargs):

    gm = ground_motion_fields(rupture=rupture,
                              sites=sites,
                              imts=imts,
                              gsim=gsim,
                              truncation_level=truncation_level,
                              realizations=realizations)
    return gm