Skip to content

Commit

Permalink
fix: πŸ› phase shift
Browse files Browse the repository at this point in the history
fix: πŸ› phaseshift

fix: πŸ› phaseshift
  • Loading branch information
noshita committed Feb 8, 2024
1 parent 834c1f0 commit 25450bc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
25 changes: 18 additions & 7 deletions ktch/outline/_elliptic_Fourier_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ def _transform_single(

return X_transformed

def _normalize(self, an, bn, cn, dn):
def _normalize(self, an, bn, cn, dn, keep_start_point=False):
"""Normalize Fourier coefficients.
Todo:
Expand All @@ -343,18 +343,29 @@ def _normalize(self, an, bn, cn, dn):
c1 = cn[1]
d1 = dn[1]

theta = (1 / 2) * np.arctan2(
2 * (a1 * b1 + c1 * d1), (a1**2 + c1**2 - b1**2 - d1**2)
theta = (1 / 2) * np.arctan(
2 * (a1 * b1 + c1 * d1) / (a1**2 + c1**2 - b1**2 - d1**2)
)
if theta < 0:
theta = theta + 2 * np.pi

[[a_s, b_s], [c_s, d_s]] = np.array([[a1, b1], [c1, d1]]).dot(
rotation_matrix_2d(theta)
)
s1 = a_s**2 + c_s**2
s2 = b_s**2 + d_s**2

if s1 < s2:
if theta < 0:
theta = theta + np.pi / 2
else:
theta = theta - np.pi / 2

a_s = a1 * np.cos(theta) + b1 * np.sin(theta)
c_s = c1 * np.cos(theta) + d1 * np.sin(theta)
scale = np.sqrt(a_s**2 + c_s**2)
psi = np.arctan2(c_s, a_s)
if psi < 0:
psi = psi + 2 * np.pi

if keep_start_point:
theta = 0

coef_norm_list = []
r_psi = rotation_matrix_2d(-psi)
Expand Down
10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ version = "0.3.1"
[tool.poetry.dependencies]
numpy = ">=1.22"
pandas = ">=1.5"
python = "^3.8"
python = "^3.9"
scikit-learn = ">=1.2"
scipy = ">=1.8"
toml = ">=0.10"
Expand All @@ -48,20 +48,20 @@ jupyter = "^1.0.0"
jupyterlab = "^3.4.4"
jupytext = "^1.14.5"
liccheck = "^0.7.2"
llvmlite = "^0.39.1"
matplotlib = "^3.5.2"
llvmlite = "^0.41"
module-name = "^0.6.0"
numba = "^0.56.4"
numba = "^0.58"
opencv-python = "^4.7.0.68"
plotly = "^5.9.0"
poetry2conda = "^0.3.0"
pytest = "^7.1"
pytest-cov = "^3.0"
seaborn = "^0.11.0"
setuptools = "<60.0"
tqdm = "^4.64.1"
tslearn = "^0.5.3.2"
xarray = "^2022.6.0"
matplotlib = "^3.8.2"
seaborn = "^0.13.0"

[tool.poetry.group.doc.dependencies]
myst-nb = "^0.17.2"
Expand Down

0 comments on commit 25450bc

Please sign in to comment.