Start messing with data funcitons

This commit is contained in:
Cal Wing 2024-10-15 20:33:26 +10:00
parent 9a8cf1a2c2
commit 97669563d7
2 changed files with 73 additions and 52 deletions

View File

@ -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

119
main.py
View File

@ -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]])