Skip to content
1 change: 1 addition & 0 deletions doc/changelog.d/619.miscellaneous.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Feat: Added time filtering to importThermalSignal API.
4 changes: 3 additions & 1 deletion src/ansys/sherlock/core/lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -2152,7 +2152,9 @@ def import_thermal_signal(
>>> time_removal= False,
>>> load_range_percentage=0.25,
>>> number_of_bins=0,
>>> filtering_limit=0.0,
>>> temperature_range_filtering_limit=0.0,
>>> time_filtering_limit=72.0,
>>> time_filtering_limit_units="hr",
>>> generated_cycles_label="Second Generated Cycles from Python",
>>> )
>>> )
Expand Down
20 changes: 14 additions & 6 deletions src/ansys/sherlock/core/types/lifecycle_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,21 @@ class ImportThermalSignalRequest(BaseModel):
time_removal: bool
"""Option to indicate that time results with shorter half-cycle durations are removed."""
load_range_percentage: float
"""Defines the fraction of the range near peaks and valleys considered as a dwell region"""
"""Defines the fraction of the range near peaks and valleys considered as a dwell region."""
number_of_bins: int
"""Number of bins for binning cycles, 0 for no binning"""
filtering_limit: float
"""Minimum cycle range to include in results, 0 for not filtering"""
"""Number of bins for binning cycles, 0 for no binning."""
temperature_range_filtering_limit: float
"""Minimum cycle range to include in results, 0 for not filtering."""
time_filtering_limit: float
"""Maximum cycle time to include in results, default is 72 hours."""
time_filtering_limit_units: str
"""Units of the time filtering limit."""
generated_cycles_label: str
"""Label used to define the name of all generated thermal events."""

@field_validator("file_name", "project", "phase_name", "generated_cycles_label")
@field_validator(
"file_name", "project", "phase_name", "time_filtering_limit_units", "generated_cycles_label"
)
@classmethod
def str_validation(cls, value: str, info: ValidationInfo):
"""Validate string fields listed."""
Expand All @@ -105,6 +111,8 @@ def _convert_to_grpc(self) -> SherlockLifeCycleService_pb2.ImportThermalSignalRe
timeRemoval=self.time_removal,
loadRangePercentage=self.load_range_percentage,
numberOfBins=self.number_of_bins,
filteringLimit=self.filtering_limit,
temperatureRangeFilteringLimit=self.temperature_range_filtering_limit,
timeFilteringLimit=self.time_filtering_limit,
timeFilteringLimitUnits=self.time_filtering_limit_units,
generatedCyclesLabel=self.generated_cycles_label,
)
52 changes: 47 additions & 5 deletions tests/test_lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -2073,7 +2073,9 @@ def helper_test_import_thermal_signal(lifecycle: Lifecycle):
time_removal=False,
load_range_percentage=0.25,
number_of_bins=0,
filtering_limit=0.0,
temperature_range_filtering_limit=0.0,
time_filtering_limit=72.0,
time_filtering_limit_units="hr",
generated_cycles_label="Generated Cycles from pySherlock",
)
)
Expand Down Expand Up @@ -2103,7 +2105,9 @@ def helper_test_import_thermal_signal(lifecycle: Lifecycle):
time_removal=False,
load_range_percentage=0.25,
number_of_bins=0,
filtering_limit=0.0,
temperature_range_filtering_limit=0.0,
time_filtering_limit=72.0,
time_filtering_limit_units="hr",
generated_cycles_label="Generated Cycles from pySherlock",
)
)
Expand Down Expand Up @@ -2133,7 +2137,9 @@ def helper_test_import_thermal_signal(lifecycle: Lifecycle):
time_removal=False,
load_range_percentage=0.25,
number_of_bins=0,
filtering_limit=0.0,
temperature_range_filtering_limit=0.0,
time_filtering_limit=72.0,
time_filtering_limit_units="hr",
generated_cycles_label="Generated Cycles from pySherlock",
)
)
Expand Down Expand Up @@ -2163,7 +2169,9 @@ def helper_test_import_thermal_signal(lifecycle: Lifecycle):
time_removal=False,
load_range_percentage=0.25,
number_of_bins=-1,
filtering_limit=0.0,
temperature_range_filtering_limit=0.0,
time_filtering_limit=72.0,
time_filtering_limit_units="hr",
generated_cycles_label="Generated Cycles from pySherlock",
)
)
Expand Down Expand Up @@ -2193,7 +2201,41 @@ def helper_test_import_thermal_signal(lifecycle: Lifecycle):
time_removal=False,
load_range_percentage=0.25,
number_of_bins=0,
filtering_limit=0.0,
temperature_range_filtering_limit=0.0,
time_filtering_limit=72.0,
time_filtering_limit_units="",
generated_cycles_label="Generated Cycles from pySherlock",
)
)
pytest.fail("No exception raised when using a missing time_filtering_limit_units parameter")
except Exception as e:
assert isinstance(e, pydantic.ValidationError)
assert (
str(e.errors()[0]["msg"])
== "Value error, time_filtering_limit_units is invalid because it is None or empty."
)

try:
lifecycle.import_thermal_signal(
ImportThermalSignalRequest(
file_name="C:/Temp/ThermalSignalMissing.csv",
project="Tutorial Project",
thermal_signal_file_properties=ThermalSignalFileProperties(
header_row_count=0,
numeric_format="English",
column_delimiter=",",
time_column="Time",
time_units="sec",
temperature_column="Temperature",
temperature_units="C",
),
phase_name="Environmental",
time_removal=False,
load_range_percentage=0.25,
number_of_bins=0,
temperature_range_filtering_limit=0.0,
time_filtering_limit=72.0,
time_filtering_limit_units="hr",
generated_cycles_label="",
)
)
Expand Down
Loading