basic shock detection
This commit is contained in:
		@@ -12,10 +12,14 @@ shot-info:
 | 
			
		||||
  config: "x2s5823.config"
 | 
			
		||||
  info: "x2s5823.txt"
 | 
			
		||||
 | 
			
		||||
pcb-refs:
 | 
			
		||||
  - "st1"
 | 
			
		||||
  - "st3"
 | 
			
		||||
 | 
			
		||||
probe-info:
 | 
			
		||||
  type: "Fat"
 | 
			
		||||
  locations: # In order of pulse
 | 
			
		||||
    - "ST2"
 | 
			
		||||
    - "st2"
 | 
			
		||||
  overhang: 1 # mm
 | 
			
		||||
  c2c: 5.6 # mm
 | 
			
		||||
  gauge-diam: 3.05 # mm
 | 
			
		||||
 
 | 
			
		||||
@@ -12,11 +12,14 @@ shot-info:
 | 
			
		||||
  config: "x2s5824.config"
 | 
			
		||||
  info: "x2s5824.txt"
 | 
			
		||||
 | 
			
		||||
pcb-refs:
 | 
			
		||||
  - "st1"
 | 
			
		||||
  - "st3"
 | 
			
		||||
 | 
			
		||||
probe-info:
 | 
			
		||||
  type: "Thin"
 | 
			
		||||
  locations: # In order of pulse
 | 
			
		||||
    - "ST2"
 | 
			
		||||
    - "st2"
 | 
			
		||||
  overhang: 1 # mm
 | 
			
		||||
  c2c: 5.6 # mm
 | 
			
		||||
  gauge-diam: 0.8 # mm
 | 
			
		||||
 
 | 
			
		||||
@@ -12,12 +12,14 @@ shot-info:
 | 
			
		||||
  config: "x2s5827.config"
 | 
			
		||||
  info: "x2s5827.txt"
 | 
			
		||||
 | 
			
		||||
pcb-refs:
 | 
			
		||||
  - "st1"
 | 
			
		||||
 | 
			
		||||
probe-info:
 | 
			
		||||
  type: "Thin"
 | 
			
		||||
  locations: # In order of pulse
 | 
			
		||||
    - "ST2"
 | 
			
		||||
    - "ST3"
 | 
			
		||||
    - "st2"
 | 
			
		||||
    - "st3"
 | 
			
		||||
  overhang: 1 # mm
 | 
			
		||||
  c2c: 5.6 # mm
 | 
			
		||||
  gauge-diam: 0.8 # mm
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										70
									
								
								main.py
									
									
									
									
									
								
							
							
						
						
									
										70
									
								
								main.py
									
									
									
									
									
								
							@@ -169,9 +169,44 @@ def load_data(data_to_load: list[str]) -> dict:
 | 
			
		||||
            data[x2_shot]["data"]["scope"] = {}
 | 
			
		||||
            for i, header in enumerate(scope_header):
 | 
			
		||||
                if i == 0: continue # Don't record time
 | 
			
		||||
                data[x2_shot]["data"]["scope"][header] = scope_data[:, i]
 | 
			
		||||
 | 
			
		||||
                # Python reference so its the same object
 | 
			
		||||
                ref = scope_data[:, i]
 | 
			
		||||
                data[x2_shot]["data"]["scope"][i] = ref
 | 
			
		||||
                data[x2_shot]["data"]["scope"][header] = ref
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        # Find Shock Times
 | 
			
		||||
        # X2 - Canning Edge
 | 
			
		||||
        data[x2_shot]["shock-point"] = {}
 | 
			
		||||
        for ref in dataInfo["pcb-refs"]:
 | 
			
		||||
            refData = data[x2_shot]["data"]["x2"][ref]
 | 
			
		||||
            first_value, first_value_uncertainty, _, _ = canny_shock_finder(x2_time_us, refData, plot=False)
 | 
			
		||||
            shock_point = np.where(x2_time_us >= first_value)[0][0] # [BUG] Seems to give n+1
 | 
			
		||||
            
 | 
			
		||||
            data[x2_shot]["shock-point"][ref] = shock_point, first_value
 | 
			
		||||
        
 | 
			
		||||
        for probe in dataInfo["probe-info"]["locations"]:
 | 
			
		||||
            probeCh1 = data[x2_shot]["data"]["scope"][1]
 | 
			
		||||
            probeCh2 = data[x2_shot]["data"]["scope"][2]
 | 
			
		||||
 | 
			
		||||
            #first_value, first_value_uncertainty, _, _ = canny_shock_finder(scope_time, probeCh1, plot=True)
 | 
			
		||||
            #shock_point = np.where(scope_time >= first_value)[0][0] # [BUG] Seems to give n+1
 | 
			
		||||
            
 | 
			
		||||
            #[HACK] For detection
 | 
			
		||||
            shock_point = np.where(probeCh1 >= 0.3)[0][0]
 | 
			
		||||
            first_value = scope_time[shock_point]
 | 
			
		||||
            data[x2_shot]["shock-point"][f"{probe}-g1"] = shock_point, first_value
 | 
			
		||||
 | 
			
		||||
            #first_value, first_value_uncertainty, _, _ = canny_shock_finder(scope_time, probeCh2, plot=False)
 | 
			
		||||
            #shock_point = np.where(scope_time >= first_value)[0][0] # [BUG] Seems to give n+1
 | 
			
		||||
                
 | 
			
		||||
            #[HACK] For detection
 | 
			
		||||
            shock_point = np.where(probeCh2 >= 0.3)[0][0]
 | 
			
		||||
            first_value = scope_time[shock_point]
 | 
			
		||||
            data[x2_shot]["shock-point"][f"{probe}-g2"] = shock_point, first_value
 | 
			
		||||
            
 | 
			
		||||
        
 | 
			
		||||
    # Return the data & the successfully loaded data keys  
 | 
			
		||||
    return data, tuple(data.keys())
 | 
			
		||||
    
 | 
			
		||||
