Exemplo n.º 1
0
    def clear(self):
        """Clear the parameters.

        """
        AbstractPopulationPostprocessor.clear(self)
        self.impact_total = None
        self.female_ratio = None
Exemplo n.º 2
0
    def clear(self):
        """Clear the parameters.

        """
        AbstractPopulationPostprocessor.clear(self)
        self.impact_total = None
        self.female_ratio = None
Exemplo n.º 3
0
    def setup(self, params):
        """Concrete implementation to ensure needed parameters are initialized.

        :param params: Dict of parameters to pass to the post processor.
        :type params: dict

        """
        AbstractPopulationPostprocessor.setup(self, None)
        if self.impact_total is not None:
            self._raise_error('clear needs to be called before setup')

        self.impact_total = params['impact_total']
        try:
            # either all 3 ratio are custom set or we use defaults
            self.youth_ratio = params['youth_ratio']
            self.adult_ratio = params['adult_ratio']
            self.elderly_ratio = params['elderly_ratio']

            ratios_total = (self.youth_ratio + self.adult_ratio +
                            self.elderly_ratio)
            if ratios_total > 1:
                self._raise_error('Age ratios should sum up to 1. Found: '
                                  '%s + %s + %s = %s ' %
                                  (self.youth_ratio, self.adult_ratio,
                                   self.elderly_ratio, ratios_total))
        except KeyError:
            self._log_message('either all 3 age ratio are custom set or we'
                              ' use defaults')
            defaults = get_defaults()
            self.youth_ratio = defaults['YOUTH_RATIO']
            self.adult_ratio = defaults['ADULT_RATIO']
            self.elderly_ratio = defaults['ELDERLY_RATIO']
Exemplo n.º 4
0
    def setup(self, params):
        """Initialise parameters.

        """
        AbstractPopulationPostprocessor.setup(self, None)
        if self.impact_total is not None or self.female_ratio is not None:
            self._raise_error('clear needs to be called before setup')
        self.impact_total = params['impact_total']
        self.female_ratio = params['female_ratio']
        if self.female_ratio > 1:
            self._raise_error('Female ratio should be lower max 1. Found: '
                              '%s ' % self.female_ratio)
    def __init__(self):
        """
        Constructor for AgePostprocessor postprocessor class.

        It takes care of defining self.impact_total
        """
        AbstractPopulationPostprocessor.__init__(self)
        self.youth_ratio = None
        self.adult_ratio = None
        self.elderly_ratio = None
        self.impact_total = None
        self._description = tr('Calculates age related statistics.')
Exemplo n.º 6
0
    def __init__(self):
        """
        Constructor for AgePostprocessor postprocessor class.

        It takes care of defining self.impact_total
        """
        AbstractPopulationPostprocessor.__init__(self)
        self.youth_ratio = None
        self.adult_ratio = None
        self.elderly_ratio = None
        self.impact_total = None
        self._description = tr('Calculates age related statistics.')
Exemplo n.º 7
0
    def setup(self, params):
        """Initialise parameters.

        """
        AbstractPopulationPostprocessor.setup(self, None)
        if self.impact_total is not None or self.female_ratio is not None:
            self._raise_error('clear needs to be called before setup')
        self.impact_total = params['impact_total']
        self.female_ratio = params['female_ratio']
        if self.female_ratio > 1:
            self._raise_error(
                'Female ratio should be lower max 1. Found: '
                '%s ' % self.female_ratio)
Exemplo n.º 8
0
 def process(self):
     """Performs all the indicator calculations.
     """
     AbstractPopulationPostprocessor.process(self)
     if self.impact_total is None:
         self._log_message('%s not all params have been correctly '
                           'initialized, setup needs to be called before '
                           'process. Skipping this postprocessor' %
                           self.__class__.__name__)
     else:
         self._calculate_total()
         self._calculate_youth()
         self._calculate_adult()
         self._calculate_elderly()
Exemplo n.º 9
0
    def process(self):
        """Setup parameters parameters and performs all the calculations.

        """
        AbstractPopulationPostprocessor.process(self)
        if self.impact_total is None or self.female_ratio is None:
            self._log_message('%s not all params have been correctly '
                              'initialized, setup needs to be called before '
                              'process. Skipping this postprocessor' %
                              self.__class__.__name__)
        else:
            self._calculate_total()
            self._calculate_females()
            self._calculate_weekly_hygene_packs()
            self._calculate_weekly_increased_calories()
Exemplo n.º 10
0
 def process(self):
     """Performs all the indicator calculations.
     """
     AbstractPopulationPostprocessor.process(self)
     if self.impact_total is None:
         self._log_message(
             '%s not all params have been correctly '
             'initialized, setup needs to be called before '
             'process. Skipping this postprocessor'
             % self.__class__.__name__)
     else:
         self._calculate_total()
         self._calculate_youth()
         self._calculate_adult()
         self._calculate_elderly()
Exemplo n.º 11
0
    def process(self):
        """Setup parameters parameters and performs all the calculations.

        """
        AbstractPopulationPostprocessor.process(self)
        if self.impact_total is None or self.female_ratio is None:
            self._log_message(
                '%s not all params have been correctly '
                'initialized, setup needs to be called before '
                'process. Skipping this postprocessor'
                % self.__class__.__name__)
        else:
            self._calculate_total()
            self._calculate_females()
            self._calculate_weekly_hygene_packs()
            self._calculate_weekly_increased_calories()
Exemplo n.º 12
0
    def setup(self, params):
        """Concrete implementation to ensure needed parameters are initialized.

        :param params: Dict of parameters to pass to the post processor.
        :type params: dict

        """
        AbstractPopulationPostprocessor.setup(self, None)
        if self.impact_total is not None:
            self._raise_error('clear needs to be called before setup')

        self.impact_total = params['impact_total']
        try:
            # either all 3 ratio are custom set or we use defaults
            self.youth_ratio = params['youth_ratio']
            self.adult_ratio = params['adult_ratio']
            self.elderly_ratio = params['elderly_ratio']

            ratios_total = (self.youth_ratio +
                            self.adult_ratio +
                            self.elderly_ratio)
            if ratios_total > 1:
                self._raise_error(
                    'Age ratios should sum up to 1. Found: '
                    '%s + %s + %s = %s ' % (
                        self.youth_ratio,
                        self.adult_ratio,
                        self.elderly_ratio,
                        ratios_total))
        except KeyError:
            self._log_message('either all 3 age ratio are custom set or we'
                              ' use defaults')
            defaults = get_defaults()
            self.youth_ratio = defaults['YOUTH_RATIO']
            self.adult_ratio = defaults['ADULT_RATIO']
            self.elderly_ratio = defaults['ELDERLY_RATIO']
Exemplo n.º 13
0
 def __init__(self):
     AbstractPopulationPostprocessor.__init__(self)
     self.impact_total = None
     self.female_ratio = None
     self._description = tr('Calculates gender related statistics.')
Exemplo n.º 14
0
 def clear(self):
     """Clear postprocessor state.
     """
     AbstractPopulationPostprocessor.clear(self)
     self.impact_total = None
Exemplo n.º 15
0
 def __init__(self):
     AbstractPopulationPostprocessor.__init__(self)
     self.impact_total = None
     self.female_ratio = None
     self._description = tr('Calculates gender related statistics.')
Exemplo n.º 16
0
 def clear(self):
     """Clear postprocessor state.
     """
     AbstractPopulationPostprocessor.clear(self)
     self.impact_total = None