需求分析:研究需要使用到—中国多尺度排放清单模型MEIC中的数据。下载的MEIC含.xml, .nc以及.asc三种不同类型的文件,如下;.nc以及.asc中的数据理论上相同,但需要验证。
- 数据读取
import xarray as xr
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import os
Dir = '../MEIC/2015/'
file = os.listdir(Dir)
industry_ncfile = [f for f in file if f.endswith('.nc') and f.split('_')[2] == 'industry']
industry_ascfile = [f for f in file if f.endswith('.asc') and f.split('_')[2] == 'industry']
# nc文件的打开结果
xs = xr.open_dataset(Dir + industry_ncfile[0]) # 内含x_range, y_range, spacing, dimension以及z五个参数, 大小为320*200=64000个有效数据
lon = np.arange(xs.x_range[0], xs.x_range[1], xs.spacing[0])
lat = np.arange(xs.y_range[0], xs.y_range[1], xs.spacing[0])
xs.z[xs.z == xs.z.nodata_value] = np.nan # 将填补值设置为空
xs_data= xs.z.values
# asc文件的打开结果
acs = np.loadtxt(Dir+industry_ascfile[0], skiprows = 6) # 跳过前六行
acs[acs == -9999] = np.nan
# 验证.nc以及.asc文件保存的内容是否一致
acs = acs.reshape(-1)
print(xs_data[~np.isnan(xs_data)], acs[~np.isnan(acs)].astype('float32'))
print(xs_data[~np.isnan(xs_data)] == acs[~np.isnan(acs)].astype('float32'))
- 结果
runfile('G:/3_Atmos/O3_Mapping/read_meic.py', wdir='G:/3_Atmos/O3_Mapping')
[2.2673947e-05 3.2877232e-04 2.5508177e-04 ... 2.5880449e+01 2.6455739e+00
3.9224476e+01] [2.2673947e-05 3.2877232e-04 2.5508177e-04 ... 2.5880449e+01 2.6455739e+00
3.9224476e+01]
[ True True True ... True True True]
3.总结
MEIC数据是包含NOX、COX等众多排放数据的一个开源数据。目前的最新版本为MEIC V1.3,含2008-2017逐年的排放数据;其空间范围[10, 60]&[70, 150], 最高空间分辨率为0.25。