Esempio n. 1
0
def export_gmf_scenario_xml(output, target):
    """
    Export the GMFs specified by ``output`` to the ``target``.

    :param output:
        :class:`openquake.engine.db.models.Output`
        with an `output_type` of `gmf_scenario`.
    :param target:
        The same ``target`` as :func:`export`.

    :returns:
        The same return value as defined by :func:`export`.
    """
    haz_calc = output.oq_job
    dest = _get_result_export_dest(haz_calc.id, target, output.gmf)
    gmfs = models.get_gmfs_scenario(output)
    writer = writers.ScenarioGMFXMLWriter(dest)
    writer.serialize(gmfs)
    return dest
Esempio n. 2
0
def export_gmf_scenario_xml(output, target):
    """
    Export the GMFs specified by ``output`` to the ``target``.

    :param output:
        :class:`openquake.engine.db.models.Output`
        with an `output_type` of `gmf_scenario`.
    :param target:
        The same ``target`` as :func:`export`.

    :returns:
        The same return value as defined by :func:`export`.
    """
    haz_calc = output.oq_job.hazard_calculation
    dest = _get_result_export_dest(haz_calc.id, target, output.gmf)
    gmfs = models.get_gmfs_scenario(output)
    writer = writers.ScenarioGMFXMLWriter(dest)
    writer.serialize(gmfs)
    return dest
Esempio n. 3
0
def export_gmf_scenario(output, target_dir):
    """
    Export the GMFs specified by ``output`` to the ``target_dir``.

    :param output:
        :class:`openquake.engine.db.models.Output`
        with an `output_type` of `gmf_scenario`.
    :param str target_dir:
        Destination directory location for exported files.

    :returns:
        A list of exported file names (including the absolute path to each
        file).
    """
    gmfs = models.get_gmfs_scenario(output)
    filename = GMF_SCENARIO_FMT % dict(output_id=output.id)
    path = os.path.abspath(os.path.join(target_dir, filename))
    writer = nrml_writers.ScenarioGMFXMLWriter(path)
    writer.serialize(gmfs)
    return [path]
Esempio n. 4
0
def export_gmf_scenario(output, target_dir):
    """
    Export the GMFs specified by ``output`` to the ``target_dir``.

    :param output:
        :class:`openquake.engine.db.models.Output`
        with an `output_type` of `gmf_scenario`.
    :param str target_dir:
        Destination directory location for exported files.

    :returns:
        A list of exported file names (including the absolute path to each
        file).
    """
    haz_calc = output.oq_job.hazard_calculation
    calc_dir = 'calc_%s' % haz_calc.id
    path = os.path.abspath(os.path.join(target_dir, calc_dir,
                                        'gmf', 'gmf.xml'))
    core.makedirs(os.path.dirname(path))
    gmfs = models.get_gmfs_scenario(output)
    writer = writers.ScenarioGMFXMLWriter(path)
    writer.serialize(gmfs)
    return [path]
Esempio n. 5
0
def get_gmfs_per_site(output, imt):
    for gmf in models.get_gmfs_scenario(output, imt):
        yield [gmfnode.gmv for gmfnode in gmf]