From 44c7f9a4081c1f88567e97ec83862eb86d27991f Mon Sep 17 00:00:00 2001 From: jupfi Date: Sat, 16 Dec 2023 11:09:14 +0100 Subject: [PATCH] Flattened data arrays. --- src/nqrduck_spectrometer/measurement.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/nqrduck_spectrometer/measurement.py b/src/nqrduck_spectrometer/measurement.py index 997397d..ce60173 100644 --- a/src/nqrduck_spectrometer/measurement.py +++ b/src/nqrduck_spectrometer/measurement.py @@ -31,7 +31,7 @@ class Measurement(): def to_json(self): """Converts the measurement to a json-compatible format.""" return { - "tdx": [[x.real, x.imag] for x in self.tdx], # Convert complex numbers to list + "tdx": self.tdx.tolist(), "tdy": [[x.real, x.imag] for x in self.tdy], # Convert complex numbers to list "target_frequency": self.target_frequency, "IF_frequency": self.IF_frequency @@ -40,13 +40,12 @@ class Measurement(): @classmethod def from_json(cls, json): """Converts the json format to a measurement.""" - tdx = np.array([complex(x[0], x[1]) for x in json["tdx"]]) tdy = np.array([complex(y[0], y[1]) for y in json["tdy"]]) return cls( - tdx, + np.array(json["tdx"]), tdy, - json["target_frequency"], - json["IF_frequency"] + target_frequency = json["target_frequency"], + IF_frequency = json["IF_frequency"] ) # Measurement data