예제 #1
0
    def setup(self, params):
        """concrete implementation it takes care of the needed parameters being
         initialized

        :param params: Parameters to pass to the post processor.
        :type params: dict
        """
        AbstractPostprocessor.setup(self, None)
        if self.impact_total is not None or self.minimum_needs is not None:
            self._raise_error('clear needs to be called before setup')

        try:
            evacuation_percentage = 1
            if 'function_params' in params.keys():
                function_params = params['function_params']
                if 'evacuation_percentage' in function_params.keys():
                    evacuation_percentage = function_params[
                        'evacuation_percentage'].value
                    evacuation_percentage /= 100.0  # make it decimal

            self.impact_total = int(
                round(params['impact_total'] * evacuation_percentage))
        except (ValueError, TypeError):
            self.impact_total = self.NO_DATA_TEXT
        self.minimum_needs = filter_needs_parameters(
            params['function_params']['minimum needs'])
예제 #2
0
 def __init__(self):
     """
     Constructor for AgePostprocessor postprocessor class,
     It takes care of defining self.impact_total
     """
     AbstractPostprocessor.__init__(self)
     self.impact_total = None
    def setup(self, params):
        """concrete implementation it takes care of the needed parameters being
         initialized

        :param params: dict of parameters to pass to the post processor
        """
        AbstractPostprocessor.setup(self, None)
        if (self.impact_total is not None or
                self.impact_attrs is not None or
                self.target_field is not None or
                self.valid_type_fields is not None or
                self.type_fields is not None):
            self._raise_error('clear needs to be called before setup')

        self.impact_total = params['impact_total']
        self.impact_attrs = params['impact_attrs']
        self.target_field = params['target_field']
        self.valid_type_fields = params['key_attribute']

        # find which attribute field has to be used
        self.type_fields = []
        try:
            for key in self.impact_attrs[0].iterkeys():
                if key.lower() in self.valid_type_fields:
                    self.type_fields.append(key)
        except IndexError:
            pass

        if len(self.type_fields) == 0:
            self.type_fields = None

        self.no_features = False
        # there are no features in this postprocessing polygon
        if self.impact_attrs == []:
            self.no_features = True
예제 #4
0
 def __init__(self):
     """
     Constructor for AgePostprocessor postprocessor class,
     It takes care of defining self.impact_total
     """
     AbstractPostprocessor.__init__(self)
     self.impact_total = None
    def __init__(self):
        """
        Constructor for postprocessor class,
        It takes care of defining self.impact_total
        """
        AbstractPostprocessor.__init__(self)

        # Integer with total number of features/meters affected.
        self.impact_total = None

        # List of features
        self.impact_attrs = None

        # Name the field in the impact layer for the result.
        self.target_field = None

        # The name of field in the exposure layer.
        self.valid_type_fields = None

        # The value mapping for the exposure layer.
        self.value_mapping = None

        # Bool to know if there are some features. We will be computed later.
        self.no_features = None

        # Find which attribute field has to be used
        self.type_fields = None

        # Dictionary key - display name for the mapping.
        self._labels = {}

        # The categories order.
        self._order = None
