Esempio n. 1
0
 def test_invalid_fccs_and_covertype_ids(self):
     # fccs id 1 isn't in ou
     with raises(ValueError) as e_info:
         Fccs2Ef("1", True)
     with raises(ValueError) as e_info:
         Fccs2Ef("1", False)
     with raises(ValueError) as e_info:
         CoverType2Ef("2", True)
     with raises(ValueError) as e_info:
         CoverType2Ef("2", False)
Esempio n. 2
0
    def setup(self):
        fccs2covertype.FCCS_2_COVERTYPE = FCCS_2_COVERTYPE
        efgroup2ef.EF_GROUP_2_EF = EF_GROUP_2_EF
        covertype2efgroup.COVERTYPE_2_EF_GROUP = COVERTYPE_2_EF_GROUP
        catphase2efgroup.CAT_PHASE_2_EF_GROUP = CAT_PHASE_2_EF_GROUP

        self.lookups = {
            "fccs2ef_213_rx": Fccs2Ef('213', True),
            "fccs2ef_213_wf": Fccs2Ef('213', False),
            "ct2ef_1_rx": CoverType2Ef('1', True),
            "ct2ef_10_wf": CoverType2Ef('10', False)
        }
Esempio n. 3
0
    def _run_on_fire(self, fire):
        if 'activity' not in fire:
            raise ValueError(
                "Missing activity data required for computing emissions")

        for aa in fire.active_areas:
            for loc in aa.locations:
                if 'fuelbeds' not in loc:
                    raise ValueError(
                        "Missing fuelbed data required for computing emissions"
                    )
                for fb in loc['fuelbeds']:
                    if 'consumption' not in fb:
                        raise ValueError(
                            "Missing consumption data required for computing emissions"
                        )
                    if 'fccs_id' not in fb:
                        raise ValueError(
                            "Missing FCCS Id required for computing emissions")
                    fccs2ef = Fccs2Ef(fb["fccs_id"],
                                      is_rx=(fire["type"] == "rx"))
                    calculator = EmissionsCalculator(fccs2ef,
                                                     species=self.species)
                    _calculate(calculator, fb, self.include_emissions_details)
                    # Convert from lbs to tons
                    # TODO: Update EFs to be tons/ton in a) eflookup package,
                    #   b) just after instantiating look-up objects, above,
                    #   or c) just before calling EmissionsCalculator, above
                    datautils.multiply_nested_data(fb['emissions'],
                                                   self.CONVERSION_FACTOR)
                    if self.include_emissions_details:
                        datautils.multiply_nested_data(fb['emissions_details'],
                                                       self.CONVERSION_FACTOR)