Пример #1
0
    def update_pollutant_emissions(self, ds):
        """
        Update pollutant emissions based on GAINS data.
        :return:
        """

        # Update biosphere exchanges according to GAINS emission values
        for exc in ws.biosphere(
                ds,
                ws.either(
                    *[ws.contains("name", x) for x in self.emissions_map])):
            iam_emission_label = self.emissions_map[exc["name"]]

            try:
                iam_emission = self.iam_data.cement_emissions.loc[dict(
                    region=ds["location"],
                    pollutant=iam_emission_label)].values.item(0)
            except KeyError:
                # TODO: fix this.
                # GAINS does not have a 'World' region, hence we use Europe as a temporary fix
                iam_emission = self.iam_data.cement_emissions.loc[dict(
                    region=self.geo.iam_to_GAINS_region("World"),
                    pollutant=iam_emission_label)].values.item(0)

            if exc["amount"] == 0:
                wurst.rescale_exchange(exc,
                                       iam_emission / 1,
                                       remove_uncertainty=True)
            else:
                wurst.rescale_exchange(exc, iam_emission / exc["amount"])
        return ds
Пример #2
0
    def add_negative_CO2_flows_for_biomass_CCS(self):
        """
        Rescale the amount of all exchanges of carbon dioxide, non-fossil by a factor -9 (.9/-.1),
        to account for sequestered CO2.

        All CO2 capture and storage in the Carma datasets is assumed to be 90% efficient.
        Thus, we can simply find out what the new CO2 emission is and then we know how much gets stored in the ground.
        It's very important that we ONLY do this for biomass CCS plants, as only they will have negative emissions!

        Modifies in place (does not return anything).

        """
        for ds in ws.get_many(self.db, ws.contains('name', 'storage'), ws.equals('database', 'Carma CCS')):
            for exc in ws.biosphere(ds, ws.equals('name', 'Carbon dioxide, non-fossil')):
                wurst.rescale_exchange(exc, (0.9 / -0.1), remove_uncertainty=True)
Пример #3
0
def test_rescale_exchange():
    given = {
        "amount": 2,
        "foo": "bar",
        "minimum": 7,
        "uncertainty type": -1,
    }
    expected = {"amount": 1, "loc": 1, "foo": "bar", "uncertainty type": 0}
    assert rescale_exchange(given, 0.5) == expected
Пример #4
0
def test_rescale_exchange():
    given = {
        'amount': 2,
        'foo': 'bar',
        'minimum': 7,
        'uncertainty type': -1,
    }
    expected = {'amount': 1, 'loc': 1, 'foo': 'bar', 'uncertainty type': 0}
    assert rescale_exchange(given, 0.5) == expected
Пример #5
0
def test_rescale_exchange_wrong_inputs():
    with pytest.raises(AssertionError):
        rescale_exchange([], 4)
    with pytest.raises(AssertionError):
        rescale_exchange({}, "four")