【空气质量数据分析专题九】污染物浓度小时变化分析
前言
对空气质量小时级别五年数据进行小时变化分析,可以看出污染物浓度在一天中逐小时变化的特征。
分析流程
对数据进行专题二的预处理后,计算出各污染物全时段的各小时的平均浓度,最后进行可视化分析。处理方法是使用小时级别的数据,计算五年所有该小时的平均浓度,从而得到一天中各小时的平均浓度。
核心代码
使用Python透视表函数计算出一天中逐小时的平均浓度,继而可视化分析。
def hourly_data_analysis(self, df_total, station_list, year_list): """ 小时级别数据分析 :param df_total: 全小时数居 :param station_list: 站点列表 :param year_list: 年份列表 :return: None """ for station in station_list: df_single_station = df_total[df_total['station'] == station] pm10_hour = pd.pivot_table(df_single_station, index='hour', values='PM10', aggfunc='mean') pm25_hour = pd.pivot_table(df_single_station, index='hour', values='PM2.5', aggfunc='mean') so2_hour = pd.pivot_table(df_single_station, index='hour', values='SO2', aggfunc='mean') no2_hour = pd.pivot_table(df_single_station, index='hour', values='NO2', aggfunc='mean') co_hour = pd.pivot_table(df_single_station, index='hour', values='CO', aggfunc='mean') o3_hour = pd.pivot_table(df_single_station, index='hour', values='O3', aggfunc='mean') fig = plt.figure() ax1 = fig.add_subplot(111) ax1.bar(x=co_hour.index.values, height=co_hour.values.reshape(-1), width=0.6, label='CO', color='#e6daa6') ax1.set_ylim(0, 1) ax1.set_yticks(np.linspace(0, 1, 6)) plt.legend(ncol=1, loc='upper left', fontsize=8) # 显示图例 plt.ylabel('CO浓度(mg/m${^3}$)') # 纵坐标轴标题 # plt.legend(bbox_to_anchor=(0.25, 0.9)) plt.legend(loc='upper left', fontsize=9.5) ax2 = ax1.twinx() ax2.plot(pm10_hour, marker='o', label='PM$_{10}$') ax2.plot(pm25_hour, marker='v', label='PM$_{2.5}$') ax2.plot(so2_hour, marker='<', label='SO$_{2}$') ax2.plot(no2_hour, marker='>', label='NO$_{2}$') ax2.plot(o3_hour, marker='d', label='O$_{3}$') ax2.set_ylim(0, 100) ax2.set_yticks(np.linspace(0, 100, 6)) plt.ylabel('五项污染物浓度(${μ}$g/m${^3}$)') plt.xticks(range(0, 25, 4), ['00:00', '04:00', '08:00', '12:00', '16:00', '20:00', '00:00'], rotation=15) # 倾斜15度 plt.legend(ncol=6, fontsize=9.5) plt.grid(axis='y', ls='--') pic_loc0 = Path(self.cf_info['output']['picture']).joinpath(df_single_station['city'].values[0]) pic_loc = pic_loc0.joinpath('污染物小时变化特征') if not os.path.exists(pic_loc): os.mkdir(pic_loc) plt.savefig(pic_loc / (df_single_station['station'].values[0] + str(year_list[0]) + '-' + str(year_list[-1]) + '年各污染物浓度日变化.png'), dpi=1200, bbox_inches='tight') plt.show()
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647结果展示与分析
结果如下图所示,可以比较明显的看出各污染物浓度在一天中的变化特征。
(图片右键新标签页打开会很清晰)
预告
下期为数据分析专题最后一期,主要内容为不同区域的对比分析。
以下是本人独自运营的微信公众号,用于分享个人学习及工作生活趣事,大佬们可以关注一波。
相关知识
四年春节空气监测:烟花爆竹越少,PM2.5浓度越“老实”
浓度及浓度单位换算
科学网—基于Delft3D模型水体流动、污染物对流扩散、质点运移、溢油漂移及地表水环境报告编制
专家解读《环境空气质量标准》修改单
幼儿园室内环境质量,如何利用智能空气净化系统的智能运行模式,根据空气质量自动调节净化强度?
空气检测实时监控污染源
空气检测实时掌握污染变化
实时监测与数据分析:景区空气质量检测仪的核心功能
花卉大数据分析与市场预测
室内主要空气污染物与处理方法概述
网址: 【空气质量数据分析专题九】污染物浓度小时变化分析 https://www.huajiangbk.com/newsview2013613.html
上一篇: 《2025年气候变化对环境空气质 |
下一篇: 呼吸纠结:桂花很香,空气污染很重 |
推荐分享

- 1君子兰什么品种最名贵 十大名 4012
- 2世界上最名贵的10种兰花图片 3364
- 3花圈挽联怎么写? 3286
- 4迷信说家里不能放假花 家里摆 1878
- 5香山红叶什么时候红 1493
- 6花的意思,花的解释,花的拼音 1210
- 7教师节送什么花最合适 1167
- 8勿忘我花图片 1103
- 9橄榄枝的象征意义 1093
- 10洛阳的市花 1039