Use all speed values
This commit is contained in:
		| @@ -23,26 +23,26 @@ canny-args: | |||||||
|  |  | ||||||
| no-graph: | no-graph: | ||||||
|   - "None" |   - "None" | ||||||
|   # - "at1" |   - "at1" | ||||||
|   # - "at2" |   - "at2" | ||||||
|   # - "at3" |   - "at3" | ||||||
|  |  | ||||||
|   # - "at4" |   - "at4" | ||||||
|   # - "at5" |   - "at5" | ||||||
|   # - "at6" |   - "at6" | ||||||
|  |  | ||||||
| pcb-refs: | pcb-refs: | ||||||
|   #- "at1" |  | ||||||
|   #- "at2" |  | ||||||
|   #- "at3" |  | ||||||
|   # |  | ||||||
|   #- "at4" |  | ||||||
|   #- "at5" |  | ||||||
|   #- "at6" |  | ||||||
|  |  | ||||||
|   - "st1" |   - "st1" | ||||||
|   - "st3" |   - "st3" | ||||||
|    |    | ||||||
|  |   - "at1" | ||||||
|  |   - "at2" | ||||||
|  |   - "at3" | ||||||
|  |    | ||||||
|  |   - "at4" | ||||||
|  |   - "at5" | ||||||
|  |   - "at6" | ||||||
|  |  | ||||||
| probe-info: | probe-info: | ||||||
|   type: "Thin" |   type: "Thin" | ||||||
|   overhang: 1 # mm |   overhang: 1 # mm | ||||||
|   | |||||||
| @@ -26,25 +26,26 @@ canny-args: | |||||||
|  |  | ||||||
| no-graph: | no-graph: | ||||||
|   - "None" |   - "None" | ||||||
|   # - "at1" |   - "at1" | ||||||
|   # - "at2" |   - "at2" | ||||||
|   # - "at3" |   - "at3" | ||||||
|  |  | ||||||
|   # - "at4" |   - "at4" | ||||||
|   # - "at5" |   - "at5" | ||||||
|   # - "at6" |   - "at6" | ||||||
|  |  | ||||||
| pcb-refs: | pcb-refs: | ||||||
|   #- "at1" |  | ||||||
|   #- "at2" |  | ||||||
|   #- "at3" |  | ||||||
|   # |  | ||||||
|   #- "at4" |  | ||||||
|   #- "at5" |  | ||||||
|   #- "at6" |  | ||||||
|  |  | ||||||
|   - "st1" |   - "st1" | ||||||
|    |    | ||||||
|  |   - "at1" | ||||||
|  |   - "at2" | ||||||
|  |   - "at3" | ||||||
|  |    | ||||||
|  |   - "at4" | ||||||
|  |   - "at5" | ||||||
|  |   - "at6" | ||||||
|  |  | ||||||
|  |  | ||||||
| probe-info: | probe-info: | ||||||
|   type: "Thin" |   type: "Thin" | ||||||
|   overhang: 1 # mm |   overhang: 1 # mm | ||||||
|   | |||||||
| @@ -28,25 +28,26 @@ pcb-canny: | |||||||
|  |  | ||||||
| no-graph: | no-graph: | ||||||
|   - "None" |   - "None" | ||||||
|   # - "at1" |   - "at1" | ||||||
|   # - "at2" |   - "at2" | ||||||
|   # - "at3" |   - "at3" | ||||||
|  |  | ||||||
|   # - "at4" |   - "at4" | ||||||
|   # - "at5" |   - "at5" | ||||||
|   # - "at6" |   - "at6" | ||||||
|  |  | ||||||
| pcb-refs: | pcb-refs: | ||||||
|   #- "at1" |  | ||||||
|   #- "at2" |  | ||||||
|   #- "at3" |  | ||||||
|   # |  | ||||||
|   #- "at4" |  | ||||||
|   #- "at5" |  | ||||||
|   #- "at6" |  | ||||||
|  |  | ||||||
|   - "st1" |   - "st1" | ||||||
|    |    | ||||||
|  |   - "at1" | ||||||
|  |   - "at2" | ||||||
|  |   - "at3" | ||||||
|  |    | ||||||
|  |   - "at4" | ||||||
|  |   - "at5" | ||||||
|  |   - "at6" | ||||||
|  |  | ||||||
|  |  | ||||||
| probe-info: | probe-info: | ||||||
|   type: "Thin" |   type: "Thin" | ||||||
|   overhang: 1 # mm |   overhang: 1 # mm | ||||||
|   | |||||||
| @@ -35,6 +35,8 @@ no-graph: | |||||||
|   - "at6" |   - "at6" | ||||||
|  |  | ||||||
| pcb-refs: | pcb-refs: | ||||||
|  |   - "st1" | ||||||
|  |  | ||||||
|   - "at1" |   - "at1" | ||||||
|   - "at2" |   - "at2" | ||||||
|   - "at3" |   - "at3" | ||||||
| @@ -43,7 +45,6 @@ pcb-refs: | |||||||
|   - "at5" |   - "at5" | ||||||
|   - "at6" |   - "at6" | ||||||
|  |  | ||||||
|   - "st1" |  | ||||||
|  |  | ||||||
| probe-info: | probe-info: | ||||||
|   type: "Thin" |   type: "Thin" | ||||||
|   | |||||||
| @@ -13,6 +13,10 @@ shot-info: | |||||||
|   config: "{0}.config" |   config: "{0}.config" | ||||||
|   info: "{0}.txt" |   info: "{0}.txt" | ||||||
|  |  | ||||||
|  | pcb-canny: | ||||||
|  |   - sigma: 4 | ||||||
|  |     post_pres: 0.05 | ||||||
|  |  | ||||||
| # Canny Args | # Canny Args | ||||||
| canny-args: | canny-args: | ||||||
|   - sigma: 2 |   - sigma: 2 | ||||||
|   | |||||||
| @@ -29,13 +29,13 @@ canny-args: | |||||||
|  |  | ||||||
| no-graph: | no-graph: | ||||||
|   - "None" |   - "None" | ||||||
|   # - "at1" |   - "at1" | ||||||
|   # - "at2" |   - "at2" | ||||||
|   # - "at3" |   - "at3" | ||||||
|  |  | ||||||
|   # - "at4" |   - "at4" | ||||||
|   # - "at5" |   - "at5" | ||||||
|   # - "at6" |   - "at6" | ||||||
|  |  | ||||||
| pcb-refs: | pcb-refs: | ||||||
|   - "at1" |   - "at1" | ||||||
|   | |||||||
							
								
								
									
										35
									
								
								main.py
									
									
									
									
									
								
							
							
						
						
									
										35
									
								
								main.py
									
									
									
									
									
								
							| @@ -266,6 +266,8 @@ def load_data(data_path: str, data={}) -> dict: | |||||||
