Add x2 data loading
This commit is contained in:
parent
8125efa26a
commit
511995830c
@ -25,6 +25,14 @@ canny-args:
|
||||
- sigma: 1
|
||||
post_pres: 0.05
|
||||
|
||||
|
||||
x2-canny:
|
||||
- sigma: 1
|
||||
post_pres: 0.02
|
||||
|
||||
- sigma: 0.5
|
||||
post_pres: 0.01
|
||||
|
||||
no-graph:
|
||||
- "at1"
|
||||
- "at2"
|
||||
@ -71,9 +79,13 @@ probe-info:
|
||||
|
||||
- type: "x2"
|
||||
channels: # Gauge Channel Name
|
||||
- "st2"
|
||||
- "st1"
|
||||
- "st3"
|
||||
|
||||
scaler:
|
||||
st1: 1
|
||||
st3: 10
|
||||
|
||||
trigger:
|
||||
type: "x2"
|
||||
# Info isn't really needed
|
||||
|
@ -27,6 +27,13 @@ canny-args:
|
||||
- sigma: 1
|
||||
post_pres: 0.05
|
||||
|
||||
x2-canny:
|
||||
- sigma: 1
|
||||
post_pres: 0.02
|
||||
|
||||
- sigma: 0.5
|
||||
post_pres: 0.02
|
||||
|
||||
no-graph:
|
||||
- "None"
|
||||
- "at1"
|
||||
@ -74,9 +81,13 @@ probe-info:
|
||||
|
||||
- type: "x2"
|
||||
channels: # Gauge Channel Name
|
||||
- "st2"
|
||||
- "st1"
|
||||
- "st3"
|
||||
|
||||
scaler:
|
||||
st1: 1
|
||||
st3: 10
|
||||
|
||||
trigger:
|
||||
type: "x2"
|
||||
# Info isn't really needed
|
||||
|
106
main.py
106
main.py
@ -179,6 +179,22 @@ def load_data(data_path: str, data={}) -> dict:
|
||||
"probes": x2_time_us, # Until otherwise overridden - probe time is x2 time
|
||||
}
|
||||
|
||||
# Setup custom scaling on the gauge values
|
||||
if "x2" in data_locs:
|
||||
for ch in dataInfo["probe-info"]["data-records"][data_locs.index("x2")]["channels"]:
|
||||
if ch in dataInfo["probe-info"]["data-records"][data_locs.index("x2")]["scaler"]:
|
||||
# Get the channel index from its name
|
||||
chIndex = x2_channel_names.index(channel)
|
||||
|
||||
# Calculate the average noise offset
|
||||
avg_noise = x2_channels[chIndex][0:SAMPLES_TO_AVG].mean()
|
||||
|
||||
# Save the channel data
|
||||
data[x2_shot]["data"]["x2"][channel] = (x2_channels[chIndex][:] - avg_noise) * dataInfo["probe-info"]["data-records"][data_locs.index("x2")]["scaler"][ch]
|
||||
|
||||
#[TODO] This could be better
|
||||
#if "x2" in data_locs:
|
||||
# data[x2_shot]["data"]["probes"] = [data[x2_shot]["data"]["x2"]["st1"][:], data[x2_shot]["data"]["x2"]["st3"][:]]
|
||||
|
||||
# Scope timing _if it exists_
|
||||
if "scope" in data_locs:
|
||||
@ -220,13 +236,12 @@ def load_data(data_path: str, data={}) -> dict:
|
||||
data[x2_shot]["time"]["probes"] = data[x2_shot]["time"]["scope"]
|
||||
data[x2_shot]["time"]["probe_uncert"] = scope_data_info["time-uncert"]
|
||||
|
||||
|
||||
# Find Shock Times
|
||||
# X2 - Canning Edge
|
||||
data[x2_shot]["shock-point"] = {}
|
||||
cArgs = dataInfo["pcb-canny"]
|
||||
for i, ref in enumerate(dataInfo["pcb-refs"]):
|
||||
refData = data[x2_shot]["data"]["x2"][ref]
|
||||
chData = data[x2_shot]["data"]["x2"][ref]
|
||||
|
||||
if i in range(len(cArgs)):
|
||||
sigma = cArgs[i]["sigma"]
|
||||
@ -235,18 +250,67 @@ def load_data(data_path: str, data={}) -> dict:
|
||||
sigma = cArgs[-1]["sigma"]
|
||||
post_sup_thresh = cArgs[-1]["post_pres"]
|
||||
|
||||
first_value, first_value_uncertainty, _, _ = canny_shock_finder(x2_time_us, refData, sigma=sigma, post_suppression_threshold=post_sup_thresh, plot=False, print_func=None)
|
||||
first_value, first_value_uncertainty, _, _ = canny_shock_finder(x2_time_us, chData, sigma=sigma, post_suppression_threshold=post_sup_thresh, plot=False, print_func=None)
|
||||
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, first_value_uncertainty
|
||||
|
||||
|
||||
if "x2" in data_locs:
|
||||
cArgs = dataInfo["x2-canny"]
|
||||
data[x2_shot]["shock-point"]["x2"] = {}
|
||||
|
||||
probeCh1 = data[x2_shot]["data"]["x2"]["st1"]
|
||||
probeCh2 = data[x2_shot]["data"]["x2"]["st3"]
|
||||
for i, probe in enumerate(dataInfo["probe-info"]["locations"]):
|
||||
|
||||
# Get the canny-args
|
||||
cArgs = dataInfo["x2-canny"]
|
||||
doCannyPlot = False
|
||||
if i in range(len(cArgs)):
|
||||
sigma = cArgs[i]["sigma"]
|
||||
post_sup_thresh = cArgs[i]["post_pres"]
|
||||
else:
|
||||
sigma = cArgs[-1]["sigma"]
|
||||
post_sup_thresh = cArgs[-1]["post_pres"]
|
||||
|
||||
# If this _isn't_ the first probe then apply a time offset
|
||||
if i > 0:
|
||||
privPoint = dataInfo["probe-info"]["locations"][i-1]
|
||||
time_offset = data[x2_shot]["shock-point"]["x2"][f"{privPoint}-g1"][1] + CANNY_TIME_OFFSET
|
||||
else:
|
||||
time_offset = None
|
||||
|
||||
# Find G1 Shock Time
|
||||
if 1 in dataInfo["probe-info"]["gauges"]:
|
||||
first_value, first_value_uncertainty, _, _ = canny_shock_finder(x2_time_us, probeCh1, sigma=sigma, post_suppression_threshold=post_sup_thresh, plot=doCannyPlot, start_time=time_offset, print_func=None)
|
||||
if first_value is None:
|
||||
print(f"[ERROR] {x2_shot} - {probe}-g1 could not be detected using: Sigma = {sigma}, post_suppression_threshold = {post_sup_thresh}")
|
||||
#raise ValueError(f"{probe}-g1 not detected"
|
||||
else:
|
||||
shock_point = np.where(x2_time_us >= first_value)[0][0] # [BUG] Seems to give n+1
|
||||
|
||||
data[x2_shot]["shock-point"]["x2"][f"{probe}-g1"] = shock_point, first_value, first_value_uncertainty
|
||||
|
||||
if 2 in dataInfo["probe-info"]["gauges"]:
|
||||
# Do the same for G2
|
||||
if i > 0:
|
||||
time_offset = data[x2_shot]["shock-point"]["x2"][f"{privPoint}-g2"][1] + CANNY_TIME_OFFSET
|
||||
|
||||
# Find G2 Shock Time
|
||||
first_value, first_value_uncertainty, _, _ = canny_shock_finder(x2_time_us, probeCh2, sigma=sigma, post_suppression_threshold=post_sup_thresh, plot=doCannyPlot, start_time=time_offset, print_func=None)
|
||||
if first_value is None:
|
||||
print(f"[ERROR] {x2_shot} - {probe}-g2 could not be detected using: Sigma = {sigma}, post_suppression_threshold = {post_sup_thresh}")
|
||||
#raise ValueError(f"{probe}-g2 not detected")
|
||||
else:
|
||||
shock_point = np.where(x2_time_us >= first_value)[0][0] # [BUG] Seems to give n+1
|
||||
data[x2_shot]["shock-point"]["x2"][f"{probe}-g2"] = shock_point, first_value, first_value_uncertainty
|
||||
|
||||
|
||||
# ---- Gauge Canning Edge ----
|
||||
for i, probe in enumerate(dataInfo["probe-info"]["locations"]):
|
||||
probeCh1 = data[x2_shot]["data"]["probes"][0]
|
||||
probeCh2 = data[x2_shot]["data"]["probes"][1]
|
||||
|
||||
for i, probe in enumerate(dataInfo["probe-info"]["locations"]):
|
||||
# Get the canny-args
|
||||
cArgs = dataInfo["canny-args"]
|
||||
doCannyPlot = False
|
||||
@ -944,24 +1008,24 @@ print("Loaded Data")
|
||||
print("Graphing Data")
|
||||
|
||||
# General Shot Graphing
|
||||
for shot in loaded_data:
|
||||
#print(data[shot]['info']['long_name'].rsplit("\n", 1)[-1])
|
||||
genGraph(data[shot], showPlot=False, addShockInfo=False)
|
||||
genGraph(data[shot], showPlot=False, forcePlots=True)
|
||||
|
||||
combo_data = data.copy()
|
||||
combo_data.pop(loaded_data[-2])
|
||||
combo_data.pop(loaded_data[-1])
|
||||
|
||||
genComboDataGraph(combo_data, doShockLabels=True)
|
||||
#for shot in loaded_data:
|
||||
# #print(data[shot]['info']['long_name'].rsplit("\n", 1)[-1])
|
||||
# genGraph(data[shot], showPlot=False, addShockInfo=False)
|
||||
# genGraph(data[shot], showPlot=False, forcePlots=True)
|
||||
#
|
||||
#combo_data = data.copy()
|
||||
#combo_data.pop(loaded_data[-2])
|
||||
#combo_data.pop(loaded_data[-1])
|
||||
#
|
||||
#genComboDataGraph(combo_data, doShockLabels=True)
|
||||
|
||||
# Reference Data
|
||||
for shot in ref_data:
|
||||
genRefGraph(ref_data[shot], showPlot=False, addShockInfo=False)
|
||||
genRefGraph(ref_data[shot], showPlot=False, forcePlots=True)
|
||||
|
||||
genComboRefGraph(ref_data, doShockLabels=True)
|
||||
genComboRefGraph(ref_data, ref_data[ref_data_to_load[0]]["info"]["pcb-refs"], addShockInfo=True)
|
||||
#for shot in ref_data:
|
||||
# genRefGraph(ref_data[shot], showPlot=False, addShockInfo=False)
|
||||
# genRefGraph(ref_data[shot], showPlot=False, forcePlots=True)
|
||||
#
|
||||
#genComboRefGraph(ref_data, doShockLabels=True)
|
||||
#genComboRefGraph(ref_data, ref_data[ref_data_to_load[0]]["info"]["pcb-refs"], addShockInfo=True)
|
||||
|
||||
|
||||
# This forces matplotlib to hang until I tell it to close all windows
|
||||
|
Loading…
x
Reference in New Issue
Block a user