import numpy as np
import pandas as pd
import datetime
import re
import time
import glob
import copy
import matplotlib.dates as mdate
from scipy.interpolate import make_interp_spline
from scipy.interpolate import interp1d
from matplotlib import pyplot as plt
time_parse = lambda date: datetime.datetime.strptime(date, '%Y-%m-%d %H:%M:%S')
df = pd.read_csv(r'.20200713_0_000_20-07-13_194858_ASCt.csv',encoding='utf-8', parse_dates=['date'], date_parser=time_parse)
z = np.array(df['value'])
b = df.groupby('date')
pt = []
# 获得值
for date,b1 in b:
pt.append(np.array(b1['value']).reshape(len(b1['value']),1))
c= pt[0]
c= np.hstack((c,pt[1]))
z= c
df.set_index(df['date'],inplace=True)
print(z)
## 获得时间
a = df.groupby(['hb'])
o1 = a.get_group(2.18)
s= o1.index
# print(s)
c = []
x=np.array(s)
#
#
for et,val in a:
c.append(et)
y = np.array(c)*-1
print(x)
print(y)
# X,Y =np.meshgrid(x,y)
# print(X)
# print(Y)
plt.rcParams['font.sans-serif'] = 'Microsoft YaHei'
plt.gca().xaxis.set_major_formatter(mdate.DateFormatter('%Y-%m-%d %H:%M:%S'))
plt.xticks(pd.date_range(o1.index[0],o1.index[-1],freq='H'),rotation=45)
SC = plt.contourf(x,y,z,50,cmap = 'rainbow') # 200代表了等高线的数量
plt.colorbar()
C = plt.contour(x,y,z,5,colors = 'black') # 画出等值线
plt.clabel(C,inline = True,fontsize = 10) #标明等值线的大小
plt.show()