Files
pyfa/graphs/data/fitHeat/graph.py

97 lines
3.4 KiB
Python

# =============================================================================
# Copyright (C) 2026
#
# This file is part of pyfa.
#
# pyfa is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# pyfa is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
# =============================================================================
# noinspection PyPackageRequirements
import wx
from service.const import GraphCacheCleanupReason
from graphs.data.base import FitGraph, Input, XDef, YDef
from .getter import (
Time2BurnoutCdfHiGetter,
Time2BurnoutCdfLowGetter,
Time2BurnoutCdfMedGetter,
Time2RackHeatHiGetter,
Time2RackHeatLowGetter,
Time2RackHeatMedGetter,
)
_t = wx.GetTranslation
_CDF_Y_HANDLES = frozenset(("burnoutCdfHi", "burnoutCdfMed", "burnoutCdfLow"))
class FitHeatGraph(FitGraph):
def getPlotPoints(self, mainInput, miscInputs, xSpec, ySpec, src, tgt=None):
if ySpec.handle in _CDF_Y_HANDLES:
return self._calcPlotPoints(
mainInput=mainInput, miscInputs=miscInputs,
xSpec=xSpec, ySpec=ySpec, src=src, tgt=tgt)
return super().getPlotPoints(
mainInput=mainInput, miscInputs=miscInputs,
xSpec=xSpec, ySpec=ySpec, src=src, tgt=tgt)
# UI stuff
internalName = "heatGraph"
name = _t("Heat")
xDefs = [
XDef(handle="time", unit="s", label=_t("Time"), mainInput=("time", "s")),
]
yDefs = [
YDef(handle="rackHeatHi", unit="%", label=_t("High rack heat")),
YDef(handle="rackHeatMed", unit="%", label=_t("Mid rack heat")),
YDef(handle="rackHeatLow", unit="%", label=_t("Low rack heat")),
YDef(handle="burnoutCdfHi", unit=None, label=_t("High rack first-burnout CDF")),
YDef(handle="burnoutCdfMed", unit=None, label=_t("Mid rack first-burnout CDF")),
YDef(handle="burnoutCdfLow", unit=None, label=_t("Low rack first-burnout CDF")),
]
inputs = [
Input(
handle="time",
unit="s",
label=_t("Time"),
iconID=1392,
defaultValue=300,
defaultRange=(0, 120),
)
]
srcExtraCols = ()
# Calculation stuff
_limiters = {
"time": lambda src, tgt: (0, 3600),
}
_getters = {
("time", "rackHeatHi"): Time2RackHeatHiGetter,
("time", "rackHeatMed"): Time2RackHeatMedGetter,
("time", "rackHeatLow"): Time2RackHeatLowGetter,
("time", "burnoutCdfHi"): Time2BurnoutCdfHiGetter,
("time", "burnoutCdfMed"): Time2BurnoutCdfMedGetter,
("time", "burnoutCdfLow"): Time2BurnoutCdfLowGetter,
}
def clearCache(self, reason, extraData=None):
super().clearCache(reason=reason, extraData=extraData)
from .calc import clear_burnout_samples_cache
if reason in (GraphCacheCleanupReason.fitChanged, GraphCacheCleanupReason.fitRemoved) and extraData is not None:
clear_burnout_samples_cache(fit_id=extraData)