Пример #1
0
    def _store_con_fmodel(self):
        [ism] = models.inputs4job(self.job.id, input_type="fragility")

        fmodel = models.FragilityModel(
            owner=ism.owner, input=ism,
            lss=["LS1", "LS2"], format="continuous")

        fmodel.save()

        models.Ffc(
            fragility_model=fmodel, taxonomy="RC",
            ls="LS2", mean="0.35", stddev="0.10", lsi=2).save()

        models.Ffc(
            fragility_model=fmodel, taxonomy="RC",
            ls="LS1", mean="0.20", stddev="0.05", lsi=1).save()

        models.Ffc(
            fragility_model=fmodel, taxonomy="RM",
            ls="LS2", mean="0.40", stddev="0.12", lsi=2).save()

        models.Ffc(
            fragility_model=fmodel, taxonomy="RM",
            ls="LS1", mean="0.25", stddev="0.08", lsi=1).save()

        return fmodel
Пример #2
0
    def _store_dsc_fmodel(self):
        [ism] = models.inputs4job(self.job.id, input_type="fragility")

        fmodel = models.FragilityModel(
            owner=ism.owner, input=ism, imls=[0.1, 0.3, 0.5, 0.7],
            imt="mmi", lss=["LS1", "LS2"], format="discrete",
            no_damage_limit=0.05)

        fmodel.save()

        models.Ffd(
            fragility_model=fmodel, taxonomy="RC",
            ls="LS2", poes=[0.00, 0.05, 0.20, 0.50], lsi=2).save()

        models.Ffd(
            fragility_model=fmodel, taxonomy="RC",
            ls="LS1", poes=[0.05, 0.20, 0.50, 1.00], lsi=1).save()

        models.Ffd(
            fragility_model=fmodel, taxonomy="RM",
            ls="LS2", poes=[0.02, 0.07, 0.25, 0.60], lsi=2).save()

        models.Ffd(
            fragility_model=fmodel, taxonomy="RM",
            ls="LS1", poes=[0.03, 0.12, 0.42, 0.90], lsi=1).save()

        return fmodel
Пример #3
0
    def test_dda_iml_below_range_damage_limit_defined(self):
        # corner case where we have a ground motion value
        # (that corresponds to the intensity measure level in the
        # fragility function) that is lower than the lowest
        # intensity measure level defined in the model (in this
        # particular case 0.1) and lower than the no_damage_limit
        # attribute defined in the model. Given this condition, the
        # fractions of buildings is 100% no_damage and 0% for the
        # remaining limit states defined in the model.

        [ism] = models.inputs4job(self.job.id, input_type="fragility")

        fmodel = models.FragilityModel(
            owner=ism.owner, input=ism, imls=[0.1, 0.3, 0.5, 0.7],
            imt="mmi", lss=["LS1"], format="discrete", no_damage_limit=0.05)

        fmodel.save()

        func = models.Ffd(
            fragility_model=fmodel, taxonomy="RC",
            ls="LS1", poes=[0.05, 0.20, 0.50, 1.00], lsi=1)

        func.save()

        self._close_to([1.0, 0.0],
            compute_gmv_fractions([func], 0.02))
Пример #4
0
    def test_dda_iml_above_range(self):
        # corner case where we have a ground motion value
        # (that corresponds to the intensity measure level in the
        # fragility function) that is higher than the highest
        # intensity measure level defined in the model (in this
        # particular case 0.7). Given this condition, to compute
        # the fractions of buildings we use the highest intensity
        # measure level defined in the model (0.7 in this case)

        [ism] = models.inputs4job(self.job.id, input_type="fragility")

        fmodel = models.FragilityModel(
            owner=ism.owner, input=ism, imls=[0.1, 0.3, 0.5, 0.7],
            imt="mmi", lss=["LS1"], format="discrete")

        fmodel.save()

        func = models.Ffd(
            fragility_model=fmodel, taxonomy="RC",
            ls="LS1", poes=[0.05, 0.20, 0.50, 1.00], lsi=1)

        func.save()

        self._close_to(compute_gmv_fractions([func], 0.7),
                compute_gmv_fractions([func], 0.8))
Пример #5
0
 def setUp(self):
     fmdl_input = models.Input(input_type="fragility",
                               size=123,
                               path="/tmp/fake-fragility-path",
                               owner=self.job.owner)
     fmdl_input.save()
     i2j = models.Input2job(input=fmdl_input, oq_job=self.job)
     i2j.save()
     self.mdl = models.FragilityModel(input=fmdl_input,
                                      owner=self.job.owner,
                                      format="discrete",
                                      lss="a b c".split(),
                                      imls=[0.2, 0.3],
                                      imt="mmi")
     self.mdl.save()
     self.continuous_mdl = models.FragilityModel(input=fmdl_input,
                                                 owner=self.job.owner,
                                                 format="continuous",
                                                 lss="d e f".split())
     self.continuous_mdl.save()
Пример #6
0
 def setUp(self):
     fmdl_input = models.Input(input_type="fragility",
                               size=123,
                               path="/tmp/fake-fragility-path",
                               owner=self.job.owner)
     fmdl_input.save()
     i2j = models.Input2job(input=fmdl_input, oq_job=self.job)
     i2j.save()
     self.mdl = models.FragilityModel(input=fmdl_input,
                                      owner=self.job.owner,
                                      format="continuous")
Пример #7
0
    def insert_datum(self, ff):
        """
        Insert a single fragility function (either discrete or continuous).

        :param ff: fragility function
        :type ff: one of :class:`openquake.parser.fragility.FFC` or
            :class:`openquake.parser.fragility.FFD`

        It also inserts the fragility model entry if not already present.
        """
        if not self.model:
            fragm = self.parser.model
            self.model = models.FragilityModel(
                owner=self.owner,
                input=self.smi,
                lss=fragm.limits,
                format=fragm.format,
                iml_unit=fragm.iml_unit,
                max_iml=fragm.max_iml,
                min_iml=fragm.min_iml,
                no_damage_limit=fragm.no_damage_limit)
            for key, tag in self.model_attrs:
                value = getattr(fragm, tag)
                if value:
                    if tag == "imt":
                        value = value.lower()
                    setattr(self.model, key, value)
            self.model.save()
            self.lsi = dict(zip(self.model.lss, itertools.count(1)))

        discrete = self.model.format == "discrete"
        ctor = models.Ffd if discrete else models.Ffc
        data = ctor(fragility_model=self.model,
                    taxonomy=ff.taxonomy,
                    ls=ff.limit,
                    lsi=self.lsi[ff.limit])
        if discrete:
            data.poes = ff.poes
        else:
            if ff.type:
                data.ftype = ff.type
            data.mean = ff.mean
            data.stddev = ff.stddev
        data.save()