算月综合AQI指数
Posted avivi
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了算月综合AQI指数相关的知识,希望对你有一定的参考价值。
# author:xgx
# create time: 2018/12/11
import pandas as pd
import os
import numpy as np
def i_so2(para):
"""
:param para: so2一个月的日均值, 数组
:return: so2的单项指数
"""
para = para.dropna()
para = np.sort(para)
# 计算单项月平均
# 规定月有效值不能小于27个,考虑到情况复杂,这里取15
if len(para) < 15:
final_i = np.nan
else:
cia = para.mean()
cia_item = cia / 60
k = 1 + (len(para) - 1)*0.98
s = int(k)
xs = para[s - 1]
xs_1 = para[s]
mp = xs + (xs_1 - xs)*(k-s)
cid_per = mp
cid_per_item = cid_per/150
final_i = max(cia_item, cid_per_item)
return final_i
def i_no2(para):
"""
:param para: no2一个月的日均值
:return: no2的单项指数
"""
para = para.dropna()
para = np.sort(para)
# 计算单项月平均
if len(para) < 15:
final_i = np.nan
else:
cia = para.mean()
cia_item = cia / 40
k = 1 + (len(para) - 1)*0.98
s = int(k)
xs = para[s - 1]
xs_1 = para[s]
mp = xs + (xs_1 - xs)*(k-s)
cid_per = mp
cid_per_item = cid_per/80
final_i = max(cia_item, cid_per_item)
return final_i
def i_pm10(para):
"""
:param para: pm10一个月的日均值
:return: pm10的单项指数
"""
para = para.dropna()
para = np.sort(para)
# 计算单项日平均
if len(para) < 15:
final_i = np.nan
else:
cia = para.mean()
cia_item = cia / 70
k = 1 + (len(para) - 1)*0.95
s = int(k)
xs = para[s - 1]
xs_1 = para[s]
mp = xs + (xs_1 - xs)*(k-s)
cid_per = mp
cid_per_item = cid_per/150
final_i = max(cia_item, cid_per_item)
return final_i
def i_pm25(para):
"""
:param para: pm25一个月的日均值
:return: pm25的单项指数
"""
para = para.dropna()
para = np.sort(para)
# 计算单项日平均
if len(para) < 15:
final_i = np.nan
else:
cia = para.mean()
cia_item = cia / 35
k = 1 + (