# Make plot of diurnal changes in TEMPO SO2 SCD and VCD and other parameters 
# for two oil/gas field in Gulf of Mexico

import h5py
import numpy as np
import matplotlib.pyplot as plt

# Read Input file
infile_Cantarell = 'TEMPO_SO2_diurnal_Cantarell.h5'
f = h5py.File(infile_Cantarell)
hours = f['/hour_all'][2:]
RMS_fit_mean_Cantarell = f['/RMS_fit_mean_all'][2:]
SCD_mean_Cantarell = f['/SCD_mean_all'][2:]
SCD_std_Cantarell = f['/SCD_std_all'][2:]
VCD_mean_Cantarell = f['/VCD_mean_all'][2:]
VCD_std_Cantarell = f['/VCD_std_all'][2:]
count_Cantarell = f['/count_all'][2:]
f.close()


# Make plots

fig, axes = plt.subplots(nrows=2,ncols=2,figsize=(13.5,8))
plt.rcParams.update({'font.size': 13})

axes[0,0].plot(hours, SCD_mean_Cantarell,'-o',color='black',label='Cantarell')
axes[0,0].set_ylabel('SO2 SCD (DU)',fontsize=15)
axes[0,0].set_ylim(0,0.4)
axes[0,0].set_xlim(11,23.5)
axes[0,0].text(11.2,0.4*0.9,'(a)',fontsize=15)


axes[0,1].plot(hours, VCD_mean_Cantarell,'-o',color='black',label='Cantarell')
axes[0,1].set_ylabel('SO2 VCD (DU)',fontsize=15)
axes[0,1].set_ylim(0,1.0)
axes[0,1].set_xlim(11,23.5)
axes[0,1].text(11.2,1.0*0.9,'(b)',fontsize=15)


axes[1,0].plot(hours, RMS_fit_mean_Cantarell,'-o',color='black',label='Cantarell')
axes[1,0].set_ylabel('RMS_fit',fontsize=15)
axes[1,0].set_xlabel('Hour (UTC)',fontsize=15)
axes[1,0].set_ylim(0.02,0.07)
axes[1,0].set_xlim(11,23.5)
axes[1,0].text(11.2,0.02+0.05*0.9,'(c)',fontsize=15)

axes[1,1].plot(hours, count_Cantarell,'-o',color='black',label='Cantarell')
axes[1,1].set_ylabel('Pixel Count',fontsize=15)
axes[1,1].set_xlabel('Hour (UTC)',fontsize=15)
axes[1,1].set_xlim(11,23.5)
axes[1,1].set_ylim(0,12000)
axes[1,1].text(11.2,12000*0.9,'(d)',fontsize=15)

#plt.tight_layout()
plt.savefig( 'FigureS4_TEMPO_SO2_diurnal_Cantarell.png')
plt.clf()
plt.close()
