Export API¶
Functions for listing completed calculations and outputs, as well as exporting outputs to files.
Functions for getting information about completed jobs and calculation outputs, as well as exporting outputs from the database to various file formats.
-
openquake.engine.export.core.
LT_PATH_JOIN_TOKEN
= '_'¶ Used to separate node labels in a logic tree path
-
openquake.engine.export.core.
export
(output_id, target, export_type='xml, geojson, csv')[source]¶ Export the given calculation output_id from the database to the specified target directory in the specified export_type.
-
openquake.engine.export.core.
get_outputs
(job_id, output_type=None)[source]¶ Get all
openquake.engine.db.models.Output
objects associated with the specified job and output_type.Parameters: - job_id (int) – ID of a
openquake.engine.db.models.OqJob
. - output_type (str) – the output type; if None, return all outputs
Returns: django.db.models.query.QuerySet
ofopenquake.engine.db.models.Output
objects.- job_id (int) – ID of a
-
openquake.engine.export.core.
makedirs
(path)[source]¶ Make all of the directories in the
path
using os.makedirs.
Hazard Export¶
API for exporting hazard artifacts from the DB.
Functionality for exporting and serializing hazard curve calculation results.
-
openquake.engine.export.hazard.
export_disagg_matrix_xml
(key, output, target)[source]¶ Export disaggregation histograms to the
target
.Parameters: - output –
openquake.engine.db.models.Output
with an output_type of disagg_matrix. - target (str) – Destination directory location for exported files.
Returns: A list of exported file name (including the absolute path to each file).
- output –
-
openquake.engine.export.hazard.
export_gmf_csv
(key, output, target)[source]¶ Export the GMF Collection specified by
output
to thetarget
.Parameters: - output –
openquake.engine.db.models.Output
with an output_type of gmf. - target – The same
target
asexport()
.
Returns: The same return value as defined by
export()
.- output –
-
openquake.engine.export.hazard.
export_gmf_xml
(key, output, target)[source]¶ Export the GMF Collection specified by
output
to thetarget
.Parameters: - output –
openquake.engine.db.models.Output
with an output_type of gmf. - target – The same
target
asexport()
.
Returns: The same return value as defined by
export()
.- output –
-
openquake.engine.export.hazard.
export_hazard_curve
(key, output, target)[source]¶ Export the specified hazard curve
output
to thetarget
.Parameters: - output –
openquake.engine.db.models.Output
with an output_type of hazard_curve. - target – The same
target
asexport()
.
Returns: The same return value as defined by
export()
.- output –
-
openquake.engine.export.hazard.
export_hazard_curve_csv
(key, output, target)[source]¶ Save a hazard curve (of a given IMT) as a .csv file in the format (lon lat poe1 ... poeN), where the fields are space separated.
-
openquake.engine.export.hazard.
export_hazard_map
(key, output, target)[source]¶ General hazard map export code.
-
openquake.engine.export.hazard.
export_hazard_map_csv
(key, output, target)[source]¶ General hazard map export code.
-
openquake.engine.export.hazard.
export_ses_csv
(key, output, target)[source]¶ Export the Stochastic Event Set Collection specified by
output
to thetarget
in csv format.Parameters: - output –
openquake.engine.db.models.Output
with an output_type of ses. - target (str) – Destination directory location for exported files.
Returns: The exported file path
- output –
-
openquake.engine.export.hazard.
export_ses_xml
(key, output, target)[source]¶ Export the Stochastic Event Set Collection specified by
output
to thetarget
.Parameters: - output –
openquake.engine.db.models.Output
with an output_type of ses. - target (str) – Destination directory location for exported files.
Returns: The exported file path
- output –
-
openquake.engine.export.hazard.
export_uh_spectra_xml
(key, output, target)[source]¶ Export the specified UHS
output
to thetarget
.Parameters: - output –
openquake.engine.db.models.Output
with an output_type of uh_spectra. - target (str) – Destination directory location for exported files.
Returns: A list containing the exported file name.
- output –
-
openquake.engine.export.hazard.
regroup
(idx_gmv_imt_triples)[source]¶ Regroup the GMF data in a form suitable for export.
>>> data = [(1, 0.1, 'PGA'), (2, 0.2, 'PGA'), ... (1, 0.11, 'SA(0.1)'), (2, 0.21, 'SA(0.1)'), ... (1, 0.12, 'SA(0.2)'), (2, 0.22, 'SA(0.2)')] >>> regroup(data) [(1, 2), [0.1, 0.2], [0.11, 0.21], [0.12, 0.22]]