Skip to content

Commit

Permalink
Fix qftrace bug. (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterKraus committed Jan 27, 2023
1 parent 16d103a commit af17833
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/yadg/parsers/qftrace/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
"{{ trace_name }}": # detector name, currently hard-coded to S11
f: # frequency-axis units are always Hz
{n: [!!float, ...], s: [!!float, ...], u: "Hz"}
Re(Γ): # real part of the reflection coefficient
Re(G): # real part of the reflection coefficient
{n: [!!float, ...], s: [!!float, ...], u: !!str}
Im(Γ): # imaginary part of the reflection coefficient
Im(G): # imaginary part of the reflection coefficient
{n: [!!float, ...], s: [!!float, ...], u: !!str}
.. admonition:: DEPRECATED in ``yadg-4.2``
Expand Down
10 changes: 5 additions & 5 deletions src/yadg/parsers/qftrace/labviewcsv.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,18 @@ def process(
c = complex(ren, imn)
gamma.append(c)
absgamma.append(abs(c))
temp = {"f": {}, "Re(Γ)": {}, "Im(Γ)": {}}
temp = {"f": {}, "Re(G)": {}, "Im(G)": {}}
freq = [np.array(i) for i in zip(*freq)]
temp["fvals"], temp["fsigs"] = freq
temp["gamma"] = np.array(gamma)
temp["absgamma"] = np.array(absgamma)
temp["f"]["n"], temp["f"]["s"] = [i.tolist() for i in freq]
temp["f"]["u"] = "Hz"
real = [np.array(i) for i in zip(*real)]
temp["Re(Γ)"]["n"], temp["Re(Γ)"]["s"] = [i.tolist() for i in real]
temp["Re(Γ)"]["u"] = " "
temp["Re(G)"]["n"], temp["Re(G)"]["s"] = [i.tolist() for i in real]
temp["Re(G)"]["u"] = " "
imag = [np.array(i) for i in zip(*imag)]
temp["Im(Γ)"]["n"], temp["Im(Γ)"]["s"] = [i.tolist() for i in imag]
temp["Im(Γ)"]["u"] = " "
temp["Im(G)"]["n"], temp["Im(G)"]["s"] = [i.tolist() for i in imag]
temp["Im(G)"]["u"] = " "
data["raw"]["traces"]["S11"] = temp
return [data], None
6 changes: 3 additions & 3 deletions tests/test_qftrace.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ def special_datagram_test(datagram, testspec):
tstep = step["data"][testspec["point"]]
assert (
len(tstep["raw"]["traces"]["S11"]["f"]["n"]) == testspec["tracelen"]
and len(tstep["raw"]["traces"]["S11"]["Re(Γ)"]["n"]) == testspec["tracelen"]
and len(tstep["raw"]["traces"]["S11"]["Im(Γ)"]["n"]) == testspec["tracelen"]
and len(tstep["raw"]["traces"]["S11"]["Re(G)"]["n"]) == testspec["tracelen"]
and len(tstep["raw"]["traces"]["S11"]["Im(G)"]["n"]) == testspec["tracelen"]
), "length of 'f', 'Re(Γ)', 'Im(Γ)' not as prescribed."

assert (
Expand Down Expand Up @@ -172,6 +172,6 @@ def test_compare_raw_values(datadir):
with open("yvals.json", "r") as infile:
ref = json.load(infile)["traces"]
for k, v in ret["steps"][0]["data"][0]["raw"]["traces"].items():
for kk in ["f", "Re(Γ)", "Im(Γ)"]:
for kk in ["f", "Re(G)", "Im(G)"]:
for kkk in ["n", "s"]:
assert np.allclose(ref[k][kk][kkk], v[kk][kkk])
2 changes: 1 addition & 1 deletion tests/test_qftrace/yvals.json

Large diffs are not rendered by default.

0 comments on commit af17833

Please sign in to comment.