shakemap.utils.utils

shakemap.utils.utils.migrate_gmpe(old_gmpe, config=None)[source]

Return the GMPE that should be used to replace SM3.5 GMPE

By default, this uses the migrate.conf file found in the ShakeMap repository. Users can optionally pass in their own config.

Parameters:
  • old_gmpe (str) – ShakeMap 3.5 GMPE string

  • config (dict) – Input configobj dict or None.

Returns:

New GMPE string, and GMPE reference string.

Return type:

tuple

shakemap.utils.utils.set_gmpe(gmpe, config, eventid)[source]
shakemap.utils.utils.get_network_name(netid)[source]

Return a string representing a name of a network given its ID.

Note: Uses an internet connection to ComCat.

Parameters:

netid (str) – Usually two-character network ID (us,ci, etc.)

Returns:

Network name, or “unknown” if input netid is invalid.

Return type:

str

shakemap.utils.utils.get_object_from_config(obj, section, cfg, *args)[source]

Helper function for things (ipe, gmice, ccf) that don’t have a fromConfig() constructor yet. Instantiates an instance of a class from config entry, ‘name’, that has a corresponding ‘name’_module dictionary of class name, module path.

Parameters:
  • obj (str) – Name of the parameter in the config file that specifies the object to be instantiated.

  • section (str) – The section of the config in which ‘obj’ resides.

  • cfg (dict) – The configuration file in which ‘obj’ and the module definitions reside.

  • args – Additional arguments that will be passed to the constructor of the thing being instantiated.

Returns:

An instance of the object specified by the ‘obj’ parameter

in the config file..

Return type:

object

shakemap.utils.utils.query_yes_no(question, default='yes')[source]

Ask a yes/no question via raw_input() and return their answer.

Parameters:
  • question (str) – a string that is presented to the user.

  • default (str) – the presumed answer if the user just hits <Enter>. It must be “yes” (the default), “no” or None (meaning an answer is required of the user).

Returns:

The “answer” return value is True for “yes” or False for “no”.

Return type:

bool