四站氣象對比(ECMWF+NOAA+中國氣象網+GFS)——大氣數據分析研究


一、ECMWF(方正附近,46,128.75,張志浩)

from netCDF4 import Dataset
from netCDF4 import num2date
nc_obj = Dataset ( "download.nc" )
# 查看nc文件中的變量
print ( nc_obj.variables.keys() )
odict_keys(['longitude', 'latitude', 'time', 'u10', 'v10', 't2m', 'sp'])
# 查看每個變量的單位
for i in nc_obj.variables.keys ():
    print ( nc_obj.variables[i].units )
degrees_east
degrees_north
hours since 1900-01-01 00:00:00.0
m s**-1
m s**-1
K
Pa
# 查看每個變量的形狀(維度)
for i in nc_obj.variables.keys ():
    print ( nc_obj.variables[i].shape )
(21,)
(41,)
(144,)
(144, 41, 21)
(144, 41, 21)
(144, 41, 21)
(144, 41, 21)
#取出時間
time=nc_obj['time'][:]
print(time[:5])
[1051152 1051153 1051154 1051155 1051156]
#將時間轉化為人類可讀時間 datetime.datetime
time1=num2date(time,units=nc_obj['time'].units)
print(time1[:5])
[datetime.datetime(2019, 12, 1, 0, 0) datetime.datetime(2019, 12, 1, 1, 0)
 datetime.datetime(2019, 12, 1, 2, 0) datetime.datetime(2019, 12, 1, 3, 0)
 datetime.datetime(2019, 12, 1, 4, 0)]
#經度 128.5 14 128.75 15
longitude=nc_obj['longitude'][:]
print(longitude)
# print(nc_obj['longitude'][14])
[125.   125.25 125.5  125.75 126.   126.25 126.5  126.75 127.   127.25
 127.5  127.75 128.   128.25 128.5  128.75 129.   129.25 129.5  129.75
 130.  ]
#緯度 45.5 18 46 16
latitude=nc_obj['latitude'][:]
print(latitude)
# print(nc_obj['latitude'][18])
# print(nc_obj['latitude'][16])
[50.   49.75 49.5  49.25 49.   48.75 48.5  48.25 48.   47.75 47.5  47.25
 47.   46.75 46.5  46.25 46.   45.75 45.5  45.25 45.   44.75 44.5  44.25
 44.   43.75 43.5  43.25 43.   42.75 42.5  42.25 42.   41.75 41.5  41.25
 41.   40.75 40.5  40.25 40.  ]
#取出變量blh 10 metre V wind component(10米V風分量)
v10=nc_obj['v10'][:]
#取出北緯46東經128.75的v10數值
a = [0]*144
for i in range(144):
    a[i]=nc_obj.variables['v10'][i][16][15]
#取出變量10 metre U wind component,(10米U風分量)
u10=nc_obj['u10'][:]
#取出北緯46東經128.75的u10數值
b = [0]*144
for i in range(144):
    b[i]=nc_obj.variables['u10'][i][16][15]
#對v10和u10平方和開平方
c = [0]*144
for i in range(144):
    c[i]=(a[i]**2+b[i]**2)**0.5
import matplotlib.pyplot as plt
import  pandas as pd
plt.rc('font', family='SimHei', size=15) #繪圖中的中文顯示問題,圖表字體為SimHei,字號為15
#plt.rcParams['font.sans-serif']=['SimHei'] #用來正常顯示中文標簽
plt.rcParams['axes.unicode_minus']=False #用來正常顯示負號
plt.figure(figsize=(31,8))
plt.title('ECMWF風速(v10和u10平方和的開平方)與時間的函數')  #有標題(風速與風向的函數)
plt.xlabel('時間') #橫坐標的標題
plt.ylabel('風速(m/s)') #縱坐標的標題
plt.grid(color='#95a5a6',linestyle='--',linewidth=3,axis='both',alpha=0.4) #設置網格
plt.plot(time1,c,marker='o',c='r')
# plt.xticks(pd.date_range('2019-12-01','2019-01-31'))
# plt.xticks(rotation='vertical')
# plt.xticks(rotation=30)
plt.gcf().autofmt_xdate()
# plt.savefig('ECMWF.png') #保存圖片
plt.show() 
D:\Users\zzh\Anaconda3\lib\site-packages\pandas\plotting\_matplotlib\converter.py:103: FutureWarning: Using an implicitly registered datetime converter for a matplotlib plotting method. The converter was registered by pandas on import. Future versions of pandas will require you to explicitly register matplotlib converters.

