files=['Cl_pulse_1.hdf5','Ar_pulse_1.hdf5','Cl_pulse_2.hdf5','Ar_pulse_2.hdf5','Cl_pulse_3.hdf5','Ar_pulse_3.hdf5','Cl_pulse_4.hdf5','Ar_pulse_4.hdf5']
monolayer=16
hook=CleanVacuumRegion(fuzz_factor=1.15)
impact=[]
uptake=[]
total_impacts=0
for file in files:
    sps=nlread(file,SurfaceProcessSimulation)[-1]
    traj=sps.trajectories()
    for i in range(0,len(traj)):
        conf=traj[i].lastImage()
        hook._apply(conf)
        sym=conf.symbols()
        count=sym.count('Cl')
        impact.append(total_impacts+i)
        uptake.append(count/monolayer)
    total_impacts+=len(traj)
    
# PlotModel with custom units.
model = Plot.PlotModel()

# Set axis label and scale
model.xAxis().setLabel('Impacts')
model.yAxis().setLabel('Uptake [ML]')

#Line
line = Plot.Line(impact,uptake)

# Add line.
model.addItem(line)

# Auto-adjust axis limits.
model.setLimits()

# Show plot and save afterwards to file and as raster.
Plot.show(model)
Plot.save(model, 'uptake_plot.hdf5')
