Skip to content

Commit 20293f5

Browse files
feat: Updated rainflow cycle binning to use separate binning parameters for range, mean, and dwell. (#630)
Co-authored-by: pyansys-ci-bot <[email protected]>
1 parent 9fa3005 commit 20293f5

File tree

4 files changed

+102
-13
lines changed

4 files changed

+102
-13
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Feat: Updated rainflow cycle binning to use separate binning parameters for range, mean, and dwell.

src/ansys/sherlock/core/lifecycle.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2151,7 +2151,9 @@ def import_thermal_signal(
21512151
>>> phase_name=phaseName,
21522152
>>> time_removal= False,
21532153
>>> load_range_percentage=0.25,
2154-
>>> number_of_bins=0,
2154+
>>> number_of_range_bins=0,
2155+
>>> number_of_mean_bins=0,
2156+
>>> number_of_dwell_bins=0,
21552157
>>> temperature_range_filtering_limit=0.0,
21562158
>>> time_filtering_limit=72.0,
21572159
>>> time_filtering_limit_units="hr",

src/ansys/sherlock/core/types/lifecycle_types.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,12 @@ class ImportThermalSignalRequest(BaseModel):
7474
"""Option to indicate that time results with shorter half-cycle durations are removed."""
7575
load_range_percentage: float
7676
"""Defines the fraction of the range near peaks and valleys considered as a dwell region."""
77-
number_of_bins: int
78-
"""Number of bins for binning cycles, 0 for no binning."""
77+
number_of_range_bins: int
78+
"""Number of range bins for binning cycles, 0 for no range binning."""
79+
number_of_mean_bins: int
80+
"""Number of mean bins for binning cycles, 0 for no mean binning."""
81+
number_of_dwell_bins: int
82+
"""Number of dwell bins for binning cycles, 0 for no dwell binning."""
7983
temperature_range_filtering_limit: float
8084
"""Minimum cycle range to include in results, 0 for not filtering."""
8185
time_filtering_limit: float
@@ -93,7 +97,7 @@ def str_validation(cls, value: str, info: ValidationInfo):
9397
"""Validate string fields listed."""
9498
return basic_str_validator(value, info.field_name)
9599

96-
@field_validator("number_of_bins")
100+
@field_validator("number_of_range_bins", "number_of_mean_bins", "number_of_dwell_bins")
97101
@classmethod
98102
def non_negative_int_validation(cls, value: int, info: ValidationInfo):
99103
"""Validate integer fields listed contain non-negative values."""
@@ -110,7 +114,9 @@ def _convert_to_grpc(self) -> SherlockLifeCycleService_pb2.ImportThermalSignalRe
110114
fileProperties=self.thermal_signal_file_properties._convert_to_grpc(),
111115
timeRemoval=self.time_removal,
112116
loadRangePercentage=self.load_range_percentage,
113-
numberOfBins=self.number_of_bins,
117+
numberOfRangeBins=self.number_of_range_bins,
118+
numberOfMeanBins=self.number_of_mean_bins,
119+
numberOfDwellBins=self.number_of_dwell_bins,
114120
temperatureRangeFilteringLimit=self.temperature_range_filtering_limit,
115121
timeFilteringLimit=self.time_filtering_limit,
116122
timeFilteringLimitUnits=self.time_filtering_limit_units,

tests/test_lifecycle.py

Lines changed: 88 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2072,7 +2072,9 @@ def helper_test_import_thermal_signal(lifecycle: Lifecycle):
20722072
phase_name="Environmental",
20732073
time_removal=False,
20742074
load_range_percentage=0.25,
2075-
number_of_bins=0,
2075+
number_of_range_bins=0,
2076+
number_of_mean_bins=0,
2077+
number_of_dwell_bins=0,
20762078
temperature_range_filtering_limit=0.0,
20772079
time_filtering_limit=72.0,
20782080
time_filtering_limit_units="hr",
@@ -2104,7 +2106,9 @@ def helper_test_import_thermal_signal(lifecycle: Lifecycle):
21042106
phase_name="Environmental",
21052107
time_removal=False,
21062108
load_range_percentage=0.25,
2107-
number_of_bins=0,
2109+
number_of_range_bins=0,
2110+
number_of_mean_bins=0,
2111+
number_of_dwell_bins=0,
21082112
temperature_range_filtering_limit=0.0,
21092113
time_filtering_limit=72.0,
21102114
time_filtering_limit_units="hr",
@@ -2136,7 +2140,9 @@ def helper_test_import_thermal_signal(lifecycle: Lifecycle):
21362140
phase_name="",
21372141
time_removal=False,
21382142
load_range_percentage=0.25,
2139-
number_of_bins=0,
2143+
number_of_range_bins=0,
2144+
number_of_mean_bins=0,
2145+
number_of_dwell_bins=0,
21402146
temperature_range_filtering_limit=0.0,
21412147
time_filtering_limit=72.0,
21422148
time_filtering_limit_units="hr",
@@ -2168,19 +2174,89 @@ def helper_test_import_thermal_signal(lifecycle: Lifecycle):
21682174
phase_name="Environmental",
21692175
time_removal=False,
21702176
load_range_percentage=0.25,
2171-
number_of_bins=-1,
2177+
number_of_range_bins=-1,
2178+
number_of_mean_bins=0,
2179+
number_of_dwell_bins=0,
21722180
temperature_range_filtering_limit=0.0,
21732181
time_filtering_limit=72.0,
21742182
time_filtering_limit_units="hr",
21752183
generated_cycles_label="Generated Cycles from pySherlock",
21762184
)
21772185
)
2178-
pytest.fail("No exception raised when using a missing generated_cycles_label parameter")
2186+
pytest.fail("No exception raised when using invalid number_of_range_bins parameter")
2187+
except Exception as e:
2188+
assert isinstance(e, pydantic.ValidationError)
2189+
assert (
2190+
str(e.errors()[0]["msg"])
2191+
== "Value error, number_of_range_bins must be greater than or equal to 0."
2192+
)
2193+
2194+
try:
2195+
lifecycle.import_thermal_signal(
2196+
ImportThermalSignalRequest(
2197+
file_name="C:/Temp/ThermalSignalMissing.csv",
2198+
project="Tutorial Project",
2199+
thermal_signal_file_properties=ThermalSignalFileProperties(
2200+
header_row_count=0,
2201+
numeric_format="English",
2202+
column_delimiter=",",
2203+
time_column="Time",
2204+
time_units="sec",
2205+
temperature_column="Temperature",
2206+
temperature_units="C",
2207+
),
2208+
phase_name="Environmental",
2209+
time_removal=False,
2210+
load_range_percentage=0.25,
2211+
number_of_range_bins=0,
2212+
number_of_mean_bins=-1,
2213+
number_of_dwell_bins=0,
2214+
temperature_range_filtering_limit=0.0,
2215+
time_filtering_limit=72.0,
2216+
time_filtering_limit_units="hr",
2217+
generated_cycles_label="Generated Cycles from pySherlock",
2218+
)
2219+
)
2220+
pytest.fail("No exception raised when using invalid number_of_mean_bins parameter")
2221+
except Exception as e:
2222+
assert isinstance(e, pydantic.ValidationError)
2223+
assert (
2224+
str(e.errors()[0]["msg"])
2225+
== "Value error, number_of_mean_bins must be greater than or equal to 0."
2226+
)
2227+
2228+
try:
2229+
lifecycle.import_thermal_signal(
2230+
ImportThermalSignalRequest(
2231+
file_name="C:/Temp/ThermalSignalMissing.csv",
2232+
project="Tutorial Project",
2233+
thermal_signal_file_properties=ThermalSignalFileProperties(
2234+
header_row_count=0,
2235+
numeric_format="English",
2236+
column_delimiter=",",
2237+
time_column="Time",
2238+
time_units="sec",
2239+
temperature_column="Temperature",
2240+
temperature_units="C",
2241+
),
2242+
phase_name="Environmental",
2243+
time_removal=False,
2244+
load_range_percentage=0.25,
2245+
number_of_range_bins=0,
2246+
number_of_mean_bins=0,
2247+
number_of_dwell_bins=-1,
2248+
temperature_range_filtering_limit=0.0,
2249+
time_filtering_limit=72.0,
2250+
time_filtering_limit_units="hr",
2251+
generated_cycles_label="Generated Cycles from pySherlock",
2252+
)
2253+
)
2254+
pytest.fail("No exception raised when using invalid number_of_dwell_bins parameter")
21792255
except Exception as e:
21802256
assert isinstance(e, pydantic.ValidationError)
21812257
assert (
21822258
str(e.errors()[0]["msg"])
2183-
== "Value error, number_of_bins must be greater than or equal to 0."
2259+
== "Value error, number_of_dwell_bins must be greater than or equal to 0."
21842260
)
21852261

21862262
try:
@@ -2200,7 +2276,9 @@ def helper_test_import_thermal_signal(lifecycle: Lifecycle):
22002276
phase_name="Environmental",
22012277
time_removal=False,
22022278
load_range_percentage=0.25,
2203-
number_of_bins=0,
2279+
number_of_range_bins=0,
2280+
number_of_mean_bins=0,
2281+
number_of_dwell_bins=0,
22042282
temperature_range_filtering_limit=0.0,
22052283
time_filtering_limit=72.0,
22062284
time_filtering_limit_units="",
@@ -2232,7 +2310,9 @@ def helper_test_import_thermal_signal(lifecycle: Lifecycle):
22322310
phase_name="Environmental",
22332311
time_removal=False,
22342312
load_range_percentage=0.25,
2235-
number_of_bins=0,
2313+
number_of_range_bins=0,
2314+
number_of_mean_bins=0,
2315+
number_of_dwell_bins=0,
22362316
temperature_range_filtering_limit=0.0,
22372317
time_filtering_limit=72.0,
22382318
time_filtering_limit_units="hr",

0 commit comments

Comments
 (0)