To register the converters:
	>>> from pandas.plotting import register_matplotlib_converters
	>>> register_matplotlib_converters()
  warnings.warn(msg, FutureWarning)

在這里插入圖片描述

t2m=nc_obj['t2m'][:]
# print(t2m)
#取出北緯46東經128.75的t2m數值
t2m1 = [0]*144
for i in range(144):
    t2m1[i]=nc_obj.variables['t2m'][i][16][15]
# 將開氏度轉化為攝氏度 
# 1攝氏度(℃)=274.15開氏度(K)
t2m2=[]
for i in t2m1:
    t2m2.append(i/274.15)
plt.figure(figsize=(31,8))
plt.title('ECMWF的2米溫度(t2m)與時間的函數')  #有標題(風速與風向的函數)
plt.xlabel('時間') #橫坐標的標題
plt.ylabel('溫度(K)') #縱坐標的標題
plt.grid(color='#95a5a6',linestyle='--',linewidth=3,axis='both',alpha=0.4) #設置網格
plt.plot(time1,t2m2,marker='o',c='r')
# plt.xticks(pd.date_range('2019-12-01','2019-01-31'))
# plt.xticks(rotation='vertical')
# plt.xticks(rotation=30)
plt.gcf().autofmt_xdate()
# plt.savefig('ECMWF.png') #保存圖片
plt.show() 

在這里插入圖片描述

sp=nc_obj['sp'][:]
# print(sp)
#取出北緯46東經128.75的sp數值
e = [0]*144
for i in range(144):
    e[i]=nc_obj.variables['sp'][i][16][15]
plt.figure(figsize=(31,8))
plt.title('ECMWF的表明壓力(sp)與時間的函數')  #有標題(風速與風向的函數)
plt.xlabel('時間') #橫坐標的標題
plt.ylabel('壓力(Pa)') #縱坐標的標題
plt.grid(color='#95a5a6',linestyle='--',linewidth=3,axis='both',alpha=0.4) #設置網格
plt.plot(time1,e,marker='o',c='r')
# plt.xticks(pd.date_range('2019-12-01','2019-01-31'))
# plt.xticks(rotation='vertical')
# plt.xticks(rotation=30)
plt.gcf().autofmt_xdate()
# plt.savefig('ECMWF.png') #保存圖片
plt.show() 

在這里插入圖片描述

#將數據存儲到csv文件
import pandas as pd
#a和b的長c度必須保持一致,否則報錯
#字典中的key值即為csv中列名
dataframe = pd.DataFrame({'時間':time1,'風速(m/s)':c,'2米溫度(℃)':t2m2,'壓力(Pa)':e})
#將DataFrame存儲為csv,index表示是否顯示行名,default=True
dataframe.to_csv(r"ECMWF(方正)20191201-06.csv",sep=',',index=False)

二、NOAA(通河,45.967 ,128.733王闊)

from datetime import datetime
import  pandas as pd
noaa=pd.read_csv("C:\\Users\\zzh\\Desktop\\tonghe1201-1208.csv")
print(noaa.shape)
(64, 33)
noaa.head()
USAF WBAN TIME DIR SPD GUS CLG SKC L M ... SLP ALT STP MAX MIN PCP01 PCP06 PCP24 PCPXX SD
0 509630 ***** 201912010000 261 18 28 *** *** * * ... 1023.6 ***** 1009.2 *** *** ***** ***** 0.19 ***** 0
1 509630 ***** 201912010300 272 12 28 *** *** * * ... 1023.4 ***** 1009.0 *** *** ***** 0.00 0.19 ***** 0
2 509630 ***** 201912010600 292 7 28 *** *** * * ... 1022.7 ***** 1008.3 20 14 ***** 0.01 0.19 ***** 0
3 509630 ***** 201912010900 300 4 28 722 CLR * * ... 1022.5 ***** 1007.9 *** *** ***** 0.00 0.16 0.01 **
4 509630 ***** 201912011200 223 1 25 722 CLR * * ... 1021.6 ***** 1006.8 *** *** ***** ***** 0.05 ***** 0

5 rows × 33 columns

#取出時間
TIME=noaa['TIME'][:64,]
print(TIME)
0     201912010000
1     201912010300
2     201912010600
3     201912010900
4     201912011200
          ...     
