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

35
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,15 +85,23 @@ 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]
print("Graphing Data")
gData = data[loaded_data[0]]
trigger_info = gData["info"]["probe-info"]["data-record"]["trigger"] # Get the scope trigger info
x2_time = (gData["x2"][0][:] - gData["x2"][0][0]).astype('timedelta64[ns]')
# 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')
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')
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"]}",
@ -134,6 +144,17 @@ graphData = {
]
}
makeGraph(graphData)
gData = data[loaded_data[0]]
x2_time, scope_time = process_data(gData)
x2_out = canny_shock_finder(x2_time, (gData["x2"][4][:] - gData["x2"][4][0]) * 0.0148, plot=False)
print(x2_out)
input("foo")
#print("Graphing Data")
#genGraph(data[loaded_data[0]])
#genGraph(data[loaded_data[1]])