예제 #6
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

        """
        AbstractPostprocessor.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']
    def setup(self, params):
        """concrete implementation it takes care of the needed parameters being
         initialized

        :param params: Parameters to pass to the post processor.
        :type params: dict
        """
        AbstractPostprocessor.setup(self, None)
        if self.impact_total is not None or self.minimum_needs is not None:
            self._raise_error('clear needs to be called before setup')

        try:
            evacuation_percentage = 1
            if 'function_params' in params.keys():
                function_params = params['function_params']
                if 'evacuation_percentage' in function_params.keys():
                    evacuation_percentage = function_params[
                        'evacuation_percentage']
                    evacuation_percentage /= 100.0  # make it decimal

            self.impact_total = int(round(params['impact_total'] *
                                          evacuation_percentage))
        except (ValueError, TypeError):
            self.impact_total = self.NO_DATA_TEXT
        self.minimum_needs = params['function_params']['minimum needs']
 def clear(self):
     """Clear properly parameters.
     """
     AbstractPostprocessor.clear(self)
     self.impact_classes = None
     self.impact_attrs = None
     self.target_field = None
 def clear(self):
     """concrete implementation it takes care of the needed parameters being
      properly cleared
     """
     AbstractPostprocessor.clear(self)
     self.impact_total = None
     self.minimum_needs = None
예제 #10
0
    def __init__(self):
        """
        Constructor for postprocessor class,
        It takes care of defining self.impact_total
        """
        AbstractPostprocessor.__init__(self)
        self.impact_total = None
        self.impact_attrs = None
        self.target_field = None
        self.no_features = None
        self.type_fields = None
        self.valid_type_fields = None
        self.fields_values = OrderedDict([
            ('Medical', ['Clinic/Doctor', 'Hospital']),
            ('Schools', ['School', 'University/College', ]),
            ('Places of worship', ['Place of Worship - Unitarian',
                                   'Place of Worship - Islam',
                                   'Place of Worship - Buddhist',
                                   'Place of Worship']),
            ('Residential', ['Residential']),
            ('Government', ['Government']),
            ('Public Building', ['Public Building']),
            ('Fire Station', ['Fire Station']),
            ('Police Station', ['Police Station']),
            ('Supermarket', ['Supermarket']),
            ('Commercial', ['Commercial']),
            ('Industrial', ['Industrial']),
            ('Utility', ['Utility']),
            ('Sports Facility', ['Sports Facility']),
            ('Other', [])])

        self.known_types = []
        self._update_known_types()
예제 #11
0
    def __init__(self):
        """
        Constructor for postprocessor class,
        It takes care of defining self.impact_total
        """
        AbstractPostprocessor.__init__(self)
        self.impact_total = None
        self.impact_attrs = None
        self.target_field = None
        self.no_features = None
        self.type_fields = None
        self.valid_type_fields = None
        self.fields_values = OrderedDict([
            ('Medical', ['Clinic/Doctor', 'Hospital']),
            ('Schools', [
                'School',
                'University/College',
            ]),
            ('Places of worship', [
                'Place of Worship - Unitarian', 'Place of Worship - Islam',
                'Place of Worship - Buddhist', 'Place of Worship'
            ]), ('Residential', ['Residential']),
            ('Government', ['Government']),
            ('Public Building', ['Public Building']),
            ('Fire Station', ['Fire Station']),
            ('Police Station', ['Police Station']),
            ('Supermarket', ['Supermarket']), ('Commercial', ['Commercial']),
            ('Industrial', ['Industrial']), ('Utility', ['Utility']),
            ('Sports Facility', ['Sports Facility']), ('Other', [])
        ])

        self.known_types = []
        self._update_known_types()
    def __init__(self):
        """
        Constructor for postprocessor class,
        It takes care of defining self.impact_total
        """
        AbstractPostprocessor.__init__(self)

        # Integer with total number of features/meters affected.
        self.impact_total = None

        # List of features
        self.impact_attrs = None

        # Name the field in the impact layer for the result.
        self.target_field = None

        # The name of field in the exposure layer.
        self.valid_type_fields = None

        # The value mapping for the exposure layer.
        self.value_mapping = None

        # Bool to know if there are some features. We will be computed later.
        self.no_features = None

        # Find which attribute field has to be used
        self.type_fields = None

        # Dictionary key - display name for the mapping.
        self._labels = {}

        # The categories order.
        self._order = None
예제 #13
0
 def clear(self):
     """concrete implementation it takes care of the needed parameters being
      properly cleared
     """
     AbstractPostprocessor.clear(self)
     self.impact_total = None
     self.minimum_needs = None
예제 #14
0
    def setup(self, params):
        """concrete implementation it takes care of the needed parameters being
         initialized

        Args:
            params: dict of parameters to pass to the post processor
        Returns:
            None
        Raises:
            None
        """
        AbstractPostprocessor.setup(self, None)
        if (self.impact_total is not None or self.impact_attrs is not None
                or self.target_field is not None
                or self.type_field is not None):
            self._raise_error('clear needs to be called before setup')

        self.impact_total = params['impact_total']
        self.impact_attrs = params['impact_attrs']
        self.target_field = params['target_field']

        #find which attribute field has to be used
        try:
            for key in self.impact_attrs[0].iterkeys():
                if key in self.valid_type_fields:
                    self.type_field = key
                    break
        except IndexError:
            pass

        #there are no features in this postprocessing polygon
        if self.impact_attrs == []:
            self.noFeatures = True
        else:
            self.noFeatures = False
예제 #15
0
    def clear(self):
        """Clear the parameters.

        """
        AbstractPostprocessor.clear(self)
        self.impact_total = None
        self.female_ratio = None
 def __init__(self):
     """
     Constructor for postprocessor class,
     It takes care of defining self.impact_total
     """
     AbstractPostprocessor.__init__(self)
     self.impact_total = None
     self.impact_attrs = None
     self.target_field = None
     self.no_features = None
     self.fields_values = {
         'Medical': ['Clinic/Doctor', 'Hospital'],
         'Schools': ['School', 'University/College', ],
         'Places of worship': ['Place of Worship - Unitarian',
                               'Place of Worship - Islam',
                               'Place of Worship - Buddhist',
                               'Place of Worship'],
         'Residential': ['Residential'],
         'Government': ['Government'],
         'Public Building': ['Public Building'],
         'Fire Station': ['Fire Station'],
         'Police Station': ['Police Station'],
         'Supermarket': ['Supermarket'],
         'Commercial': ['Commercial'],
         'Industrial': ['Industrial'],
         'Utility': ['Utility'],
         'Sports Facility': ['Sports Facility'], }
     self.type_fields = None
     self.valid_type_fields = ['type']
예제 #17
0
    def clear(self):
        """Clear the parameters.

        """
        AbstractPostprocessor.clear(self)
        self.impact_total = None
        self.female_ratio = None
예제 #18
0
    def setup(self, params):
        """concrete implementation it takes care of the needed parameters being
         initialized

        :param params: dict of parameters to pass to the post processor
        """
        AbstractPostprocessor.setup(self, None)
        if (self.impact_total is not None or self.impact_attrs is not None
                or self.target_field is not None
                or self.valid_type_fields is not None
                or self.type_fields is not None):
            self._raise_error('clear needs to be called before setup')

        self.impact_total = params['impact_total']
        self.impact_attrs = params['impact_attrs']
        self.target_field = params['target_field']
        self.valid_type_fields = params['key_attribute']

        # find which attribute field has to be used
        self.type_fields = []
        try:
            for key in self.impact_attrs[0].iterkeys():
                if key.lower() in self.valid_type_fields:
                    self.type_fields.append(key)
        except IndexError:
            pass

        if len(self.type_fields) == 0:
            self.type_fields = None

        self.no_features = False
        # there are no features in this postprocessing polygon
        if self.impact_attrs == []:
            self.no_features = True
 def clear(self):
     """Clear properly parameters.
     """
     AbstractPostprocessor.clear(self)
     self.impact_classes = None
     self.impact_attrs = None
     self.target_field = None
예제 #20
0
    def setup(self, params):
        """concrete implementation it takes care of the needed parameters being
         initialized

        Args:
            params: dict of parameters to pass to the post processor
        Returns:
            None
        Raises:
            None
        """
        AbstractPostprocessor.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.elder_ratio = params['elder_ratio']
        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.elder_ratio = defaults['ELDER_RATIO']
예제 #21
0
 def __init__(self):
     """
     Constructor for MinimumNeedsPostprocessor postprocessor class,
     It takes care of defining self.impact_total
     """
     AbstractPostprocessor.__init__(self)
     self.impact_total = None
     self.minimum_needs = None
 def __init__(self):
     """
     Constructor for MinimumNeedsPostprocessor postprocessor class,
     It takes care of defining self.impact_total
     """
     AbstractPostprocessor.__init__(self)
     self.impact_total = None
     self.minimum_needs = None
 def __init__(self):
     """
     Constructor for postprocessor class,
     It takes care of defining self.impact_classes
     """
     AbstractPostprocessor.__init__(self)
     self.impact_classes = None
     self.impact_attrs = None
     self.target_field = None
예제 #24
0
 def clear(self):
     """concrete implementation that ensures needed parameters are cleared.
     """
     AbstractPostprocessor.clear(self)
     self.impact_total = None
     self.impact_attrs = None
     self.target_field = None
     self.type_fields = None
     self.valid_type_fields = None
예제 #25
0
 def clear(self):
     """concrete implementation that ensures needed parameters are cleared.
     """
     AbstractPostprocessor.clear(self)
     self.impact_total = None
     self.impact_attrs = None
     self.target_field = None
     self.type_fields = None
     self.valid_type_fields = None
 def __init__(self):
     """
     Constructor for MinimumNeedsPostprocessor postprocessor class,
     It takes care of defining self.impact_total
     """
     AbstractPostprocessor.__init__(self)
     self.impact_total = None
     self.minimum_needs = None
     self._description = tr('Aggregates minimum needs.')
 def __init__(self):
     """
     Constructor for postprocessor class,
     It takes care of defining self.impact_classes
     """
     AbstractPostprocessor.__init__(self)
     self.impact_classes = None
     self.impact_attrs = None
     self.target_field = None
예제 #28
0
    def __init__(self):
        """
        Constructor for AgePostprocessor postprocessor class.

        It takes care of defining self.impact_total
        """
        AbstractPostprocessor.__init__(self)
        self.youth_ratio = None
        self.adult_ratio = None
        self.elderly_ratio = None
        self.impact_total = None
예제 #29
0
    def __init__(self):
        """
        Constructor for AgePostprocessor postprocessor class.

        It takes care of defining self.impact_total
        """
        AbstractPostprocessor.__init__(self)
        self.youth_ratio = None
        self.adult_ratio = None
        self.elderly_ratio = None
        self.impact_total = None
예제 #30
0
    def setup(self, params):
        """Initialise parameters.

        """
        AbstractPostprocessor.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)
예제 #31
0
    def setup(self, params):
        """Initialise needed parameters.
        """
        AbstractPostprocessor.setup(self, None)
        if (self.impact_classes is not None or self.impact_attrs is not None
                or self.target_field is not None):
            self._raise_error('clear needs to be called before setup')

        self.impact_classes = params['impact_classes']
        self.impact_attrs = params['impact_attrs']
        self.target_field = params['target_field']
        self._log_message(self.impact_attrs)
 def process(self):
     """concrete implementation it takes care of the needed parameters being
      available and performs all the indicators calculations
     """
     AbstractPostprocessor.process(self)
     if self.impact_total is None or self.minimum_needs 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_needs()
예제 #33
0
 def process(self):
     """Performs all the indicators calculations.
     """
     AbstractPostprocessor.process(self)
     if (self.impact_classes is None or self.impact_attrs is None
             or self.target_field 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_categories()
예제 #34
0
    def setup(self, params):
        """Initialise parameters.

        """
        AbstractPostprocessor.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)
예제 #35
0
 def process(self):
     """concrete implementation it takes care of the needed parameters being
      available and performs all the indicators calculations
     """
     AbstractPostprocessor.process(self)
     if self.impact_total is None or self.minimum_needs 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_needs()
    def setup(self, params):
        """Initialise needed parameters.
        """
        AbstractPostprocessor.setup(self, None)
        if (self.impact_classes is not None or
            self.impact_attrs is not None or
            self.target_field is not None):
            self._raise_error('clear needs to be called before setup')

        self.impact_classes = params['impact_classes']
        self.impact_attrs = params['impact_attrs']
        self.target_field = params['target_field']
        self._log_message(self.impact_attrs)
예제 #37
0
    def setup(self, params):
        """concrete implementation it takes care of the needed parameters being
         initialized

        :param params: Parameters to pass to the post processor.
        :type params: dict
        """
        AbstractPostprocessor.setup(self, None)
        if self.impact_total is not None or self.minimum_needs is not None:
            self._raise_error('clear needs to be called before setup')

        self.impact_total = int(round(params['impact_total']))
        self.minimum_needs = params['function_params']['minimum needs']
예제 #38
0
    def clear(self):
        """concrete implementation it takes care of the needed parameters being
         properly cleared

        Args:
            None
        Returns:
            None
        Raises:
            None
        """
        AbstractPostprocessor.clear(self)
        self.impact_total = None
예제 #39
0
    def clear(self):
        """concrete implementation it takes care of the needed parameters being
         properly cleared

        Args:
            None
        Returns:
            None
        Raises:
            None
        """
        AbstractPostprocessor.clear(self)
        self.impact_total = None
예제 #40
0
 def process(self):
     """Performs all the indicator calculations.
     """
     AbstractPostprocessor.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()
예제 #41
0
 def __init__(self):
     """
     Constructor for postprocessor class,
     It takes care of defining self.impact_total
     """
     AbstractPostprocessor.__init__(self)
     self.impact_total = None
     self.impact_attrs = None
     self.target_field = None
     self.type_fields = None
     self.valid_type_fields = ['AMENITY', 'TYPE']
     self.fields_values = {'Hospitals': ['medical', 'clinic', 'hospital'],
                   'Places of worship': ['place_of_worship'],
                   'Schools': ['school']}
 def process(self):
     """Performs all the indicators calculations.
     """
     AbstractPostprocessor.process(self)
     if (self.impact_classes is None or
         self.impact_attrs is None or
         self.target_field 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_categories()
 def __init__(self):
     """
     Constructor for postprocessor class,
     It takes care of defining self.impact_total
     """
     AbstractPostprocessor.__init__(self)
     self.impact_total = None
     self.impact_attrs = None
     self.target_field = None
     self.type_field = None
     self.valid_type_fields = ['amenity', 'type']
     self.types = {'Hospitals': ['medical', 'clinic', 'hospital'],
                   'Places of worship': ['place_of_worship'],
                   'Schools': ['school']}
    def process(self):
        """Concrete implementation that performs all indicators calculations.
        """
        AbstractPostprocessor.process(self)

        if (self.impact_total is None or self.impact_attrs is None
                or self.value_mapping is None or self.target_field 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:
            for title in self.value_mapping:
                self._calculate_type(title)
            self.translate_results()
예제 #45
0
    def process(self):
        """Setup parameters parameters and performs all the calculations.

        """
        AbstractPostprocessor.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()
예제 #46
0
 def process(self):
     """Performs all the indicator calculations.
     """
     AbstractPostprocessor.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()
예제 #47
0
    def process(self):
        """Concrete implementation that performs all indicators calculations.
        """
        AbstractPostprocessor.process(self)

        if (self.impact_total is None or self.impact_attrs is None
                or self.target_field 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()
            for title, field_values in self.fields_values.iteritems():
                self._calculate_type(title, field_values)
    def clear(self):
        """concrete implementation it takes care of the needed parameters being
         properly cleared

        Args:
            None
        Returns:
            None
        Raises:
            None
        """
        AbstractPostprocessor.clear(self)
        self.impact_classes = None
        self.impact_attrs = None
        self.target_field = None
    def clear(self):
        """concrete implementation it takes care of the needed parameters being
         properly cleared

        Args:
            None
        Returns:
            None
        Raises:
            None
        """
        AbstractPostprocessor.clear(self)
        self.impact_classes = None
        self.impact_attrs = None
        self.target_field = None
    def process(self):
        """Concrete implementation that performs all indicators calculations.
        """
        AbstractPostprocessor.process(self)

        if self.impact_total is None or self.impact_attrs is None or self.target_field 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()
            for title, field_values in self.fields_values.iteritems():
                self._calculate_type(title, field_values)
예제 #51
0
    def process(self):
        """Setup parameters parameters and performs all the calculations.

        """
        AbstractPostprocessor.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()
예제 #52
0
    def process(self):
        """concrete implementation it takes care of the needed parameters being
         available and performs all the indicators calculations

        Args:
            None
        Returns:
            None
        Raises:
            None
        """
        AbstractPostprocessor.process(self)
        if self.impact_total is None:
            self._raise_error('setup needs to be called before process')
        self._calculate_total()
예제 #53
0
    def setup(self, params):
        """concrete implementation it takes care of the needed parameters being
         initialized

        Args:
            params: Dict of parameters to pass to the post processor
        Returns:
            None
        Raises:
            None
        """
        AbstractPostprocessor.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']
예제 #54
0
    def setup(self, params):
        """concrete implementation it takes care of the needed parameters being
         initialized

        Args:
            params: Dict of parameters to pass to the post processor
        Returns:
            None
        Raises:
            None
        """
        AbstractPostprocessor.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']
    def process(self):
        """Concrete implementation that performs all indicators calculations.
        """
        AbstractPostprocessor.process(self)

        if (self.impact_total is None or
                self.impact_attrs is None or
                self.value_mapping is None or
                self.target_field 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:
            for title in self.value_mapping:
                self._calculate_type(title)
            self.translate_results()
예제 #56
0
    def process(self):
        """concrete implementation it takes care of the needed parameters being
         available and performs all the indicators calculations

        Args:
            None
        Returns:
            None
        Raises:
            None
        """
        AbstractPostprocessor.process(self)
        if self.population_total is None or self.female_ratio is None:
            self._raise_error('setup needs to be called before process')
        self._calculate_total()
        self._calculate_females()
        self._calculate_weekly_hygene_packs()
        self._calculate_weekly_increased_calories()