Field_ID = 0
LineWidth = 1.5
FontSize = 8
LgdSize = 6
MinX = 5
MaxX = 35
MinY = -700
MaxY = 100

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

File_List=[
  'MCG_Template.h5', # 0
  'ALPHA_STAR_1.h5', # 1
  'ALPHA_STAR_2.h5', # 2
  'ALPHA_STAR_MINI_1.h5', # 3
  'ALPHA_STAR_MINI_2.h5', # 4
  'A_LW_1.h5', # 5
  'A_LW_2.h5', # 6
  'A_VCB_1.h5', # 7
  'A_VCB_2.h5', # 8
  'BETA_LW_1.h5', # 9
  'BETA_LW_2.h5', # 10
  'BETA_VCB_1.h5', # 11
  'BETA_VCB_2.h5', # 12
  'F_ESC7_MINI_1.h5', # 13
  'F_ESC7_MINI_2.h5', # 14
  'F_STAR10_1.h5', # 15
  'F_STAR10_2.h5', # 16
  'F_STAR7_MINI_1.h5', # 17
  'F_STAR7_MINI_2.h5', # 18
  'L_X_1.h5', # 19
  'L_X_2.h5', # 20
  'L_X_MINI_1.h5', # 21
  'L_X_MINI_2.h5', # 22
  'NU_X_THRESH_1.h5', # 23
  'NU_X_THRESH_2.h5', # 24
]

Field_List=[
  'brightness_temp', #0
  'Ts_box', #1
  'Tk_box', #2
  'xH_box', #3
  'Trad_box', #4
  'density', #5
  'dNrec_box', #6
  'Gamma12_box', #7
  'J_21_LW_box', #8
  'z_re_box', #9
  'Fcoll', #10
]
Y_Labels=[ 
    '$T_{21}$ (mK)',
    '$T_{\mathrm{s}}$ (K)',
    '$T_{\mathrm{k}}$ (K)',
    '$x_{\mathrm{H}}$',
    '$T_{\mathrm{Radio}}$ (K)',
    Field_List[Field_ID],
    Field_List[Field_ID],
    Field_List[Field_ID],
    Field_List[Field_ID],
    '$z_{\mathrm{rei}}$',
    '$f_{\mathrm{coll}}$'
]

FilePath = '/Users/cangtao/Desktop/cache21/MCG/'
Field = 'global_quantities/'+Field_List[Field_ID]
F0 = h5py.File(FilePath+File_List[0],'r')
F1 = h5py.File(FilePath+File_List[1],'r')
F2 = h5py.File(FilePath+File_List[2],'r')
F3 = h5py.File(FilePath+File_List[3],'r')
F4 = h5py.File(FilePath+File_List[4],'r')
F5 = h5py.File(FilePath+File_List[5],'r')
F6 = h5py.File(FilePath+File_List[6],'r')
F7 = h5py.File(FilePath+File_List[7],'r')
F8 = h5py.File(FilePath+File_List[8],'r')
F9 = h5py.File(FilePath+File_List[9],'r')
F10 = h5py.File(FilePath+File_List[10],'r')
F11 = h5py.File(FilePath+File_List[11],'r')
F12 = h5py.File(FilePath+File_List[12],'r')
F13 = h5py.File(FilePath+File_List[13],'r')
F14 = h5py.File(FilePath+File_List[14],'r')
F15 = h5py.File(FilePath+File_List[15],'r')
F16 = h5py.File(FilePath+File_List[16],'r')
F17 = h5py.File(FilePath+File_List[17],'r')
F18 = h5py.File(FilePath+File_List[18],'r')
F19 = h5py.File(FilePath+File_List[19],'r')
F20 = h5py.File(FilePath+File_List[20],'r')
F21 = h5py.File(FilePath+File_List[21],'r')
F22 = h5py.File(FilePath+File_List[22],'r')
F23 = h5py.File(FilePath+File_List[23],'r')
F24 = h5py.File(FilePath+File_List[24],'r')
# Reading data
z = F0['node_redshifts'][:]
T0 = F0[Field][:]
T1 = F1[Field][:]
T2 = F2[Field][:]
T3 = F3[Field][:]
T4 = F4[Field][:]
T5 = F5[Field][:]
T6 = F6[Field][:]
T7 = F7[Field][:]
T8 = F8[Field][:]
T9 = F9[Field][:]
T10 = F10[Field][:]
T11 = F11[Field][:]
T12 = F12[Field][:]
T13 = F13[Field][:]
T14 = F14[Field][:]
T15 = F15[Field][:]
T16 = F16[Field][:]
T17 = F17[Field][:]
T18 = F18[Field][:]
T19 = F19[Field][:]
T20 = F20[Field][:]
T21 = F21[Field][:]
T22 = F22[Field][:]
T23 = F23[Field][:]
T24 = F24[Field][:]

