# -*- coding: utf-8 -*- """ Created on Sat Feb 1 08:09:10 2020 @author: ppantina """ # -*- coding: utf-8 -*- """ Created on Mon Dec 30 15:56:49 2019 @author: ppantina """ ##Import some libraries import sys from matplotlib import pyplot as plt import numpy as np import time import datetime ##Define some paths plot_path = '/eraid2a/webshare/IMPACTS-2022/radar_rt_plot/pressure/' sys.path.append('/home/ppantina/programs/subroutines') ##Choose between real or simulated data. This helps ##with changing the start/end times. ##Right now you still have to manually choose the simulated start time. real_time = int(input('Realtime or Simulated?\n\ REALTIME = 1\n\ SIMULATED = 2\n')) if real_time == 1: end_time = int(time.time())##set the end-time (RHS of plot) to current time, for REALTIME if real_time == 2: end_time = 1720712500 ##Epoch for SIMULATED data if real_time == 1: pause_time = 55 ##time to pause between images (essentially a time-step) if real_time == 2: pause_time = 0.2 ##time to pause between images (essentially a time-step) save_step = 10 import sub_radar_pressure import sub_plot_options_nrt #plot enhancer import sub_radar_processing from matplotlib.dates import MinuteLocator, DateFormatter minu = MinuteLocator(interval = 20) datesFmt = DateFormatter('%H:%M') fig = plt.figure(figsize = (11,8.5)) plt.ioff() for k in range(100000): start_time = end_time - 3600 ##grab 1 hr of data (LHS of initial plot) ##Read the IWG information sdateTemp, sdateD1, sdateD2, temp, druck1, druck2 = sub_radar_pressure.sub_druck_reader((start_time), int(end_time)) ##Format the end_time for figtext plottime = datetime.datetime.fromtimestamp(end_time + 3600*5.).strftime("%m/%d/%Y, %H:%M:%S") ##Make the plot ax = fig.add_subplot(211) #plot latlon ax.plot(sdateTemp, temp, 'k') ax.set_xlabel ('Time') ax.set_ylabel ('Temp [C]') ax.xaxis.set_major_locator (minu) ax.xaxis.set_major_formatter(datesFmt) ax.grid(True) ax = fig.add_subplot(212) ##plot the altitude ax.plot(sdateD1, druck1, color = 'red', label = 'DRUCK1') ax.plot(sdateD2, druck2, color = 'gold', linestyle = 'dashed', label = 'DRUCK2') ax.set_xlabel ('Time') ax.set_ylabel ('Pressure [mb]') #ax.set_ylim(50, 1000) ax.grid(True) ax.xaxis.set_major_locator (minu) ax.xaxis.set_major_formatter(datesFmt) plt.legend() ##Save the fit plt.figtext(0.50, 0.91, 'PSB Box Temp/Pressure at ' + plottime + 'UTC', fontsize = 12, horizontalalignment = 'center') #plt.tight_layout() ##maximixe space plt.savefig(plot_path + 'pressure_current.png') if np.mod(k, save_step) == 0: ##save an additional figure every x steps plot_savetime = datetime.datetime.fromtimestamp(end_time) plt.savefig(plot_path + 'pressure_' + str(plot_savetime.year) + str(plot_savetime.month).zfill(2) + str(plot_savetime.day).zfill(2) + str(plot_savetime.hour).zfill(2) + str(plot_savetime.minute).zfill(2) + str(plot_savetime.second).zfill(2) + '.png', bbox_inches='tight') print ('Step ' + str(k)) plt.pause(pause_time) plt.clf() ##Set starttime to endtime. Redefine endtime for next plot if real_time == 1: end_time = int(time.time())#REALTIME if real_time == 2: end_time = end_time + 300 #SIMULATED