mirror of
https://github.com/nqrduck/quackseq.git
synced 2025-01-05 02:38:07 +00:00
Fixed loading and saving of measurement data.
This commit is contained in:
parent
214c7d5743
commit
93d9b89c36
1 changed files with 15 additions and 3 deletions
|
@ -64,7 +64,7 @@ class Measurement:
|
||||||
"""
|
"""
|
||||||
# Add the y data in the second dimension
|
# Add the y data in the second dimension
|
||||||
self.tdy = np.concatenate((self.tdy, tdy), axis=1)
|
self.tdy = np.concatenate((self.tdy, tdy), axis=1)
|
||||||
_, fdy = sp.fft(self.tdx, tdy, self.frequency_shift)
|
_, fdy = sp.fft(self.tdx, tdy, self.frequency_shift)
|
||||||
self.fdy = np.concatenate((self.fdy, fdy), axis=1)
|
self.fdy = np.concatenate((self.fdy, fdy), axis=1)
|
||||||
|
|
||||||
def apodization(self, function: Function) -> "Measurement":
|
def apodization(self, function: Function) -> "Measurement":
|
||||||
|
@ -140,7 +140,7 @@ class Measurement:
|
||||||
return {
|
return {
|
||||||
"name": self.name,
|
"name": self.name,
|
||||||
"tdx": self.tdx.tolist(),
|
"tdx": self.tdx.tolist(),
|
||||||
"tdy": [[x.real, x.imag] for x in self.tdy],
|
"tdy": self.serialize_complex_array(self.tdy),
|
||||||
"target_frequency": self.target_frequency,
|
"target_frequency": self.target_frequency,
|
||||||
"IF_frequency": self.IF_frequency,
|
"IF_frequency": self.IF_frequency,
|
||||||
"fits": [fit.to_json() for fit in self.fits],
|
"fits": [fit.to_json() for fit in self.fits],
|
||||||
|
@ -156,7 +156,8 @@ class Measurement:
|
||||||
Returns:
|
Returns:
|
||||||
Measurement: The measurement.
|
Measurement: The measurement.
|
||||||
"""
|
"""
|
||||||
tdy = np.array([complex(y[0], y[1]) for y in json["tdy"]])
|
tdy = np.array(json["tdy"][0]) + 1j * np.array(json["tdy"][1])
|
||||||
|
|
||||||
measurement = cls(
|
measurement = cls(
|
||||||
json["name"],
|
json["name"],
|
||||||
np.array(json["tdx"]),
|
np.array(json["tdx"]),
|
||||||
|
@ -169,6 +170,17 @@ class Measurement:
|
||||||
measurement.add_fit(Fit.from_json(fit_json, measurement))
|
measurement.add_fit(Fit.from_json(fit_json, measurement))
|
||||||
|
|
||||||
return measurement
|
return measurement
|
||||||
|
|
||||||
|
def serialize_complex_array(self, array: np.array) -> list:
|
||||||
|
"""Serializes a complex array to a list.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
array (np.array): The complex array.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list: The serialized complex array.
|
||||||
|
"""
|
||||||
|
return [array.real.tolist(), array.imag.tolist()]
|
||||||
|
|
||||||
# Properties for encapsulation
|
# Properties for encapsulation
|
||||||
@property
|
@property
|
||||||
|
|
Loading…
Reference in a new issue