# Gett plot
plt.rcParams.update({'font.family':'Times'})
plt.rcParams['text.usetex'] = True
fig, axs = plt.subplots(3, 4, sharex = True, sharey = True)

axs[0, 0].plot(z,T0,color = 'k',linestyle='-',linewidth=1.5*LineWidth)
axs[0, 0].plot(z,T1,color = 'b',linestyle='-',linewidth=LineWidth,label='$/ 3$')
axs[0, 0].plot(z,T2,color = 'r',linestyle='-',linewidth=LineWidth,label='$\\times 3$')
axs[0, 0].legend(fontsize=LgdSize,loc = 'lower right')
axs[0, 0].set_title('ALPHA\_STAR',fontsize=FontSize)

axs[0, 1].plot(z,T0,color = 'k',linestyle='-',linewidth=1.5*LineWidth)
axs[0, 1].plot(z,T3,color = 'b',linestyle='-',linewidth=LineWidth,label='-0.5')
axs[0, 1].plot(z,T4,color = 'r',linestyle='-',linewidth=LineWidth,label='+0.5')
axs[0, 1].legend(fontsize=LgdSize,loc = 'lower right')
axs[0, 1].set_title('ALPHA\_STAR\_MINI',fontsize=FontSize)

axs[0, 2].plot(z,T0,color = 'k',linestyle='-',linewidth=1.5*LineWidth)
axs[0, 2].plot(z,T5,color = 'b',linestyle='-',linewidth=LineWidth,label='$/3$')
axs[0, 2].plot(z,T6,color = 'r',linestyle='-',linewidth=LineWidth,label='$\\times 3$')
axs[0, 2].legend(fontsize=LgdSize,loc = 'lower right')
axs[0, 2].set_title('A\_LW',fontsize=FontSize)

axs[0, 3].plot(z,T0,color = 'k',linestyle='-',linewidth=1.5*LineWidth)
axs[0, 3].plot(z,T7,color = 'b',linestyle='-',linewidth=LineWidth,label='$/3$')
axs[0, 3].plot(z,T8,color = 'r',linestyle='-',linewidth=LineWidth,label='$\\times 3$')
axs[0, 3].legend(fontsize=LgdSize,loc = 'lower right')
axs[0, 3].set_title('A\_VCB',fontsize=FontSize)

axs[1, 0].plot(z,T0,color = 'k',linestyle='-',linewidth=1.5*LineWidth)
axs[1, 0].plot(z,T9,color = 'b',linestyle='-',linewidth=LineWidth,label='$/2$')
axs[1, 0].plot(z,T10,color = 'r',linestyle='-',linewidth=LineWidth,label='$\\times 2$')
axs[1, 0].legend(fontsize=LgdSize,loc = 'lower right')
axs[1, 0].set_title('BETA\_LW',fontsize=FontSize)

axs[1, 1].plot(z,T0,color = 'k',linestyle='-',linewidth=1.5*LineWidth)
axs[1, 1].plot(z,T11,color = 'b',linestyle='-',linewidth=LineWidth,label='$/3$')
axs[1, 1].plot(z,T12,color = 'r',linestyle='-',linewidth=LineWidth,label='$\\times 3$')
axs[1, 1].legend(fontsize=LgdSize,loc = 'lower right')
axs[1, 1].set_title('BETA\_VCB',fontsize=FontSize)

