openquake.commands package

db command

openquake.commands.db.convert(strings)[source]

Convert strings into literal Python objects

openquake.commands.db.db(cmd, args=())[source]

Run a database command

dbserver command

openquake.commands.dbserver.dbserver(cmd, dbhostport=None, dbpath='/home/ubuntu/oqdata/db.sqlite3', loglevel='INFO', foreground=False)[source]

start/stop/restart the database server, or return its status

engine command

openquake.commands.engine.del_calculation(job_id, confirmed=False)[source]

Delete a calculation and all associated outputs.

openquake.commands.engine.get_job_id(job_id, username=None)[source]
openquake.commands.engine.run_job(job_ini, log_level='info', log_file=None, exports='', username='ubuntu', **kw)[source]

Run a job using the specified config file and other options.

Parameters
  • job_ini (str) – Path to calculation config (INI-style) files.

  • log_level (str) – ‘debug’, ‘info’, ‘warn’, ‘error’, or ‘critical’

  • log_file (str) – Path to log file.

  • exports – A comma-separated string of export types requested by the user.

  • username – Name of the user running the job

  • kw – Extra parameters like hazard_calculation_id and calculation_mode

openquake.commands.engine.run_tile(job_ini, sites_slice)[source]

Used in tiling calculations

openquake.commands.engine.smart_run(job_ini, oqparam, log_level, log_file, exports, reuse_hazard)[source]

Run calculations by storing their hazard checksum and reusing previous calculations if requested.

export command

openquake.commands.export.export(datastore_key, calc_id=-1, exports='csv', export_dir='.')[source]

Export an output from the datastore. To see the available datastore keys, use the command oq info –exports.

from_shapefile command

openquake.commands.from_shapefile.from_shapefile(output, input_shp_files, validate)[source]

Convert multiple ESRI Shapefile(s) into a single NRML source model file.

info command

openquake.commands.info.do_build_reports(directory)[source]

Walk the directory and builds pre-calculation reports for all the job.ini files found.

openquake.commands.info.info(calculators, gsims, views, exports, extracts, parameters, report, input_file='')[source]

Give information. You can pass the name of an available calculator, a job.ini file, or a zip archive with the input files.

openquake.commands.info.print_csm_info(fname)[source]

Parse the composite source model without instantiating the sources and prints information about its composition and the full logic tree

openquake.commands.info.source_model_info(nodes)[source]

Extract information about NRML/0.5 source models. Returns a table with TRTs as rows and source classes as columns.

plot_agg_curve command

openquake.commands.plot_agg_curve.make_figure(curves)[source]
openquake.commands.plot_agg_curve.plot_ac(calc_id)[source]

Aggregate loss curves plotter.

plot command

openquake.commands.plot.basemap(projection, sitecol)[source]
openquake.commands.plot.make_figure_disagg(extractors, what)[source]

$ oq plot ‘disagg?by=Dist&imt=PGA’

openquake.commands.plot.make_figure_event_based_mfd(extractors, what)[source]
Parameters

plots – list of pairs (task_name, memory array)

openquake.commands.plot.make_figure_hcurves(extractors, what)[source]

$ oq plot ‘hcurves?kind=mean&imt=PGA&site_id=0’

openquake.commands.plot.make_figure_hmaps(extractors, what)[source]

$ oq plot ‘hmaps?kind=mean&imt=PGA’

openquake.commands.plot.make_figure_memory(extractors, what)[source]
Parameters

plots – list of pairs (task_name, memory array)

openquake.commands.plot.make_figure_source_geom(extractors, what)[source]

Extract the geometry of a given sources Example: http://127.0.0.1:8800/v1/calc/30/extract/source_geom/1,2,3

openquake.commands.plot.make_figure_task_info(extractors, what)[source]

Plot an histogram with the task distribution. Example: http://127.0.0.1:8800/v1/calc/30/extract/task_info?kind=classical

openquake.commands.plot.make_figure_uhs(extractors, what)[source]

$ oq plot ‘uhs?kind=mean&site_id=0’

openquake.commands.plot.plot(what, calc_id=-1, other_id=None, webapi=False)[source]

Generic plotter for local and remote calculations.

plot_sites command

