openquake.commonlib.export package

openquake.commonlib.export.hazard module

class openquake.commonlib.export.hazard.DisaggMatrix(poe, iml, dim_labels, matrix)

Bases: tuple

dim_labels

Alias for field number 2

iml

Alias for field number 1

matrix

Alias for field number 3

poe

Alias for field number 0

class openquake.commonlib.export.hazard.GmfCollection(sitecol, imts, ruptures, investigation_time)[source]

Bases: object

Object converting the parameters

Parameters:
  • sitecol – SiteCollection
  • ruptures – ruptures
  • investigation_time – investigation time

into an object with the right form for the EventBasedGMFXMLWriter. Iterating over a GmfCollection yields GmfSet objects.

class openquake.commonlib.export.hazard.GmfSet(gmfset, investigation_time, ses_idx)[source]

Bases: object

Small wrapper around the list of Gmf objects associated to the given SES.

class openquake.commonlib.export.hazard.GroundMotionField(imt, sa_period, sa_damping, rupture_id, gmf_nodes)[source]

Bases: object

The Ground Motion Field generated by the given rupture

class openquake.commonlib.export.hazard.GroundMotionFieldNode(gmv, loc)[source]

Bases: object

class openquake.commonlib.export.hazard.HazardCurve(location, poes)

Bases: tuple

location

Alias for field number 0

poes

Alias for field number 1

class openquake.commonlib.export.hazard.HazardMap(lon, lat, iml)

Bases: tuple

iml

Alias for field number 2

lat

Alias for field number 1

lon

Alias for field number 0

class openquake.commonlib.export.hazard.Location(xy)[source]

Bases: object

class openquake.commonlib.export.hazard.SES(ruptures, investigation_time, ordinal=1)[source]

Bases: object

Stochastic Event Set: A container for 1 or more ruptures associated with a specific investigation time span.

class openquake.commonlib.export.hazard.SESCollection(idx_ses_dict, investigation_time=None)[source]

Bases: object

Stochastic Event Set Collection

class openquake.commonlib.export.hazard.UHS(imls, location)

Bases: tuple

imls

Alias for field number 0

location

Alias for field number 1

openquake.commonlib.export.hazard.add_imt(fname, imt)[source]
>>> add_imt('/path/to/hcurve_23.csv', 'SA(0.1)')
'/path/to/hcurve-SA(0.1)_23.csv'
openquake.commonlib.export.hazard.export_disagg_xml(ekey, dstore)[source]
openquake.commonlib.export.hazard.export_gmf(ekey, dstore)[source]
Parameters:
  • ekey – export key, i.e. a pair (datastore key, fmt)
  • dstore – datastore object
openquake.commonlib.export.hazard.export_gmf_scenario(ekey, dstore)[source]
openquake.commonlib.export.hazard.export_gmf_spec(ekey, dstore, spec)[source]
Parameters:
  • ekey – export key, i.e. a pair (datastore key, fmt)
  • dstore – datastore object
  • spec – a string specifying what to export exactly
openquake.commonlib.export.hazard.export_gmf_txt(key, dest, sitecol, imts, ruptures, rlz, investigation_time)[source]
Parameters:
  • key – output_type and export_type
  • dest – name of the exported file
  • sitecol – the full site collection
  • imts – the list of intensity measure types
  • ruptures – an ordered list of ruptures
  • rlz – a realization object
  • investigation_time – investigation time (None for scenario)
openquake.commonlib.export.hazard.export_gmf_xml(key, dest, sitecol, imts, ruptures, rlz, investigation_time)[source]
Parameters:
  • key – output_type and export_type
  • dest – name of the exported file
  • sitecol – the full site collection
  • imts – the list of intensity measure types
  • ruptures – an ordered list of ruptures
  • rlz – a realization object
  • investigation_time – investigation time (None for scenario)
openquake.commonlib.export.hazard.export_hazard_curves_csv(key, dest, sitecol, curves_by_imt, imtls, investigation_time=None)[source]

Export the curves of the given realization into CSV.

Parameters:
  • key – output_type and export_type
  • dest – name of the exported file
  • sitecol – site collection
  • curves_by_imt – dictionary with the curves keyed by IMT
  • imtls (dict) – intensity measure types and levels
  • investigation_time – investigation time
openquake.commonlib.export.hazard.export_hazard_curves_xml(key, dest, sitecol, curves_by_imt, imtls, investigation_time)[source]

Export the curves of the given realization into XML.

Parameters:
  • key – output_type and export_type
  • dest – name of the exported file
  • sitecol – site collection
  • curves_by_imt – dictionary with the curves keyed by IMT
  • imtls – dictionary with the intensity measure types and levels
  • investigation_time – investigation time in years
