#!/usr/bin/env python

"""
Runs the conduction example, produces some output
"""

from __future__ import print_function
from boututils.run_wrapper import shell, launch, getmpirun
from boututils.plotdata import plotdata
from boutdata.collect import collect
import numpy as np

nproc = 2  # Number of processors to use


print("Making conduction example")
shell("make > make.log")

s, out = launch("./conduction ", nproc=nproc, pipe=True)
f = open("run.log", "w") # Save the output in a log file
f.write(out)
f.close()

# Collect the data
T = collect("T", path="data", xind=2, info=True, yguards=True)

# T has dimensions [Time, X, Y, Z]
# Make contour plot
plotdata(T[:,0,:,0])