59    201912080900
60    201912081200
61    201912081500
62    201912081800
63    201912082100
Name: TIME, Length: 64, dtype: int64
# 201901041500,
# 每一個時間如上所示,為2019-01-04,15:00
# 我把分鍾數截斷,因為所有數據分鍾數都是00
TIME1=[]
for i in TIME:
    # 201901041500
    TIME1.append((str.split(str(i)[:10]))[0])
print(TIME1)
['2019120100', '2019120103', '2019120106', '2019120109', '2019120112', '2019120115', '2019120118', '2019120121', '2019120200', '2019120203', '2019120206', '2019120209', '2019120212', '2019120215', '2019120218', '2019120221', '2019120300', '2019120303', '2019120306', '2019120309', '2019120312', '2019120315', '2019120318', '2019120321', '2019120400', '2019120403', '2019120406', '2019120409', '2019120412', '2019120415', '2019120418', '2019120421', '2019120500', '2019120503', '2019120506', '2019120509', '2019120512', '2019120515', '2019120518', '2019120521', '2019120600', '2019120603', '2019120606', '2019120609', '2019120612', '2019120615', '2019120618', '2019120621', '2019120700', '2019120703', '2019120706', '2019120709', '2019120712', '2019120715', '2019120718', '2019120721', '2019120800', '2019120803', '2019120806', '2019120809', '2019120812', '2019120815', '2019120818', '2019120821']
TIME2 =[]
for i in TIME1:
    # 2019010415
    TIME2.append(datetime.strptime(i,'%Y%m%d%H'))
# # 隔行選取數據
# TIME3 =[]
# for i in range(0,247,2):
# TIME3 .append(TIME2[i])
SPD=noaa['SPD'][:64,]
# print(DIR)
#將英里每小時轉化為米每秒
# 1英里每小時(mile/h)=0.44704米每秒(m/s)
SPD1=[]
for i in SPD:
    SPD1.append(i*0.44704)
# print(spd)
# # 隔行選取數據
# SPD2 =[]
# for i in range(0,247,2):
# SPD2 .append(SPD1[i])
plt.figure(figsize=(31,8))
plt.title('NOAA風速與時間的函數')  #有標題(風速與風向的函數)
plt.xlabel('時間') #橫坐標的標題
plt.ylabel('風速(m/s)') #縱坐標的標題
plt.grid(color='#95a5a6',linestyle='--',linewidth=3,axis='both',alpha=0.4) #設置網格
plt.plot(TIME2,SPD1,marker='o',c='g')
# plt.xticks(pd.date_range('2019-01-01','2019-01-31'))
# plt.xticks(rotation='vertical')
# plt.xticks(rotation=30)
plt.gcf().autofmt_xdate()
# plt.savefig('NOAA.png') #保存圖片
plt.show()

在這里插入圖片描述

# TEMP 溫度 華氏度
TEMP=noaa['TEMP'][:64,]
# 將華氏度轉化為攝氏度
# 1攝氏度(℃)=33.8華氏度(℉)
TEMP1=[]
for i in TEMP:
    TEMP1.append(i/33.8)
plt.figure(figsize=(31,8))
plt.title('NOAA溫度與時間的函數')  #有標題(風速與風向的函數)
plt.xlabel('時間') #橫坐標的標題
plt.ylabel('溫度(℃)') #縱坐標的標題
plt.grid(color='#95a5a6',linestyle='--',linewidth=3,axis='both',alpha=0.4) #設置網格
plt.plot(TIME2,TEMP1,marker='o',c='g')
# plt.xticks(pd.date_range('2019-01-01','2019-01-31'))
# plt.xticks(rotation='vertical')
# plt.xticks(rotation=30)
plt.gcf().autofmt_xdate()
# plt.savefig('NOAA.png') #保存圖片
plt.show()

在這里插入圖片描述

plt.figure(figsize=(31,8))
plt.title('NOAA溫度與時間的函數')  #有標題(風速與風向的函數)
plt.xlabel('時間') #橫坐標的標題
plt.ylabel('溫度(℃)') #縱坐標的標題
plt.grid(color='#95a5a6',linestyle='--',linewidth=3,axis='both',alpha=0.4) #設置網格
plt.plot(TIME2,TEMP1,marker='o',c='g')
# plt.xticks(pd.date_range('2019-01-01','2019-01-31'))
# plt.xticks(rotation='vertical')
# plt.xticks(rotation=30)
plt.gcf().autofmt_xdate()
# plt.savefig('NOAA.png') #保存圖片
plt.show()

在這里插入圖片描述

