def _boundary_coverage(self, target: IDataProviderTarget) -> IDataProviderTarget: """ Test on boundary coverage: Option 1: minimal coverage threshold For S1+S2 targets: coverage% must be at or above 95%, for S3 targets coverage must be above 67% Option 2: weighted coverage Thresholds are still 95% and 67%, target is always valid. Below threshold ambition is scaled.* New target ambition = input target ambition * coverage *either here or in tem score module Option 3: default coverage Target is always valid, % uncovered is given default score in temperature score module. :param target: The input target :return: The original target with a weighted reduction ambition, if so required """ if target.scope == EScope.S1S2: if target.coverage_s1 < 0.95: target.reduction_ambition = target.reduction_ambition * target.coverage_s1 elif target.scope == EScope.S3: if target.coverage_s3 < 0.67: target.reduction_ambition = target.reduction_ambition * target.coverage_s3 return target
def _combine_s1_s2(self, target: IDataProviderTarget): """ Check if there is an S2 target that matches this target exactly (if this is a S1 target) and combine them into one target. :param target: The input target :return: The combined target (or the original if no combining was required) """ if target.scope == EScope.S1 and not pd.isnull( target.base_year_ghg_s1): matches = [ t for t in self.s2_targets if t.company_id == target.company_id and t.base_year == target. base_year and t.start_year == target.start_year and t.end_year == target.end_year and t.target_type == target.target_type and t.intensity_metric == target.intensity_metric ] if len(matches) > 0: matches.sort(key=lambda t: t.coverage_s2, reverse=True) s2 = matches[0] combined_coverage = (target.coverage_s1 * target.base_year_ghg_s1 + s2.coverage_s2 * s2.base_year_ghg_s2) / \ (target.base_year_ghg_s1 + s2.base_year_ghg_s2) target.reduction_ambition = target.reduction_ambition * target.coverage_s1 * target.base_year_ghg_s1 + \ s2.reduction_ambition * s2.coverage_s1 * s2.base_year_ghg_s2 / \ (target.base_year_ghg_s1 + s2.base_year_ghg_s1) / combined_coverage target.coverage_s1 = combined_coverage target.coverage_s2 = combined_coverage # We don't need to delete the S2 target as it'll be definition have a lower coverage than the combined # target, therefore it won't be picked for our 9-box grid return target