tfse-model-api-v0.2/Esg/scripts/environmental.py

373 lines
11 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import operator
def environmental_rating(param):
"""
环境部分打分
Parameters:
param dict 填报问卷
Returns:
score float 环境部分得分
"""
result = dict()
result['单位收入二氧化碳排放'] = calculation_01(param)
result['单位收入的能耗'] = calculation_02(param)
result['单位收入的耗水'] = calculation_03(param)
result['绿色业务收入占比(%'] = calculation_04(param)
result['公司是否有温室气体减排目标'] = calculation_05(param)
result['企业是否有节能目标'] = calculation_06(param)
result['企业是否有节约用水目标'] = calculation_07(param)
result['是否有绿色业务'] = calculation_08(param)
result['近三年是否被环境或水务等监管部门处罚'] = calculation_09(param)
result['国家双碳目标对企业业务是否有不利影响'] = calculation_10(param)
result['国家双碳目标对企业业务是否有有利影响'] = calculation_11(param)
result['企业是否使用风电、光电、水电等清洁能源,是否使用清洁交通工具'] = calculation_02(param)
fraction = list()
if result['近三年是否被环境或水务等监管部门处罚'] == 'E=0':
score = 0
else:
for key, value in result.items():
if key == '近三年是否被环境或水务等监管部门处罚':
continue
else:
fraction.append(value)
score = sum(fraction)
result['合计'] = score
return result
def calculation_01(param):
"""
单位收入二氧化碳排放
Parameters:
param dict 环境问卷
Returns:
score int 得分
"""
# Parameter
three_year_data = sorted(param['环境问卷']['近三年公司数据'], key=operator.itemgetter('年份'), reverse=False)
def calculation_co2(data):
"""
计算每年碳排放
Parameters:
data dict 当前年公司能耗数据
Returns:
result float 当年碳排放量
"""
total = list()
total.append(round(data['公司当年消耗的原煤(千克)'] * 1.9003, 2))
total.append(round(data['公司当年消耗的焦炭(千克)'] * 2.8604, 2))
total.append(round(data['公司当年消耗的原油(升)'] * 0.86 * 3.0202, 2))
total.append(round(data['公司当年消耗的燃料油(升)'] * 0.86 * 3.1705, 2))
total.append(round(data['公司当年消耗的汽油(升)'] * 0.73 * 2.9251, 2))
total.append(round(data['公司当年消耗的煤油(升)'] * 0.82 * 3.0179, 2))
total.append(round(data['公司当年消耗的柴油(升)'] * 0.85 * 3.0959, 2))
total.append(round(data['公司当年消耗的液化石油气(千克)'] * 3.1013, 2))
total.append(round(data['公司当年消耗的天然气(立方米)'] * 2.1622, 2))
total.append(round(data['公司当年消耗的煤气(立方米)'] * 0.7100, 2))
total.append(round(data['公司当年消耗的电(千瓦时)'] * 0.6101, 2))
amount = sum(total)
return amount
year_begin = calculation_co2(three_year_data[0])
year_middle = calculation_co2(three_year_data[1])
year_end = calculation_co2(three_year_data[2])
factor_01 = ((year_end/year_begin)**(1/2)-1) <= -0.04 and year_begin >= year_middle >= year_end
factor_02 = -0.04 < ((year_end/year_begin)**(1/2)-1) <= -0.03 and year_begin >= year_middle >= year_end
factor_03 = -0.03 < ((year_end/year_begin)**(1/2)-1) <= -0.02 and year_begin >= year_middle >= year_end
factor_04 = -0.02 < ((year_end/year_begin)**(1/2)-1) <= 0.01 and year_begin >= year_middle >= year_end
factor_05 = -0.01 < ((year_end/year_begin)**(1/2)-1) <= 0 and year_begin >= year_middle >= year_end
try:
if factor_01:
score = 15
elif factor_02:
score = 12
elif factor_03:
score = 9
elif factor_04:
score = 6
elif factor_05:
score = 3
else:
score = 0
except ZeroDivisionError:
score = 0
return score
def calculation_02(param):
"""
单位收入的能耗
Parameters:
param dict 环境问卷
Returns:
score int 得分
"""
# Parameter
three_year_data = sorted(param['环境问卷']['近三年公司数据'], key=operator.itemgetter('年份'), reverse=False)
def calculation_co2(data):
"""
计算每年能耗
Parameters:
data dict 当前年公司能耗数据
Returns:
result float 当年碳排放量
"""
total = list()
total.append(round(data['公司当年消耗的原煤(千克)'] * 20.9080, 2))
total.append(round(data['公司当年消耗的焦炭(千克)'] * 28.4350, 2))
total.append(round(data['公司当年消耗的原油(升)'] * 0.86 * 41.8160, 2))
total.append(round(data['公司当年消耗的燃料油(升)'] * 0.86 * 41.8160, 2))
total.append(round(data['公司当年消耗的汽油(升)'] * 0.73 * 43.0700, 2))
total.append(round(data['公司当年消耗的煤油(升)'] * 0.82 * 43.0700, 2))
total.append(round(data['公司当年消耗的柴油(升)'] * 0.85 * 42.6520, 2))
total.append(round(data['公司当年消耗的液化石油气(千克)'] * 50.1790, 2))
total.append(round(data['公司当年消耗的天然气(立方米)'] * 38.9310, 2))
total.append(round(data['公司当年消耗的煤气(立方米)'] * 17.0000, 2))
total.append(round(data['公司当年消耗的电(千瓦时)'] * 11.8400, 2))
amount = sum(total)
return amount
year_begin = calculation_co2(three_year_data[0])
year_middle = calculation_co2(three_year_data[1])
year_end = calculation_co2(three_year_data[2])
factor_01 = ((year_end/year_begin)**(1/2)-1) <= -0.028 and year_begin >= year_middle >= year_end
factor_02 = -0.028 < ((year_end/year_begin)**(1/2)-1) <= -0.02 and year_begin >= year_middle >= year_end
factor_03 = -0.02 < ((year_end/year_begin)**(1/2)-1) <= -0.01 and year_begin >= year_middle >= year_end
factor_04 = -0.01 < ((year_end/year_begin)**(1/2)-1) <= 0 and year_begin >= year_middle >= year_end
try:
if factor_01:
score = 11
elif factor_02:
score = 8
elif factor_03:
score = 5
elif factor_04:
score = 2
else:
score = 0
except ZeroDivisionError:
score = 0
return score
def calculation_03(param):
"""
单位收入的耗水
Parameters:
param dict 环境问卷
Returns:
score int 得分
"""
# Parameter
three_year_data = sorted(param['环境问卷']['近三年公司数据'], key=operator.itemgetter('年份'), reverse=False)
year_begin = three_year_data[0]['公司当年耗水(吨)']
year_middle = three_year_data[1]['公司当年耗水(吨)']
year_end = three_year_data[2]['公司当年耗水(吨)']
factor_01 = ((year_end/year_begin)**(1/2)-1) <= -0.01 and year_begin >= year_middle >= year_end
factor_02 = -0.01 < ((year_end/year_begin)**(1/2)-1) <= 0 and year_begin >= year_middle >= year_end
try:
if factor_01:
score = 6
elif factor_02:
score = 3
else:
score = 0
except ZeroDivisionError:
score = 0
return score
def calculation_04(param):
"""
绿色业务收入占比(加分项)
Parameters:
param dict 环境问卷
Returns:
score int 得分
"""
# Parameter
three_year_data = sorted(param['环境问卷']['近三年公司数据'], key=operator.itemgetter('年份'), reverse=False)
try:
income = param['公司当年收入(万元)'][three_year_data[2]['年份']]
green_income = three_year_data[2]['公司当年绿色业务收入(万元)——包括不限于清洁能源、清洁交通、绿色建筑、清洁技术等']
prop = round(green_income / income, 2)
if prop >= 50:
score = 10
elif prop >= 30:
score = 6
elif prop >= 10:
score = 3
elif prop > 0:
score = 1
else:
score = 0
except ZeroDivisionError:
score = 0
return score
def calculation_05(param):
"""
公司是否有温室气体减排目标
Parameters:
param dict 环境问卷
Returns:
score int 得分
"""
# Parameter
answer = param['环境问卷']['其他类型问卷'][0]
if isinstance(answer, list) and len(answer) == 2:
score = 1
else:
score = 0
return score
def calculation_06(param):
"""
企业是否有节能目标
Parameters:
param dict 环境问卷
Returns:
score int 得分
"""
answer = param['环境问卷']['其他类型问卷'][1]
if isinstance(answer, list) and len(answer) == 2:
score = 1
else:
score = 0
return score
def calculation_07(param):
"""
企业是否有节约用水目标
Parameters:
param dict 环境问卷
Returns:
score int 得分
"""
answer = param['环境问卷']['其他类型问卷'][2]
if isinstance(answer, list) and len(answer) == 2:
score = 1
else:
score = 0
return score
def calculation_08(param):
"""
是否有绿色业务(加分项)
Parameters:
param dict 环境问卷
Returns:
score int 得分
"""
answer = param['环境问卷']['其他类型问卷'][3]
if isinstance(answer, list) and len(answer) == 2:
score = 2
else:
score = 0
return score
def calculation_09(param):
"""
近三年是否被环境或水务等监管部门处罚
Parameters:
param dict 环境问卷
Returns:
score int 得分
"""
answer = param['环境问卷']['其他类型问卷'][4]
if answer[0] == 'A':
score = 'E=0'
else:
score = 0
return score
def calculation_10(param):
"""
国家双碳目标对企业业务是否有不利影响(减分项)
Parameters:
param dict 环境问卷
Returns:
score int 得分
"""
answer = param['环境问卷']['其他类型问卷'][5]
if answer[0] == 'B':
score = -2
else:
score = 0
return score
def calculation_11(param):
"""
国家双碳目标对企业业务是否有有利影响(加分项)
Parameters:
param dict 环境问卷
Returns:
score int 得分
"""
answer = param['环境问卷']['其他类型问卷'][6]
if isinstance(answer, list) and len(answer) == 2:
score = 2
else:
score = 0
return score
def calculation_12(param):
"""
企业是否使用风电、光电、水电等清洁能源,是否使用清洁交通工具(加分项)
Parameters:
param dict 环境问卷
Returns:
score int 得分
"""
answer = param['环境问卷']['其他类型问卷'][7]
if isinstance(answer, list) and len(answer) == 2:
score = 3
else:
score = 0
return score