我试图得到我的421个连续日期(显示在x轴),分为一个月。因此,我不想把一月份的31天贴上标签,我只想把这31天贴上一个标签,称为“2000年1月”,以此类推
我会包括一个图像,但我需要更高的代表。所以,y轴是纬度和x轴是每个月,作为一个时间序列。需要帮忙吗
import numpy as np
from netCDF4 import Dataset
from matplotlib.dates import date2num
from datetime import datetime, timedelta
from netCDF4 import num2date, date2num, date2index
### by defining the directory pathway ###
expname='xnsbi'
inpath = 'E://Data Files (NetCDF)/'+expname+'/Monthly_AOD/'
mnames= ['0sep','0oct','0nov','0dec','1jan','1feb','1mar','1apr','1may','1jun','1jul', '1aug','1sep','1oct','1nov']
######################### Extracting the data for the plots
### Looping the variables needed to be extracted for the different months ###
Dates = []
array = []
for name in mnames:
infile= inpath+expname+'a_pd200'+name+'sAODtracersMDSJamesB.nc' # Complete
#the pathway to loop all files #
vn=Dataset(infile)
lon = vn.variables['longitude'][:]
lat = vn.variables['latitude'][:]
time = vn.variables['t'][:]
aod550 = vn.variables['aod'][:]
### Set the time and date of each plots ####
t_unit="days since 2000-09-01T00:00:00Z"
t_cal = "360_day"
dates =num2date(time,units=t_unit,calendar=t_cal)
fmt = '%m/%Y'
label = dates[0].strftime(fmt)
print(label)
ntime=len(time)
Mlon = np.mean(aod550,axis=1)
array.append(Mlon)
fig = plt.figure(figsize=(15.745,15), edgecolor='w')
在这里你可以看到连续421天。这在我的x轴上绘制了421个不同的日期(非常模糊)
sdate=str(label)
Dates.append(sdate)
data = np.zeros((145,421)) # For the zonal mean
for i in range(421):
data[:,i] = array[i]
######## Construct the plot
cs = plt.contourf(Dates,lat,data,cmap='jet')
目前没有回答
相关问题 更多 >
编程相关推荐