其他分享
首页 > 其他分享> > 日记

日记

作者:互联网

import xarray as xr
import numpy as np
import os
import matplotlib.pyplot as plt
from pandas.core.frame import DataFrame 
from scipy.stats.mstats import ttest_ind
import cartopy.crs as ccrs
import cartopy.feature as cfeature
import cartopy.mpl.ticker as cticker
import matplotlib.patches as patches
filePath = '文件夹路径'
#获取文件夹下所有文件名
filename = os.listdir(filePath)
#文件名过滤
filename = list(filter(lambda x:x.startswith('文件名头'), filename))

tmax_all = np.zeros((9,37*62))
for i in range(9):
    f = xr.open_dataset('/home/mw/input/mysqzj8460/{}'.format(filename[i]))
    tmax = f.TMAX.loc[f.time.dt.month.isin([7,8])].loc['1979-07-01':'2015-08-31']
    tmax_all[i] = tmax.interpolate_na(dim="time", method="linear")
tmax_mean = np.nanmean(tmax_all,axis=0)
tmax_2d = tmax_mean.reshape((37,62))

tmax_copy = tmax_mean.copy()
for i in range(1,37*62-1,1):
    if ((tmax_copy[i]>=33)&(tmax_copy[i-1]<33)&(tmax_copy[i+1]<33)):
        tmax_copy[i]=32
tmax_copy_2d = tmax_copy.reshape((37,62))

 

标签:tmax,37,filename,62,import,copy,日记
来源: https://www.cnblogs.com/eroeg/p/16643241.html