def setup_classic_job(self, create_job_path=True, upload_id=None): """Create a classic job with associated upload and inputs. :param integer upload_id: if set use upload record with given db key. :param bool create_job_path: if set the path for the job will be created and captured in the job record :returns: a :py:class:`geonode.mtapi.models.OqJob` instance """ upload = self.setup_upload(upload_id) oqp = OqParams() oqp.job_type = "classical" oqp.upload = upload oqp.region_grid_spacing = 0.01 oqp.min_magnitude = 5.0 oqp.investigation_time = 50.0 oqp.component = "gmroti50" oqp.imt = "pga" oqp.truncation_type = "twosided" oqp.truncation_level = 3 oqp.reference_vs30_value = 760 oqp.imls = [ 0.005, 0.007, 0.0098, 0.0137, 0.0192, 0.0269, 0.0376, 0.0527, 0.0738, 0.103, 0.145, 0.203, 0.284, 0.397, 0.556, 0.778, ] oqp.poes = [0.01, 0.10] oqp.realizations = 1 from django.contrib.gis import geos oqp.region = geos.Polygon(((-122.2, 38.0), (-121.7, 38.0), (-121.7, 37.5), (-122.2, 37.5), (-122.2, 38.0))) oqp.save() job = OqJob(oq_params=oqp, owner=upload.owner, job_type="classical") job.save() if create_job_path: job.path = os.path.join(upload.path, str(job.id)) os.mkdir(job.path) os.chmod(job.path, 0777) job.save() return job
def setup_classic_job(self, create_job_path=True, upload_id=None): """Create a classic job with associated upload and inputs. :param integer upload_id: if set use upload record with given db key. :param bool create_job_path: if set the path for the job will be created and captured in the job record :returns: a :py:class:`geonode.mtapi.models.OqJob` instance """ upload = self.setup_upload(upload_id) oqp = OqParams() oqp.job_type = "classical" oqp.upload = upload oqp.region_grid_spacing = 0.01 oqp.min_magnitude = 5.0 oqp.investigation_time = 50.0 oqp.component = "gmroti50" oqp.imt = "pga" oqp.truncation_type = "twosided" oqp.truncation_level = 3 oqp.reference_vs30_value = 760 oqp.imls = [ 0.005, 0.007, 0.0098, 0.0137, 0.0192, 0.0269, 0.0376, 0.0527, 0.0738, 0.103, 0.145, 0.203, 0.284, 0.397, 0.556, 0.778 ] oqp.poes = [0.01, 0.10] oqp.realizations = 1 from django.contrib.gis import geos oqp.region = geos.Polygon( ((-122.2, 38.0), (-121.7, 38.0), (-121.7, 37.5), (-122.2, 37.5), (-122.2, 38.0))) oqp.save() job = OqJob(oq_params=oqp, owner=upload.owner, job_type="classical") job.save() if create_job_path: job.path = os.path.join(upload.path, str(job.id)) os.mkdir(job.path) os.chmod(job.path, 0777) job.save() return job