openquake.commonlib.export.hazard.export_hazard_hdf5(ekey, dstore)[source]
openquake.commonlib.export.hazard.export_hcurves_by_imt_csv(key, dest, sitecol, curves_by_imt, imtls, investigation_time=None)[source]

Export the curves of the given realization into CSV.

Parameters:
  • key – output_type and export_type
  • dest – name of the exported file
  • sitecol – site collection
  • curves_by_imt – dictionary with the curves keyed by IMT
  • imtls (dict) – intensity measure types and levels
  • investigation_time – investigation time
openquake.commonlib.export.hazard.export_hcurves_csv(ekey, dstore)[source]

Exports the hazard curves into several .csv files

Parameters:
  • ekey – export key, i.e. a pair (datastore key, fmt)
  • dstore – datastore object
openquake.commonlib.export.hazard.export_hcurves_xml_json(ekey, dstore)[source]
openquake.commonlib.export.hazard.export_hmaps_xml_json(ekey, dstore)[source]
openquake.commonlib.export.hazard.export_rup_data(ekey, dstore)[source]
openquake.commonlib.export.hazard.export_ses_xml(ekey, dstore)[source]
Parameters:
  • ekey – export key, i.e. a pair (datastore key, fmt)
  • dstore – datastore object
openquake.commonlib.export.hazard.export_uhs_xml(ekey, dstore)[source]
openquake.commonlib.export.hazard.get_mesh(sitecol)[source]
openquake.commonlib.export.hazard.get_metadata(realizations, kind)[source]
Parameters:
  • realizations (list) – realization objects
  • kind (str) – kind of data, i.e. a key in the datastore
Returns:

a dictionary with smlt_path, gsimlt_path, statistics, quantile_value

openquake.commonlib.export.hazard.get_rup_idx(ebrup, etag)[source]
openquake.commonlib.export.hazard.hazard_curve_name(dstore, ekey, kind, rlzs_assoc)[source]
Parameters:
  • calc_id – the calculation ID
  • ekey – the export key
  • kind – the kind of key
  • rlzs_assoc – a RlzsAssoc instance

openquake.commonlib.export.risk module

class openquake.commonlib.export.risk.AggCurve(losses, poes, average_loss, stddev_loss)

Bases: tuple

average_loss

Alias for field number 2

losses

Alias for field number 0

poes

Alias for field number 1

stddev_loss

Alias for field number 3

class openquake.commonlib.export.risk.BcrData(location, asset_ref, average_annual_loss_original, average_annual_loss_retrofitted, bcr)

Bases: tuple

asset_ref

Alias for field number 1

average_annual_loss_original

Alias for field number 2

average_annual_loss_retrofitted

Alias for field number 3

bcr

Alias for field number 4

location

Alias for field number 0

class openquake.commonlib.export.risk.Location(x, y)[source]

Bases: object

class openquake.commonlib.export.risk.LossCurve(location, asset_ref, poes, losses, loss_ratios, average_loss, stddev_loss)

Bases: tuple

asset_ref

Alias for field number 1

average_loss

Alias for field number 5

location

Alias for field number 0

loss_ratios

Alias for field number 4

losses

Alias for field number 3

poes

Alias for field number 2

stddev_loss

Alias for field number 6

class openquake.commonlib.export.risk.LossMap(location, asset_ref, value, std_dev)

Bases: tuple

asset_ref

Alias for field number 1

location

Alias for field number 0

std_dev

Alias for field number 3

value

Alias for field number 2

class openquake.commonlib.export.risk.Output(ltype, path, array)

Bases: tuple

array

Alias for field number 2

ltype

Alias for field number 0

path

Alias for field number 1

openquake.commonlib.export.risk.add_quotes(values)[source]
openquake.commonlib.export.risk.build_damage_array(data, damage_dt)[source]
Parameters:
  • data – an array of length N with fields ‘mean’ and ‘stddev’
  • damage_dt – a damage composite data type loss_type -> states
Returns:

a composite array of length N and dtype damage_dt

openquake.commonlib.export.risk.build_damage_dt(dstore)[source]
Parameters:dstore – a datastore instance
Returns:a composite dtype loss_type -> (mean_ds1, stdv_ds1, ...)
openquake.commonlib.export.risk.compactify(array)[source]

Compactify a composite array of type (name, N1, N2, N3, 2) into a composite array of type (name, N1, N2, (N3, 2)). Works with any number of Ns.

openquake.commonlib.export.risk.export_agg_curve(ekey, dstore)[source]
openquake.commonlib.export.risk.export_agg_losses(ekey, dstore)[source]
Parameters:
  • ekey – export key, i.e. a pair (datastore key, fmt)
  • dstore – datastore object
openquake.commonlib.export.risk.export_agg_losses_ebr(ekey, dstore)[source]
Parameters:
  • ekey – export key, i.e. a pair (datastore key, fmt)
  • dstore – datastore object
