def write_uh_spectra(job_ctxt): """Write the top-level Uniform Hazard Spectra calculation results records to the database. In the workflow of the UHS calculator, this should be written prior to the execution of the main job. (See :method:`openquake.calculators.base.Calculator.pre_execute`.) This function writes: * 1 record to uiapi.output * 1 record to hzrdr.uh_spectra * 1 record to hzrdr.uh_spectrum, per PoE defined in the calculation config :param job_ctxt: :class:`openquake.engine.JobContext` instance for the current UHS job. """ oq_job_profile = job_ctxt.oq_job_profile oq_job = job_ctxt.oq_job output = Output( owner=oq_job.owner, oq_job=oq_job, display_name="UH Spectra for calculation id %s" % oq_job.id, db_backed=True, output_type="uh_spectra", ) output.save() uh_spectra = UhSpectra( output=output, timespan=oq_job_profile.investigation_time, realizations=oq_job_profile.realizations, periods=oq_job_profile.uhs_periods, ) uh_spectra.save() for poe in oq_job_profile.poes: uh_spectrum = UhSpectrum(uh_spectra=uh_spectra, poe=poe) uh_spectrum.save()
def write_uh_spectra(job_ctxt): """Write the top-level Uniform Hazard Spectra calculation results records to the database. In the workflow of the UHS calculator, this should be written prior to the execution of the main job. (See :method:`openquake.calculators.base.Calculator.pre_execute`.) This function writes: * 1 record to uiapi.output * 1 record to hzrdr.uh_spectra * 1 record to hzrdr.uh_spectrum, per PoE defined in the calculation config :param job_ctxt: :class:`openquake.engine.JobContext` instance for the current UHS job. """ oq_job_profile = job_ctxt.oq_job_profile oq_job = job_ctxt.oq_job output = Output( owner=oq_job.owner, oq_job=oq_job, display_name='UH Spectra for calculation id %s' % oq_job.id, db_backed=True, output_type='uh_spectra') output.save() uh_spectra = UhSpectra( output=output, timespan=oq_job_profile.investigation_time, realizations=oq_job_profile.realizations, periods=oq_job_profile.uhs_periods) uh_spectra.save() for poe in oq_job_profile.poes: uh_spectrum = UhSpectrum(uh_spectra=uh_spectra, poe=poe) uh_spectrum.save()
def pre_execute(self): """ Perform the following pre-execution tasks: * store the exposure model specified in the configuration file into database * store the fragility model specified in the configuration file into database * split the interested sites into blocks for later processing * write the initial database container records for calculation results """ self.store_exposure_assets() self.store_fragility_model() self.partition() oq_job = self.job_ctxt.oq_job fm = _fm(oq_job) output = Output(owner=oq_job.owner, oq_job=oq_job, display_name="SDA (damage distributions per asset) " "results for calculation id %s" % oq_job.id, db_backed=True, output_type="dmg_dist_per_asset") output.save() DmgDistPerAsset(output=output, dmg_states=_damage_states(fm.lss)).save() output = Output(owner=oq_job.owner, oq_job=oq_job, display_name="SDA (damage distributions per taxonomy) " "results for calculation id %s" % oq_job.id, db_backed=True, output_type="dmg_dist_per_taxonomy") output.save() DmgDistPerTaxonomy(output=output, dmg_states=_damage_states(fm.lss)).save() output = Output(owner=oq_job.owner, oq_job=oq_job, display_name="SDA (total damage distributions) " "results for calculation id %s" % oq_job.id, db_backed=True, output_type="dmg_dist_total") output.save() DmgDistTotal(output=output, dmg_states=_damage_states(fm.lss)).save() output = Output(owner=oq_job.owner, oq_job=oq_job, display_name="SDA (collapse map) " "results for calculation id %s" % oq_job.id, db_backed=True, output_type="collapse_map") output.save() [ism] = inputs4job(oq_job.id, input_type="exposure") [em] = ExposureModel.objects.filter(input=ism, owner=oq_job.owner) CollapseMap(output=output, exposure_model=em).save()
def pre_execute(self): """ Perform the following pre-execution tasks: * store the exposure model specified in the configuration file into database * store the fragility model specified in the configuration file into database * split the interested sites into blocks for later processing * write the initial database container records for calculation results """ self.store_exposure_assets() self.store_fragility_model() self.partition() oq_job = self.job_ctxt.oq_job fm = _fm(oq_job) damage_states = scenario_damage.damage_states(fm) output = Output( owner=oq_job.owner, oq_job=oq_job, display_name="SDA (damage distributions per asset) " "results for calculation id %s" % oq_job.id, db_backed=True, output_type="dmg_dist_per_asset") output.save() DmgDistPerAsset( output=output, dmg_states=damage_states).save() output = Output( owner=oq_job.owner, oq_job=oq_job, display_name="SDA (damage distributions per taxonomy) " "results for calculation id %s" % oq_job.id, db_backed=True, output_type="dmg_dist_per_taxonomy") output.save() DmgDistPerTaxonomy( output=output, dmg_states=damage_states).save() output = Output( owner=oq_job.owner, oq_job=oq_job, display_name="SDA (total damage distributions) " "results for calculation id %s" % oq_job.id, db_backed=True, output_type="dmg_dist_total") output.save() DmgDistTotal( output=output, dmg_states=damage_states).save() output = Output( owner=oq_job.owner, oq_job=oq_job, display_name="SDA (collapse map) " "results for calculation id %s" % oq_job.id, db_backed=True, output_type="collapse_map") output.save() [ism] = inputs4job(oq_job.id, input_type="exposure") [em] = ExposureModel.objects.filter(input=ism, owner=oq_job.owner) CollapseMap( output=output, exposure_model=em).save()
def pre_execute(self): """ Perform the following pre-execution tasks: * store the exposure model specified in the configuration file into database * store the fragility model specified in the configuration file into database * split the interested sites into blocks for later processing * write the initial database container records for calculation results """ self.store_exposure_assets() self.store_fragility_model() self.partition() oq_job = self.job_ctxt.oq_job fm = _fm(oq_job) output = Output( owner=oq_job.owner, oq_job=oq_job, display_name="SDA (damage distributions per asset) " "results for calculation id %s" % oq_job.id, db_backed=True, output_type="dmg_dist_per_asset") output.save() DmgDistPerAsset( output=output, dmg_states=_damage_states(fm.lss)).save() output = Output( owner=oq_job.owner, oq_job=oq_job, display_name="SDA (damage distributions per taxonomy) " "results for calculation id %s" % oq_job.id, db_backed=True, output_type="dmg_dist_per_taxonomy") output.save() DmgDistPerTaxonomy( output=output, dmg_states=_damage_states(fm.lss)).save() output = Output( owner=oq_job.owner, oq_job=oq_job, display_name="SDA (total damage distributions) " "results for calculation id %s" % oq_job.id, db_backed=True, output_type="dmg_dist_total") output.save() DmgDistTotal( output=output, dmg_states=_damage_states(fm.lss)).save()