Simplify dat file processing
* rename "omega" -> "om", and "counts" -> "Counts" for consistency with the column names
This commit is contained in:
parent
8b3f1b568f
commit
fe1d8044a3
@ -58,8 +58,8 @@ def ccl_findpeaks(
|
|||||||
print("Invalid value for prominence, select positive number, new value set to:", prominence)
|
print("Invalid value for prominence, select positive number, new value set to:", prominence)
|
||||||
|
|
||||||
|
|
||||||
omega = data["Measurements"][str(keys)]["omega"]
|
omega = data["Measurements"][str(keys)]["om"]
|
||||||
counts = np.array(data["Measurements"][str(keys)]["counts"])
|
counts = np.array(data["Measurements"][str(keys)]["Counts"])
|
||||||
if smooth is True:
|
if smooth is True:
|
||||||
itp = interp1d(omega, counts, kind="linear")
|
itp = interp1d(omega, counts, kind="linear")
|
||||||
absintensity = [abs(number) for number in counts]
|
absintensity = [abs(number) for number in counts]
|
||||||
|
@ -40,8 +40,8 @@ def fitccl(
|
|||||||
print("NO PEAK or more than 1 peak")
|
print("NO PEAK or more than 1 peak")
|
||||||
return
|
return
|
||||||
|
|
||||||
x = list(data["Measurements"][str(keys)]["omega"])
|
x = list(data["Measurements"][str(keys)]["om"])
|
||||||
y = list(data["Measurements"][str(keys)]["counts"])
|
y = list(data["Measurements"][str(keys)]["Counts"])
|
||||||
peak_index = data["Measurements"][str(keys)]["peak_indexes"]
|
peak_index = data["Measurements"][str(keys)]["peak_indexes"]
|
||||||
peak_height = data["Measurements"][str(keys)]["peak_heights"]
|
peak_height = data["Measurements"][str(keys)]["peak_heights"]
|
||||||
print("before", constraints_min)
|
print("before", constraints_min)
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
import re
|
import re
|
||||||
import numpy as np
|
from collections import defaultdict
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
META_VARS_STR = (
|
META_VARS_STR = (
|
||||||
"instrument",
|
"instrument",
|
||||||
"title",
|
"title",
|
||||||
@ -133,14 +135,14 @@ def load_1D(filepath):
|
|||||||
fileline = data[position + 2 + i].split()
|
fileline = data[position + 2 + i].split()
|
||||||
numbers = [int(w) for w in fileline]
|
numbers = [int(w) for w in fileline]
|
||||||
counts = counts + numbers
|
counts = counts + numbers
|
||||||
d["omega"] = np.linspace(
|
d["om"] = np.linspace(
|
||||||
float(lines.split()[5])
|
float(lines.split()[5])
|
||||||
- (int(next_line.split()[0]) / 2) * float(next_line.split()[1]),
|
- (int(next_line.split()[0]) / 2) * float(next_line.split()[1]),
|
||||||
float(lines.split()[5])
|
float(lines.split()[5])
|
||||||
+ (int(next_line.split()[0]) / 2) * float(next_line.split()[1]),
|
+ (int(next_line.split()[0]) / 2) * float(next_line.split()[1]),
|
||||||
int(next_line.split()[0]),
|
int(next_line.split()[0]),
|
||||||
)
|
)
|
||||||
d["counts"] = counts
|
d["Counts"] = counts
|
||||||
det_variables["Measurements"][str("M" + str(measurement_number))] = d
|
det_variables["Measurements"][str("M" + str(measurement_number))] = d
|
||||||
|
|
||||||
if all(decimal):
|
if all(decimal):
|
||||||
@ -149,27 +151,21 @@ def load_1D(filepath):
|
|||||||
det_variables["meta"]["indices"] = "real"
|
det_variables["meta"]["indices"] = "real"
|
||||||
|
|
||||||
elif det_variables["file_type"] == "dat":
|
elif det_variables["file_type"] == "dat":
|
||||||
data = infile.readlines()
|
# skip the first 2 rows, the third row contans the column names
|
||||||
num_of_points = int(data[1].split()[0])
|
next(infile)
|
||||||
omega = []
|
next(infile)
|
||||||
counts = []
|
row_names = next(infile).split()
|
||||||
monitor1 = []
|
|
||||||
monitor2 = []
|
data_cols = defaultdict(list)
|
||||||
monitor3 = []
|
for line in infile:
|
||||||
time = []
|
if "END-OF-DATA" in line:
|
||||||
for position in range(num_of_points):
|
# this is the end of data
|
||||||
omega.append(float(data[position + 3].split()[1]))
|
break
|
||||||
counts.append(float(data[position + 3].split()[2]))
|
|
||||||
monitor1.append(float(data[position + 3].split()[3]))
|
for name, val in zip(row_names, line.split()):
|
||||||
monitor2.append(float(data[position + 3].split()[4]))
|
data_cols[name].append(float(val))
|
||||||
monitor3.append(float(data[position + 3].split()[5]))
|
|
||||||
time.append(float(data[position + 3].split()[6]))
|
det_variables["Measurements"] = dict(data_cols)
|
||||||
det_variables["Measurements"]["omega"] = omega
|
|
||||||
det_variables["Measurements"]["counts"] = counts
|
|
||||||
det_variables["Measurements"]["Monitor1"] = monitor1
|
|
||||||
det_variables["Measurements"]["Monitor2"] = monitor2
|
|
||||||
det_variables["Measurements"]["Monitor3"] = monitor3
|
|
||||||
det_variables["Measurements"]["time"] = time
|
|
||||||
else:
|
else:
|
||||||
print("Unknown file extention")
|
print("Unknown file extention")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user