@@ -189,27 +224,54 @@ def genGraph(gData: dict, showPlot: bool = True):
 | 
			
		||||
        "plots": []
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    for label in ["st1", "st3", "trigbox"]:
 | 
			
		||||
    for label in gData["info"]["pcb-refs"] + ["trigbox"]:
 | 
			
		||||
        graphData["plots"].append({
 | 
			
		||||
            "x": gData["time"]["x2"],
 | 
			
		||||
            "y": gData["data"]["x2"][label],
 | 
			
		||||
            "label": label
 | 
			
		||||
        })
 | 
			
		||||
 | 
			
		||||
    for label, d in [("1 [V]", "G1"),("2 [V]", "G1"), ("4 [V]", "Gauge Trigger")]:
 | 
			
		||||
        if label in gData["info"]["pcb-refs"]:
 | 
			
		||||
            graphData["plots"].append({
 | 
			
		||||
                "type": "axvLine",
 | 
			
		||||
                "x": gData["shock-point"][label][1],
 | 
			
		||||
                "label": f"{label} - Shock Point {gData["shock-point"][label][1]}$\\mu$s",
 | 
			
		||||
                "colour": "gray",
 | 
			
		||||
                "args":{"zorder":2, "linestyle":"--"}
 | 
			
		||||
            })
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    for label, d in [("1 [V]", "G1"),("2 [V]", "G2"), ("4 [V]", "Gauge Trigger")]:
 | 
			
		||||
        graphData["plots"].append({
 | 
			
		||||
            "x": gData["time"]["scope"],
 | 
			
		||||
            "y": gData["data"]["scope"][label],
 | 
			
		||||
            "label": d
 | 
			
		||||
        })
 | 
			
		||||
 | 
			
		||||
    for probe in gData["info"]["probe-info"]["locations"]:
 | 
			
		||||
        graphData["plots"].append({
 | 
			
		||||
            "type": "axvLine",
 | 
			
		||||
            "x": gData["shock-point"][f"{probe}-g1"][1],
 | 
			
		||||
            "label": f"{label}-G1 - Shock Point {gData["shock-point"][f"{probe}-g1"][1]}$\\mu$s",
 | 
			
		||||
            "colour": "gray",
 | 
			
		||||
            "args":{"zorder":2, "linestyle":"--"}
 | 
			
		||||
        })
 | 
			
		||||
        graphData["plots"].append({
 | 
			
		||||
            "type": "axvLine",
 | 
			
		||||
            "x": gData["shock-point"][f"{probe}-g2"][1],
 | 
			
		||||
            "label": f"{label}-G2 - Shock Point {gData["shock-point"][f"{probe}-g2"][1]}$\\mu$s",
 | 
			
		||||
            "colour": "gray",
 | 
			
		||||
            "args":{"zorder":2, "linestyle":"--"}
 | 
			
		||||
        })
 | 
			
		||||
    
 | 
			
		||||
    makeGraph(graphData, doProgramBlock=False, showPlot=showPlot, figSavePath="./images/{0}.png")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
print("Graphing showPlot=showPlot, Data")
 | 
			
		||||
print("Graphing Data")
 | 
			
		||||
genGraph(data[loaded_data[0]], showPlot=False)
 | 
			
		||||
genGraph(data[loaded_data[1]], showPlot=False)
 | 
			
		||||
genGraph(data[loaded_data[2]], showPlot=False)
 | 
			
		||||
 | 
			
		||||
from pprint import pprint
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user