mirror of
https://github.com/nqrduck/nqrduck-spectrometer.git
synced 2024-11-09 12:30:01 +00:00
Added methods for editing fit information.
This commit is contained in:
parent
60ba648958
commit
a273bed28a
1 changed files with 21 additions and 0 deletions
|
@ -91,6 +91,25 @@ class Measurement:
|
||||||
"""
|
"""
|
||||||
self.fits.append(fit)
|
self.fits.append(fit)
|
||||||
|
|
||||||
|
def delete_fit(self, fit):
|
||||||
|
"""Deletes a fit from the measurement.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
fit (Fit): The fit to delete.
|
||||||
|
"""
|
||||||
|
|
||||||
|
self.fits.remove(fit)
|
||||||
|
|
||||||
|
def edit_fit_name(self, fit, name : str):
|
||||||
|
"""Edits the name of a fit.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
fit (Fit): The fit to edit.
|
||||||
|
name (str): The new name.
|
||||||
|
"""
|
||||||
|
logger.debug(f"Editing fit name to {name}.")
|
||||||
|
fit.name = name
|
||||||
|
|
||||||
# Data saving and loading
|
# Data saving and loading
|
||||||
|
|
||||||
def to_json(self):
|
def to_json(self):
|
||||||
|
@ -107,6 +126,7 @@ class Measurement:
|
||||||
], # Convert complex numbers to list
|
], # Convert complex numbers to list
|
||||||
"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],
|
||||||
}
|
}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -126,6 +146,7 @@ class Measurement:
|
||||||
tdy,
|
tdy,
|
||||||
target_frequency=json["target_frequency"],
|
target_frequency=json["target_frequency"],
|
||||||
IF_frequency=json["IF_frequency"],
|
IF_frequency=json["IF_frequency"],
|
||||||
|
fits=[Fit.from_json(fit) for fit in json["fits"]],
|
||||||
)
|
)
|
||||||
|
|
||||||
# Measurement data
|
# Measurement data
|
||||||
|
|
Loading…
Reference in a new issue