diff --git a/observations.py b/observations.py index f2f9cbea1188f5d79239f48900ce75529e27e557..dc8e6a71aad832e94754bb75fdf456cc3fef41cb 100644 --- a/observations.py +++ b/observations.py @@ -7,6 +7,8 @@ import os import glob import pandas as pd +is_sorted = lambda a: np.all(a[:-1] <= a[1:]) + def decode_observations(observation_files): # Read set of CSV files into a pandas dataframe. @@ -98,19 +100,30 @@ if __name__ == '__main__': makeplots = True # Make plots if makeplots: + + # If observations are shuffled, sort them again + ntimes = ocoords.shape[0] + for k in range(ntimes): + if is_sorted(ocoords[k,:]): + pass + else: + indices = np.argsort(ocoords[k,:]) + ocoords[k,:] = ocoords[k,indices] + observations[k,:] = observations[k,indices] + fig, ax1 = p.subplots(1,1,constrained_layout=True) fig.set_size_inches(4,3) tint = 300 t = np.linspace(0,tint*(ocoords.shape[0]-1),ocoords.shape[0])[:,None]+np.zeros(ocoords.shape) t = t/3600. - c = ax1.scatter(t,ocoords,s=5,c=observations,vmin=290,vmax=296) - #c = ax1.pcolormesh(t,ocoords,observations,vmin=290,vmax=296) - #ax1.contour(t,ocoords,observations, - # np.linspace(290,290+0.003*2000,13), - # colors='white', - # linestyles='--', - # linewidths=0.75) + #c = ax1.scatter(t,ocoords,s=5,c=observations,vmin=290,vmax=296) + c = ax1.pcolormesh(t,ocoords,observations,vmin=290,vmax=296) + ax1.contour(t,ocoords,observations, + np.linspace(290,290+0.003*2000,13), + colors='white', + linestyles='--', + linewidths=0.75) ax1.set_ylim([0,2000]) ax1.set_ylabel(r'Height (m)') ax1.set_xlabel(r'Time (s)')