openquake.commonlib.export.risk.export_agglosses(ekey, dstore)[source]
openquake.commonlib.export.risk.export_avg_losses(ekey, dstore)[source]
Parameters:
  • ekey – export key, i.e. a pair (datastore key, fmt)
  • dstore – datastore object
openquake.commonlib.export.risk.export_avg_losses_stats(ekey, dstore)[source]
Parameters:
  • ekey – export key, i.e. a pair (datastore key, fmt)
  • dstore – datastore object
openquake.commonlib.export.risk.export_avglosses_csv(ekey, dstore)[source]
Parameters:
  • ekey – export key, i.e. a pair (datastore key, fmt)
  • dstore – datastore object
openquake.commonlib.export.risk.export_bcr_map_rlzs(ekey, dstore)[source]
openquake.commonlib.export.risk.export_csq_by_taxon_csv(ekey, dstore)[source]
openquake.commonlib.export.risk.export_csq_total_csv(ekey, dstore)[source]
openquake.commonlib.export.risk.export_damage(ekey, dstore)[source]
openquake.commonlib.export.risk.export_damage_taxon(ekey, dstore)[source]
openquake.commonlib.export.risk.export_damage_total(ekey, dstore)[source]
openquake.commonlib.export.risk.export_dmg_by_asset_csv(ekey, dstore)[source]
openquake.commonlib.export.risk.export_dmg_by_taxon_csv(ekey, dstore)[source]
openquake.commonlib.export.risk.export_dmg_totalcsv(ekey, dstore)[source]
openquake.commonlib.export.risk.export_dmg_xml(key, dstore, damage_states, dmg_data, lt, rlz)[source]

Export damage outputs in XML format.

Parameters:
  • key – dmg_dist_per_asset|dmg_dist_per_taxonomy|dmg_dist_total|collapse_map
  • dstore – the datastore
  • damage_states – the list of damage states
  • dmg_data – a list [(loss_type, unit, asset_ref, mean, stddev), ...]
  • lt – loss type string
  • rlz – a realization object
openquake.commonlib.export.risk.export_loss_curves(ekey, dstore)[source]
openquake.commonlib.export.risk.export_loss_curves_rlzs(ekey, dstore)[source]
openquake.commonlib.export.risk.export_loss_curves_stats(ekey, dstore)[source]
openquake.commonlib.export.risk.export_loss_map_xml_geojson(ekey, dstore)[source]
openquake.commonlib.export.risk.export_loss_maps_csv(ekey, dstore)[source]
openquake.commonlib.export.risk.export_loss_maps_rlzs_xml_geojson(ekey, dstore)[source]
openquake.commonlib.export.risk.export_loss_maps_stats_xml_geojson(ekey, dstore)[source]
openquake.commonlib.export.risk.export_rcurves(ekey, dstore)[source]
openquake.commonlib.export.risk.export_rcurves_rlzs(ekey, dstore)[source]
openquake.commonlib.export.risk.export_realizations(ekey, dstore)[source]
openquake.commonlib.export.risk.export_rlzs_by_asset_csv(ekey, dstore)[source]
openquake.commonlib.export.risk.extract_outputs(dkey, dstore, loss_type=None, ext='')[source]

An utility to extract outputs ordered by loss types from a datastore containing nested structures as follows:

>> dstore = { .. ‘risk_output’: .. {‘structural’: .. {‘b1’: array N x 2, .. ‘b2’: array N x 2, .. }}} >> outputs = extract_outputs(‘risk_output’, dstore) >> [o.path for o in outputs] [‘risk_output-structural-b1’, ‘risk_output-structural-b2’] >> [o.ltype for o in outputs] [‘structural’, ‘structural’]

openquake.commonlib.export.risk.get_paths(rlz)[source]
Parameters:rlz – a logic tree realization (composite or simple)
Returns:a dict {‘source_model_tree_path’: string, ‘gsim_tree_path’: string}

Module contents

exception openquake.commonlib.export.MissingExporter[source]

Bases: exceptions.Exception

Raised when there is not exporter for the given pair (dskey, fmt)

openquake.commonlib.export.dispatch_on_colon(ekey, dstore)[source]

If the datastore key contains a colon, i.e. it is of the form dskey:spec, then call export((‘<dskey>:’, fmt), dstore, spec).

Parameters:
  • ekey – export key of the form (k0, ext) with k0 of the form <dskey>:<spec>
  • dstore – datastore instance

This function is called only for ekey not present in the datastore.

openquake.commonlib.export.export_csv(ekey, dstore)[source]

Default csv exporter for arrays stored in the output.hdf5 file

Parameters:
  • ekey – export key
  • dstore – datastore object
Returns:

a list with the path of the exported file