# STP 站壓 毫巴
STP=noaa['STP'][:64,]
# 講毫巴轉化成帕
# 1毫巴(mbar)=100帕斯卡(Pa)Pa
STP1=[]
for i in STP:
    STP1.append(i*100)
plt.figure(figsize=(31,8))
plt.title('NOAA站壓與時間的函數')  #有標題(風速與風向的函數)
plt.xlabel('時間') #橫坐標的標題
plt.ylabel('氣壓(Pa)') #縱坐標的標題
plt.grid(color='#95a5a6',linestyle='--',linewidth=3,axis='both',alpha=0.4) #設置網格
plt.plot(TIME2,STP1,marker='o',c='g')
# plt.xticks(pd.date_range('2019-01-01','2019-01-31'))
# plt.xticks(rotation='vertical')
# plt.xticks(rotation=30)
plt.gcf().autofmt_xdate()
# plt.savefig('NOAA.png') #保存圖片
plt.show()

在這里插入圖片描述

三、中國氣象網(方正,45.50,128.48,王闊)

china=pd.read_csv("C:\\Users\\zzh\\Desktop\\方正1202-1208.csv")
print(china.head())
   Unnamed: 0  Station_Id_C  Year  Mon  Day  Hour    PRS  PRS_Sea  PRS_Max  \
0           1         50964  2019   12    2     0  998.4   1014.2    998.5   
1           2         50964  2019   12    2     1  998.3   1014.1    998.5   
2           3         50964  2019   12    2     2  998.5   1014.3    998.6   
3           4         50964  2019   12    2     3  997.8   1013.6    998.5   
4           5         50964  2019   12    2     4  997.7   1013.5    997.9   

   PRS_Min  ...  WIN_S_Avg_2mi  WIN_D_Avg_2mi  WEP_Now  WIN_S_Inst_Max  tigan  \
0    998.3  ...            3.8            206      0.0             8.0 -12.66   
1    998.2  ...            2.9            217     22.0             9.6 -12.96   
2    998.2  ...            5.8            200     70.0            11.0 -12.70   
3    997.8  ...            4.1            220      0.0            11.3 -11.98   
4    997.7  ...            5.4            218     70.0            11.9 -12.68   

   windpower      VIS  CLO_Cov  CLO_Cov_Low  CLO_COV_LM  
0          3   7200.0   999999       999999      999999  
1          3  10500.0   999999       999999      999999  
2          3  11200.0   999999       999999      999999  
3          3  16900.0   999999       999999      999999  
4          3   5000.0   999999       999999      999999  

[5 rows x 30 columns]
china['Year'] = [str(i) for i in china['Year']]
china['Mon'] = [str(i) for i in china['Mon']]
china['Day'] = ['0'+str(i) for i in china['Day']]
china['Hour'] = [str(i) for i in china['Hour']]
# china['time'] = china[['Year', 'Mon','Day','Hour']].apply(lambda x: ''.join(x), axis=1)
china['time'] =china['Year']+china['Mon']+china['Day']+china['Hour']
print(china.head())
   Unnamed: 0  Station_Id_C  Year Mon Day Hour    PRS  PRS_Sea  PRS_Max  \
0           1         50964  2019  12  02    0  998.4   1014.2    998.5   
1           2         50964  2019  12  02    1  998.3   1014.1    998.5   
2           3         50964  2019  12  02    2  998.5   1014.3    998.6   
3           4         50964  2019  12  02    3  997.8   1013.6    998.5   
4           5         50964  2019  12  02    4  997.7   1013.5    997.9   

   PRS_Min  ...  WIN_D_Avg_2mi  WEP_Now  WIN_S_Inst_Max  tigan  windpower  \
0    998.3  ...            206      0.0             8.0 -12.66          3   
1    998.2  ...            217     22.0             9.6 -12.96          3   
2    998.2  ...            200     70.0            11.0 -12.70          3   
3    997.8  ...            220      0.0            11.3 -11.98          3   
4    997.7  ...            218     70.0            11.9 -12.68          3   

       VIS  CLO_Cov  CLO_Cov_Low  CLO_COV_LM       time  
0   7200.0   999999       999999      999999  201912020  
1  10500.0   999999       999999      999999  201912021  
2  11200.0   999999       999999      999999  201912022  
3  16900.0   999999       999999      999999  201912023  
4   5000.0   999999       999999      999999  201912024  

