diff --git a/data/x2s5824/_info.yaml b/data/x2s5824/_info.yaml index 18f5548..41837f6 100644 --- a/data/x2s5824/_info.yaml +++ b/data/x2s5824/_info.yaml @@ -16,8 +16,8 @@ shot-info: probe-info: type: "Thin" c2c: 5.6 # mm - gauge-diam: 3.05 # mm - gauge-c2c: 4 #mm + gauge-diam: 0.8 # mm + gauge-c2c: 1.8 #mm data-record: type: "scope" config: "eProbe-Scope.txt" @@ -26,7 +26,7 @@ probe-info: trigger: # Redundant? type: "channel" channel: 4 - alignment-offset: 0 # ns + alignment-offset: 499500 # ns delay: 100 # us diff --git a/main.py b/main.py index 39d6605..30eb93a 100644 --- a/main.py +++ b/main.py @@ -11,6 +11,8 @@ import yaml from nptdms import TdmsFile from makeGraph import makeGraph, pltKeyClose, UQ_COLOURS as UQC +from canny_shock_finder import canny_shock_finder + # Folder correction # Make sure the relevant folders folder exists folders = ["./images"] @@ -83,57 +85,76 @@ loaded_data = list(data.keys()) print("Loaded Data") +def process_data(gData): + x2_time = (gData["x2"][0][:] - gData["x2"][0][0]).astype('timedelta64[ns]') # Convert x2 to timedelta64[ns] + + trigger_info = gData["info"]["probe-info"]["data-record"]["trigger"] # Get the scope trigger info + + # Convert the scope times into timedelta64 & apply config offsets & delays + scope_time = np.array([ pd.Timedelta(t, 's').to_numpy() for t in (gData["probes"][:, 0] - gData["probes"][0, 0])]) + scope_time =- np.timedelta64(trigger_info["alignment-offset"], 'ns') + scope_time =+ np.timedelta64(trigger_info["delay"], 'us') + + + + return x2_time, scope_time + + +def genGraph(gData): + x2_time, scope_time = process_data(gData) + + graphData = { + "title": f"Shock response Time\nFor {gData["info"]["long_name"]}", + "xLabel": "Time (ns)", + "yLabel": "Voltage Reading (V)", + "grid": True, + "plots": [ + { + "x": x2_time, + "y": (gData["x2"][4][:] - gData["x2"][4][0]) * 0.0148, + "label": "ST1" + }, + { + "x": x2_time, + "y": (gData["x2"][6][:] - gData["x2"][6][0]) * 0.0148, + "label": "ST3" + }, + { + "x": x2_time, + "y": (gData["x2"][16][:] - gData["x2"][16][0])/1000, + "label": "Trigger" + }, + + { + "x": scope_time, + "y": (gData["probes"][:, 1] - gData["probes"][0, 1]), + "label": "ST2-G1" + }, + { + "x": scope_time, + "y": (gData["probes"][:, 2] - gData["probes"][0, 2]), + "label": "ST2-G2" + }, + { + "x": scope_time, + "y": (gData["probes"][:, 3] - gData["probes"][0, 3]), + "label": "ST2-Trigger" + }, + + ] + } + + makeGraph(graphData) + -print("Graphing Data") gData = data[loaded_data[0]] +x2_time, scope_time = process_data(gData) -x2_time = (gData["x2"][0][:] - gData["x2"][0][0]).astype('timedelta64[ns]') +x2_out = canny_shock_finder(x2_time, (gData["x2"][4][:] - gData["x2"][4][0]) * 0.0148, plot=False) +print(x2_out) +input("foo") -trigger_info = gData["info"]["probe-info"]["data-record"]["trigger"] -scope_time = np.array([ pd.Timedelta(t, 's').to_numpy() for t in (gData["probes"][:, 0] - gData["probes"][0, 0])]) - np.timedelta64(trigger_info["alignment-offset"], 'ns') + np.timedelta64(trigger_info["delay"], 'us') - -graphData = { - "title": f"Shock response Time\nFor {gData["info"]["long_name"]}", - "xLabel": "Time (ns)", - "yLabel": "Voltage Reading (V)", - "grid": True, - "plots": [ - { - "x": x2_time, - "y": (gData["x2"][4][:] - gData["x2"][4][0]) * 0.0148, - "label": "ST1" - }, - { - "x": x2_time, - "y": (gData["x2"][6][:] - gData["x2"][6][0]) * 0.0148, - "label": "ST3" - }, - { - "x": x2_time, - "y": (gData["x2"][16][:] - gData["x2"][16][0])/1000, - "label": "Trigger" - }, - - { - "x": scope_time, - "y": (gData["probes"][:, 1] - gData["probes"][0, 1]), - "label": "ST2-G1" - }, - { - "x": scope_time, - "y": (gData["probes"][:, 2] - gData["probes"][0, 2]), - "label": "ST2-G2" - }, - { - "x": scope_time, - "y": (gData["probes"][:, 3] - gData["probes"][0, 3]), - "label": "ST2-Trigger" - }, - - ] -} - - - -makeGraph(graphData) +#print("Graphing Data") +#genGraph(data[loaded_data[0]]) +#genGraph(data[loaded_data[1]]) \ No newline at end of file