import matplotlib.pyplot as plt import math import numpy as np import csv plt.style.use('_mpl-gallery-nogrid') running= True while(running): name = str(input("What is the name of the file you would like to analyze/edit?")) results = [] with open(name) as csvfile: reader = csv.reader(csvfile, quoting=csv.QUOTE_NONNUMERIC) #change contents to floats for row in reader: # each row is a list results.append(row) X,Y= np.meshgrid(np.linspace(0, len(results[0])-1, len(results[0])), np.linspace(0, len(results)-1, len(results))) Z=np.array(results) fig, ax = plt.subplots() print("Scale: ",np.amin(Z)," - ",np.amax(Z)) ax.pcolormesh(X, Y, Z, vmin=np.amin(Z), vmax=np.amax(Z)) plt.show() if(input("Would you like to export a subset? (y/n)")=="y"): startK = int(input("What is the x you would like to begin at? (includes endpoints)")) endK = int(input("How about end?")) startI = int(input("What is the y you would like to begin at?")) endI = int(input("And end?")) sizeK = endK-startK+1 sizeI = endI-startI+1 newArr = np.array([[0.0]*sizeK]*sizeI) i=startI while(i<=endI): k=startK while(k<=endK): newArr[i-startI][k-startK]=results[i][k] k+=1 i+=1 X,Y= np.meshgrid(np.linspace(0, len(newArr[0])-1, len(newArr[0])), np.linspace(0, len(newArr)-1, len(newArr))) Z=newArr fig, ax = plt.subplots() print("New Data"); print("Scale: ",np.amin(Z)," - ",np.amax(Z)) ax.pcolormesh(X, Y, Z, vmin=np.amin(Z), vmax=np.amax(Z)) plt.show() newName = "%s%d%s%d" % (name,len(newArr),"x",len(newArr[0])) np.savetxt(newName, newArr, delimiter=",") if(input("Would you like to change the scale? (y/n)")=="y"): max = float(input("What should the max value be?")) min = float(input("What should the min value be?")) fig, ax = plt.subplots() print("Scale: ",max," - ",min) ax.pcolormesh(X, Y, Z, vmin=min, vmax=max) plt.show() if(input("Would you like to continue analyzing? (y/n)")=="y"): running = True else: running = False