from itertools import izip from numpy import zeros from numpy import allclose from numpy import sin, cos, arctan2, sqrt, radians from shapely import geometry from scipy.interpolate import interp1d from openquake.hazardlib import geo as hazardlib_geo from openquake.engine.utils import round_float from openquake.engine import logs LOGGER = logs.LOG logs.set_logger_level(LOGGER, logs.LEVELS.get('debug')) class Region(object): """A container of polygons, used for bounds checking.""" def __init__(self, polygon): self._grid = None self.cell_size = 0.1 self.polygon = polygon @classmethod def from_coordinates(cls, coordinates): """ Build a region from a list of polygon coordinates.
job.save() kvs.mark_job_as_current(job.id) _do_run_calc(job, exports, calc, job_type) except Exception, ex: logs.LOG.critical("Calculation failed with exception: '%s'" % str(ex)) raise finally: job.is_running = False job.save() return supervisor_pid = os.fork() if not supervisor_pid: # supervisor process logs.set_logger_level(logs.logging.root, log_level) # TODO: deal with KVS garbage collection supervisor.supervise(job_pid, job.id, log_file=log_file) return # parent process # ignore Ctrl-C as well as supervisor process does. thus only # job executor terminates on SIGINT supervisor.ignore_sigint() # wait till both child processes are done os.waitpid(job_pid, 0) os.waitpid(supervisor_pid, 0) # Refresh the job record, since the forked processes are going to modify # job state.
# calculation executor process try: _job_exec(job, log_level, exports, job_type, calc) except Exception, ex: logs.LOG.critical("Calculation failed with exception: '%s'" % str(ex)) raise finally: job.is_running = False job.save() return supervisor_pid = os.fork() if not supervisor_pid: # supervisor process logs.set_logger_level(logs.logging.root, log_level) # TODO: deal with KVS garbage collection supervisor.supervise(job_pid, job.id, log_file=log_file) return # parent process # ignore Ctrl-C as well as supervisor process does. thus only # job executor terminates on SIGINT supervisor.ignore_sigint() # wait till both child processes are done os.waitpid(job_pid, 0) os.waitpid(supervisor_pid, 0) else: try: _job_exec(job, log_level, exports, job_type, calc)