|             shock_point = np.where(scope_time >= first_value)[0][0] # [BUG] Seems to give n+1 |             shock_point = np.where(scope_time >= first_value)[0][0] # [BUG] Seems to give n+1 | ||||||
|             data[x2_shot]["shock-point"][f"{probe}-g2"] = shock_point, first_value |             data[x2_shot]["shock-point"][f"{probe}-g2"] = shock_point, first_value | ||||||
|  |  | ||||||
|  |      | ||||||
|  |      | ||||||
|     # Calculate Shock Speeds |     # Calculate Shock Speeds | ||||||
|     print("="*30, x2_shot, "="*30) |     print("="*30, x2_shot, "="*30) | ||||||
|     print("--", dataInfo["long_name"], "--") |     print("--", dataInfo["long_name"], "--") | ||||||
| @@ -278,7 +280,7 @@ def load_data(data_path: str, data={}) -> dict: | |||||||
|  |  | ||||||
|         probe_velocity = p2p_dist / abs(p2_time - p1_time) # m/s |         probe_velocity = p2p_dist / abs(p2_time - p1_time) # m/s | ||||||
|         print(f"{refProbe}-{dataInfo["pcb-refs"][i-1]} Measured a shock speed of {probe_velocity:.2f} m/s ({probe_velocity/1000:.2f} km/s)") |         print(f"{refProbe}-{dataInfo["pcb-refs"][i-1]} Measured a shock speed of {probe_velocity:.2f} m/s ({probe_velocity/1000:.2f} km/s)") | ||||||
|  |         data[x2_shot]["shock-speed"][f"{refProbe}-{dataInfo["pcb-refs"][i-1]}"] = probe_velocity, True # Speed, Ref | ||||||
|  |  | ||||||
|     print() |     print() | ||||||
|     for probe in dataInfo["probe-info"]["locations"]: |     for probe in dataInfo["probe-info"]["locations"]: | ||||||
| @@ -290,7 +292,7 @@ def load_data(data_path: str, data={}) -> dict: | |||||||
|             probe_velocity = c2c_dist / abs(g2_time - g1_time) # m/s |             probe_velocity = c2c_dist / abs(g2_time - g1_time) # m/s | ||||||
|  |  | ||||||
|             print(f"{probe} Measured a shock speed of {probe_velocity:.2f} m/s ({probe_velocity/1000:.2f} km/s)") |             print(f"{probe} Measured a shock speed of {probe_velocity:.2f} m/s ({probe_velocity/1000:.2f} km/s)") | ||||||
|             data[x2_shot]["shock-speed"][probe] = probe_velocity # m/s |             data[x2_shot]["shock-speed"][probe] = probe_velocity, False # Speed, Ref # m/s | ||||||
|         else: |         else: | ||||||
|             print(f"Unable to calculate probe velocity, only have one probe: {f"{probe}-g2" if f"{probe}-g2" in data[x2_shot]["shock-point"] else f"{probe}-g1"}") |             print(f"Unable to calculate probe velocity, only have one probe: {f"{probe}-g2" if f"{probe}-g2" in data[x2_shot]["shock-point"] else f"{probe}-g1"}") | ||||||
|  |  | ||||||
| @@ -304,16 +306,17 @@ def load_data(data_path: str, data={}) -> dict: | |||||||
|                 p1_g1_time = data[x2_shot]["shock-point"][f"{probe_locs[i]}-g1"][1] / 1e6 # Convert to seconds |                 p1_g1_time = data[x2_shot]["shock-point"][f"{probe_locs[i]}-g1"][1] / 1e6 # Convert to seconds | ||||||
|                 p2_g1_time = data[x2_shot]["shock-point"][f"{probe_locs[i+1]}-g1"][1] / 1e6 # Convert to seconds |                 p2_g1_time = data[x2_shot]["shock-point"][f"{probe_locs[i+1]}-g1"][1] / 1e6 # Convert to seconds | ||||||
|                 p2p_1 = p2p / abs(p2_g1_time - p1_g1_time) # m/s |                 p2p_1 = p2p / abs(p2_g1_time - p1_g1_time) # m/s | ||||||
|  |  | ||||||
|                 print(f"{probe_locs[i]}-{probe_locs[i + 1]} - G1 - Measured a shock speed of {p2p_1:.2f} m/s ({p2p_1/1000:.2f} km/s)") |                 print(f"{probe_locs[i]}-{probe_locs[i + 1]} - G1 - Measured a shock speed of {p2p_1:.2f} m/s ({p2p_1/1000:.2f} km/s)") | ||||||
|                 data[x2_shot]["shock-speed"][f"{probe_locs[i]}-{probe_locs[i + 1]}-g2"] = p2p_2 |                 data[x2_shot]["shock-speed"][f"{probe_locs[i]}-{probe_locs[i + 1]}-g1"] = p2p_1, False # Speed, Ref | ||||||
|              |              | ||||||
|             if f"{probe_locs[i]}-g2" in data[x2_shot]["shock-point"] and f"{probe_locs[i+1]}-g2" in data[x2_shot]["shock-point"]: |             if f"{probe_locs[i]}-g2" in data[x2_shot]["shock-point"] and f"{probe_locs[i+1]}-g2" in data[x2_shot]["shock-point"]: | ||||||
|                 p1_g2_time = data[x2_shot]["shock-point"][f"{probe_locs[i]}-g2"][1] / 1e6 # Convert to seconds |                 p1_g2_time = data[x2_shot]["shock-point"][f"{probe_locs[i]}-g2"][1] / 1e6 # Convert to seconds | ||||||
|                 p2_g2_time = data[x2_shot]["shock-point"][f"{probe_locs[i+1]}-g2"][1] / 1e6 # Convert to seconds |                 p2_g2_time = data[x2_shot]["shock-point"][f"{probe_locs[i+1]}-g2"][1] / 1e6 # Convert to seconds | ||||||
|                 p2p_2 = p2p / abs(p2_g2_time - p1_g2_time) # m/s |                 p2p_2 = p2p / abs(p2_g2_time - p1_g2_time) # m/s | ||||||
|                 print(f"{probe_locs[i]}-{probe_locs[i + 1]} - G2 - Measured a shock speed of {p2p_2:.2f} m/s ({p2p_2/1000:.2f} km/s)") |  | ||||||
|                 data[x2_shot]["shock-speed"][f"{probe_locs[i]}-{probe_locs[i + 1]}-g1"] = p2p_1 |  | ||||||
|  |  | ||||||
|  |                 print(f"{probe_locs[i]}-{probe_locs[i + 1]} - G2 - Measured a shock speed of {p2p_2:.2f} m/s ({p2p_2/1000:.2f} km/s)") | ||||||
|  |                 data[x2_shot]["shock-speed"][f"{probe_locs[i]}-{probe_locs[i + 1]}-g2"] = p2p_2, False # Speed, Ref | ||||||
|     print() |     print() | ||||||
|  |  | ||||||
|     # Return the data & the successfully loaded data keys |     # Return the data & the successfully loaded data keys | ||||||
| @@ -330,7 +333,7 @@ print("Loaded Data") | |||||||
|  |  | ||||||
|  |  | ||||||
| #[TODO] Refactor | #[TODO] Refactor | ||||||
| def genGraph(gData: dict, showPlot: bool = True): | def genGraph(gData: dict, showPlot: bool = True, doLimits: bool = True, forcePlots: bool = False): | ||||||
|     graphData = { |     graphData = { | ||||||
|         "title": f"Shock response Time\nFor {gData['info']['long_name']}", |         "title": f"Shock response Time\nFor {gData['info']['long_name']}", | ||||||
|         "xLabel": "Time ($\\mu$s)", |         "xLabel": "Time ($\\mu$s)", | ||||||
| @@ -344,7 +347,7 @@ def genGraph(gData: dict, showPlot: bool = True): | |||||||
|     lims = [] |     lims = [] | ||||||
|  |  | ||||||
|     for label in gData["info"]["pcb-refs"]: # + ["trigbox"]: |     for label in gData["info"]["pcb-refs"]: # + ["trigbox"]: | ||||||
|         if label in gData["info"]["no-graph"]: continue |         if not forcePlots and  label in gData["info"]["no-graph"]: continue | ||||||
|         graphData["plots"].append({ |         graphData["plots"].append({ | ||||||
|             "x": gData["time"]["x2"], |             "x": gData["time"]["x2"], | ||||||
|             "y": gData["data"]["x2"][label], |             "y": gData["data"]["x2"][label], | ||||||
| @@ -370,6 +373,7 @@ def genGraph(gData: dict, showPlot: bool = True): | |||||||
|         }) |         }) | ||||||
|  |  | ||||||
|     for i, probe in enumerate(gData["info"]["probe-info"]["locations"]): |     for i, probe in enumerate(gData["info"]["probe-info"]["locations"]): | ||||||
|  |         if f"{probe}-g1" in gData["shock-point"]: | ||||||
|             graphData["plots"].append({ |             graphData["plots"].append({ | ||||||
|                 "type": "axvLine", |                 "type": "axvLine", | ||||||
|                 "x": gData["shock-point"][f"{probe}-g1"][1],#[i], |                 "x": gData["shock-point"][f"{probe}-g1"][1],#[i], | ||||||
| @@ -377,6 +381,9 @@ def genGraph(gData: dict, showPlot: bool = True): | |||||||
|                 #"colour": "gray", |                 #"colour": "gray", | ||||||
|                 "args":{"zorder":2, "linestyle":"--"} |                 "args":{"zorder":2, "linestyle":"--"} | ||||||
|             }) |             }) | ||||||
|  |             lims.append(gData["shock-point"][f"{probe}-g1"][1]) | ||||||
|  |  | ||||||
|  |         if f"{probe}-g2" in gData["shock-point"]: | ||||||
|             graphData["plots"].append({ |             graphData["plots"].append({ | ||||||
|                 "type": "axvLine", |                 "type": "axvLine", | ||||||
|                 "x": gData["shock-point"][f"{probe}-g2"][1],#[i], |                 "x": gData["shock-point"][f"{probe}-g2"][1],#[i], | ||||||
| @@ -386,11 +393,12 @@ def genGraph(gData: dict, showPlot: bool = True): | |||||||
|             }) |             }) | ||||||
|  |  | ||||||
|             lims.append(gData["shock-point"][f"{probe}-g2"][1]) |             lims.append(gData["shock-point"][f"{probe}-g2"][1]) | ||||||
|         lims.append(gData["shock-point"][f"{probe}-g1"][1]) |  | ||||||
|  |  | ||||||
|     probeText = "" |     probeText = "" | ||||||
|     for shock_speed_loc in gData["shock-speed"]: |     for shock_speed_loc in gData["shock-speed"]: | ||||||
|         probeText += f"\n{shock_speed_loc} - {gData["shock-speed"][shock_speed_loc]/1000:.2f} km/s" |         probeText += "\n"  | ||||||
|  |         #probeText += "(Reference) " if gData["shock-speed"][shock_speed_loc][1] else "" | ||||||
|  |         probeText += f"{shock_speed_loc} - {gData["shock-speed"][shock_speed_loc][0]/1000:.2f} km/s" | ||||||
|  |  | ||||||
|     graphData["plots"].append({ |     graphData["plots"].append({ | ||||||
|         "type": "text", |         "type": "text", | ||||||
| @@ -399,12 +407,12 @@ def genGraph(gData: dict, showPlot: bool = True): | |||||||
|         "x": 0.94, "y": 0.94 |         "x": 0.94, "y": 0.94 | ||||||
|     }) |     }) | ||||||
|  |  | ||||||
|     #if len(lims) > 1: |     if doLimits and len(lims) > 1: | ||||||
|     #    OFFSET = 10 |         OFFSET = 10 | ||||||
|     #    graphData["xLim"] = (float(min(lims) - OFFSET), float(max(lims) + OFFSET)) |         graphData["xLim"] = (float(min(lims) - OFFSET), float(max(lims) + OFFSET)) | ||||||
|  |  | ||||||
|  |  | ||||||
|     makeGraph(graphData, doProgramBlock=False, showPlot=showPlot, figSavePath="./images/{0}.png") |     makeGraph(graphData, doProgramBlock=False, showPlot=showPlot, figSavePath=f"./images/{{0}}{"-noLims" if not doLimits else ""}.png") | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -412,6 +420,7 @@ print("Graphing Data") | |||||||
| for shot in loaded_data: | for shot in loaded_data: | ||||||
|     #if shot != loaded_data[-2]: continue |     #if shot != loaded_data[-2]: continue | ||||||
|     genGraph(data[shot], showPlot=False) |     genGraph(data[shot], showPlot=False) | ||||||
|  |     genGraph(data[shot], showPlot=False, doLimits=False, forcePlots=True) | ||||||
|  |  | ||||||
| # This forces matplotlib to hang until I tell it to close all windows | # This forces matplotlib to hang until I tell it to close all windows | ||||||
| pltKeyClose() | pltKeyClose() | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user