def build_rupture_from_file(rupture_file, trt="Active Shallow Crust"): """ Reads an OpenQuake Rupture Model file and parses it to an instance of :calass: openquake.hazardlib.source.rupture.Rupture """ parser = RuptureModelParser(rupture_file) rupture = parser.parse() surface = build_planar_surface(rupture.geometry) hypocentre = Point(rupture.hypocenter[0], rupture.hypocenter[1], rupture.hypocenter[2]) return Rupture(rupture.magnitude, rupture.rake, trt, hypocentre, surface, SimpleFaultSource)
def initialize_sources(self): """ Get the rupture_model file from the job.ini file, and store a parsed version of it in the database (see :class:`openquake.engine.db.models.ParsedRupture``) in pickle format. """ # Get the rupture model in input [inp] = models.inputs4hcalc(self.hc.id, input_type='rupture_model') # Associate the source input to the calculation: models.Input2hcalc.objects.get_or_create( input=inp, hazard_calculation=self.hc) # Store the ParsedRupture record src_content = StringIO(inp.model_content.raw_content) rupt_parser = RuptureModelParser(src_content) src_db_writer = source.RuptureDBWriter(inp, rupt_parser.parse()) src_db_writer.serialize()
def initialize_sources(self): """ Get the rupture_model file from the job.ini file, and store a parsed version of it in the database (see :class:`openquake.engine.db.models.ParsedRupture``) in pickle format. """ # Get the rupture model in input src_db_writer = source.RuptureDBWriter( self.job, RuptureModelParser( self.hc.inputs['rupture_model']).parse()) src_db_writer.serialize()