import numpy as np from spmFunctions import import_matrix_file, get_path_gui import matplotlib.pyplot as plt file_path = get_path_gui() root_path = file_path.split("/default") # TODO include input somehow in the function calling. Need to think about the use cases. print("Type 0: up forward, 1: up retrace, 2: down forward, 3: down retrace") file_index = int(input()) image, image_raw = import_matrix_file(file_index, file_path) # Averaging image per row mean_array = np.mean(image, axis=1, dtype=np.float64) # Getting image size (number of points) and image height image_height = image_raw.height image_size = image.shape[0] # Creating an axis to plot the average value of Df x_axis = np.arange(start=0.0, stop=image_height, step=image_height / image_size) # in case you need to slice x,y to show in graph #x_axis = x_axis[:300] #mean_array = mean_array[:300] temp_title = file_path.split("--") plot_title = temp_title[1].replace("_mtrx", "")
import access2thematrix import matplotlib.pyplot as plt import numpy as np from spmFunctions import get_path_gui # Load data mtrx_data = access2thematrix.MtrxData() data_file = get_path_gui() traces, message = mtrx_data.open(data_file) im, _ = mtrx_data.select_image(traces[1]) image = im.data # Plot images plt.imshow(image) # Take max, min of each line im_max = np.max(image, axis=1) im_min = np.min(image, axis=1) im_diff = im_max - im_min # Split im_diff to get data we actually give a toss about im_diff_filtered = im_diff[im_diff <= 2e-9] # Make histrogram plt.hist(im_diff_filtered, bins=40) plt.xlabel("Height Difference.") plt.ylabel("Num.") plt.show()
# Starts with a .txt called in a folder. # Atributes order - #file_number,spec type (Df(Z),I(Z)),spec_files_number(234_1, 235_1, 233_1, 123 etc) # Creates a canvas based on the height of image number. Asks in terminal # if you want to get another image (like a .png). # root_paths must be edited for each folder you are working on # may need to change the forward slash in windows or linux! # Sybolic Links don't work here. Need to be a real path! root = f"/mnt/bigdrive/LTData/2020-08-03/" root_matrix = f"20200803-130406_GaAs(110)--AFM_NonContact_QPlus--" root_image_path = f"{root}{root_matrix}" root_specs_path = f"{root}specs/{root_matrix}" print("Select the input file")1 f = open(get_path_gui(), "r") txt_input = (f.read()).split(" ") # If looking at other images then Z you must change image_path string variable image_path = f"{root_image_path}{txt_input[0]}.Z_mtrx" specs_list = txt_input[2:] specs_list[-1] = specs_list[-1].rstrip("\n") specs_path = [] for item in specs_list: specs_path.append(f"{root_specs_path}{item}-{txt_input[1]}_1.txt") # Retreive size of image from image_path - and check if must keep it # TODO check if I really need this. For now use file_index=0 print("Select which image you want")
# Script for opening .txt and saving spec files exported from vernisage. import numpy as np import matplotlib.pyplot as plt from spmFunctions import load_spec, get_path_gui print("Select the ON curve") data_on_path = get_path_gui() print("Select the OFF curve") data_off_path = get_path_gui() data_on_tuple = load_spec(data_on_path) data_off_tuple = load_spec(data_off_path) # TODO rewrite this so it only uses the object now. Makes it simpler to read. data_forward_diff = np.asarray( [x - y for x, y in zip(data_on_tuple[0][:, 1], data_off_tuple[0][:, 1])] ) data_retrace_diff = np.asarray( [x - y for x, y in zip(data_on_tuple[1][:, 1], data_off_tuple[1][:, 1])] ) #TODO add the tick positions in this graph as I did in loadspecsript.py. plot_title_on = data_on_path.split("--")[1].replace(".txt", "") plot_title_off = data_off_path.split("--")[1].replace(".txt", "") plot_title = f"Df difference = {plot_title_on} (ON) - {plot_title_off} (OFF)" plt.plot(data_on_tuple[0][:, 0], data_forward_diff, "#2A9D8F") plt.plot(data_on_tuple[1][:, 0], data_retrace_diff, "#E9C46A") plt.title(plot_title) plt.xlabel("Z[nm]") plt.ylabel("Df[Hz]")