mirror of
https://github.com/nqrduck/quackseq.git
synced 2024-11-24 14:52:26 +00:00
Linting.
This commit is contained in:
parent
a8c5a93ae5
commit
b0cfd270fe
5 changed files with 94 additions and 72 deletions
|
@ -44,9 +44,6 @@ extend-select = [
|
||||||
"D", # pydocstyle
|
"D", # pydocstyle
|
||||||
]
|
]
|
||||||
|
|
||||||
[tool.ruff.lint.per-file-ignores]
|
|
||||||
"__init__.py" = ["F401"]
|
|
||||||
|
|
||||||
[tool.ruff.lint.pydocstyle]
|
[tool.ruff.lint.pydocstyle]
|
||||||
convention = "google"
|
convention = "google"
|
||||||
|
|
||||||
|
|
|
@ -134,7 +134,7 @@ class Function:
|
||||||
"""
|
"""
|
||||||
return {
|
return {
|
||||||
"name": self.name,
|
"name": self.name,
|
||||||
"class" : self.__class__.__name__,
|
"class": self.__class__.__name__,
|
||||||
"parameters": [parameter.to_json() for parameter in self.parameters],
|
"parameters": [parameter.to_json() for parameter in self.parameters],
|
||||||
"expression": str(self.expr),
|
"expression": str(self.expr),
|
||||||
"resolution": self.resolution,
|
"resolution": self.resolution,
|
||||||
|
|
|
@ -338,6 +338,7 @@ class T2StarFit(Fit):
|
||||||
"""Initial guess for the T2* fit."""
|
"""Initial guess for the T2* fit."""
|
||||||
return [1, 1]
|
return [1, 1]
|
||||||
|
|
||||||
|
|
||||||
class LorentzianFit(Fit):
|
class LorentzianFit(Fit):
|
||||||
"""Lorentzian fit for measurement data."""
|
"""Lorentzian fit for measurement data."""
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,12 @@ import logging
|
||||||
from numpy.core.multiarray import array as array
|
from numpy.core.multiarray import array as array
|
||||||
|
|
||||||
from quackseq.options import BooleanOption, FunctionOption, NumericOption, Option
|
from quackseq.options import BooleanOption, FunctionOption, NumericOption, Option
|
||||||
from quackseq.functions import RectFunction, SincFunction, GaussianFunction, CustomFunction
|
from quackseq.functions import (
|
||||||
|
RectFunction,
|
||||||
|
SincFunction,
|
||||||
|
GaussianFunction,
|
||||||
|
CustomFunction,
|
||||||
|
)
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -71,7 +76,6 @@ class PulseParameter:
|
||||||
raise ValueError(f"Option with name {name} not found")
|
raise ValueError(f"Option with name {name} not found")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class TXPulse(PulseParameter):
|
class TXPulse(PulseParameter):
|
||||||
"""Basic TX Pulse Parameter. It includes options for the relative amplitude, the phase and the pulse shape.
|
"""Basic TX Pulse Parameter. It includes options for the relative amplitude, the phase and the pulse shape.
|
||||||
|
|
||||||
|
@ -104,12 +108,22 @@ class TXPulse(PulseParameter):
|
||||||
self.add_option(NumericOption(self.TX_PHASE, 0))
|
self.add_option(NumericOption(self.TX_PHASE, 0))
|
||||||
self.add_option(
|
self.add_option(
|
||||||
NumericOption(
|
NumericOption(
|
||||||
self.N_PHASE_CYCLES, 1, is_float=False, min_value=1, max_value=360, slider=False
|
self.N_PHASE_CYCLES,
|
||||||
|
1,
|
||||||
|
is_float=False,
|
||||||
|
min_value=1,
|
||||||
|
max_value=360,
|
||||||
|
slider=False,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
self.add_option(
|
self.add_option(
|
||||||
NumericOption(
|
NumericOption(
|
||||||
self.PHASE_CYCLE_LEVEL, 0, is_float=False, min_value=0, max_value=10, slider=False
|
self.PHASE_CYCLE_LEVEL,
|
||||||
|
0,
|
||||||
|
is_float=False,
|
||||||
|
min_value=0,
|
||||||
|
max_value=10,
|
||||||
|
slider=False,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
self.add_option(
|
self.add_option(
|
||||||
|
@ -124,6 +138,7 @@ class TXPulse(PulseParameter):
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class RXReadout(PulseParameter):
|
class RXReadout(PulseParameter):
|
||||||
"""Basic PulseParameter for the RX Readout. It includes an option for the RX Readout state.
|
"""Basic PulseParameter for the RX Readout. It includes an option for the RX Readout state.
|
||||||
|
|
||||||
|
@ -144,6 +159,7 @@ class RXReadout(PulseParameter):
|
||||||
super().__init__(name)
|
super().__init__(name)
|
||||||
self.add_option(BooleanOption(self.RX, False))
|
self.add_option(BooleanOption(self.RX, False))
|
||||||
|
|
||||||
|
|
||||||
class Gate(PulseParameter):
|
class Gate(PulseParameter):
|
||||||
"""Basic PulseParameter for the Gate. It includes an option for the Gate state.
|
"""Basic PulseParameter for the Gate. It includes an option for the Gate state.
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
"""Helper used for signal processing."""
|
"""Helper used for signal processing."""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from scipy.fft import fft, fftfreq, fftshift
|
from scipy.fft import fft, fftfreq, fftshift
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
@ -6,11 +7,14 @@ import sympy
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class SignalProcessing:
|
class SignalProcessing:
|
||||||
"""This class provides various signal processing methods that can then be used by nqrduck modules."""
|
"""This class provides various signal processing methods that can then be used by nqrduck modules."""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def fft(cls, tdx : np.array, tdy: np.array, freq_shift : float = 0, zero_padding = 1000) -> tuple[np.array, np.array]:
|
def fft(
|
||||||
|
cls, tdx: np.array, tdy: np.array, freq_shift: float = 0, zero_padding=1000
|
||||||
|
) -> tuple[np.array, np.array]:
|
||||||
"""This method calculates the FFT of the time domain data.
|
"""This method calculates the FFT of the time domain data.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -23,7 +27,7 @@ class SignalProcessing:
|
||||||
np.array: Frequency domain x data in MHz.
|
np.array: Frequency domain x data in MHz.
|
||||||
np.array: Frequency domain magnitude y data.
|
np.array: Frequency domain magnitude y data.
|
||||||
"""
|
"""
|
||||||
dwell_time = (tdx[1] - tdx[0])
|
dwell_time = tdx[1] - tdx[0]
|
||||||
|
|
||||||
N = len(tdx) + zero_padding
|
N = len(tdx) + zero_padding
|
||||||
|
|
||||||
|
@ -43,7 +47,7 @@ class SignalProcessing:
|
||||||
return xdf, ydf
|
return xdf, ydf
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def baseline_correction(cls, fdx : np.array, fdy : np.array, order : int) -> np.array:
|
def baseline_correction(cls, fdx: np.array, fdy: np.array, order: int) -> np.array:
|
||||||
"""This method calculates the baseline correction of the frequency domain data.
|
"""This method calculates the baseline correction of the frequency domain data.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -57,7 +61,9 @@ class SignalProcessing:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def apodization(cls, tdx : np.array, tdy : np.array, apodization_function : sympy.Expr) -> np.array:
|
def apodization(
|
||||||
|
cls, tdx: np.array, tdy: np.array, apodization_function: sympy.Expr
|
||||||
|
) -> np.array:
|
||||||
"""This method calculates the apodization of the time domain data.
|
"""This method calculates the apodization of the time domain data.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -72,7 +78,9 @@ class SignalProcessing:
|
||||||
return tdy * weight
|
return tdy * weight
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def peak_picking(cls, fdx: np.array, fdy: np.array, threshold : float = 0.05) -> tuple[np.array, np.array]:
|
def peak_picking(
|
||||||
|
cls, fdx: np.array, fdy: np.array, threshold: float = 0.05
|
||||||
|
) -> tuple[np.array, np.array]:
|
||||||
"""This method calculates the peak picking of the frequency domain data.
|
"""This method calculates the peak picking of the frequency domain data.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
|
Loading…
Reference in a new issue