Skip to content

Commit c097372

Browse files
committed
fix: adding min/max angle to trig profile
1 parent 596e59f commit c097372

File tree

1 file changed

+48
-8
lines changed

1 file changed

+48
-8
lines changed

LoopStructural/modelling/features/fold/fold_function/_trigo_fold_rotation_angle.py

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ def __init__(
1414
fold_frame_coordinate: Optional[npt.NDArray[np.float64]] = None,
1515
origin: float = 0,
1616
wavelength: float = 0,
17-
inflectionpointangle: float = 0,
17+
inflectionpointangle_min: float = 0,
18+
inflectionpointangle_max: float = 0,
1819
):
1920
"""The fold frame function using the trigo profile from Laurent 2016
2021
@@ -34,7 +35,8 @@ def __init__(
3435
super().__init__(rotation_angle, fold_frame_coordinate)
3536
self._origin = origin
3637
self._wavelength = wavelength
37-
self._inflectionpointangle = inflectionpointangle
38+
self._inflectionpointangle_min = inflectionpointangle_min
39+
self._inflectionpointangle_max = inflectionpointangle_max
3840

3941
@property
4042
def origin(self):
@@ -43,7 +45,39 @@ def origin(self):
4345
@property
4446
def wavelength(self):
4547
return self._wavelength
46-
48+
@property
49+
def inflectionpointangle_min(self):
50+
return self._inflectionpointangle_min
51+
@property
52+
def inflectionpointangle_max(self):
53+
return self._inflectionpointangle_max
54+
@inflectionpointangle_max.setter
55+
def inflectionpointangle_max(self, value):
56+
if np.isfinite(value):
57+
if value < np.deg2rad(-90) or value > np.deg2rad(90):
58+
logger.error(f"Inflection point angle max is {np.rad2deg(value)} degrees")
59+
raise ValueError("inflectionpointangle_max must be between 0 and 90")
60+
self.notify_observers()
61+
self._inflectionpointangle_max = value
62+
else:
63+
raise ValueError("inflectionpointangle_max must be a finite number")
64+
@inflectionpointangle_min.setter
65+
def inflectionpointangle_min(self, value):
66+
if np.isfinite(value):
67+
if value < np.deg2rad(-90) or value > np.deg2rad(90):
68+
logger.error(f"Inflection point angle min is {np.rad2deg(value)} degrees")
69+
raise ValueError("inflectionpointangle_min must be between -90 and 0")
70+
self.notify_observers()
71+
self._inflectionpointangle_min = value
72+
else:
73+
raise ValueError("inflectionpointangle_min must be a finite number")
74+
@property
75+
def inflectionpointangle_half(self):
76+
return (self._inflectionpointangle_max - self._inflectionpointangle_min) / 2
77+
78+
@property
79+
def inflectionpointangle_shift(self):
80+
return (self._inflectionpointangle_max + self._inflectionpointangle_min) / 2
4781
@property
4882
def inflectionpointangle(self):
4983
return self._inflectionpointangle
@@ -83,11 +117,12 @@ def params(self):
83117
return {
84118
"origin": self.origin,
85119
"wavelength": self.wavelength,
86-
"inflectionpointangle": self.inflectionpointangle,
120+
"inflectionpointangle_min": self.inflectionpointangle_min,
121+
"inflectionpointangle_max": self.inflectionpointangle_max,
87122
}
88123

89124
@staticmethod
90-
def _function(s, origin, wavelength, inflectionpointangle):
125+
def _function(s, origin, wavelength, inflectionpointangle_min, inflectionpointangle_max):
91126
"""
92127
93128
Parameters
@@ -101,8 +136,12 @@ def _function(s, origin, wavelength, inflectionpointangle):
101136
-------
102137
103138
"""
104-
tan_alpha_delta_half = np.tan(inflectionpointangle)
105-
tan_alpha_shift = 0
139+
inflectionpointangle_half = (inflectionpointangle_max - inflectionpointangle_min) / 2
140+
inflectionpointangle_shift = (inflectionpointangle_max + inflectionpointangle_min) / 2
141+
tan_alpha_delta_half = np.tan(inflectionpointangle_half)
142+
tan_alpha_shift = np.tan(inflectionpointangle_shift)
143+
print(f"tan_alpha_delta_half {np.rad2deg(np.arctan(tan_alpha_delta_half))} degrees")
144+
print(f"tan_alpha_shift {np.rad2deg(np.arctan(tan_alpha_shift))} degrees")
106145
x = (s - origin) / wavelength
107146
return tan_alpha_delta_half * np.sin(2 * np.pi * x) + tan_alpha_shift
108147

@@ -123,7 +162,8 @@ def calculate_misfit(
123162
def update_params(self, params: Union[List, npt.NDArray[np.float64]]) -> None:
124163
self.origin = params[0]
125164
self.wavelength = params[1]
126-
self.inflectionpointangle = params[2]
165+
self.inflectionpointangle_min = params[2]
166+
self.inflectionpointangle_max = params[3]
127167

128168
def initial_guess(
129169
self,

0 commit comments

Comments
 (0)