[5 rows x 31 columns]
china_time=china['time']
print(china_time)
0       201912020
1       201912021
2       201912022
3       201912023
4       201912024
          ...    
163    2019120819
164    2019120820
165    2019120821
166    2019120822
167    2019120823
Name: time, Length: 168, dtype: object
china_time1 =[]
for i in china_time:
    # 2019010415
    china_time1.append(datetime.strptime(i,'%Y%m%d%H'))
WIN_S_Avg_2mi=china['WIN_S_Avg_2mi']
plt.figure(figsize=(31,8))
plt.title('中國氣象網2分鍾平均風速與時間的函數')  #有標題(風速與風向的函數)
plt.xlabel('時間') #橫坐標的標題
plt.ylabel('風速(m/s)') #縱坐標的標題
plt.grid(color='#95a5a6',linestyle='--',linewidth=3,axis='both',alpha=0.4) #設置網格
plt.plot(china_time1,WIN_S_Avg_2mi,marker='o',c='y')
# plt.xticks(pd.date_range('2019-01-01','2019-01-31'))
# plt.xticks(rotation='vertical')
# plt.xticks(rotation=30)
plt.gcf().autofmt_xdate()
# plt.savefig('NOAA.png') #保存圖片
plt.show()

在這里插入圖片描述

TEM=china['TEM']
# TEM1 = [-i for i in TEM]
plt.figure(figsize=(31,8))
plt.title('中國氣象網溫度與時間的函數')  #有標題(風速與風向的函數)
plt.xlabel('時間') #橫坐標的標題
plt.ylabel('溫度(℃)') #縱坐標的標題
plt.grid(color='#95a5a6',linestyle='--',linewidth=3,axis='both',alpha=0.4) #設置網格
plt.plot(china_time1,TEM,marker='o',c='y')
# plt.xticks(pd.date_range('2019-01-01','2019-01-31'))
# plt.xticks(rotation='vertical')
# plt.xticks(rotation=30)
plt.gcf().autofmt_xdate()
# plt.savefig('NOAA.png') #保存圖片
plt.show()

在這里插入圖片描述

PRS=china['PRS']
# 將百帕轉化成帕
# 1百帕(hpa)=100帕斯卡(Pa)
PRS1=[]
for i in PRS:
    PRS1.append(i*100)
plt.figure(figsize=(31,8))
plt.title('中國氣象網氣壓與時間的函數')  #有標題(風速與風向的函數)
plt.xlabel('時間') #橫坐標的標題
plt.ylabel('氣壓(Pa)') #縱坐標的標題
plt.grid(color='#95a5a6',linestyle='--',linewidth=3,axis='both',alpha=0.4) #設置網格
plt.plot(china_time1,PRS1,marker='o',c='y')
# plt.xticks(pd.date_range('2019-01-01','2019-01-31'))
# plt.xticks(rotation='vertical')
# plt.xticks(rotation=30)
plt.gcf().autofmt_xdate()
# plt.savefig('NOAA.png') #保存圖片
plt.show()

在這里插入圖片描述

四、GFS(方正附近,46.0、128.75,梁晨)

from datetime import datetime
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
df1 = pd.read_csv("C:\\Users\\zzh\Desktop\\20191130-1209.csv",header=None)
print(df1[:5])
                     0                    1     2        3       4     5  \
0  2019-12-09 06:00:00  2019-12-09 06:00:00  GUST  surface  128.00  45.0   
1  2019-12-09 06:00:00  2019-12-09 06:00:00  GUST  surface  128.25  45.0   
2  2019-12-09 06:00:00  2019-12-09 06:00:00  GUST  surface  128.50  45.0   
3  2019-12-09 06:00:00  2019-12-09 06:00:00  GUST  surface  128.75  45.0   
4  2019-12-09 06:00:00  2019-12-09 06:00:00  GUST  surface  129.00  45.0   

        6  
0  7.1135  
1  2.3135  
2  3.2135  
3  4.1135  
4  3.4135  
df1.columns=["time1","time2","WindSpeed","level","longitude","latitude","value"]
print(df1[:5])
                 time1                time2 WindSpeed    level  longitude  \
0  2019-12-09 06:00:00  2019-12-09 06:00:00      GUST  surface     128.00   
1  2019-12-09 06:00:00  2019-12-09 06:00:00      GUST  surface     128.25   
2  2019-12-09 06:00:00  2019-12-09 06:00:00      GUST  surface     128.50   
3  2019-12-09 06:00:00  2019-12-09 06:00:00      GUST  surface     128.75   
4  2019-12-09 06:00:00  2019-12-09 06:00:00      GUST  surface     129.00   

   latitude   value  
