# -*- coding: utf-8 -*- """ Created on Tue Feb 4 16:30:16 2020 @author: ppantina """ import platform import time import numpy as np from PIL import Image import time import datetime ##Choose computer-name-based paths computer_name = platform.node() if (computer_name == 'gs614-ppantinwl'): plot_path = 'C:/HAR/programs/radar_rt_plot/' if (computer_name == 'erika.gsfc.nasa.gov'): plot_path = '/eraid2a/webshare/IMPACTS-2022/radar_rt_plot/' files = [plot_path + 'CRS/CRS_rt_current.png', plot_path + 'HIWRAP_KA/HIWRAP_KA_rt_current.png', plot_path + 'HIWRAP_KU/HIWRAP_KU_rt_current.png', plot_path + 'EXRAD/EXRAD_rt_current.png',] x_dim = 400 y_dim = 674 for k in range(10000): try: result = Image.new("RGB", (x_dim, y_dim),color=(255,255,255,0)) end_time = int(time.time()) ##set the end-time (RHS of plot) to current time start_time = end_time - 3600 ##grab 1 hr of data (LHS of initial plot) img = Image.open(files[0]) img.thumbnail((400, 400), Image.ANTIALIAS) a = img.crop((0, 0, 400, 168)) result.paste(a, (0, 0, a.size[0], a.size[1])) img = Image.open(files[1]) img.thumbnail((400, 400), Image.ANTIALIAS) b = img.crop((0, 0, 400, 168)) result.paste(b, (0, a.size[1], b.size[0], b.size[1] + a.size[1])) img = Image.open(files[2]) img.thumbnail((400, 400), Image.ANTIALIAS) c = img.crop((0, 0, 400, 168)) result.paste(c, (0, b.size[1] + a.size[1], c.size[0], c.size[1] + b.size[1] + a.size[1])) img = Image.open(files[3]) img.thumbnail((400, 400), Image.ANTIALIAS) d = img.crop((0, 0, 400, 170)) result.paste(d, (0, c.size[1] + b.size[1] + a.size[1], d.size[0], d.size[1] + c.size[1] + b.size[1] + a.size[1])) plot_savetime = datetime.datetime.fromtimestamp(int(time.time())) ##make plot save label result.save(plot_path + '/radars_rt_current_merge.png') if np.mod(k, 20) == 0: ##save an additional figure every x steps result.save(plot_path + '/merge/radars_rt_merge_' + 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 ('saving the plot') print ('Step ' + str(k)) except OSError: print ('Bad Image') time.sleep(6) #Increment the times start_time = np.copy(end_time)