openquake.commands.plot_sites.plot_sites(calc_id=-1)[source]

Plot the sites

purge command

openquake.commands.purge.purge(calc_id, force=False)[source]

Remove the given calculation. If you want to remove all calculations, use oq reset.

openquake.commands.purge.purge_all(user=None)[source]

Remove all calculations of the given user

openquake.commands.purge.purge_one(calc_id, user, force)[source]

Remove one calculation ID from the database and remove its datastore

reduce command

openquake.commands.reduce.reduce(fname, reduction_factor)[source]

Produce a submodel from fname by sampling the nodes randomly. Supports source models, site models and exposure models. As a special case, it is also able to reduce .csv files by sampling the lines. This is a debugging utility to reduce large computations to small ones.

openquake.commands.reduce.reduce_source_model(fname, reduction_factor)[source]
openquake.commands.reduce.save_bak(fname, node, num_nodes, total)[source]

reset command

openquake.commands.reset.reset(yes)[source]

Remove all the datastores and the database of the current user

run command

class openquake.commands.run.PStatData(ncalls, tottime, percall, cumtime, percall2, path)

Bases: tuple

property cumtime

Alias for field number 3

property ncalls

Alias for field number 0

property path

Alias for field number 5

property percall

Alias for field number 2

property percall2

Alias for field number 4

property tottime

Alias for field number 1

openquake.commands.run.get_pstats(pstatfile, n)[source]

Return profiling information as an RST table.

Parameters
  • pstatfile – path to a .pstat file

  • n – the maximum number of stats to retrieve

openquake.commands.run.run(job_ini, slowest=False, hc=None, param='', concurrent_tasks=None, exports='', loglevel='info', pdb=None)[source]

Run a calculation bypassing the database layer

openquake.commands.run.run2(job_haz, job_risk, calc_id, concurrent_tasks, pdb, loglevel, exports, params)[source]

Run both hazard and risk, one after the other

show command

openquake.commands.show.show(what='contents', calc_id=-1, extra=())[source]

Show the content of a datastore (by default the last one).

openquake.commands.show.str_or_int(calc_id)[source]

show_attrs command

openquake.commands.show_attrs.show_attrs(key, calc_id=-1)[source]

Show the attributes of a HDF5 dataset in the datastore.

tidy command

openquake.commands.tidy.tidy(fnames)[source]

Reformat a NRML file in a canonical form. That also means reducing the precision of the floats to a standard value. If the file is invalid, a clear error message is shown.

to_hdf5 command

openquake.commands.to_hdf5.convert_npz_hdf5(input_file, output_file)[source]
openquake.commands.to_hdf5.convert_xml_hdf5(input_file, output_file)[source]
openquake.commands.to_hdf5.to_hdf5(input)[source]

Convert .xml and .npz files to .hdf5 files.

to_shapefile command

openquake.commands.to_shapefile.to_shapefile(output, input_nrml_file, validate)[source]

Convert a NRML source model file to ESRI Shapefile(s).

For each type of source geometry defined in the NRML file (point, area, simple fault, complex fault, planar) a separate shapefile is created. Each shapefile is differentiated by a specific ending(‘_point’, ‘_area’, ‘_simple’, ‘_complex’, ‘_planar’).

NB: nonparametric sources are not supported.

upgrade_nrml command

openquake.commands.upgrade_nrml.get_vulnerability_functions_04(fname)[source]

Parse the vulnerability model in NRML 0.4 format.

Parameters

fname – path of the vulnerability file

Returns

a dictionary imt, taxonomy -> vulnerability function + vset

openquake.commands.upgrade_nrml.upgrade_file(path, multipoint)[source]

Upgrade to the latest NRML version

openquake.commands.upgrade_nrml.upgrade_nrml(directory, dry_run, multipoint)[source]

Upgrade all the NRML files contained in the given directory to the latest NRML version. Works by walking all subdirectories. WARNING: there is no downgrade!

webui command

openquake.commands.webui.rundjango(subcmd, hostport=None, skip_browser=False)[source]
openquake.commands.webui.webui(cmd, hostport='127.0.0.1:8800', skip_browser=False)[source]

start the webui server in foreground or perform other operation on the django application