mirror of
https://github.com/nqrduck/nqrduck-spectrometer.git
synced 2024-11-09 12:30:01 +00:00
Merge pull request #21 from nqrduck/measurement-name
Added name to measurement.
This commit is contained in:
commit
a4ef8fa9d9
1 changed files with 18 additions and 6 deletions
|
@ -15,6 +15,7 @@ class Measurement:
|
||||||
Every spectrometer should adhere to this data structure in order to be compatible with the rest of the nqrduck.
|
Every spectrometer should adhere to this data structure in order to be compatible with the rest of the nqrduck.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
name (str): Name of the measurement.
|
||||||
tdx (np.array): Time axis for the x axis of the measurement data.
|
tdx (np.array): Time axis for the x axis of the measurement data.
|
||||||
tdy (np.array): Time axis for the y axis of the measurement data.
|
tdy (np.array): Time axis for the y axis of the measurement data.
|
||||||
target_frequency (float): Target frequency of the measurement.
|
target_frequency (float): Target frequency of the measurement.
|
||||||
|
@ -33,21 +34,22 @@ class Measurement:
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
tdx,
|
name: str,
|
||||||
tdy,
|
tdx: np.array,
|
||||||
target_frequency,
|
tdy: np.array,
|
||||||
|
target_frequency: float,
|
||||||
frequency_shift: float = 0,
|
frequency_shift: float = 0,
|
||||||
IF_frequency: float = 0,
|
IF_frequency: float = 0,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initializes the measurement."""
|
"""Initializes the measurement."""
|
||||||
# Convert to decimal
|
self.name = name
|
||||||
self.tdx = tdx
|
self.tdx = tdx
|
||||||
self.tdy = tdy
|
self.tdy = tdy
|
||||||
self.target_frequency = target_frequency
|
self.target_frequency = target_frequency
|
||||||
self.fdx, self.fdy = sp.fft(tdx, tdy, frequency_shift)
|
self.fdx, self.fdy = sp.fft(tdx, tdy, frequency_shift)
|
||||||
self.IF_frequency = IF_frequency
|
self.IF_frequency = IF_frequency
|
||||||
|
|
||||||
def apodization(self, function : Function):
|
def apodization(self, function: Function):
|
||||||
"""Applies apodization to the measurement data.
|
"""Applies apodization to the measurement data.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -76,7 +78,6 @@ class Measurement:
|
||||||
|
|
||||||
return apodized_measurement
|
return apodized_measurement
|
||||||
|
|
||||||
|
|
||||||
# Data saving and loading
|
# Data saving and loading
|
||||||
|
|
||||||
def to_json(self):
|
def to_json(self):
|
||||||
|
@ -86,6 +87,7 @@ class Measurement:
|
||||||
dict : The measurement in json-compatible format.
|
dict : The measurement in json-compatible format.
|
||||||
"""
|
"""
|
||||||
return {
|
return {
|
||||||
|
"name": self.name,
|
||||||
"tdx": self.tdx.tolist(),
|
"tdx": self.tdx.tolist(),
|
||||||
"tdy": [
|
"tdy": [
|
||||||
[x.real, x.imag] for x in self.tdy
|
[x.real, x.imag] for x in self.tdy
|
||||||
|
@ -106,6 +108,7 @@ class Measurement:
|
||||||
"""
|
"""
|
||||||
tdy = np.array([complex(y[0], y[1]) for y in json["tdy"]])
|
tdy = np.array([complex(y[0], y[1]) for y in json["tdy"]])
|
||||||
return cls(
|
return cls(
|
||||||
|
json["name"],
|
||||||
np.array(json["tdx"]),
|
np.array(json["tdx"]),
|
||||||
tdy,
|
tdy,
|
||||||
target_frequency=json["target_frequency"],
|
target_frequency=json["target_frequency"],
|
||||||
|
@ -113,6 +116,15 @@ class Measurement:
|
||||||
)
|
)
|
||||||
|
|
||||||
# Measurement data
|
# Measurement data
|
||||||
|
@property
|
||||||
|
def name(self):
|
||||||
|
"""Name of the measurement."""
|
||||||
|
return self._name
|
||||||
|
|
||||||
|
@name.setter
|
||||||
|
def name(self, value):
|
||||||
|
self._name = value
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def tdx(self):
|
def tdx(self):
|
||||||
"""Time axis for the x axis of the measurement data."""
|
"""Time axis for the x axis of the measurement data."""
|
||||||
|
|
Loading…
Reference in a new issue