60 KiB
60 KiB
In [1]:
import pandas as pd
In [2]:
import numpy as np import time
$E = E_{燃烧} + E_{脱硫} + E_{电}$
$E_{燃烧} = \sum_i (AD_i\times EF_i)$
$AD_i = FC_i \times NCV_i \times 10^{-6}$ 消耗量*低位热值
$EF_i = CC_i \times OF_i \times \frac{44}{12}$ 单位热值含碳量 * 碳氧化率
In [3]:
def cal_ad(fc, ncv): return fc * ncv * 1e-6
In [4]:
def cal_ef(cc, of): return cc * of * 44 / 12
In [5]:
cc_map = { "无烟煤": 27.49, "烟煤": 26.18, "褐煤": 27.97, "贫煤": 26.0, }
In [6]:
data = pd.read_excel('./total_data.xlsx')
In [7]:
data['入炉煤低位热值(kJ/kg)'] = data['入炉煤低位热值(kJ/kg)'].apply(lambda x: x*1000 if x < 100 else x*1) data['燃煤灰份Aar(%)'] = data['燃煤灰份Aar(%)'].apply(lambda x: x / 1000 if x > 10000 else x*1) data['燃煤挥发份Var(%)'] = data['燃煤挥发份Var(%)'].apply(lambda x: x / 1000 if x > 10000 else x*1)
In [8]:
def cal_ctype(ncv, vdaf, ash): if pd.isna(ncv) or pd.isna(vdaf) or pd.isna(ash): return pd.NA else: if vdaf / (1 - ash/100 - 0.07196) < 10: return '无烟煤' elif vdaf / (1 - ash/100 - 0.06825) < 20: return '贫煤' elif vdaf / (1 - ash/100 - 0.08679) < 37 and ncv > 16730: return '烟煤' elif ncv < 16730: return '褐煤' else: return '烟煤'
In [9]:
data['煤种'] = data.apply(lambda x: cal_ctype(x['入炉煤低位热值(kJ/kg)'], x['燃煤挥发份Var(%)'], x['燃煤灰份Aar(%)']), axis=1)
In [10]:
data = data[~data['煤种'].isna()].copy()
In [11]:
data = data[data['入炉煤低位热值(kJ/kg)']> 8000].copy()
In [12]:
data = data[~((data['发电用标煤量(t)'].isna())|(data['发电用标煤量(t)']==0))].copy() data = data[~((data['发电用标煤量(t)'].isna())|(data['发电用标煤量(t)']==0))].copy()
In [13]:
drop_cols = [x for x in data.columns if '.1' in x or '.2' in x] drop_cols
Out[13]:
['出力系数(%).1', '出力系数(%).2', '化学系统耗电率 (%).1', '额再热蒸汽温度 (℃).1']
In [14]:
data.drop(columns=drop_cols, inplace=True)
In [15]:
data['工业供热量'].fillna(0, inplace=True) data['采暖供热量'].fillna(0, inplace=True)
In [16]:
drop_index = data[(data['发电量(万kWh)']<10000)|(data['总供热量']<=10000)|(data['供热用标煤量(t)']==0)].index.values drop_index
Out[16]:
array([ 56, 96, 122, ..., 16724, 16725, 16837], dtype=int64)
In [17]:
data.drop(index=drop_index, inplace=True) data.reset_index(inplace=True, drop=True)
In [18]:
data['发电碳排放因子(kg/kWh)'] = data.apply(lambda x: (cal_ad(x['发电用标煤量(t)'], x['入炉煤低位热值(kJ/kg)']) * cal_ef(cc_map.get(x['煤种']), 0.98))/x['发电量(万kWh)']/10, axis=1)
In [19]:
data['供热碳排放因子(kg/MJ)'] = data.apply(lambda x:(cal_ad(x['供热用标煤量(t)'], x['入炉煤低位热值(kJ/kg)']) * cal_ef(cc_map.get(x['煤种']), 0.98))/x['总供热量'] if x['总供热量'] != 0 else 0, axis=1)
In [20]:
data[['总供热量', '供热碳排放因子(kg/MJ)']]
Out[20]:
总供热量 | 供热碳排放因子(kg/MJ) | |
---|---|---|
0 | 8.294556e+05 | 0.076843 |
1 | 8.789928e+04 | 0.077676 |
2 | 8.481764e+05 | 0.074823 |
3 | 4.473469e+05 | 0.081628 |
4 | 7.157164e+05 | 0.081103 |
... | ... | ... |
7252 | 1.532303e+06 | 0.078776 |
7253 | 2.147545e+06 | 0.076622 |
7254 | 2.131207e+06 | 0.074772 |
7255 | 3.039811e+06 | 0.091482 |
7256 | 3.039813e+06 | 0.091483 |
7257 rows × 2 columns
In [21]:
data[data['电厂名称']=='华电内蒙古能源有限公司包头发电分公司']['发电碳排放因子(kg/kWh)']
Out[21]:
126 0.460130 127 0.480800 128 0.493493 129 0.487034 130 0.475439 131 0.481355 132 0.450568 133 0.454952 134 0.460595 135 0.478949 136 0.486923 137 0.483407 138 0.488134 139 0.471598 140 0.450577 141 0.461044 Name: 发电碳排放因子(kg/kWh), dtype: float64
In [22]:
loc_data = pd.read_csv('./电厂机组地理信息.csv') loc_data.head()
Out[22]:
plant | longitude | latitude | altitude | |
---|---|---|---|---|
0 | 万方发电厂(焦作爱依斯万方电力有限公司) | 113.381649 | 35.255622 | 88.0 |
1 | 三河发电有限责任公司 | 116.860260 | 39.953617 | 27.0 |
2 | 上海上电漕泾发电有限公司 | 121.407593 | 30.765242 | 4.0 |
3 | 上海吴泾发电有限责任公司 | 121.471140 | 31.065113 | 3.0 |
4 | 上海吴泾第二发电有限责任公司 | 121.471340 | 31.062532 | 4.0 |
In [23]:
loc_data.rename(columns={'plant':'电厂名称'}, inplace=True)
In [24]:
data = data.merge(loc_data, how='left', on='电厂名称')
In [25]:
data.columns[-5:]
Out[25]:
Index(['发电碳排放因子(kg/kWh)', '供热碳排放因子(kg/MJ)', 'longitude', 'latitude', 'altitude'], dtype='object')
In [26]:
uni = data.groupby(['电厂名称', '机组编号'])['铭牌容量 (MW)'].unique().to_frame()
In [27]:
uni['len'] = uni['铭牌容量 (MW)'].apply(len)
In [28]:
uni[uni.len==2]
Out[28]:
铭牌容量 (MW) | len | ||
---|---|---|---|
电厂名称 | 机组编号 |
In [29]:
data = data[data['供热碳排放因子(kg/MJ)'] < 0.2].copy()
In [30]:
import seaborn as sns
In [31]:
from scipy.stats import norm
In [32]:
data[data['供热碳排放因子(kg/MJ)'] <= 0]
Out[32]:
电厂名称 | 机组编号 | 铭牌容量 (MW) | 投产时间 | 机组类型 | 参数分类 | 所处地区 | 冷凝器型式 | 时间 | 发电量(万kWh) | ... | 引风机最大风压(Pa) | 引风机最大流量(m3/S) | 引风机电机电压(V) | 引风机电机功率(KW) | 煤种 | 发电碳排放因子(kg/kWh) | 供热碳排放因子(kg/MJ) | longitude | latitude | altitude |
---|
0 rows × 134 columns
In [33]:
sns.distplot(data['供热碳排放因子(kg/MJ)'], fit=norm)
D:\miniconda3\envs\py37\lib\site-packages\ipykernel_launcher.py:1: UserWarning: `distplot` is a deprecated function and will be removed in seaborn v0.14.0. Please adapt your code to use either `displot` (a figure-level function with similar flexibility) or `histplot` (an axes-level function for histograms). For a guide to updating your code to use the new functions, please see https://gist.github.com/mwaskom/de44147ed2974457ad6372750bbe5751 """Entry point for launching an IPython kernel.
Out[33]:
<matplotlib.axes._subplots.AxesSubplot at 0x12eeb377708>
D:\miniconda3\envs\py37\lib\site-packages\matplotlib\backends\backend_agg.py:214: RuntimeWarning: Glyph 20379 missing from current font. font.set_text(s, 0.0, flags=flags) D:\miniconda3\envs\py37\lib\site-packages\matplotlib\backends\backend_agg.py:214: RuntimeWarning: Glyph 28909 missing from current font. font.set_text(s, 0.0, flags=flags) D:\miniconda3\envs\py37\lib\site-packages\matplotlib\backends\backend_agg.py:214: RuntimeWarning: Glyph 30899 missing from current font. font.set_text(s, 0.0, flags=flags) D:\miniconda3\envs\py37\lib\site-packages\matplotlib\backends\backend_agg.py:214: RuntimeWarning: Glyph 25490 missing from current font. font.set_text(s, 0.0, flags=flags) D:\miniconda3\envs\py37\lib\site-packages\matplotlib\backends\backend_agg.py:214: RuntimeWarning: Glyph 25918 missing from current font. font.set_text(s, 0.0, flags=flags) D:\miniconda3\envs\py37\lib\site-packages\matplotlib\backends\backend_agg.py:214: RuntimeWarning: Glyph 22240 missing from current font. font.set_text(s, 0.0, flags=flags) D:\miniconda3\envs\py37\lib\site-packages\matplotlib\backends\backend_agg.py:214: RuntimeWarning: Glyph 23376 missing from current font. font.set_text(s, 0.0, flags=flags) D:\miniconda3\envs\py37\lib\site-packages\matplotlib\backends\backend_agg.py:183: RuntimeWarning: Glyph 20379 missing from current font. font.set_text(s, 0, flags=flags) D:\miniconda3\envs\py37\lib\site-packages\matplotlib\backends\backend_agg.py:183: RuntimeWarning: Glyph 28909 missing from current font. font.set_text(s, 0, flags=flags) D:\miniconda3\envs\py37\lib\site-packages\matplotlib\backends\backend_agg.py:183: RuntimeWarning: Glyph 30899 missing from current font. font.set_text(s, 0, flags=flags) D:\miniconda3\envs\py37\lib\site-packages\matplotlib\backends\backend_agg.py:183: RuntimeWarning: Glyph 25490 missing from current font. font.set_text(s, 0, flags=flags) D:\miniconda3\envs\py37\lib\site-packages\matplotlib\backends\backend_agg.py:183: RuntimeWarning: Glyph 25918 missing from current font. font.set_text(s, 0, flags=flags) D:\miniconda3\envs\py37\lib\site-packages\matplotlib\backends\backend_agg.py:183: RuntimeWarning: Glyph 22240 missing from current font. font.set_text(s, 0, flags=flags) D:\miniconda3\envs\py37\lib\site-packages\matplotlib\backends\backend_agg.py:183: RuntimeWarning: Glyph 23376 missing from current font. font.set_text(s, 0, flags=flags)
In [34]:
data[['电厂名称', '机组编号', '铭牌容量 (MW)', '机组类型', '参数分类', '冷凝器型式', '入炉煤低位热值(kJ/kg)', '燃煤挥发份Var(%)', '燃煤灰份Aar(%)', '煤种', '所处地区', 'longitude', 'latitude', 'altitude','发电碳排放因子(kg/kWh)', '供热碳排放因子(kg/MJ)']].to_csv('./train_data.csv', index=False, encoding='utf-8-sig')
In [ ]: