1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
import sys
import json
import numpy as np
import pylab
def plot(X, Y, theory, data, err):
# print "theory",theory[1:6,1:6]
# print "data",data[1:6,1:6]
# print "delta",(data-theory)[1:6,1:6]
pylab.subplot(3, 1, 1)
pylab.pcolormesh(X, Y, data)
pylab.subplot(3, 1, 2)
pylab.pcolormesh(X, Y, theory)
pylab.subplot(3, 1, 3)
pylab.pcolormesh(X, Y, (data - theory) / (err + 1))
def load_results(filename):
"""
Reload results from the json file created by Peaks.save
"""
data = json.load(open(filename))
# Convert array info back into numpy arrays
data.update((k, np.array(data[k])) for k in ("X", "Y", "data", "err", "theory"))
return data
def main():
data = load_results(sys.argv[1])
plot(data["X"], data["Y"], data["theory"], data["data"], data["err"])
pylab.show()
if __name__ == "__main__":
main()
|