Advertisement
OreganoHauch

Weird list error?

Nov 14th, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. def plotIV(coordinate=None, sample_size=100, set_region=(0,999,0,999), showPosition=False, inset=False, figsize=(30,30), savepng=False, dpi=None, savepdf=False, annotations=False, data_processing=1, return_only=False):
  2.  
  3. start = time.time()
  4. # voltages
  5. voltages = [-1000, -500, -200, -100, 0, 100, 200, 500, 600]
  6. # scans (ordered by voltages)
  7. scans_ordered = [ 189, 188, 185, 183,181,182, 186, 187, 190]
  8.  
  9. # convert list to array
  10. voltages, scans_ordered = np.array(voltages), np.array(scans_ordered)
  11.  
  12. current_array_list = []
  13. current_mean = []
  14.  
  15. # plot either with or without negative values and select if the solar cell channel should be selected for the current
  16. options_dic = {
  17. 1: (False, False, "Lock in R , ohne Negativwerte"),
  18. 2: (False, True, "Lock in R, mit Negativwerten"),
  19. 3: (True, False, "solar cell channel, ohne Negativwerte"),
  20. 4: (True, True, "solar cell channel, mit Negativwerten")
  21. }
  22. if not return_only:
  23. print(options_dic[data_processing][2])
  24. A = 2 # plot only from scan_ordered[A] to ...
  25. B = -2 # ... scan_ordered[B]
  26. counter = 0
  27. for scan in scans_ordered[A:B]:
  28. positions = load_h5(scan, "positions")
  29. y_axis_h5 = positions["/data/encoder_fast/data"]
  30. z_axis_h5 = positions["/data/encoder_slow/data"]
  31. y_axis = np.array(y_axis_h5)
  32. z_axis = np.array(z_axis_h5)
  33. current = counts2amps(scan,solar_cell_channel_only=options_dic[data_processing][0], negative=options_dic[data_processing][1])
  34.  
  35. y_grid, z_grid, current_array = supergrid(y_axis,z_axis,current,1000)
  36.  
  37. if scan != 181:
  38. warp_matrix = ImageRegistrationDic[scan]
  39. current_array = cv2.warpAffine(current_array, warp_matrix, (1000, 1000), flags = cv2.INTER_LINEAR + cv2.WARP_INVERSE_MAP, borderValue = float("NaN")).astype(np.float32)
  40.  
  41. current_array_list.append(current_array)
  42. current_mean.append(np.nanmean(current_array))
  43.  
  44. print(current_mean[counter])
  45. print(f"Mean current for scan {scan} is {current_mean[counter]} nA. Its min/max current is {np.nanmin(current_array)}/{np.nanmax(current_array)} nA.")
  46. counter += 1
  47.  
  48. pixelplotting_array = np.stack(current_array_list)
  49.  
  50. if return_only:
  51. return current_array_list, pixelplotting_array
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement