#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Feb 21 12:36:32 2019

@author: marc
"""

import numpy as np
import matplotlib.pyplot as plt

#read output data
params=np.loadtxt('data2/plotmat.dat');
nx = int(params[2,0])
ny = int(params[2,1])
dx = params[3,0]
x = dx*np.arange(nx)+dx/2-1000
h=np.fromfile('data2/rho.bin',dtype=np.float32)
h=np.reshape(h,(nx,ny,-1),order='F')
nbim=int(h.size/nx/ny)
t=np.loadtxt('data2/time_im.d')

i10=np.argmin(np.abs(t-10))
i20=np.argmin(np.abs(t-20))

#Read analytical solution at 10s and 20s
# TODO : Replace with analytical expression of the solution
h10=np.loadtxt('t_10s.txt',delimiter=' ')
h20=np.loadtxt('t_20s.txt',delimiter=' ')
hanal=np.concatenate((h10,h20))

#Plot Results

fig=plt.figure(figsize=(10,5))
axe=plt.gca()
axe.plot(x,h[:,1,i10],label='t=10s')
axe.plot(x,h[:,1,i20],label='t=20s')
axe.plot(hanal[:,0],hanal[:,1],'ok',label='Analytical solution')
axe.legend()