0      45.0  7.1135  
1      45.0  2.3135  
2      45.0  3.2135  
3      45.0  4.1135  
4      45.0  3.4135  
#df2=df1[(df1["longitude"]==128.75)&(df1["latitude"]==46.00)]
df1 =df1.sort_values("time1",inplace=False)
df1 = df1.reset_index(drop=True)
n_time=[]
for i in range(0,df1.iloc[:,0].size):
    if (df1["longitude"][i]==128.75)&(df1["latitude"][i]==46.00):
        n_time.append(datetime.strptime( df1["time1"][i], "%Y-%m-%d %H:%M:%S"))
n_gust=[]
for i in range(0,df1.iloc[:,0].size):
    if (df1["longitude"][i]==128.75)&(df1["latitude"][i]==46.00):
        n_gust.append(df1["value"][i])
plt.figure(figsize=(30,8))
plt.plot(n_time,n_gust,'go-')
plt.title("201903-09 00:00 06:00 12:00 18:00 GUST")
Text(0.5, 1.0, '201903-09  00:00 06:00 12:00 18:00   GUST')

在這里插入圖片描述

五、對比圖

plt.figure(figsize=(31,8))
plt.title('風速與時間的函數')  #有標題(風速與風向的函數)
plt.xlabel('時間') #橫坐標的標題
plt.ylabel('風速(m/s)') #縱坐標的標題
plt.grid(color='#95a5a6',linestyle='--',linewidth=3,axis='both',alpha=0.4) #設置網格
plt.plot(time1,c,marker='o',c='r',label='ECMWF')#ECMWF
plt.plot(TIME2,SPD1,marker='o',c='g',label='NOAA')#NOAA
plt.plot(n_time,n_gust,marker='o',c='b',label='GFS')#GFS
plt.plot(china_time1,WIN_S_Avg_2mi,marker='o',c='y',label='中國氣象網')#中國氣象網
# plt.xticks(pd.date_range('2019-01-01','2019-01-31'))
plt.xticks(rotation='vertical')
# plt.xticks(rotation=30)
# plt.gcf().autofmt_xdate()
plt.legend(loc='best')
plt.gcf().autofmt_xdate()
plt.savefig('風速對比圖') #保存圖片
plt.show()

在這里插入圖片描述

plt.figure(figsize=(31,8))
plt.title('溫度與時間的函數')  #有標題(風速與風向的函數)
plt.xlabel('時間') #橫坐標的標題
plt.ylabel('溫度(℃)') #縱坐標的標題
plt.grid(color='#95a5a6',linestyle='--',linewidth=3,axis='both',alpha=0.4) #設置網格
plt.plot(time1,t2m2,marker='o',c='r',label='ECMWF')#ECMWF
plt.plot(TIME2,TEMP1,marker='o',c='g',label='NOAA')#NOAA
# plt.plot(china_time1,TEM,marker='o',c='y',label='中國氣象網')#中國氣象網
# plt.xticks(pd.date_range('2019-01-01','2019-01-31'))
plt.xticks(rotation='vertical')
# plt.xticks(rotation=30)
# plt.gcf().autofmt_xdate()
plt.legend(loc='best')
plt.gcf().autofmt_xdate()
plt.savefig('溫度對比圖') #保存圖片
plt.show()

在這里插入圖片描述

plt.figure(figsize=(31,8))
plt.title('氣壓與時間的函數')  #有標題(風速與風向的函數)
plt.xlabel('時間') #橫坐標的標題
plt.ylabel('氣壓(Pa)') #縱坐標的標題
plt.grid(color='#95a5a6',linestyle='--',linewidth=3,axis='both',alpha=0.4) #設置網格
plt.plot(time1,e,marker='o',c='r',label='ECMWF')#ECMWF
plt.plot(TIME2,STP1,marker='o',c='g',label='NOAA',)#NOAA
plt.plot(china_time1,PRS1,marker='o',c='y',label='中國氣象網')#中國氣象網
# plt.xticks(pd.date_range('2019-01-01','2019-01-31'))
plt.xticks(rotation='vertical')
# plt.xticks(rotation=30)
# plt.gcf().autofmt_xdate()
plt.legend(loc='best')
plt.gcf().autofmt_xdate()
plt.savefig('氣壓對比圖') #保存圖片
plt.show()

在這里插入圖片描述


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM