from numpy import *
import numpy as np
from matplotlib.pyplot import *
import matplotlib as mpl
mpl.rcParams['xtick.major.size'] = 8
mpl.rcParams['xtick.minor.size'] = 4
mpl.rcParams['xtick.major.width'] = 1.5
mpl.rcParams['xtick.minor.width'] = 1.5
mpl.rcParams['ytick.major.size'] = 8
mpl.rcParams['ytick.minor.size'] = 4
mpl.rcParams['ytick.major.width'] = 1.5
mpl.rcParams['ytick.minor.width'] = 1.5

ticksize=20
labelsize=22

data=loadtxt('stof_1998_quiet_times.dat')

tof=data[:,0]
epqst=data[:,1]
energy=data[:,2]

mask=energy>36
H, xedges, yedges = np.histogram2d(tof[mask],epqst[mask],bins=[np.arange(0.5,400.5,1),np.arange(0.5,120,1)])
H = np.rot90(H)
H = np.flipud(H)
Hmasked = np.ma.masked_where(H==0,H)


figure(figsize=(14,10))
subplot(221)
pcolormesh(xedges,yedges,Hmasked)


ylim(1,120)
xlim(1,400)
#yscale('log')
#xscale('log')

xticks(fontsize=ticksize)
yticks(fontsize=ticksize)
xlabel(r'$\tau_{\#}$',fontsize=labelsize)
ylabel('$E/q_{\#}$',fontsize=labelsize)
tick_params(right='off',top='off',which='both')
#title('HSTOF',fontsize=labelsize)
show()
######################################################################################################

H, xedges, yedges = np.histogram2d(energy,epqst,bins=[np.arange(0.5,400.5,1),np.arange(0.5,120,1)])
H = np.rot90(H)
H = np.flipud(H)
Hmasked = np.ma.masked_where(H==0,H)

subplot(222)
pcolormesh(xedges,yedges,Hmasked)


ylim(1,120)
xlim(1,400)
#yscale('log')
#xscale('log')

xticks(fontsize=ticksize)
yticks(fontsize=ticksize)
xlabel('$E_{SSD\#}$',fontsize=labelsize)
ylabel('$E/q_{\#}$',fontsize=labelsize)
tick_params(right='off',top='off',which='both')
#title('HSTOF',fontsize=labelsize)
show()

######################################################################################################
H, xedges, yedges = np.histogram2d(tof,energy,bins=[np.arange(0.5,400.5,1),np.arange(0.5,200.5,1)])
H = np.rot90(H)
H = np.flipud(H)
Hmasked = np.ma.masked_where(H==0,H)

subplot(223)
pcolormesh(xedges,yedges,Hmasked)


ylim(1,200)
xlim(1,400)
#yscale('log')
#xscale('log')

xticks(fontsize=ticksize)
yticks(fontsize=ticksize)
xlabel(r'$\tau_{\#}$',fontsize=labelsize)
ylabel('$E_{SSD\#}$',fontsize=labelsize)
tick_params(right='off',top='off',which='both')
#title('HSTOF',fontsize=labelsize)
show()

######################################################################################################


m_q=data[:,3]
mass=data[:,4]

H, xedges, yedges = np.histogram2d(m_q,mass,bins=np.logspace(-1,2,300))
H = np.rot90(H)
H = np.flipud(H)
Hmasked = np.ma.masked_where(H==0,H)



subplot(224)
pcolormesh(xedges,yedges,Hmasked)


ylim(0.1,100)
xlim(0.1,100)
yscale('log')
xscale('log')

xticks([1,10,100],fontsize=ticksize)
yticks([0.1,1,10,100],fontsize=ticksize)
xlabel('Mass/Charge [amu/e]',fontsize=labelsize)
ylabel('Mass [amu]',fontsize=labelsize)
tick_params(right='off',top='off',which='both')
#title('HSTOF',fontsize=labelsize)
show()






tight_layout(pad=0.4,h_pad=0.01,w_pad=0.001)