axs[1, 2].plot(z,T0,color = 'k',linestyle='-',linewidth=1.5*LineWidth)
axs[1, 2].plot(z,T13,color = 'b',linestyle='-',linewidth=LineWidth,label='$/3$')
axs[1, 2].plot(z,T14,color = 'r',linestyle='-',linewidth=LineWidth,label='$\\times 3$')
axs[1, 2].legend(fontsize=LgdSize,loc = 'lower right')
axs[1, 2].set_title('F\_ESC7\_MINI',fontsize=FontSize)

axs[1, 3].plot(z,T0,color = 'k',linestyle='-',linewidth=1.5*LineWidth)
axs[1, 3].plot(z,T15,color = 'b',linestyle='-',linewidth=LineWidth,label='$/3$')
axs[1, 3].plot(z,T16,color = 'r',linestyle='-',linewidth=LineWidth,label='$\\times 3$')
axs[1, 3].legend(fontsize=LgdSize,loc = 'lower right')
axs[1, 3].set_title('F\_STAR10',fontsize=FontSize)

axs[2, 0].plot(z,T0,color = 'k',linestyle='-',linewidth=1.5*LineWidth)
axs[2, 0].plot(z,T17,color = 'b',linestyle='-',linewidth=LineWidth,label='$/3$')
axs[2, 0].plot(z,T18,color = 'r',linestyle='-',linewidth=LineWidth,label='$\\times 3$')
axs[2, 0].legend(fontsize=LgdSize,loc = 'lower right')
axs[2, 0].set_title('F\_STAR7\_MINI',fontsize=FontSize)

axs[2, 1].plot(z,T0,color = 'k',linestyle='-',linewidth=1.5*LineWidth)
axs[2, 1].plot(z,T19,color = 'b',linestyle='-',linewidth=LineWidth,label='$/3$')
axs[2, 1].plot(z,T20,color = 'r',linestyle='-',linewidth=LineWidth,label='$\\times 3$')
axs[2, 1].legend(fontsize=LgdSize,loc = 'lower right')
axs[2, 1].set_title('L\_X',fontsize=FontSize)

axs[2, 2].plot(z,T0,color = 'k',linestyle='-',linewidth=1.5*LineWidth)
axs[2, 2].plot(z,T21,color = 'b',linestyle='-',linewidth=LineWidth,label='$/3$')
axs[2, 2].plot(z,T22,color = 'r',linestyle='-',linewidth=LineWidth,label='$\\times 3$')
axs[2, 2].legend(fontsize=LgdSize,loc = 'lower right')
axs[2, 2].set_title('L\_X\_MINI',fontsize=FontSize)

axs[2, 3].plot(z,T0,color = 'k',linestyle='-',linewidth=1.5*LineWidth)
axs[2, 3].plot(z,T23,color = 'b',linestyle='-',linewidth=LineWidth,label='$/3$')
axs[2, 3].plot(z,T24,color = 'r',linestyle='-',linewidth=LineWidth,label='$\\times 3$')
axs[2, 3].legend(fontsize=LgdSize,loc = 'lower right')
axs[2, 3].set_title('NU\_X\_THRESH',fontsize=FontSize)

plt.xlim([MinX,MaxX])
plt.ylim([MinY,MaxY])
plt.yticks(np.arange(MinY,MaxY+200,200),size=FontSize)

for ax in axs.flat:
    ax.set(xlabel='$z$', ylabel='$T_{21}$ (K)')

# Hide x labels and tick labels for top plots and y ticks for right plots.
for ax in axs.flat:
    ax.label_outer()
plt.savefig('/Users/cangtao/Desktop/tmp.pdf',bbox_inches='tight')
os.system('open /Users/cangtao/Desktop/tmp.pdf')
